Commit graph

12884 commits

Author SHA1 Message Date
Xavier Hallade
1849e53986 Fix #129235: Cycles: out of bound read from Embree
6c03339e48 moved from
rtcSetNewGeometryBuffer to rtcSetSharedGeometryBuffer but kept the
additional padding of 1 element in the function call.

It was previously used for over-allocating, to allow 16-byte reads of
all accessed elements, as Embree requires.
With rtcSetSharedGeometryBuffer, this argument led to an out-of-bounds
read as memory was already allocated without padding.
float3 is already 16-bytes so there is no need for padding, hence we
remove it.

We can also note that now, even when using rtcSetSharedGeometryBuffer,
over-allocating is not needed as it's done and functional on Embree side
since v3.6.

Pull Request: https://projects.blender.org/blender/blender/pulls/129643

Pull Request: https://projects.blender.org/blender/blender/pulls/130274
2024-11-15 09:30:41 +01:00
Brecht Van Lommel
21142a807c Fix #118514: Cycles MetalRT crash with empty scene
Pull Request: https://projects.blender.org/blender/blender/pulls/118907

Pull Request: https://projects.blender.org/blender/blender/pulls/127500
2024-09-12 15:54:14 +02:00
Jesse Yurkovich
1da590cd2e Build: Ambiguous call to isfinite for MSVC 17.11
Overload resolution must have changed and is causing issues for one
particular code path attempting to use `isfinite(ccl::uchar)`.
Compiler output attached.

It turns out that the code in question can be simplified to just remove
the ambiguity because only the float codepath wants to check for finite
values.

----
Reduced repro: https://godbolt.org/z/YWz3Yc3x8

Pull Request: https://projects.blender.org/blender/blender/pulls/125348
2024-09-12 15:13:00 +02:00
Weizhen Huang
9eabc20a48 Fix #126799: undefined behavior of shader node Arctan2 at (0, 0)
`atan2(0, 0)` is undefined on many platforms. To ensure consistent
result across platforms, we return `0` in this case.

Note only the behavior of the shader node `Artan2` is changed here.
During shading, we might still produce `atan2(0, 0)` internally and
cause different results across platforms, but that usually happens with
single samples and is not obvious, plus checking this condition all the
time is costly. If later we find out it's indeed necessary to change all
the invocation of `atan2(0, 0)`, we could change the wrapper functions
in `metal/compat.h` and `mtl_shader_defines.msl`.

Pull Request: https://projects.blender.org/blender/blender/pulls/126951
2024-09-12 15:08:41 +02:00
Alaska
99618031b3 Fix #125168: Cycles spot light theata_e can flip with a wide spread
When the spread of a spot light is at it's maximum (180 degrees),
then `atan(tan(theta_e))` could become quite unpredictable due to
a asymtote in the tan function when working with lights with this
spread (because theta_e is `spread * 0.5 = pi/2`).
This lead to issues like theta_e for the spotlight becoming negative,
which lead to rendering errors due to a malformed light tree.

This commit fixes this issue by adding a episilon region around the
troublesome values and sets theta_e to `pi/2` when in that region.

Candidate for backporting to 4.2 and potentially 3.6

Pull Request: https://projects.blender.org/blender/blender/pulls/125172
2024-08-16 14:04:44 +02:00
Weizhen Huang
5da75183d9 Fix #123448: Cycles area light using MIS when the spread is zero
area light with zero spread was introduced in bf18032977. Such paths can
only be sampled with NEE, so MIS should not be used.
This fixes the discrepancy when Direct Light Sampling is set to MIS or NEE.

Pull Request: #118584
2024-07-10 10:36:22 +02:00
Xavier Hallade
2ae87b8fb0 Cycles: oneAPI: Fix driver version check for future Intel GPU drivers
SYCL runtime currently relies on an internal driver behavior that will
break the driver version string returned by SYCL if it changes:
https://github.com/oneapi-src/unified-runtime/issues/1777
This will be fixed at SYCL runtime level but until we use a new enough
one, we need to add additional verifications to avoid blocking execution
on a driver that will change this internal behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/124084
2024-07-09 12:28:44 +02:00
Brecht Van Lommel
7999e39f35 Fix #117485: Crash rendering motion blur with changing curve count
This is not supported so there can be artifacts, but it should not
crash.

Pull Request: https://projects.blender.org/blender/blender/pulls/118859
2024-03-12 13:30:12 +01:00
Philipp Oeser
c549946417 Build: Upgrade Intel Graphics Compiler to 1.0.15468 on Linux
This corresponds the latest stable LTS release:
https://dgpu-docs.intel.com/releases/LTS_803.29_20240131.html

Graphics compiler upgrades require increasing the mininum required
driver (compute-runtime) version to the corresponding one to guarantee
compatibility, which is XX.XX.27642.38 in this release, so we bump this
requirement accordingly.

Fixes #118713

Pull Request: https://projects.blender.org/blender/blender/pulls/118814

Co-authored-by: Xavier Hallade <xavier.hallade@intel.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/119371
2024-03-12 12:59:15 +01:00
Sahar A. Kashi
b93d1c481e Fix #112983: Cycles HIP-RT crash on deleting all objects
Pull Request: https://projects.blender.org/blender/blender/pulls/118944
2024-03-11 14:44:57 +01:00
Alaska
89d8f12730 Fix: Cycles HIP incorrect rendering of clip image textures
This was fixed in the driver quite a while ago:
https://github.com/ROCm/HIP/pull/2229

Ref: #91571
Pull Request: https://projects.blender.org/blender/blender/pulls/118540
2024-03-11 14:09:32 +01:00
Alaska
5fc714999b Cycles: Improve reporting of HIP texture allocation failures
HIP fails to allocate textures, typically when they are too large.
This commit lets the user know what might be causing the issue
rather than providing a confusing internal error message.

Pull Request: https://projects.blender.org/blender/blender/pulls/118239
2024-03-11 14:08:40 +01:00
Alaska
a370276060 Fix: Cycles incorrect rendering of certain negative strength lights
This fixes an issue where lights that make use of constant negative strength
emission shaders would render with the absolute of their strength.

Pull Request: https://projects.blender.org/blender/blender/pulls/118541
2024-03-11 14:07:49 +01:00
Harley Acheson
a252833562 Fix #118351: Pixel Shift with Win32 Clipboard DibV5 Image Transfer
My misreading of the Microsoft BITMAPV5HEADER specification causes a
shift of three pixels when transferring between applications using this
format. This does not occur when moving within or between Blender
instances. This PR just removes the incorrect 12-byte offset. Note
that many applications prefer PNG transfers over DibV5 so testing this
might be non-obvious.

Pull Request: https://projects.blender.org/blender/blender/pulls/118417
2024-03-11 13:50:17 +01:00
Lukas Stockner
8508d6992b Fix #117586: Cycles: World Lightgroup not updated when creating/deleting LGs 2024-03-07 17:05:38 +01:00
Xavier Hallade
295dfd5756 Cycles: oneAPI: query graphics compiler for supported targets
In case a target isn't supported by the graphics compiler, it will be
filtered out from the target architectures to build for.

Ref #117027

Pull Request: https://projects.blender.org/blender/blender/pulls/112669
2024-02-15 17:42:14 +01:00
Xavier Hallade
c2518acd58 Cycles: oneAPI: update windows ocloc to 101.4723
The first public Windows driver version with a higher number is
101.4824, so we bump the min-required driver version on Windows to this
one to ensure compatibility.

Ref #117027
2024-02-15 17:41:54 +01:00
Xavier Hallade
f7ca183ff6 Build: upgrade Intel Graphics Compiler on Linux
In order to speedup compilation, we upgrade IGC to 1.0.14828.26 along
with ocloc and the associated dependencies.
We also bump min-driver version accordingly to 26918.

Ref #114341, #117027
2024-02-15 17:41:46 +01:00
Alaska
583af2a6e5 Fix #117771: Incorrect Cycles texture position on emissive triangles
Pull Request: https://projects.blender.org/blender/blender/pulls/117801
2024-02-14 19:54:34 +01:00
Brecht Van Lommel
02b9ea7072 Fix: Cycles MIS disabled unnecessarily with transparency, causing fireflies
This is a leftover from when there was a global option for transparent
shadows, but since it's now per material this makes no sense anymore.

Solution found by Olivier Maury.

Pull Request: https://projects.blender.org/blender/blender/pulls/117735
2024-02-14 14:36:07 +01:00
Philipp Oeser
51394779cf Fix #106425: Mantaflow guiding with domains is broken
Caused by e968b4197b / 67e23b4b29

Since culprit commits, we are not running `MANTA::initGuiding` /
`fluid_alloc_guiding` if guiding is meant to be pulled from other
domains (it does work with effectors though). This is because atm. only
the `FLUID_DOMAIN_ACTIVE_GUIDE` flag sets `mUsingGuiding` to true
(activated in `update_obstacleflags`, so only for effectors).

So to fix this, we have to ensure that `MANTA::initGuiding` runs (also
if guiding is pulled from domains), but also make sure we dont run into
the crashes from T102257.

It seems that the real reason we were getting crashes in T102257 is that
67e23b4b29 made it so that resetting the cache (including a call to
`fluid_modifier_reset_ex`) in `fluid_modifier_processDomain` happens
**after** `FluidDomainSettings.active_fields` have been updated (this
happens in `update_flowsflags` & `update_obstacleflags`).
But `fluid_modifier_reset_ex` also resets
`FluidDomainSettings.active_fields`. If we then update pointers later in
`fluid_modifier_processDomain`, we never get anything in the guiding
related pointers for the new `mCurrentID` (specifically `mPhiGuideIn`
will be a nullptr). This is the real reason `initGuiding()` runs a
second time (it does once for `fluid_modifier_init` then again as a
consequence of the call to `manta_guiding`).

This patch proposes to move the resetting process from 67e23b4b29
**above** the refreshing of the `FluidDomainSettings.active_fields`,
this way these field stay intact, we do get the first run of
`initGuiding()` from `fluid_modifier_init`, manta pointers get updated
with intact fields afterwards (so we then get a valid `mPhiGuideIn`),
which then prevents the second run from `manta_guiding` to actually call
the python script again.

The fix from e968b4197b is then not needed and reverted in this patch.

This should be good for LTS I think.

Pull Request: https://projects.blender.org/blender/blender/pulls/117067
2024-02-14 13:47:12 +01:00
Brecht Van Lommel
d9240b0724 Cleanup: make format 2024-01-11 14:43:42 +01:00
Brecht Van Lommel
bcfb2e4a83 Fix #116792: Cycles render issue velocity attribute and motion steps > 1
In this case the object transform can use more motion steps, but the
geometry needs to have its motion steps fixed since the velocity
attribute completely overrides them.
2024-01-10 19:23:15 +01:00
Alaska
f9c7acf05c Fix #116695: Cycles light tree crash with certain light visibility settings
Fixes an issue where triangles (and possibly lights) would not be added
to the light tree if the only visibility option it has enabled is volumetric
scattering.

This would lead to an assert during forward sampling because the light
would be treated as if it was in the light tree, and a light index
outside the light tree array would be sampled, which would trigger
the assert.

Pull Request: https://projects.blender.org/blender/blender/pulls/116703
2024-01-10 09:20:22 +01:00
bsavery
888612cb0e Cycles: add ROCm 6 compatibility for HIP
ROCm 6 brings some changes to the HIP API. This pull request is meant to be
backward and forward compatible.

That is Blender could be compiled with either ROCM 6 or 5 and run on either.
The main change is the hipMemoryType enum, which we check based on the
runtime version to use the correct enum values.

Without this, HIP will not work on Windows with upcoming 23.40 driver.

Pull Request: https://projects.blender.org/blender/blender/pulls/116713
2024-01-03 18:16:47 +01:00
Patrick Mours
836063cbd6 Fix #113325: Zero-sized curve leads to OptiX error
Empty hair geometry in Cycles may still report having one curve, even when
there are no actual segments in that curve. This caused an attempt to build
an acceleration structure with zero primitives, which due to other setup
OptiX rejected with an error. Fix that by checking the number of segments
rather than the number of curves in the hair geometry, since the former will
always be zero for empty geometry.

Pull Request: https://projects.blender.org/blender/blender/pulls/115044
2023-12-06 14:31:45 +01:00
Ray Molenkamp
ec6aa0b3fd Ghost: Fix build error with MSVC 17.7 preview 3
the initialization of m_pkts with an int threw an error with
17.7P3 since it decided int -> uint64_t required a narrowing
conversion. Not sure why it got picky here all of a sudden
but given it's not wrong, we may as well fix it properly.

This change changes the queueSize parameter to size_t and
adds a bounds check at the calling site to ensure the value
it gets will be positive before casting.
2023-12-06 14:29:34 +01:00
Campbell Barton
c3f67cd541 Fix uninitialized pending actions for Windows under Wayland
A windows pending actions wasn't cleared for new windows.
Although I'm not aware of user visible bugs, this prevents
unpredictable updates for new windows.
2023-12-06 14:28:37 +01:00
Leon Marz
064a48ad28 Fix: Increase thread stack size for musl libc
Manually set the stack size to 2mb, same as with Apple

Co-authored-by: Damian Kurek <starfire24680@gmail.com>

Pull Request: https://projects.blender.org/blender/blender/pulls/115094
2023-11-22 19:47:18 +01:00
Brecht Van Lommel
ade490ddd0 Fix 114336: Cycles crash switching render pass in the viewport 2023-11-14 09:59:19 +01:00
Campbell Barton
06e08069fc Fix incorrect screen-size under Wayland with transformed outputs
- The transform was incorrectly accessed as a flag.
- Missing checks for 270 degree rotation.

Back ported from [0].

[0]: ee15925716

Pull Request: https://projects.blender.org/blender/blender/pulls/114353
2023-11-07 15:32:19 +01:00
Campbell Barton
4b34443c10 Fix invalid surface size under Wayland when GHOST set the window size
When the window manager set the window size, there were no checks
the size is a multiple of the buffer scale (a requirement for Wayland).

This meant setting the window size could exit Blender without warning
if an invalid window size was set.

Back ported changes from [0] & [1].

[0]: 3ad21b2169
[1]: 46159c131d
2023-11-07 14:48:18 +01:00
Campbell Barton
4eca55cc11 Fix drag & drop crash when dragging over window decorations on Wayland
Missing null checks for drag events for non-GHOST surfaces
(typically window decorations).

Back ported from [0].

[0]: 3e9403bd76
2023-11-07 14:48:18 +01:00
Campbell Barton
98ec3826ac Fix mouse cursor failing to update for blocking actions on Wayland
Changes to the mouse cursor would only display when the main loop
was being handled, so blocking actions such as file load wouldn't
refresh the cursor.

Solve by flushing the display when the cursor changes.

Back ported from [0].

[0]: 8337b3dd3f
2023-11-07 14:48:18 +01:00
Brecht Van Lommel
b6f7ebe811 Fix #113461: Cycles subsurface artifacts with volume interior
Ignore self for the volume stack update from the the subsurface entry to
the exit point. This was meant for other objects only.
2023-11-07 09:34:07 +01:00
Sergey Sharybin
9bc7fcc36e Fix #112935: Wrong window order handling on macOS 14
The issue was caused by the custom code which was ensuring that closing
About window does not leave application without any key
windows.

Turns out that the windowWillClose is executed when menu is closed,
forcing the custom code to ensure a key window.

The solution is to only perform manual re-ordering if the closing window
was a key window. This both keeps old behavior of ensuring there is a
key window after closing About, and solves the ordering issues when a
window is created or activated via menus.

Pull Request: https://projects.blender.org/blender/blender/pulls/113515
2023-11-07 09:34:07 +01:00
Lukas Stockner
5f56992aff Fix #110183: Cycles: Numerical issues with distant area light sampling
The solid angle computation for the sampling/PDF code was running into
cancellation issues for small solid angles.
Reformulating the terms using asin() instead avoids this.
2023-11-06 18:58:16 +01:00
Brecht Van Lommel
0548b2dd3f Fix #112931: Cycles mesh light sampling artifacts 2023-11-06 18:15:32 +01:00
Weizhen Huang
9827c1f4de Cycles: more efficient and better-behaved sampling of spherical triangles
uses less inverse trigonometric functions and normalizations.
Also `q` is now guaranteed to be smaller than or equal to 1.

Pull Request: https://projects.blender.org/blender/blender/pulls/108380
2023-11-06 18:15:19 +01:00
Michael Jones
9f3f549fc2 Cycles: Metal: Fix occasional anim corruption (KernelData MD5 refresh bug)
This fixes an issue where animation frames occasionally get corrupted (e.g. when rendering "Pokedstudio" Blender 2.77 splash screen). This happens when the KernelData is refreshed but the MD5 isn't immediately regenerated which can cause the wrong PSO to be selected.

Pull Request: https://projects.blender.org/blender/blender/pulls/114153

Pull Request: https://projects.blender.org/blender/blender/pulls/114399
2023-11-02 14:52:42 +01:00
Michael Jones
04f8269ce3 Cycles: Fix animation hangs/crashes in Metal due to leaking temp objects
This PR adds `@autoreleasepool` blocks around functions that have been observed to create hidden temporary NSObjects, and eventually cause command buffer failures. A couple of allocations needed to be tweaked in order to maintain correct retain/release behaviour. This PR also fixes the command buffer error text to show more useful information.

(clone of 4e3ee4f02)
2023-11-02 14:52:41 +01:00
Michael Jones
b2d45a7993 Cycles: Fix #107714: Leak during MetalRT BVH buid
This patch fixes the memory leak described in #107714 by adding an `@autoreleasepool` around Metal BVH builds. Certain NSObjects were being retained indefinitely, specifically ones which had been value-passed via an NSArray into acceleration structure descriptors.

Pull Request: https://projects.blender.org/blender/blender/pulls/112820
2023-11-02 14:52:41 +01:00
Michael Jones
ddff3680e2 Cycles: Disable NanoVDB if not needed when specialising Metal PSOs
This patch adds a check to see whether we're actually using NanoVDB textures, and if not, removes `#define WITH_NANOVDB` when generating the scene-optimised kernels. This results in marginally faster render times (maybe 2 or 3%) for scenes that do not use NanoVDB. The generic kernels are unaffected, so this will not impact responsiveness on first render.

Pull Request: https://projects.blender.org/blender/blender/pulls/112822
2023-11-02 14:52:41 +01:00
Michael Jones
5c34161a3f Cycles: Make use of maximum concurrent compilations on Metal
This patch queries the MTLDevice `maximumConcurrentCompilationTaskCount` property (macOS >= 13.3) to spawn more compilation threads if available.

Pull Request: https://projects.blender.org/blender/blender/pulls/109689
2023-11-02 14:52:41 +01:00
coyo_t
a1bea1df6b Fix #106760: Cycles OSL boolean socket not working
Pull Request: https://projects.blender.org/blender/blender/pulls/109576
2023-10-12 13:54:41 +02:00
Brecht Van Lommel
f6558e3a23 Build: support OpenColorIO 2.3
For Linux distributions or others that upgrade before we do.

Ref #113157

Pull Request: https://projects.blender.org/blender/blender/pulls/113163
2023-10-02 19:55:51 +02:00
Brecht Van Lommel
f41ea8637d Fix #109907: Cycles multiscatter GGX transmission artifacts
Due to correlation in LCG.
2023-10-02 19:05:46 +02:00
ChengduLittleA
8159bd90e5 Fix #111820: Missing type casting in XrGraphicsBinding.cc
The line `oxr_binding.egl.getProcAddress = eglGetProcAddress` supposedly
needs a type casting for it to compile successfully under llvm16.

Pull Request: https://projects.blender.org/blender/blender/pulls/111915
2023-09-13 14:56:42 +02:00
Xavier Hallade
fe8753f375 Cycles: oneAPI: increase windows min driver requirement to 101.4644
101.4644 has been released 2023-08-15 and fixes the Windows specific
issue #109282.

Pull Request: https://projects.blender.org/blender/blender/pulls/112290
2023-09-12 17:37:13 +02:00
Xavier Hallade
0d557718eb Fix #111162: Overlay drawing issues due to shared library using fastmath
Cycles oneAPI kernel library was compiled using -ffast-math. The current
version of Clang makes it link to crtfastmath.o in that case, bringing a
static constructor that does set the FTZ/DAZ bits in MXCSR for the whole
program, leading to unwanted behavior with other components.
Instead of -ffast-math, we switch to a safer subset of compile flags.

Pull Request: https://projects.blender.org/blender/blender/pulls/111708
2023-09-12 16:12:30 +02:00