Commit Graph

6818 Commits

Author SHA1 Message Date
Campbell Barton
aa03383838 Cleanup: resolve cppcheck funcArgNamesDifferent warnings in blenlib 2024-05-07 13:07:02 +10:00
Campbell Barton
1838499f55 Cleanup: suppress unassignedVariable warning with cppcheck
While not an error this has the minor benefit of simplifying the macro.
2024-05-07 12:59:21 +10:00
Iliya Katueshenock
4e3af58885 Cleanup: Avoid unnecessary copies of VArray
Cleanup to avoid unnecessary copies of VArray. This
requires ref-qualifier overloads of dereference operator
of attribute reader and some move operators and constructor
overloads in the code.

Pull Request: https://projects.blender.org/blender/blender/pulls/118437
2024-05-07 04:02:17 +02:00
Campbell Barton
ab6e00bd7d Cleanup: sort cmake file lists 2024-05-06 09:20:57 +10:00
Campbell Barton
c5ad937f53 Cleanup: match argument names in function & declaration 2024-05-06 09:20:05 +10:00
Jacques Lucke
a7cae51cf7 Cleanup: quite gcc array-bounds warning
This warning is known to produce false-positives unfortunately.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456
2024-05-05 08:53:25 +02:00
Campbell Barton
98f319ce02 Cleanup: spelling in comments 2024-05-04 15:24:46 +10:00
Campbell Barton
4f5f0040c0 Cleanup: back-tick quote file extensions in code-comments 2024-05-04 15:06:46 +10:00
Aras Pranckevicius
3b67075f40 BLI: Make color sRGB<->Linear non-SIMD fallback path use the same approximation
All official Blender platforms use the SIMD code path, with pow() approximations
for 2.4 and 1/2.4 powers. The non-SIMD code path would only be used on other
platforms like PowerPC etc. Make that fallback scalar code path use the same
math approximation for consistency. This is part of #121312.

This also makes srgb_to_linearrgb_v3_v3 and linearrgb_to_srgb_v3_v3 functions
non-inlined. They are 50-100 CPU instructions, and thus hardly good candidates
for forced inlining into each and every call site.

Also _bli_math_blend_sse now uses actual SSE4 blend instruction instead of doing
it in a roundabout way.

Pull Request: https://projects.blender.org/blender/blender/pulls/121368
2024-05-03 12:05:56 +02:00
Campbell Barton
9918488bb1 Cleanup: use uppercase tags, following own style guide 2024-05-03 11:33:21 +10:00
Anthony Roberts
570b76f600 Enable sse2neon in BLI_simd except for hydra/USD
This should get all of the tests to pass on Windows ARM64 platforms.

Sadly it needs disabling for hydra/USD stuff as currently it doesn't play nicely with the new preprocessor. @LazyDodo suggested a USD version update may fix this, which is something I can investigate in due course - right now, let's get daily builds up and working :)

Pull Request: https://projects.blender.org/blender/blender/pulls/121361
2024-05-02 20:05:51 +02:00
Sergey Sharybin
1b0012d51c Refactor: Require C++ for users of BLI_simd.h
This is because sse2neon.h might be used to emulate SSE intrinsics
on ARM64 architecture, and it uses some preprocessor which is not
available for C language when using MSVC.

The old-style math file math_matrix.c uses this header, so needed
to become C++. Simple rename did not work since there is a new math
utility math_matrix.cc exists. Following some existing convention
the math_matrix.c is renamed to math_matrix_c.cc. Eventually all the
code should switch to use C++ style math, and the C style removed,
so it seems reasonable to not mix old and new style of API in the
same file.

There should be no functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/121335
2024-05-02 16:22:19 +02:00
Campbell Barton
f6b7464b4c Cleanup: spelling in comments 2024-05-02 16:44:10 +10:00
Campbell Barton
523d84db85 Fix incorrect XDG_CURRENT_DESKTOP check
The string was checked for equality when the spec allows for `:`
delimiter characters.
2024-05-02 10:20:58 +10:00
Campbell Barton
594ee2c766 BLI_string: add BLI_string_elem_split_by_delim
Add a utility function to check if one string contains another
when split by a delimiter.
2024-05-02 10:20:56 +10:00
Hans Goudey
19cdef03e2 BLI: Add IndexMask::from_bools_inverse utility 2024-04-30 13:03:26 -04:00
Campbell Barton
d06c34b2e5 Cleanup: note that XDG_* environment variables can't be relied on
This assumption caused #121241.

Also correct `endif` comment.
2024-04-30 15:02:29 +10:00
Campbell Barton
b93ddf30e9 Unbreak build WITH_TBB=OFF 2024-04-30 12:12:02 +10:00
Jacques Lucke
8d13a9608b BLI: generalize task size hints for parallel_for
This integrates the functionality for `parallel_for_weighted` from 9a3ceb79de
into `parallel_for`. This reduces the number of entry points to the threading
API and also makes it easier to build higher level threading primitives. For
example, `IndexMask.foreach_*` may use `parallel_for` if a `GrainSize` is
provided, but can't use `parallel_for_weighted` easily without duplicating a
fair amount of code.

The default behavior of `parallel_for` does not change. However, now one can
optionally pass in `TaskSizeHints` as the last parameter. This can be used to
specify the size of individual tasks relative to each other and relative to the
grain size. This helps scheduling more equally sized tasks which generally
improves performance because threads are used more effectively.

One generally does not construct `TaskSizeHints` manually, but calls either
`threading::individual_task_sizes` or `threading::accumulated_task_sizes`. Both
allow specifying individual task sizes, but the latter should be used when the
combined size of consecutive tasks can be computed in O(1) time. This allows
splitting up the work more efficiently. It can often be used in conjunction with
`OffsetIndices`.

Pull Request: https://projects.blender.org/blender/blender/pulls/121127
2024-04-29 23:55:22 +02:00
Hans Goudey
d97f4493dc Cleanup: Remove unnecessary template specification in Color class
This gave a very noisy warning in GCC 14.
2024-04-29 10:57:00 -04:00
Campbell Barton
c0def6c93d Cleanup: spelling in comments 2024-04-27 11:58:02 +10:00
Campbell Barton
6456fa3b9e Cleanup: use C-style comment blocks 2024-04-26 13:55:38 +10:00
Campbell Barton
0f93f70076 Cleanup: quiet unused variable warnings 2024-04-25 12:09:31 +10:00
Sean Kim
a03bf7e055 Refactor: Invert return value of array_utils::indexed_data_equal
This PR inverts the return values of `indexed_data_equal` to make the
function return as one would expect (i.e. if everything is equal then it
returns true, if any are not equal it returns false)

Pull Request: https://projects.blender.org/blender/blender/pulls/121056
2024-04-25 02:31:27 +02:00
Ray Molenkamp
d2be9cecc2 Cleanup: Make Format 2024-04-24 08:42:16 -06:00
Ben-7
0136289cb6 CMake: Windows: clang-cl fixes
Support for building blender with clang on windows on x64 was added
years ago but given there are no active users support has crumbled a
bit.

This PR brings the build system back into working order but upstream
patches in openVDB are still required for a successful build see PR
#120317 for details.

Blender when build with clang the classroom scenes rendered on the cpu
with cycles is seeing a 5% reduction in render time on both an
AMD 7700x and an Intel 14900k.
2024-04-24 15:59:47 +02:00
Campbell Barton
ce05eb98c9 Cleanup: use const pointer arguments 2024-04-23 16:09:45 +10:00
Jacques Lucke
d7d8cefd72 Fix: incorrect safe float4x4 to quaternion conversion
The issue was that when a 4x4 matrix is normalized, it does not
always mean that any inner 3x3 matrix is normalized too.
2024-04-22 19:52:47 +02:00
Campbell Barton
fd589fdca4 Cleanup: various non functional C++ changes 2024-04-20 13:46:14 +10:00
Campbell Barton
c6a9b11ef6 Cleanup: use const pointers 2024-04-20 12:41:23 +10:00
Campbell Barton
4e8b24f1d1 Cleanup: spelling in comments & punctuation 2024-04-19 15:57:06 +10:00
Campbell Barton
cf37424203 Cleanup: use const pointers, quiet cppcheck unreadVariable warning 2024-04-17 11:36:38 +10:00
Campbell Barton
8680976dc9 Cleanup: match function/declaration names 2024-04-17 11:36:36 +10:00
Aras Pranckevicius
9962c50b54 BLI: factor out BLI_path_has_hidden_component, fix it and speed it up
Factors out utility function "does the path contain any hidden file/folder
components?" function out of innards of UI code (edit_file,
is_hidden_dot_filename) into a BLI function BLI_path_has_hidden_component
and then:
- Adds unit test coverage to it, which uncovered some inconsistencies
- Fix the behavior inconsistencies:
  - A path component that is just a dot (.), was not considered hidden.
    Unless it was the first folder component (now this is fixed).
  - A path component that ended in a tilde (~) was considered hidden.
    Unless it was the first folder component (now this is fixed).
- Speedup the function by not doing several recursive scans over the
  string; instead all the logic is done in a single string scan.

Synthetic HasHiddenComponents_Performance test: 6.0s -> 1.1s for 50M calls
on Mac M1 Max.

More real world test (setup as in #120494): out of whole build_catalog_tree
time, the time taken by BLI_path_has_hidden_component drops from 37% down
to 28%

Pull Request: https://projects.blender.org/blender/blender/pulls/120541
2024-04-16 16:51:31 +02:00
Jacques Lucke
bd72562ff9 Geometry Nodes: handle matrix to rotation conversion more gracefully
Previously, this conversion would often result in invalid quaternions or
hit an assert in `normalized_to_quat_fast`. It's not super nice to convert
to euler as an intermediate step performance wise, but it seems to be
the easiest solution for now. Extracting rotations from matrices should
not be done all that often anyway.

Pull Request: https://projects.blender.org/blender/blender/pulls/120568
2024-04-15 18:04:19 +02:00
Aras Pranckevicius
e2e6b977a6 Cleanup: Remove pre-SSE4 fallbacks in BLI pixel interpolation functions
Commit 8b9743eb40 already made Blender be compiled with SSE4.2 flags
on x64 architecture, which kicked in the SSE4 code paths in
BLI_math_interp functions.

Which made them faster, e.g. in VSE on Windows/Ryzen5950X, scaling
up an image to 4K resolution:
- Bilinear 5.8ms -> 5.3ms
- Cubic Mitchell 16.3ms -> 15.7ms

This change removes the now-unneeded SSE pre-SSE4 code paths for
_mm_floor_ps, _mm_min_epi32 and _mm_max_epi32 emulation.

Additionally, including BLI_simd.h on SSE4 platform now includes
the necessary SSE4 intrinsics header.

Pull Request: https://projects.blender.org/blender/blender/pulls/120583
2024-04-15 15:21:58 +02:00
Campbell Barton
49bf7ebbdd Cleanup: use const args & variables, remove redundant checks
- Declare const variables & arguments.
- Remove redundant null checks.
- Remove break after return.
- Replace suspicious "&" with "&&".
2024-04-15 09:50:47 +10:00
Jacques Lucke
c819d9fdc9 Fix #120579: incorrect compute context hashes
The problem was that `XXH3_128bits` was called on `len` bytes
and not `HashSizeInBytes + len` as before 51f8bf53b2.
This lead to more compute context duplicates that one would expect.

I changed the code a little bit to make this mistake less likely in case
the hash function is ever changed to something else.
2024-04-14 13:20:32 +02:00
Jacques Lucke
769a9069de BLI: use float instead of int for weights in string search
Floats are a bit more convenient to deal with. Also, I find myself
expecting this to be a float on the call site.
2024-04-12 14:34:17 +02:00
Campbell Barton
3a8cceee7d Cleanup: remove redundant checks & assignments 2024-04-11 20:47:07 +10:00
Campbell Barton
962d2ca6a6 Cleanup: use a const ListBase argument to BLI_uniquename
The list-base isn't manipulated, only the link argument.
2024-04-11 17:44:27 +10:00
Campbell Barton
a70f667f8b Cleanup: pass args by reference instead of value in mesh_boolean.cc 2024-04-11 17:44:27 +10:00
Campbell Barton
09ee8d97e6 Cleanup: use C-style comments for descriptive text 2024-04-11 17:44:27 +10:00
Iliya Katueshenock
6bafe65d28 Mesh: Calculate edges with VectorSet instead of Map
Due to legacy reasons (`MEdge`), edge calculation was being done with
idea that edges cannot be temporarily copied. But today, edges are just
`int2`, so using `edge *` instead of `edge` actually made things worse.
And since `OrderedEdge` itself is the same thing as `int2`, it does not
make sense to use `Map` for edges. So, now edges are in a hash set.
To be able to take index of edges, `VectorSet` is used.

The only functional change now is that original edges will be reordered
as well. This should be okay just like an unintentional but stable
indices change.

For 2'000 x 2'000 x 2'000 cube edges calculation, change is around
`3703.47` -> `2911.18` ms.

In order to reduce memory usage, a template parameter is added to
`VectorSet` slots, so they can use a 32 instead of 64 bit index type.
Without that, the performance change is not consistent and might not be
better on a computer with more memory bandwidth.

Co-authored-by: Hans Goudey <hans@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/120224
2024-04-11 04:33:25 +02:00
Clément Foucault
99ebc1f7d3 BLI: Fix inverted 0 determinant for infinite orthographic projection
This was creating issues with triangle winding order since
the resulting matrix was degenerate (0 determinant). Which
caused the Draw manager to wrongly invert the winding.

This fixes a bug in EEVEE-Next mesh voxelization for volume
rendering (with accurate method).
2024-04-10 15:53:51 +02:00
Falk David
7ce0b625cb BLI: IndexMask: Add binary set operations
The `IndexMask` class already had a static function `from_union`.
This adds two new functions `from_difference` and `from_intersection`
as well as tests for each of them.

It also uses `from_intersection` in two grease pencil utility functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/120419
2024-04-09 12:08:14 +02:00
Campbell Barton
e01525cf2c Cleanup: remove redundant variables & assignments
Co-authored-by: Sean Kim <SeanCTKim@protonmail.com>
2024-04-09 13:52:41 +10:00
Clément Foucault
4a7e98be40 EEVEE-Next: Volume: Fragment shader voxelization
This replaces the compute shader pass for volume material properties
voxelization by a fragment shader that is run only once per pixel.
The fragment shader then execute the nodetree in a loop for each
individual froxel.

The motivations are:
- faster evaluation of homogenous materials: can evaluate nodetree
  once and fast write the properties for all froxel in a loop.
  This matches cycles homogenous material optimization (except that
  it only considers the first hit).
- no invocations for empty froxels: not restricted to box dispach.
- support for more than one material: invocations are per pixel.
- cleaner implementation (no compute shader specific paths).

Implementation wise, this is done by adding a stencil texture when
rendering volumetric objects. It is populated during the occupancy
phase but it is not directly used (the stencil test is enabled but
since we use `imageAtomic` to set the occupancy bits, the fragment
shader is forced to be run). The early depth-test is then turned
on for the material properties pass, allowing only one fragment to
be invoked.
This fragment runs the nodetree at the desired frequency: once per
direction (homogenous), or once per froxel (heterogenous).

Note that I tried to use the frontmost fragment using a depth equal
test but it was failing for some reason on Apple silicon producing
flickering artifacts. We might reconsider this frontmost fragment
approach later since the result is now face order dependant when
an object has multiple materials.

Pull Request: https://projects.blender.org/blender/blender/pulls/119439
2024-04-05 16:33:58 +02:00
Aras Pranckevicius
4cb1d7242a Tests: extend ghash performance tests to cover blender::Map
Clean up the GHash performance testing suite (more C++ constructs), and
extend to cover blender::Map equivalents of the same functionality.

Pull Request: https://projects.blender.org/blender/blender/pulls/120252
2024-04-05 08:04:52 +02:00
Hans Goudey
274d7c6d12 Cleanup: Remove unused BVH tree function 2024-04-04 14:49:01 -04:00