Commit Graph

9135 Commits

Author SHA1 Message Date
Jacques Lucke
3ae20bf166 Cleanup: remove foreach macro from .clang-format
The usage of that macro was removed in 60bec183cb,
but it was still in our .clang-format file. This lead to worse formatting when other code
used methods named `foreach`.

Pull Request: https://projects.blender.org/blender/blender/pulls/137468
2025-04-14 16:17:00 +02:00
Brecht Van Lommel
1cb2244e90 Fix: Cycles build error when WITH_CYCLES_OSL=OFF 2025-04-14 11:35:22 +02:00
Campbell Barton
5affe5fc6d Cleanup: spelling in comments (make check_spelling_*) 2025-04-12 19:31:29 +10:00
Brecht Van Lommel
c8f9fdc0c8 Fix: Cycles CUDA errors after recent changes for scene update
Broken by 86b67a20d6. Delay upload of shader data to GPU until
after kernels have been loaded.

Pull Request: https://projects.blender.org/blender/blender/pulls/137349
2025-04-11 19:14:14 +02:00
Brecht Van Lommel
86b67a20d6 Refactor: Cycles: Move scene update earlier in render iteration update
This will be needed to determine if there are volumes in the scene, before
allocation passes to aid volume sampling.

The kernels are now also loaded in the middle of scene update, at a place
where kernel features are known but before the kernels are needed for
displacement and background light evaluation..

Updating the camera to final resolution for progressive refinement still
happens later.

Pull Request: https://projects.blender.org/blender/blender/pulls/137228
2025-04-11 14:28:22 +02:00
Brecht Van Lommel
c4db213127 Refactor: Cycles: Use full resolution for viewplane bounds check
Results should be unchanged, but it's confusing if these use the progressive
refinement resolution instead of the full resolution.

Pull Request: https://projects.blender.org/blender/blender/pulls/137228
2025-04-11 14:28:22 +02:00
Sergey Sharybin
9f999adfc6 Fix #137230: Cycles OpenPGL crash with shadow catcher
The crash was caused by an overflow in the opgl_path_segment_storage
array. It happened because shadow catcher paths would write to the
segments but not clear them. This made it so the next render loop
iteration for the main path starts with non-empty segments in the
guiding data.

Disable training when megakernel is called for the shadow catcher
state.

To ensure this issue is not forgotten when the guiding is ported to
GPU add asserts in the `guiding.h`. While it is a no-op for default
GPU kernels sometimes we do compile debug kernels. But also it acts
as a plain-text reminder to the future-us in working on the code.

There is now also an assert before the main path megakernel to help
catching such cases in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/137291
2025-04-11 12:31:22 +02:00
Brecht Van Lommel
7aaa43b557 Revert "Fix: Build failures when using path with spaces on macOS"
This reverts commit be63ebd961.

This doesn't work well with MSBuild, semicolons get escaped even in
verbatim mode.
2025-04-10 13:04:34 +02:00
Sergey Sharybin
30b962b3d8 Cycles: Optimize 3d and 4d noise
The goal is to reduce the affect of the fmod() used in the noise code,
which was initially reported in the comment:

    https://projects.blender.org/blender/blender/pulls/119884#issuecomment-1258902

Basic idea is to benefit from SIMD vectorization on CPU.

Tested on Linux i9-11900K and macOS on M2 Ultra, in both cases performance
after this change is very close to what it could be with the fmod() commented
out (the call itself, `p = p + precision_correction`).

On macOS the penalty of fmod() was about 10%, on Linux it was closer to 30%
when built with GCC-13. With Linux builds from the buildbot it is more like 18%.

The optimization is only done for 3d and 4d noise. It might be possible to
gain some performance improvement for 1d and 2d cases, but the approach would
need to be different: we'd need to optimize scalar version fmodf(). Maybe
tricks with integer cast will be faster (since we are a bit optimistic in the
kernel and do not guarantee exact behavior in extreme cases such as NaN inputs).

Pull Request: https://projects.blender.org/blender/blender/pulls/137109
2025-04-09 13:40:10 +02:00
Campbell Barton
bf03a2684b Fix: error with CMake checking the wrong WEBP variable 2025-04-09 10:21:37 +10:00
Sergey Sharybin
5b0ed683a0 Cycles: Make select() and mask() for vectorized float work on CPU and GPU
Pull Request: https://projects.blender.org/blender/blender/pulls/137148
2025-04-08 17:04:18 +02:00
Brecht Van Lommel
6db2c6b864 Revert: Part of "Fix: Build failures when using path with spaces"
Commit be63ebd961

This is causing issues with CUDA kernel compilation in some setups, even
though the builbot is ok. Since this isn't yet working for oneAPI anyway,
revert all the changes to Cycles kernel compilation for now.
2025-04-08 14:55:03 +02:00
Brecht Van Lommel
be63ebd961 Fix: Build failures when using path with spaces on macOS
Use VERBATIM to ensure spaces inside command line arguments don't get
escaped automatically.

On Linux and Windows the oneAPI kernel compilation still has problems.
There is an apparent bug with single quote escaping in add_custom_command
which means it's not easy to use VERBATIM.
2025-04-07 16:29:14 +02:00
Alaska
975d61daf3 Cycles: Disable MNEE on RDNA4 GPUs
At the moment MNEE locks up Cycles, or has rendering artifacts on
RDNA4 GPUs on WIndows.

This commit disables MNEE on that configuration until a fix
is avaliable.

Pull Request: https://projects.blender.org/blender/blender/pulls/136980
2025-04-05 14:06:40 +02:00
Campbell Barton
f48b4e3abf Cleanup: wrap long lines for CMake 2025-04-05 20:30:37 +11:00
Weizhen Huang
0dc46773e0 Fix: Cycles Render Scheduler not respecting sample limit per update
Delay the clamping until later

Pull Request: https://projects.blender.org/blender/blender/pulls/136984
2025-04-04 14:17:08 +02:00
Hans Goudey
d4b23d38c9 Cleanup: Formatting 2025-04-03 11:44:25 -04:00
Michael Jones
326d5bca03 Cycles: Support Decomposed MetalRT motion interpolation
Currently MetalRT interpolates transformation matrix on per-element basis
which leads to issues like #135659.

This change adds implementation of for decomposed (Scale/Rotate/Translate)
motion interpolation, matching behavior of BVH2 and other HW-RT.

This requires macOS 15 and Xcode 16 in order to use this interpolation.
On older platforms and compilers old interpolation is used.

Currently there is no changes on the user (by default) and it is only
available via CYCLES_METALRT_PCMI environment variable. This is because
there are some issues with complex motion paths that need to be looked
into. Having code available makes it easier to do further debugging.

Ref #135659

Authored by Emma Liu

Pull Request: https://projects.blender.org/blender/blender/pulls/136253
2025-04-03 16:24:04 +02:00
Xavier Hallade
3dd6104c87 Cycles: oneAPI: Fix building for non-Intel SYCL targets without ocloc
The current logic disables WITH_CYCLES_ONEAPI_BINARIES when ocloc is not
found, which is fine, but prevented building for other non-Intel SYCL
targets without (unnecessary) ocloc.

The fix here is to remove spir64_gen target when
WITH_CYCLES_ONEAPI_BINARIES is disabled, instead of forcing only spir64.
2025-04-03 15:13:57 +02:00
Campbell Barton
f89cf19ba6 Cleanup: indentation for CMake files, strip trailing space 2025-04-02 03:01:59 +00:00
Sergey Sharybin
36559fd89f Fix #136811: HIP-RT performance regression in 4.5
Reduce the register pressure and branching in the switch() by using
subclass and cast from void* to the base class.

This ensures intersection functions are not inlined multiple times,
bringing performance back.

Alternative could be to avoid functions (they are quite large) but
that only partially resolves the performance regression.

Pull Request: https://projects.blender.org/blender/blender/pulls/136823
2025-04-01 17:59:44 +02:00
Xavier Hallade
17e0d88c05 Cycles: oneAPI: Avoid returning 0 from get_max_num_threads_per_multiprocessor
Instead of relying on the Intel extensions that may not be implemented,
we can use max_work_group_size until there is a better alternative.
Thanks to Codeplay for this proposal.

Co-authored-by: Georgi Mirazchiyski <georgi.mirazchiyski@codeplay.com>
2025-04-01 11:10:08 +02:00
Campbell Barton
e3d6051181 Cleanup: suppress cast-function-type warnings for CLANG
Extend the existing GCC pragma's and add the warning suppression
for Cycles & Freestyle.
2025-04-01 12:06:03 +11:00
Weizhen Huang
c2ec66a75b Fix #136726: Cycles: Area light visible when size is 0
Area light with a size of zero should not contribute to the scene, so
set the light as disabled.

This does not only fix the reported bug where such light is visible to
the camera, but also a regression in 4.2 where the light contributes to
the scene when light tree is off.

Pull Request: https://projects.blender.org/blender/blender/pulls/136763
2025-03-31 16:17:59 +02:00
Xavier Hallade
795a76029a Cycles: oneAPI: Restrict use of experimental copy optimization to L0
This API is not properly implemented in other SYCL backends at the
moment and we don't want it to fail at runtime, so we conservatively
enable it only for Level-Zero.
2025-03-31 16:14:36 +02:00
Xavier Hallade
e00cc8c100 Cycles: oneAPI: Use default linker on Windows
The initial issues that led to the choice of forcing the use of
linker.exe seem gone and there is currently no strong reason to use
linker.exe explicitly, so let's simplify and use the default setting.
2025-03-28 12:34:16 +01:00
Alex Fuller
a1b7ce1d22 Cycles: Move UV tangent computation into the core
This makes it available in Cycles standalone, and the implementation
can be shared with Blender. This also makes it possible to compute
tangents after tessellation for adaptive subdivision.

There is a difference in UV map tangents when there are no UVs. They
are now generated from object space coordinates instead of auto
texture space coordinates. This is more efficient, and a corner case
that we don't have to keep compatible.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>

Pull Request: https://projects.blender.org/blender/cycles/pulls/25
2025-03-27 22:07:50 +01:00
Alex Fuller
438ac2a653 Cycles: Add OSL metadata for default geometry attributes
Add support for OSL parameter metadata named `defaultgeomprop`, whose
values are interpreted the same way as the property on MaterialX node
inputs. When set to `Tworld` the tangent is then automatically linked
to the shader and generated for the mesh.

Pull Request: https://projects.blender.org/blender/cycles/pulls/25
2025-03-27 22:07:50 +01:00
Brecht Van Lommel
47e1b24c29 Refactor: Cycles: Apply static transforms later in scene update
It makes more sense to do it after geometry processing, in particular
for the tangent computation that is coming.

Pull Request: https://projects.blender.org/blender/blender/pulls/136576
2025-03-27 22:07:50 +01:00
Brecht Van Lommel
e394fd191b Refactor: Cycles: Sync various build fixes from the standalone repository
Pull Request: https://projects.blender.org/blender/blender/pulls/136576
2025-03-27 22:07:50 +01:00
Pierre Pontier
178b0cbff9 Cleanup: Fix warnings about comparing int and size_t
Pull Request: https://projects.blender.org/blender/cycles/pulls/24
2025-03-27 22:07:50 +01:00
Brecht Van Lommel
26ccbaf8b5 Fix: Cycles build broken without OpenSubdiv 2025-03-27 22:07:50 +01:00
Xavier Hallade
c4cf399755 Cycles: oneAPI: Re-enable -ffast-math
The initial limitation preventing from using -ffast-math, worked around
in 09df1f4caf, got fixed upstream in LLVM
and the fix is part of current DPC++ compiler:
63ecd2a725

We're now able to go back to using -ffast-math, which helps simplifying
the set of compiler flags.

No performance nor conformance change is expected from this change (most
of the gain is achieved already with the use of -cl-fast-relaxed-math
since 284b89a0a3) and this has been
verified on Arc B580 under Windows.
2025-03-27 17:18:30 +01:00
Brecht Van Lommel
15390b9257 License: Change NanoVDB header to Apache 2, following upstream OpenVDB
This license was changed upstream, and it's simpler if we can use the same as
most of the Cycles code.
2025-03-27 14:48:06 +01:00
Alaska
2e829ca4cf Fix #136303: Normalize the normals on the Ambient Occlusion node
This commit simply normalizes the normals of the Ambient occlusion
node before computing the output to avoid odd behaviour with
unnormalized normals.

Pull Request: https://projects.blender.org/blender/blender/pulls/136315
2025-03-27 02:58:19 +01:00
Campbell Barton
42ad772a1f Cleanup: spelling & repeated terms (make check_spelling_*)
Also use comment blocks for English text.
2025-03-27 01:13:34 +00:00
Xavier Hallade
7a257359f8 Cycles: oneAPI: Use max_compute_units in get_num_multiprocessors
Instead of returning 0 in case the Intel extension for getting the count
of Execution Units isn't available, we now use
sycl::info::device::max_compute_units.

We keep using the Intel extension in priority since it logically goes
with sycl::ext::intel::info::device::gpu_hw_threads_per_eu used in
get_max_num_threads_per_multiprocessor(), for which there is no
sycl::info::device::max_threads_per_compute_unit replacement yet.
2025-03-26 23:15:49 +01:00
Xavier Hallade
06b03b0fa6 Fix: Windows debug release builds fail at linking
The debug set of Embree prebuilt libraries currently lacks SYCL support
while the release ones have it.
This case was not gracefully handled for debug builds with Embree on GPU
enabled, leading to linking errors, trying to resolve rtcNewSYCLDevice
and rtcIsSYCLDeviceSupported.
We now test for this case to explicitly disable the use of Embree on GPU
for debug builds on Windows and print this status from CMake.
2025-03-26 23:01:39 +01:00
Sergey Sharybin
42cbc52b07 Fix: Warning in Cycles motion blur kernel features expression
This fixes the following warning with MSVC:
device_impl.cpp(287): warning C4805: '|=': unsafe mix of type 'bool' and type 'ccl::uint' in operation

The similar fix is applied to Metal code as well.

There is no short-circuiting boolean operator ||=, so expand the expression.

Pull Request: https://projects.blender.org/blender/blender/pulls/136561
2025-03-26 17:20:33 +01:00
Sergey Sharybin
2ab231d802 Refactor: Pass proper KernelGlobals
HIP-RT functions do have access to kg, and it was used inconsistently:
some functions were passed actual kg, other were passed nullptr.

This change makes it consistent and passes kg everywhere.

Pull Request: https://projects.blender.org/blender/blender/pulls/136503
2025-03-26 11:07:06 +01:00
Sergey Sharybin
709371b278 Refactor: Avoid creation of local copy of RaySelfPrimitives 2025-03-26 11:07:04 +01:00
Sergey Sharybin
888c7e1df9 Cleanup: Avoid redundant data fetch 2025-03-26 11:07:04 +01:00
Sergey Sharybin
3d882acee2 Cleanup: Else after return 2025-03-26 11:07:04 +01:00
Sergey Sharybin
b2dd523d0d Cleanup: Avoid default hit initialization
The entire object is assigned later on, no need to initialize it.
2025-03-26 11:07:04 +01:00
Sergey Sharybin
323e27d825 Cleanup: Remove redundant assignment
The payload stores pointers, no need to restore pointer
of the function argument to the same value.
2025-03-26 11:07:04 +01:00
Sergey Sharybin
e92a8042c3 Refactor: Payload for shadow intersection and filter in HIP-RT
The code before this change was relying on the ShadowPayload have
the same "header" as RayPayload for some of the primitive types
(curve, motion triangle, point): intersection functions were shared
between "regular" and shadow rays (shadow in this case is shadow_all),
but extra filter function was used for shadow rays.

This is fragile if someone changes one of these structures. What is
worse is that compiler might actually decide to shuffle things in
some structs, or remove unused fields.

This change also solves confusion about ShadowPayload::prim_type
seemingly only being assigned to PRIMITIVE_NONE. With time it is
not impossible that compiler will also see this, and constant-fold
some checks, or even remove the field. If that happens then the
render result will be wrong. Maybe it is already happening as there
are some GPU and driver and optimization flag specific bugs in the
area.

It is unclear whether it was causing any actual problem: W7800
seems to render all hair correctly on Linux.
2025-03-26 11:07:04 +01:00
Sergey Sharybin
cdb3f34944 Cleanup: Use full name for the primitive_type
Makes it extra clear locally type of what the variable contains:
primitive, ray, or something else.
2025-03-26 11:07:04 +01:00
Sergey Sharybin
72542f3bb4 Cleanup: Follow Blender style and use more const
Also make some style decisions more consistent: for example,
the way how stop/continue search return value is commented.
Prefer lower vertical space for those.
2025-03-26 11:07:04 +01:00
Sergey Sharybin
bf9c95f164 Cleanup: Move payload type cast to caller in HIP-RT
Mainly readability purposes:
- Having variables called local_payload is ambiguous: does it refer to
  LocalPayload type or to a variable be local in a function?
- Some of the functions are used for different ray types, so having the
  type case in intersectFunc and filterFunc makes it easier to scan.

For the latter: now it is more obvious that Curve_Intersect_Shadow
expects RayPayload, but Curve_Filter_Shadow expects ShadowPayload.
It might not be a problem currently as ShadowPayload has the same
"header" RayPayload, but it might change in the future. Also, compiler
might optimize fields out from one but not from the other.
2025-03-26 11:07:04 +01:00
Sergey Sharybin
3daaf21bab Cleanup: Remove unused function argument in HIP-RT 2025-03-26 11:07:04 +01:00