Commit Graph

6434 Commits

Author SHA1 Message Date
Jacques Lucke
96d2f3430f Merge branch 'blender-v5.0-release' 2025-10-16 19:20:23 +02:00
Jeroen Bakker
e2dc63c5de Fix #147618: PyGPU incorrect colors when drawing images
644fb2b679 fixed a long standing issue
that offscreen example showed the wrong colors. However the fix assumes
that input texture color space is always sRGB.

This adds a shader variation that draws textures that are stored in scene referred
linear color space (like all of our Image data-block).

Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/147788
2025-10-16 19:12:16 +02:00
Omar Emara
df8683ec2a EEVEE: Support different dimensions vector sockets
This patch adds support for the dimensions property of vector sockets,
support 2D and 4D sockets in addition to the currently supported 3D one.
This just involves assigning the correct GPU type when constructing the
GPU materials from nodes.

The only node that uses 2D sockets for now is the Radial Tilling node,
so we just need to update its interface.

Pull Request: https://projects.blender.org/blender/blender/pulls/148034
2025-10-14 13:24:17 +02:00
Omar Emara
a2146839d7 EEVEE: Unify float2 implicit conversion with other parts of Blender
This patch adjusts the implicit conversion rules involving float2 to
match other parts of Blender, like BKE Conversions, Geometry Nodes, and
the Compositor. The new rules also make much more sense to me on their
own.

The GPU_VEC2 is no currently used for GPU materials as far as I can see,
so this should not be a breaking change.

Pull Request: https://projects.blender.org/blender/blender/pulls/148033
2025-10-14 12:04:40 +02:00
Clément Foucault
139fa532c1 GPU: Add command line option to output shader source
This command line outputs only shaders whose name
matches the argument string.

Metal is missing as it waits until #147010 lands.

Pull Request: https://projects.blender.org/blender/blender/pulls/147970
2025-10-13 14:37:54 +02:00
Clément Foucault
304461e761 Merge branch 'blender-v5.0-release' 2025-10-13 14:36:00 +02:00
Clément Foucault
4ce37852fe GPU: Preprocessor: Remove disabled code before builtin parsing
This avoid issues with drw_debug_ prefix being scanned in
disabled code.

Fixes assert in debug builds.

Pull Request: https://projects.blender.org/blender/blender/pulls/147974
2025-10-13 14:35:42 +02:00
Jeroen Bakker
58a49274a0 Merge branch 'blender-v5.0-release' 2025-10-13 09:11:57 +02:00
Jeroen Bakker
d510baa4b8 Fix #147815: Vulkan: Performance NVIDIA
An oversight in b9dcc087a9 where textures aren't allocated correctly
leading to performance issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/147959
2025-10-13 09:06:11 +02:00
Jeroen Bakker
264efc1446 Merge branch 'blender-v5.0-release' 2025-10-10 15:20:43 +02:00
Jeroen Bakker
93cdea62f6 Fix #146560: Vulkan: Improve multires out of memory issue
This seems like an out of memory issue where the storage
buffer could not be allocated but still used as a destination
for a copy. After an out of memory issue memory can be fragmented
and any allocation can still fail.

On `AMD Radeon(TM) 890M Graphics Advanced Micro Devices AMD`
`24.30.58` I got to multires subdivision level 2+6 using the steps
described in the report. 2+7 is failing for me. 2+6 already requires 16GB
of memory using large chunks.

OpenGL and Vulkan work with other limits and memory models and can
have different behavior. This PR only improves the mentioned issue, but
can still fail in other areas.

Pull Request: https://projects.blender.org/blender/blender/pulls/147713
2025-10-10 15:19:43 +02:00
Jeroen Bakker
47f80fed29 Merge branch 'blender-v5.0-release' 2025-10-10 10:35:00 +02:00
Jeroen Bakker
ac9de14f03 Fix: Vulkan: Incorrect color attachments
When using a framebuffer without any color attachments there was always
a single color attachment acounted for. This oversight was detected when
looking into #147299.

Pull Request: https://projects.blender.org/blender/blender/pulls/147791
2025-10-10 10:34:03 +02:00
Jeroen Bakker
4346107cfe Merge branch 'blender-v5.0-release' 2025-10-10 09:00:14 +02:00
Jeroen Bakker
b9dcc087a9 Fix #147604, #146594: Vulkan: Crash on startup
On certain platforms Blender can crash on startup after the update of
VMA. This was because we want to select the correct memory area based on
requirements/preferences, but the overall flag was set to auto.

These options are mutual exclusive. This PR changes the flags to use the
requirements/preferences.

Pull Request: https://projects.blender.org/blender/blender/pulls/147781
2025-10-10 08:42:58 +02:00
Omar Emara
2f745308ed Nodes: Mix alpha in Mix node Mix mode
This patch mixes the alpha channel of the color in the Mix mode of the
Mix node. This has no effect on EEVEE/Cycles since they do not support
alpha, but affects the Compositor, Geometry Nodes, and Texture Nodes.

Previously, the alpha of the first color was assumed, which meant mixing
two images with transparency using a mask in the compositor resulted in
part of the image having bad alpha and required manually mixing of the
alpha channel. And this is the main motivation of this patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/146461
2025-10-10 08:00:01 +02:00
Miguel Pozo
8c425ccd4d Cleanup: Remove unused variables 2025-10-08 16:59:20 +02:00
Miguel Pozo
71f4277467 GPU: Codegen: Native support for repeat zones
Support loops at the GLSL level instead of relying on
NOD_shader_nodes_inline.
This improves compilation and runtime performance, avoids causing
recompilations on iteration count changes, and allows supporting
dynamic iteration counts.

(EEVEE-only)

Pull Request: https://projects.blender.org/blender/blender/pulls/145269
2025-10-08 16:38:14 +02:00
Clément Foucault
e5f13a727a Refactor: EEVEE: Make surfel ray list stable and baking workload auto-adjust
This avoid putting too much work in only one thread for building very long surfel lists.

Instead of insertion sort, we use a prefix sum where all surfel scan the whole ray
list to know their position. Only the coplanar surfel patching is dispatched as
one thread per list.
This is currently a bruteforce approach and could be optimized further.

On top of this, we add a heuristic to scale the amount of work from the baking
depending on the scene complexity. Complex scene will have more overhead but
will remain responsive during baking, while simple scene will be faster to bake.
This avoids hitting TDR in most cases.

The update refresh is now limited to 1 per second to avoid the readback overhead.

Fix #142988

Pull Request: https://projects.blender.org/blender/blender/pulls/146848
2025-10-08 15:59:43 +02:00
Campbell Barton
01806a62e3 Cleanup: spelling (make check_spelling_*) 2025-10-07 10:19:46 +11:00
Jeroen Bakker
f2c04f08c4 Cleanup: Fix compilation warnings 2025-10-06 14:31:42 +02:00
Jeroen Bakker
662a49f5db Fix #145315, #147064: Vulkan: Various artifacts on Qualcomm devices
Qualcomm driver team found an issue how Blender uses dynamic rendering.
The issue is that between suspend/resume of rendering only a limited
commands are possible. However we add commands that shouldn't be added
there. It is a violation of the Vulkan spec
VUID-VkSubmitInfo-pCommandBuffers-06015

It went unnoticed as it is mere a single line in the 5000+pages spec
and wasn't covered by the validation layers. This has been reported
upstream.

To fix this issue we remove the usage of suspending/resuming render
passes and fix any issue that used this together with clearops. Most
likely the fix will require a second dynamic rendering pass when
clearops are used.

Pull Request: https://projects.blender.org/blender/blender/pulls/147425
2025-10-06 11:34:47 +02:00
Miguel Pozo
4b9ce68737 Fix: OpenGL: Avoid substring out of bounds assert
Check if line_start_get result is valid.
2025-10-03 15:51:39 +02:00
Jeroen Bakker
af0d98bf1d Fix #147254: Vulkan: Text Rendering artifacts
b2eaf812b1 made sure that the min offset alignment for text rendering
was used to calculate the correct offset. However the change didn't
update the region to be uploaded to the GPU. The artifacts are caused by
reading from allocated, but uninitialized memory.

This PR fixes this by calculating the correct region to copy to the GPU.
The artifact didn't appear on AMD/NVIDIA GPUs as their alignment are
4 bytes. Intel GPU is 64 bytes.

Pull Request: https://projects.blender.org/blender/blender/pulls/147265
2025-10-03 10:34:49 +02:00
Jeroen Bakker
c279d894db Fix #141013: VSE: Show pure emissive colors in preview
VSE doesn support pure emissive colors when rendering, but weren't
showed inside the preview. This was a limitation when the background
checkerbord is draw. It renders the alpha of the overlay to 1.0 making
the background be drawn on top of the image, hiding the pure emissive
colors.

This PR fixes this by clearing the alpha. This will render the
checkerboard below the image.

Another solution would be to set the alpha to zero in the theme, but that
adds confusion as theme colors will still be able to alter the support of
pure emissive colors.

Pull Request: https://projects.blender.org/blender/blender/pulls/146562
2025-10-03 10:19:19 +02:00
Jeroen Bakker
29e3785c51 Fix #147183: Vulkan: Subresource Tracking of Mip-maps
Subimage tracking is done per layer, but workbench depth of field
required to track per mipmap level. This PR refactors sub image tracking
and implements tracking the state per mipmap level to ensure that
the correct pipeline barriers can be generated.

Most platforms wouldn't show any artifacts as the pixel layouts are the
same, but there it is a violation of the spec.

Pull Request: https://projects.blender.org/blender/blender/pulls/147207
2025-10-03 10:16:46 +02:00
Hans Goudey
a68d39e9d9 Cleanup: Formatting
Run `make format` after the library update in the previous commit.
2025-10-02 12:55:42 -04:00
Jeroen Bakker
b2eaf812b1 Fix: Vulkan: Validation error on Qualcomm
!146956 introduced buffer streaming and is used to improve the
performance of text rendering. However the solution didn't check the
minimum allowed offset for storage buffers.

This PR will use the correct offset. This was only visible on Qualcomm
devices as other systems don't limit this offset.

Detected when looking into: #147023

Pull Request: https://projects.blender.org/blender/blender/pulls/147192
2025-10-02 12:47:24 +02:00
hogan.mastanduno
dde9d21b91 OpenXR: VR Advanced Locomotion Phase 1
Includes the following changes to the existing Locomotion system for VR Scene Inspection:
 * new VR Navigation Preferences and VR Session Settings
 * changes to XR raycast logic and its visualization
 * new XR vignette that appears when moving
 * snap turning

Pull Request: https://projects.blender.org/blender/blender/pulls/144241
2025-10-01 22:16:12 +02:00
Aras Pranckevicius
ed9fc54e0e Fix #147006: VSE preview crashes with too high output resolution
Check whether creating GPU textures succeeds before using them.
However, currently when that happens there is no indication to the user
that "hey the resolution is maybe too big". Not sure what is the best
way to do that however; e.g. Workbench rendering also does not
indicate that in a similar scenario.

While at it, add GPU_is_safe_texture_size instead of duplicating
the same logic in two places.

Pull Request: https://projects.blender.org/blender/blender/pulls/147043
2025-10-01 10:08:18 +02:00
Clément Foucault
7ad9a2a72b GPU: Move gl_FragStencilRefARB to be scanned and added to created info 2025-09-30 21:33:33 +02:00
Clément Foucault
f934418af2 Cleanup: Metal: Remove remains of instanced attributes 2025-09-30 20:54:46 +02:00
Clément Foucault
ef8319aaee GPU: ShaderCreateInfo: Add convenience ResourceString
This will improve readability of shader resource generation
code.
2025-09-30 20:54:46 +02:00
Jeroen Bakker
2468b3c7dd Fix: Renderdoc uses incorrect flags
Unit tests passed incorrect flags resulting in renderdoc to not use
debug information when performing step by step debugging.

Pull Request: https://projects.blender.org/blender/blender/pulls/147063
2025-09-30 16:07:52 +02:00
Jeroen Bakker
da39dc1da8 RenderDoc: Grouping of unit tests
This PR introduces grouping of the unit tests inside debug groups.
Previously a capture would contain a single test. But for performance
reasons multiple tests are run in a single process, making it unclear
which commands belong to which test.

This PR will add a debug group for each test that is run.

Pull Request: https://projects.blender.org/blender/blender/pulls/147046
2025-09-30 13:25:11 +02:00
Jeroen Bakker
0428afbfcc Fix: Debugging gpu tests in renderdoc
Step by step debugging of unit tests inside renderdoc didn't work as the
debug information wasn't included when running unit tests. This should
have been the case, but was broken when introducing
`--debug_gpu_compile_shaders` startup parameter.

Pull Request: https://projects.blender.org/blender/blender/pulls/147040
2025-09-30 12:54:35 +02:00
Jeroen Bakker
918edbcb4c Cleanup: Remove unused method
Pull Request: https://projects.blender.org/blender/blender/pulls/147038
2025-09-30 12:53:56 +02:00
marcopavanello
390f053e32 Fix #146630: Single Scattering Sky has darker pixels near horizon
Store the ground fading of Single Scattering sky directly in the LUT.

Co-authored-by: Lukas Stockner <lukas@lukasstockner.de>
Pull Request: https://projects.blender.org/blender/blender/pulls/146659
2025-09-29 20:56:32 +02:00
Clément Foucault
596062329d GPU: Improve shader dependency logger
Add shader name to graph.
Strip CLOG prefix for mermaid lines.
2025-09-29 16:31:47 +02:00
Jeroen Bakker
cfeacef394 Vulkan: Streaming Buffers
OpenGL has the concept of streaming buffers these buffers are marked to be
rewritten and used a small number of times. Vulkan (being low-level API)
doesn't have this concept. When performing font rendering Blender uses
streaming buffers and can slow down Vulkan as GPU barriers are added
between uploading and using the buffer.

Using a different approach could reduce the GPU barriers. The overall
idea is:

Altering render graph nodes

During font rendering the streaming buffer is rewritten from start with
the data to render the next part. This could only cover a part of the fully
allocated buffer. And would introduce a barrier before and after rewritting
the next part.

The allocated buffer on the GPU can fit more data but that data needs to be
passed along the first update to reduce the barriers. Allowing access to an
existing node in the render graph would allow to change the initial upload to
upload more data, without additional barriers.

VKStreamingBuffer

A new buffer type is introduced that will keep track of the streaming buffer
on the current render graph. A streaming buffer can be shared between multiple
threads and requires state manager to be done per context.

Pull Request: https://projects.blender.org/blender/blender/pulls/146956
2025-09-29 16:15:04 +02:00
Jeroen Bakker
a0370d2fe3 Fix: Vulkan: Performance regression text drawing
7becc38a3c introduced new text rendering.
In the refactoring the vertex buffer was replaced by a more shallow
storage buffer. However the refactoring removed one optimization that
the vulkan backend uses, namely the actual amount of bytes that is being
used by the draw call. This resulted in overly large data transfers.

For example in the text editor the texts are rendered one glyph at a
time. But the storage buffer would always upload the data for 1024
glyphs.

This PR allows the usage size of a storage buffer to be set to ensure
that the data transfers are limited.

The implementation wasn't added to OpenGL as it draws incorrectly.

Issue detected during the research of !146956 That PR will implement
better data streaming inside the Vulkan backend and also requires
to know the actual usage size of the buffer to detect what data can
be grouped together.

Pull Request: https://projects.blender.org/blender/blender/pulls/146958
2025-09-29 15:55:31 +02:00
Clément Foucault
23134124dc LOG: Change shader dependency printing to its own prefix
This avoid flooding the console when using --debug-gpu.
2025-09-29 14:06:33 +02:00
Amogh Shivaram
2bd06093c7 Cycles: Thin film iridescence for metals
Applies thin film iridescence to metals in Metallic BSDF and Principled BSDF.

To get the complex IOR values for each spectral band from F82 Tint colors,
the code uses the parametrization from "Artist Friendly Metallic Fresnel",
where the g parameter is set to F82. This IOR is used to find the phase shift,
but reflectance is still calculated with the F82 Tint formula after adjusting
F0 for the film's IOR.

Co-authored-by: Lukas Stockner <lukas@lukasstockner.de>
Co-authored-by: Weizhen Huang <weizhen@blender.org>
Co-authored-by: RobertMoerland <rmoerlandrj@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/141131
2025-09-29 02:58:20 +02:00
Brecht Van Lommel
fff8d35e3f Color Management: Add option to control display emulation
In Render properties > Color Management > Display.

* Off: Directly output image as produced by OpenColorIO. This is not correct
  in general, but may be used when the system configuration and actual display
  device is known to match the chosen display.
* Automatic: Display images consistent with most other applications, to preview
  images and video for export. A best effort is made to emulate the chosen
  display on the actual display device.

The option is grayed out when the current OpenColorIO config and display/view
does not support emulation.

Ref #145022, #144911

Pull Request: https://projects.blender.org/blender/blender/pulls/146808
2025-09-26 17:05:18 +02:00
Raiko
1aee66bfa4 Fix: Partially Fix #146759 by Adding Missing Library Include to Radial Tiling Node
Node code was missing and include directive.

Pull Request: https://projects.blender.org/blender/blender/pulls/146810
2025-09-26 11:59:57 +02:00
Jeroen Bakker
be4a34d103 Refactor: Vulkan: Move memory allocator ownership to GHOST.
This PR moves the ownership of vulkan memory allocator from gpu/device
to GHOST/context/device. This will allow in the future a cleaner control
flow between OpenXR and Vulkan. Currently as the ownership is in the gpu
module many objects would need to pass from GHOST to the GPU module to be
shared between the 2 allocators. Moving both (OpenXR/Context) allocator
to GHOST would reduce the complexity.

Pull Request: https://projects.blender.org/blender/blender/pulls/146819
2025-09-26 09:34:48 +02:00
Jeroen Bakker
1a0a35ac93 Fix #146559: Vulkan: Wide lines not working in custom PyGPU shaders
For wide line rendering it is preferred to use polyline shaders. However
creating a custom shader is complicated and a stone to far for many
scriptors.

This PR allows using line_width_set when wide line rendering is
supported by the platform.

Pull Request: https://projects.blender.org/blender/blender/pulls/146762
2025-09-25 14:02:11 +02:00
Jeroen Bakker
7579dafc7e Fix: GPU Draw tests
Fail threshold needed to be modified due to recent changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/146768
2025-09-25 13:40:13 +02:00
Clément Foucault
581073533f GPU: Shader: Add orphan list to allow delayed deletion
This avoid crashes when a thread without GL context tries
to free a shader.

Fix #145966
Fix #144526

Pull Request: https://projects.blender.org/blender/blender/pulls/146720
2025-09-25 12:28:14 +02:00
Clément Foucault
0d9a80ceeb Fix #146745: EEVEE: Missing dependency for displacement node 2025-09-25 12:14:22 +02:00