Commit Graph

15010 Commits

Author SHA1 Message Date
Jeroen Bakker
bd139fef14 Fix: Vulkan: Validation error on devices without external memory
Qualcomm devices don't support external memory, but there an external
memory pool was still being constructed. This PR skips the creation and
asserts when using external memory on those devices.

Pull Request: https://projects.blender.org/blender/blender/pulls/139326
2025-05-23 15:59:29 +02:00
Jeroen Bakker
ea22ef739d Cleanup: Vulkan: Remove explicit feature VVL
We should not enable features explicitly. This also prints an info
record when using VVL. When you want to enable specific features
use vkconfig/vkLoader.

Pull Request: https://projects.blender.org/blender/blender/pulls/139324
2025-05-23 11:04:56 +02:00
Eqkoss / T1NT1N
bb9d5cdaad Lights: Add normalize property
When enabled, this normalize the strength by the light area, to keep
the total output the same regardless of shape or size. This is the
existing behavior.

This is supported in Cycles, EEVEE, Hydra, USD, COLLADA.

For add-ons, an API function to compute the area is added for conversion,
in case there is no native support for normalization.

area = light.area(matrix_world=ob.matrix_world)

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

Pull Request: https://projects.blender.org/blender/blender/pulls/136958
2025-05-22 16:32:44 +02:00
Brecht Van Lommel
a428815716 Fix: Cycles light tree poor when light normalize is off
This option was not exposed in the Blender UI, so no user visible effect.
Take into account light area when building light tree.

Ref #136958
2025-05-22 16:32:44 +02:00
Eqkoss / T1NT1N
a12bce039f Lights: Add temperature property
Similar to other renderers, this adds a temperature property to set the
light color using blackbody emission. This can be more convenient than
using nodes, and can improve interop with other software.

This is supported in Cycles, EEVEE, Hydra, USD, COLLADA and FBX.

Pull Request: https://projects.blender.org/blender/blender/pulls/134303
2025-05-22 16:32:44 +02:00
Eqkoss / T1NT1N
7e0dad0580 Lights: Add exposure property
Similar to other renderers, this adds an exposure property to multiply
the light power by 2^exposure. This can be more convenient to control
a wide range of values.

This is supported in Cycles, EEVEE, Hydra, USD, COLLADA and FBX.

Pull Request: https://projects.blender.org/blender/blender/pulls/134528
2025-05-22 16:32:44 +02:00
Brecht Van Lommel
6f45aedd85 UI: Move some advanced Cycles light settings to Settings panel
Similar to the material Settings panel. To make room for three new options
that will be added in following commits.
2025-05-22 16:32:43 +02:00
Michael Jones
8dd9aeb11e Cycles: Fix occasional failure in path_create_directories
This PR adds a global mutex to `path_create_directories` to fix a thread-safety issue which can occur when concurrently creating multiple subdirectories with common stems.

Pull Request: https://projects.blender.org/blender/blender/pulls/139266
2025-05-22 16:06:51 +02:00
Jeroen Bakker
b2a3caac5b Fix #138140: Vulkan: First few frames squashed on X11
Previous swapchain fixes didn't solve the issue on X11 so for X11 we still need
to disable VK_EXT_swapchain_maintenance1.

Pull Request: https://projects.blender.org/blender/blender/pulls/139270
2025-05-22 14:15:28 +02:00
Sebastian Herholz
5abf42012d Cycles: Guiding cleaning up and refactoring the guiding code
In detail:
- Direct accesses of state attributes are replaced with the INTEGRATOR_STATE and INTEGRATOR_STATE_WRITE macros.
- Unified the checks for the __PATH_GUIDING define to use #  if defined (__PATH_GUIDING__).
- Even if __PATH_GUIDING__ is defined, we now check if the feature is enabled using if ((kernel_data.kernel_features & KERNEL_FEATURE_PATH_GUIDING)) {. This is important for later GPU ports.
- The kernel usage of the guiding field, surface, and volume sampling distributions is wrapped behind macros for each specific device (atm only CPU). This will make it easier for a GPU port later.
2025-05-22 13:46:30 +02:00
Campbell Barton
e5deeafe92 Cleanup: spelling in comments (make check_spelling_*) 2025-05-22 11:11:48 +10:00
Brecht Van Lommel
fc686ff257 Fix #139002: Cycles particle object instance appears in center of scene
The particle system generates some particles with NaN values. The
set_if_different mechanism skipped copying those due to a refactor
in the matrix equality test. Revert that part of 689633d802 for now.

A better solution would be to improve handling of NaNs in Cycles,
and to find and fix the cause of the NaN in the particle system.

Pull Request: https://projects.blender.org/blender/blender/pulls/139238
2025-05-22 01:10:19 +02:00
Sebastian Parborg
1858eba473 Fix: Jemalloc settings not getting applied as version check fails
Some Linux multi lib setups have a helper include file for Jemalloc that
in turn includes the actual header file. This makes our version regex fail.

As the Jemalloc version we are checking for is no longer in any of
the currently supported LTS linux distros, we can safely drop it.

Pull Request: https://projects.blender.org/blender/blender/pulls/139225
2025-05-21 19:10:57 +02:00
Jeroen Bakker
60990f6b72 Refactor: OpenXR: Add begin and end submit swapchain handler
Graphics bindings would be able to share resources more easily.
Extracted from !139140

Pull Request: https://projects.blender.org/blender/blender/pulls/139155
2025-05-20 14:04:45 +02:00
Weizhen Huang
54e748852a Fix #139022: Cycles: Mix Color Node using socket values when constant folded
If Mix Color node clamps the result, we do not bypass the node, but
disconnect other inputs. However, for the case where both inputs were the
same, the disconnected one would use the stored socket value instead, so
set the factor to 0 to only use the intended input.

Pull Request: https://projects.blender.org/blender/blender/pulls/139098
2025-05-20 12:30:20 +02:00
Campbell Barton
7c668c0308 Cleanup: CMake indentation & wrap long lines 2025-05-20 11:20:09 +10:00
Damien Picard
81d9e94218 UI: Fix and improve a few messages
- "Parameters for custom (OSL-based) Cameras" -> "cameras": lower case
  in tooltips.
- "Connect two nodes ... (automatically determined": missing
  parenthesis.
- "Join curve... control points are detected(if disabled...": add
  missing space.
- "Add Selected to Active Objects Collection" -> "Active Object's":
  typo.
- "Duplicate the acive shape key" -> "active": typo.
- "Copy selected points ": remove trailing space.
- "Move cursor" -> "Cursor": title case for operator.
- "Paste text to clipboard" -> "from clipboard": typo.
- "An empty Action considered as both a 'layered' and a 'layered'
  Action." -> "is considered as both a 'legacy' and a 'layered'
  Action": likely copy-paste error.
- "Target's Z axis will constraint..." -> "will constrain": typo.
- "The layer groups is expanded in the UI" -> "layer group": typo.
- Deprecation warnings: add missing parentheses.
- "... on low poly geometry.Offset rays...": add missing space after
  period.
- "... relative to the files directory" -> "... to the file's
  directory": typo.
- "The unit multiplier for pixels per meter" -> "The base unit": this
  property description was copy and pasted.
- "... beyond the faces UVs..." -> "the faces' UVs: typo.
- "Is tracking data contains ..." -> "Whether the tracking data
  contains": grammar.
- "Selected text" -> "Text": title case for prop.
- "The user has been shown the "Online Access" prompt and make a
  choice" -> "made a choice": grammar.
- "Glare ": remove trailing space.
- "Don't collapse a curves" -> "Do not collapse curves": grammar.

Some issues reported by Tamar Mebonia.

Pull Request: https://projects.blender.org/blender/blender/pulls/139118
2025-05-19 22:12:17 +02:00
Sebastian Parborg
62ccba022c Fix #139007: Input string refresh calls missing for Win IME
The update/refresh calls got removed by mistake in #138871.
2025-05-19 16:06:19 +02:00
Jeroen Bakker
808ba086f1 Cleanup: Vulkan: Feature chain
In stead of keeping track of a local variable this PR will keep a list
of all feature structs and at the end populate the pNext.

Pull Request: https://projects.blender.org/blender/blender/pulls/139092
2025-05-19 15:45:50 +02:00
Jeroen Bakker
e844e0c90d Vulkan: Enable robustness2 null descriptors
This change will enable VK_EXT_robustness2.nullDescriptors feature.
It will be able to guarantee that shaders run even when some resources
are not attached.

There should not be any difference with before as this feature is often
the default behavior of GPUs. However it makes the intent more explicit
that failing allocations can still run similar to OpenGL. It is expected
that some tweaks are needed in Vulkan backend.

Pull Request: https://projects.blender.org/blender/blender/pulls/139090
2025-05-19 14:43:55 +02:00
Alaska
ce0ec6e708 Cycles: Disable MNEE in the HIP backend
MNEE on HIP has rendering artifacts on RDNA1 (#134978), RDNA2 (#139068)
and RDNA4 (#136980), and can lock up the GPU under specific situations with
RDNA3 (#138607).

There are certain configurations that work (E.g. RDNA4 seems to work on
Linux), but the number of configurations that work keep dropping as further
developments are made in other areas. So it was decided it's just better to
disable MNEE entirely on HIP.

This commit disables MNEE on HIP, and does a small cleanup to remove the
unused functions as a result of this change.

Fix #139068: MNEE renders with artifacts on RDNA2
Fix #138607: MNEE render test stalls on RDNA3

Pull Request: https://projects.blender.org/blender/blender/pulls/139069
2025-05-19 12:42:20 +02:00
Jeroen Bakker
2143eb7a4f Refactor: Vulkan/OpenXR: Import memory handles only once
Importing memory is done to often. when memory doens't change the
previous imported memory can be used.

The idea is to keep track of the last used buffer and keep reusing
it until the view/resolution has changed. This should not happen during
a session.

Pull Request: https://projects.blender.org/blender/blender/pulls/138984
2025-05-19 12:32:08 +02:00
Brecht Van Lommel
358de9e6c9 Fix #139010: Cycles USD motion blur shading artifacts
This code should not have been removed in 47e1b24c29.
2025-05-19 12:12:46 +02:00
Brecht Van Lommel
1e3a7c8c88 Fix #138986: Cycles curve intercept and length rendering wrong
Missed updating these in a previous refactor.
2025-05-19 12:10:46 +02:00
Brecht Van Lommel
59b4842117 Cycles: Adaptive subdivision triangular patches
There is a corner case where one side of a quad needs splitting and the other
side has only one segment. Previously this would produce either gaps or after
recent changes to stitch together geometry, uninitialized memory.

Now solve this by splitting into triangular patches, as suggested in the
DiagSplit paper. These triangular patches can be further subdivided themselves.
Dicing has special cases for 1 or 2 segments on edges. For more segments it
works the same as: quad dicing: A regular inner triangle grid stitched to the
outer edges.

Fix #136973: Inconsistent results with adaptive subdivision

Pull Request: https://projects.blender.org/blender/blender/pulls/139062
2025-05-19 12:04:11 +02:00
Brecht Van Lommel
98104d63ca Refactor: Track max subdivision depth per edge instead of per patch
This ensure results are consistent between patches for the upcoming triangle
patch case, where we can't assume alternating subdivision like quads.

Pull Request: https://projects.blender.org/blender/blender/pulls/139062
2025-05-19 12:04:08 +02:00
Brecht Van Lommel
d6b42d3eac Refactor: Rename subpatch members to prepare for triangular patch
Pull Request: https://projects.blender.org/blender/blender/pulls/139062
2025-05-19 12:03:58 +02:00
Nikita Sirgienko
54766b6a54 Cycles: Introducing the code for adoption of Embree 4.4
Embree 4.4 introduces an improvement in the Embree GPU
implementation by dropping shared memory usage in favor
of direct controllable memory transfers. This should allow
addressing several problems spotted in Blender regarding
multithreading and memory corruption when BVH and rendering
happen at the same time. However, to implement such
improvements, the API has changed for several functions, and
this commit adopts Blender code to these changes, making Blender
buildable and functional with all existing Embree 4.X
versions, before and after 4.4.

No functional changes in Blender behavior are expected if
using Embree versions below 4.4.

Pull Request: https://projects.blender.org/blender/blender/pulls/139061
2025-05-19 11:25:50 +02:00
Lukas Stockner
a6015e1411 Cycles: Fix inconsistency in Ng handling between Microfacets and other closures
In Cycles, the convention is that reflection vs. refraction are classified
based on the hemisphere defined by the *shading* normal (N).

In general, most closure code uses the shading normal for most operations,
as is expected since using the geometric normal (Ng) would break normal maps
and smooth shading.

However, there are two places that use Ng: On the one hand, BSDF sampling
functions generally reject reflections that fall below the Ng hemisphere, since
they'd intersect the geometry when tracing the bounce. This is required, and
we can't do much about it.
On the other hand, the Microfacet evaluation code also checked that the ray
is in the same hemisphere w.r.t. both shading and geometric normal.

Theoretically, this is the right thing to do, since sampling and evaluation code
are supposed to be consistent. However, doing so breaks smooth shading, since
now direct light evaluation near the terminator will sometimes be rejected.

This didn't cause problems in practice because of another inconsistency: While
the parameter of the eval functions was named Ng, the caller actually provided
N (unclear whether by mistake or as a hacky workaround to the terminator).
When this was fixed in 063a9e89, users quickly reported issues with the shadow
terminator, so it was reverted to the hacky inconsistency in 1c50dd8b.

So, let's clean this mess up properly. If we don't want to do the Ng hemisphere
check in _eval, then instead of passing in a misleading value that ends up
making it a no-op, just remove the check. After all, the other closures don't
perform it either.

This way, we avoid the mislabeled Ng, we get rid of the special case for
microfacets, and the shadow terminator continues to be fine.

Technically, we still have the _sample vs. _eval mismatch. However, this is just
unavoidable, and is irrelevant in practice: For a strongly directional light
that makes the shadow terminator noticeable, the MIS weights will be massively
in favor of eval, to the point that it doesn't really matter what sample does.

To support this argument: You can actually reproduce a broken shadow terminator
in pretty much every Cycles version going back to 2011 by just setting up a
small intense mesh emitter, turning off MIS on it to disable _eval, and then
rendering a diffuse smooth-shaded sphere with >100000 samples so that the
fireflies resolve into somewhat consistent lighting.
If nobody has complained about this affecting all closures for 11 years,
I guess it's fine.

Pull Request: https://projects.blender.org/blender/blender/pulls/138632
2025-05-18 17:20:32 +02:00
Campbell Barton
b3dfde88f3 Cleanup: spelling in comments (check_spelling_* target)
Also uppercase acronyms: API, UTF & ASCII.
2025-05-17 10:17:37 +10:00
Campbell Barton
ec7691e35c Cleanup: warnings with GCC mixing enums/ints & missing break
An unexpected GPUVertAttr::fetch_mode could have resulted in an
GPU_COMP_U16 being treated as a I32. Break & assert in this case.
2025-05-17 08:58:47 +10:00
Sebastian Parborg
e4aa758d70 Fix #137346: IME input getting lost when using Wayland
Our IME input system relied on passing around pointers to global variables.
However this will not work as the Wayland input handling is multithreaded so the content of the global variable would change while the event loop were reading the data.

Pull Request: https://projects.blender.org/blender/blender/pulls/138871
2025-05-16 14:21:06 +02:00
Jeroen Bakker
606d24d88a Fix #138942: Vulkan: Use different scaling on first swapchain
First time a swap chain is created an incorrect resolution can be
reported back by the driver as the window is still initializing. We
stretch the swap chain to cover to reduce a black line rendering in top
of the window (due to content flipping). Any subsequent frame will not
do stretching to reduce artifacts when resizing the window.

Pull Request: https://projects.blender.org/blender/blender/pulls/138964
2025-05-16 08:47:04 +02:00
Andrew Marshall
000c787059 Fix: Cycles film exposure maximum is too low
The previous value was incorrectly assuming this is 2^exposure, but it
is a simple multiplier.

Specifying large film exposure values is useful as it affects the raw data and
thus results in the same color values available in EXR, Viewer, and
Compositor, whereas using Color Management exposure is not reflected in EXR
exports, resulting in unusably low values. Using film exposure remedies that.

Pull Request: https://projects.blender.org/blender/blender/pulls/138850
2025-05-15 20:58:28 +02:00
Alaska
0d6a79a8f3 Cycles: Use CUDA 11 to compile PTX kernels
This commit makes it so CUDA 11 is used to compile the compute_75
PTX CUDA kernels.

This is being done because PTX kernels have much stricter minimum
driver requirements than standard kernels, so using the latest CUDA
toolkit to compile PTX kernels can result in the PTX kernels being
inaccessible to users with drivers that are only a few months old.

This is important because in some situations, it's either impossible
(E.g. Renting certain cloud services), or difficult to update the GPU
drivers on some machines. And we want to make sure the PTX kernels
are usable by as many people as possible

Original Author: Sergey Sharybin <sergey@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/138879
2025-05-15 15:00:47 +02:00
Jeroen Bakker
3b3cab471a Fix #138843: Vulkan: Swapchain issues
- Reduce artifacts during resizing to also recreate the swapchain
  when acquire image is suboptimal
- Do not stretch when backbuffer and swapchain have a different size

Pull Request: https://projects.blender.org/blender/blender/pulls/138925
2025-05-15 11:57:44 +02:00
Campbell Barton
3ec7748485 Cleanup: spelling in comments (make check_spelling_*)
Also replace term "playhead" with "current-frame".
2025-05-15 10:13:23 +10:00
Campbell Barton
7da0ecccce GHOST/SDL: support horizontal scroll events 2025-05-14 21:48:41 +10:00
Jacques Lucke
afd760f2b7 UI: Ghost: support horizontal scrolling for 2D editors
Some mice have an additional horizontal scroll wheel. This patch adds support
for receiving such events. By default it is used to scroll 2D editors left and right.

I originally developed this because I was missing it in the spreadsheet, but it
seems to be useful in many other editors too.

It's supported on Linux (Wayland), Windows and macos.

Pull Request: https://projects.blender.org/blender/blender/pulls/138758
2025-05-14 13:33:10 +02:00
Josh Belanich
dc02cc1d31 Fix: Vulkan: Soundness issues for Vulkan submission fences
Fixes a few render synchronization soundness issues I discovered when investigating
why resetting the pools after the submission fence in #137305 ended up causing #137395.

1. Ensure the number of submission fences in GHOST_ContextVK is the same
   as the number of resource pools in VKThreadData. Otherwise, the
   fences might get misaligned, making it difficult to predict which
   submission a fence's signal corresponds to.

2. In swapBuffers, pass the current m_frame_data's fence and semaphores
   to the Vulkan backend callbacks, rather than the following
   m_frame_data. This fixes an observed soundness issue where the fences
   were off-by-one. Now, the backend callbacks can be sure that both the
   next frame is ready for construction (and it's resources can be
   cleaned), and will use the correctly aligned fences and semaphores
   during command buffer submission.

3. Do not recreate the m_frame_data's fences during recreateSwapchain.
   This would lead to unsoundness immediately following
   recreateSwapchain where all the fences are signaled but those frames
   might still be in flight.

Pull Request: https://projects.blender.org/blender/blender/pulls/137580
2025-05-13 15:45:46 +02:00
Jeroen Bakker
e934792169 Fix #138032: Vulkan: Loading minimized windows on Windows/NVIDIA
Minimized windows have the resolution of 0,0. The surface supports
swapchains with this resolution, however it doesn't work and leads
to crashes and UBs.

This PR fixes this to use a minimum resolution of 1,1.

Pull Request: https://projects.blender.org/blender/blender/pulls/138750
2025-05-12 10:30:13 +02:00
Sergey Sharybin
7ceb4495c5 Refactor: OpenColorIO integration
Briefly about this change:
- OpenColorIO C-API is removed.
- The information about color spaces in ImBuf module is removed.
  It was stored in global ListBase in colormanagement.cc.
- Both OpenColorIO and fallback implementation supports GPU drawing.
- Fallback implementation supports white point, RGB curves, etc.
- Removed check for support of GPU drawing in IMB.

Historically it was implemented in a separate library with C-API, this
is because way back C++ code needed to stay in intern. This causes all
sort of overheads, and even calls that are strictly considered bad
level.

This change moves OpenColorIO integration into a module within imbuf,
next to movie, and next to IMB_colormanagement which is the main user
of it. This allows to avoid copy of color spaces, displays, views etc
in the ImBuf: they were used to help quickly querying information to
be shown on the interface. With this change it can be stored in the
same data structures as what is used by the OpenColorIO integration.
While it might not be fully avoiding duplication it is now less, and
there is no need in the user code to maintain the copies.

In a lot of cases this change also avoids allocations done per access
to the OpenColorIO. For example, it is not needed anymore to allocate
image descriptor in a heap.

The bigger user-visible change is that the fallback implementation now
supports GLSL drawing, with the whole list of supported features, such
as curve mapping and white point. This should help simplifying code
which relies on color space conversion on GPU: there is no need to
figure out fallback solution in such cases. The only case when drawing
will not work is when there is some actual bug, or driver issue, and
shader has failed to compile.

The change avoids having an opaque type for color space, and instead
uses forward declaration. It is a bit verbose on declaration, but helps
avoiding unsafe type-casts. There are ways to solve this in the future,
like having a header for forward declaration, or to flatten the name
space a bit.

There should be no user-level changes under normal operation.
When building without OpenColorIO or the configuration has a typo or
is missing a fuller set of color management tools is applies (such as the
white point correction).

Pull Request: https://projects.blender.org/blender/blender/pulls/138433
2025-05-09 14:01:43 +02:00
Campbell Barton
837703e585 Fix: failure to start on Wayland/GNOME with monitors at different scales
With two or more monitors of different scales, Blender would fail to
start in some cases when it opened on a monitor at a size that wasn't
a multiple of the monitors scale.

This seemed only to cause problems with LIBDECOR however the buffer size
should always be a multiple of the buffer scale, so ensure its always
valid.

See #135764 for details (a closely related bug).
2025-05-09 21:36:12 +10:00
Campbell Barton
2cd2f2ea4d Cleanup: quiet missing parenthesis & unused function warnings 2025-05-09 02:13:33 +00:00
Alexandre-Cardaillac
921c2b9d61 Shader: New Volume Coefficients Shader
Add a new shader node to control volume coefficients (scattering,
absorption and emission) directly, making it easier to model existing
volumes with measured data.

Pull Request: https://projects.blender.org/blender/blender/pulls/136287
2025-05-08 19:19:35 +02:00
Jeroen Bakker
d648ffb0f1 Fix #138140: Vulkan: Disable swapchain maintenance1
There are issues with our implementation.
- X11 can flip image incorrectly.
- VVL complains of incorrect usage.

Disabling the extension for now until it is more clear what is not
correct.
2025-05-08 15:36:45 +02:00
Campbell Barton
302a5541b3 Cleanup: don't assign the native size to the logical size
This size isn't used unless `has_size_logical` is true,
setting fallback values that aren't used is confusing especially since
output rotation isn't applied - unlike the actual logical size.
2025-05-08 12:11:42 +00:00
Campbell Barton
8836d41542 Fix #135764: Crash on startup with mutli-monitors on Gnome Wayland
Rotated outputs caused a workaround for a bug in GNOME to fail.

Also check the native size since the `size_logical` would always
be set to match the `size_native`.
2025-05-08 12:11:40 +00:00
Campbell Barton
f7dc522834 Fix: output rotation checks with WAYLAND
Only 90 & 270 degree transforms were accounted for.
Check for 90 degree rotation using a flag to include
flipped & rotated output transform.
2025-05-08 12:11:39 +00:00
Campbell Barton
702a7a0ba3 Docs: clarify usage of wayland output sizes 2025-05-08 12:11:37 +00:00