Commit Graph

776 Commits

Author SHA1 Message Date
Jeroen Bakker
32a812682c Fix #144625: Vulkan: Blacklist NVIDIA 580.76.05 on Linux
This PR disables support for NVIDIA 580.76.05 drivers as it can hang
on startup with Wayland. There are reports from other applications
that this driver is faulty and NVIDIA confirmed that an updated driver
is in the making.

For now we will blacklist this specific driver on any Linux system.

Pull Request: https://projects.blender.org/blender/blender/pulls/145094
2025-08-25 12:28:16 +02:00
Jeroen Bakker
98b4c3e252 Cleanup: Remove obsolete comment 2025-08-25 09:23:32 +02:00
Jeroen Bakker
e24e58f293 Vulkan: Recycle descriptor pools
This PR adds recycling of descriptor pools. Currently descriptor pools
are discarded when full or context is flushed. This PR allows
descriptor pools to be discarded for reuse.
It is also more conservative and only discard
Descriptor pools when they are full or fragmented.

When using the Vulkan backend a small amount of descriptor memory can leak. Even
when we clean up all resources, drivers can still keep data around on the
GPU. Eventually this can lead to out of memory issues depending on how
the GPU driver actually manages descriptor sets.

When the descriptor sets of the descriptor pool aren't used anymore
the VKDiscardPool will recycle the pools back to its original VKDescriptorPools.
It needs to be the same instance as descriptor pools/sets are owned by
a single thread.

Pull Request: https://projects.blender.org/blender/blender/pulls/144992
2025-08-22 17:11:26 +02:00
Jeroen Bakker
0ea1feabd9 Vulkan: HDR support for Windows
This PR adds HDR support for Windows for `VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT`
on `VK_FORMAT_R16G16B16A16_SFLOAT` swapchains .

For nonlinear surface formats (sRGB and extended sRGB) the back buffer is blit into the swapchain,
When VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT is used as surface format a compute shader
is used to flip and invert the gamma.

SDR white level is updated from a few window event changes, but actually
none of them immediately respond to SDR white level changes in the system.
That requires using the WinRT API, which we don't do so far.

Current limitations:
- Intel GPU support
- Dual GPU support

In the future we may add controls inside Blender for absolute HDR nits,
across different platforms. But this makes behavior closer to macOS.

See !144565 for details

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/144717
2025-08-22 10:11:55 +02:00
Jeroen Bakker
bca70c85e7 Cleanup: struct initializers 2025-08-21 12:27:19 +02:00
Jeroen Bakker
3b295618f8 Fix #144614: Vulkan: Disable optimization for large shaders
This is a workaround for an issue in SPIRV-Optimizer. When optimizing
large shaders the optimizer can crash. This can be fixed by altering the
maximum object ids and performing a compact ids in the end. However this
part of the API is not accessible via ShaderC.

To work around the issue shader optimizations are being disabled for
large shaders. The issue has been reported upstream.

Pull Request: https://projects.blender.org/blender/blender/pulls/144774
2025-08-21 09:14:56 +02:00
Jorn Visser
0f8eb1b944 Fix: Vulkan: Submission runner crash on start
In `init_submission_pool`, the submission runner was started before
initializing the queues it uses, leading to a race condition that could
result in a crash.

Pull Request: https://projects.blender.org/blender/blender/pulls/144795
2025-08-21 09:06:23 +02:00
Jeroen Bakker
43a2bfa9c3 Vulkan: Add assert for potential driver crash
Pull Request: https://projects.blender.org/blender/blender/pulls/144782
2025-08-21 07:35:15 +02:00
Clément Foucault
2f2ff44e56 GPU: Shader: Remove legacy creation API
This API is no longer used for 5.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/144819
2025-08-20 09:25:32 +02:00
Clément Foucault
869fc2cf4e GPU: Shader: Add Shared Variable in shader create info
This allows to control the type of data inside the create infos for
easy variation of the same shader.

Also this wraps the last global shader resource usage for the future
SRD.

Pull Request: https://projects.blender.org/blender/blender/pulls/144769
2025-08-19 18:27:49 +02:00
Jeroen Bakker
066280446c Vulkan: Enable maintenance4 in VMA
VK_KHR_maintenance4 is enabled when available. VMA isn't aware that we
enabled it and could still use less optimized code-paths. This PR will
inform VMA that it can use the optimized code-paths.

The improvement is that we can decide in which memory area a specific
resource will be allocated, without the need of allocating the resource
header (VkImage/VkBuffer).

Pull Request: https://projects.blender.org/blender/blender/pulls/144552
2025-08-18 09:52:08 +02:00
Jeroen Bakker
ea633b930f Fix #143989: Vulkan: Text drawing performance
Text drawing can be improved. At this moment a vertex buffer is
allocated for 2048 chars. When drawing a string the vertex buffer is
filled from the beginning with the string to draw. The next string will
replace the chars of the previous string. This locks up GPUs as the data
can only be overwritten when the buffer isn't used anymore.

Vulkan backend had an issue that uploading the new data would always
send over 2048 chars even when some chars were only used. By fixing this
the scene in the report went from 0.6 fps to 2.6 fps. OpenGL is 6 fps as
vulkan has to manage a rendergraph with 100.000 of nodes.

Text drawing performance can be improved by continue using the space of
the vertex buffers. In this case more drawing calls can be done, before
the vertex buffer needs to be updated.

Pull Request: https://projects.blender.org/blender/blender/pulls/144604
2025-08-15 10:36:27 +02:00
Jeroen Bakker
1f1098c498 Vulkan: Remove MoltenVK
Blender had some support for using MoltenVK. However there are some key
issues why MotlenVK cannot be used. Bugs have been reported up-stream.
As it doesn't work and holds back regular developments it will be removed
from the main branch.

Any efforts on making Vulkan run on Apple (including KosmicKrisp)
is considered a community effort and can be done in a development
branch.

Pull Request: https://projects.blender.org/blender/blender/pulls/144602
2025-08-15 09:36:38 +02:00
Jeroen Bakker
7286885789 Vulkan: Update VMA to 3.3.0
Updated to latest release. Has some fixes and a new API for easy
integration with Volk.

Pull Request: https://projects.blender.org/blender/blender/pulls/144434
2025-08-14 13:20:45 +02:00
Christoph Neuhauser
1384bad2d2 GPU: Add flag for shader debug info generation
This PR proposes to add a new flag `--shader-debug-info` that enables the generation of shader debug information.

I created this PR as WIP due to the following reasons:
- Currently it only works for the Vulkan backend. I do not know if it makes sense for other backends. For example, OpenGL directly receives the GLSL code, so there no need for this might exist.
- So far `--debug-gpu-renderdoc` already turns on the following changes for GLSL shader compilation with shaderc:
```
options.SetOptimizationLevel(shaderc_optimization_level_zero);
options.SetGenerateDebugInfo();
```
- While combining optimization level zero with debug info is a sensible choice for frame debuggers like RenderDoc, my use case for creating this PR is shader profiling. In this case, one does not want compiler optimizations to be turned off. At the current point in time, the only information my profiler uses (which is unfortunately not public at this point in time) is the name of the shader. When turning on debug information, shaderc/glslang store this information in the generated SPIR-V data. Otherwise, it would be impossible for the profiler to tell the user what the name of the shader it is that is profiled.
- An alternative solution would be to rename the entry point `main` of a shader to the name of the shader. But this might be an even uglier hack, as it requires editing the source code (and the name of the shader then needs to be a valid GLSL function name).
- We should first clarify if there is interest in the Blender side in upstreaming an option like this. While I could just keep this in my local fork of Blender, there is merit in having the possibility to profile arbitrary Blender builds.

Pull Request: https://projects.blender.org/blender/blender/pulls/142986
2025-08-13 13:41:41 +02:00
Jeroen Bakker
ea83567811 Vulkan: Destroy resources in submission thread
This PR moves the responsibility of destroying discarded resources to
the submission thread. Previous implementation could be blocked and
would not always run.

This solves memory leak when rendering in background and keeps the
overall memory usage lower as all is done in a single location.

Pull Request: https://projects.blender.org/blender/blender/pulls/144440
2025-08-12 15:58:49 +02:00
Clément Foucault
cae6c6d81a GPU: Remove Shader Draw Parameter workaround
With 5.0 we start requiring this extension for GL and VK.
All of our target hardware supports it with up to date
drivers.

Some old drivers were disabling this extension because of
buggy behavior. We simply drop support for them in 5.0.

This allows us to remove a lot of code and the last
shader create info override done at startup. This will
unlock more refactoring of the shader create info into
static classes to reduce binary size and other benefits.

## TODO:
- [x] Remove checks for ARB_shader_draw_parameters
- [x] Remove checks for ARB_clip_control
- [x] Check for the extension on startup for OpenGL
- [x] Check for the extension on startup for Vulkan
- [x] ~~Add user facing popup message about minimum
      requirements not being met.~~ Done using the same
      popup as old hardware.

Pull Request: https://projects.blender.org/blender/blender/pulls/142334
2025-08-12 14:04:41 +02:00
Jeroen Bakker
42c3f35780 Vulkan: Swap to system memory for device local memory
This PR will swap device local memory to system ram. It relies on
VK_EXT_external_memory and VK_EXT_pageable_device_local_memory
extensions to be supported by the system.

Most platforms support these extensions.

Pull Request: https://projects.blender.org/blender/blender/pulls/144422
2025-08-12 11:51:40 +02:00
Jeroen Bakker
3b8ea045da Vulkan: Disable descriptor buffers
There are stability issues with the vulkan backend. Some scenes indicate
that there is no space left to allocate the next descriptor buffer. For
stability reasons we will disable descriptor buffers and look into a
better solution.

Pull Request: https://projects.blender.org/blender/blender/pulls/144421
2025-08-12 10:28:28 +02:00
Campbell Barton
c00dfded27 Cleanup: consistently hyphenate the term "swap-chain" 2025-08-12 10:12:19 +10:00
Clément Foucault
7a97105b28 GPU: Remove wrapper type for gpu::StorageBuf
This is the first step into merging DRW_gpu_wrapper.hh into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/144329
2025-08-11 10:35:53 +02:00
Clément Foucault
1388a70914 GPU: Remove wrapper type for gpu::Shader
This is the first step into merging DRW_gpu_wrapper.hh into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/144229
2025-08-11 09:34:28 +02:00
Jeroen Bakker
06b32f6c1d Vulkan: Add assert to check valid API usage
Related to #143691.
2025-08-11 09:08:04 +02:00
Jeroen Bakker
e408029d5b Cleanup: Vulkan: Remove not needed code.
Would never have anything to report. Can be added back when there are
validation messages added.
2025-08-08 11:10:38 +02:00
Jeroen Bakker
073b4d4d7b Fix #144048: Vulkan: Crash minimized windows
Swapchain handling of minimized windows wasn't correct. On some
platforms it still tried to create images with no surface.

This PR will discard swapchains of minimized windows, but still being
able to flush the render graph and free resources.

Pull Request: https://projects.blender.org/blender/blender/pulls/144189
2025-08-08 11:03:02 +02:00
Jeroen Bakker
97f1aeb84c Vulkan: Remove support for render passes
Vulkan 1.0 render passes have been replaced by dynamic rendering in 1.2.
Blender Vulkan backend was implemented with dynamic rendering in mind.
All our supported platforms support dynamic rendering. Render pass support
was added to try to work around an issue with legacy drivers. However these
drivers also fail with render passes.

Using render passes had several limitations (blending and some workbench
features were not supported).  As no GPU uses it and it is quite some code
to support it is better to remove it.

Pull Request: https://projects.blender.org/blender/blender/pulls/144149
2025-08-08 08:08:58 +02:00
Jeroen Bakker
4333e070b4 Fix: SubDiv: Out of bound write loose normals
Updating loose normals leads to out of bound writes on the GPU.
The reason is that normals are float3, but the code assumed
they were float4.

Pull Request: https://projects.blender.org/blender/blender/pulls/144128
2025-08-07 15:26:42 +02:00
Jeroen Bakker
82d18d2f66 Vulkan: Add resource tracker to debug output
Helps detecting memory leaks as these numbers shows the number of
allocated buffer/image resources.
2025-08-07 13:40:22 +02:00
Clément Foucault
16430b10f1 EEVEE: World Sun Shadow no longer works in 4.5
On some drivers, the GLSL compiler doesn't reflect the omitted
`local_size_*` of a compute shader inside `gl_WorkGroupSize`.

This lead to the 2D size computation of 1D workgroups to become
0 which was bypassing the parallel reduction algorithms.

Ensuring `local_size_*` are always set fixes the issue.

For clarity, also fix the 1D shaders to not use `gl_WorkGroupSize.y`.
This also fix a copy paste error in the Metal backend.

This issue affected AMD drivers on Windows.

Rel #142046

Candidate for backporting to 4.5 LTS.

Pull Request: https://projects.blender.org/blender/blender/pulls/144056
2025-08-07 09:40:57 +02:00
Jeroen Bakker
cd00d8ca00 Fix: Vulkan: Use after free when switching scenes
Unreported issue introduced from recent changes. (memory leak in immediate mode)

Pull Request: https://projects.blender.org/blender/blender/pulls/144116
2025-08-07 08:56:59 +02:00
Jeroen Bakker
1f47a51335 Fix #142305: Vulkan: Memory leak immediate mode
Resetting and recycling of immediate drawing buffers was never done and
would leak memory as the buffers were only destroyed when Blender
exited.

This is solved by not recycling or resetting the buffers and rely on the
discard pools. Additional cleanup of removing unused code-paths is also
part of this change so it can be backported to 4.5.

Pull Request: https://projects.blender.org/blender/blender/pulls/143995
2025-08-05 14:40:54 +02:00
Jeroen Bakker
2da51cef50 Cleanup: Silent unused parameter 2025-08-04 16:15:59 +02:00
Jeroen Bakker
2da5969fdc Vulkan: Remove framebuffer slot assert
This assert was to notify developers that they are using a framebuffer
configuration that isn't supported when using render passes. Render
passes should not be used and will be removed later in 5.0. Removing the
assert will already help during triaging.

Pull Request: https://projects.blender.org/blender/blender/pulls/143936
2025-08-04 14:42:10 +02:00
Clément Foucault
475b20fc5d Refactor: GPU: Use macros for TextureFormat conversions
This reduces the risk of errors and code duplication.

Rel #130632

Pull Request: https://projects.blender.org/blender/blender/pulls/142898
2025-07-24 13:56:41 +02:00
Campbell Barton
f256e7141a Cleanup: use '*' prefixed multi-line comment blocks 2025-07-24 10:48:04 +10:00
Anthony Roberts
6af07a8abb Vulkan: Update Qualcomm driver version check
Resolves #142859

I have been informed by Qualcomm that this public version should be functional to the same degree as the one given to Jeroen for testing

Pull Request: https://projects.blender.org/blender/blender/pulls/142949
2025-07-23 13:48:10 +02:00
Campbell Barton
5e3db5fbb0 Cleanup: consistent use of back-ticks in code-comments 2025-07-23 20:59:16 +10:00
Campbell Barton
06bb402f22 Cleanup: quiet switch warnings 2025-07-22 23:25:01 +00:00
Clément Foucault
1f42ca9be3 Cleanup: GPU: Avoid warning in switch statement
Caused by 32d64d35bb.
2025-07-22 16:45:04 +02:00
Clément Foucault
32d64d35bb Refactor: GPU: Texture: Replace eGPUTextureFormat by TextureFormat
This offers better semantic and safety of the API.

Part of #130632

Pull Request: https://projects.blender.org/blender/blender/pulls/142818
2025-07-22 14:58:54 +02:00
Clément Foucault
f0254c2dcf Refactor: GPU: Remove unnecessary C wrappers for textures
This is the first step into merging `DRW_gpu_wrapper.hh` into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/142732
2025-07-22 09:48:10 +02:00
Campbell Barton
996210999b Cleanup: use C style comments for descriptive text, doxygen doc-strings
Also replace add-hoc groups in BKE_collision.h with doxy groups.
2025-07-22 11:59:43 +10:00
Campbell Barton
81e4558ab6 Cleanup: reduce right-shift in Python scripts 2025-07-22 11:59:43 +10:00
Miguel Pozo
a8975bf651 Fix #142097: Vulkan: Crash with unbound textures
On the Vulkan side, ensure that unbound textures don't result in
accessing uninitialized or out of bounds memory.
On the Draw side, ensure all Hair and Curves attributes have, at least,
a dummy attribute bound.

Pull Request: https://projects.blender.org/blender/blender/pulls/142265
2025-07-21 15:14:10 +02:00
Miguel Pozo
05dcc0377b Fix: GPU: Missing error logs
Regression from d5f84d0016.
2025-07-14 18:53:35 +02:00
Campbell Barton
ec8751f826 Cleanup: white-space around C-style comment blocks
Also use C++ style comments for disabling code.
2025-07-13 21:58:53 +10:00
Brecht Van Lommel
4653b65f7c Logging: Add DEBUG, TRACE severity, replace numeric levels
The numeric levels have no obvious meaning. This removes the distinction
between severity and levels, instead there is a single list of named levels
with defined meaning.

Debug means information that's mainly useful for developers, and trace is for
very verbose code execution tracing.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Miguel Pozo
f46aa9a1ea Core: Add BLI_thread_queue priority and cancel support
Add functionality required for using BLI_thread_queue for shader compilation, as
discussed in #140214.

Pull Request: https://projects.blender.org/blender/blender/pulls/140992
2025-07-09 18:04:51 +02:00
Jeroen Bakker
4d9c5ebd97 Vulkan: Move Wayland/HDR support out of experimental
This PR moves Wayland/HDR support out of experimental.
This allows more people to test and provide feedback. We
can always decide later to disable it for the release, but so
far we only got positive feedback.

Pull Request: https://projects.blender.org/blender/blender/pulls/141666
2025-07-09 13:24:31 +02:00
Jeroen Bakker
807931166a Merge branch 'blender-v4.5-release' 2025-07-09 08:59:36 +02:00