Commit Graph

6109 Commits

Author SHA1 Message Date
Clément Foucault
2257ee7e56 GPU: OpenGL: Add support for non-blocking specialization
This avoid having to compile specializations JIT and
use the same API as subprocess compilation.

This bridges the gap between subprocess and threaded
compilation.

Pull Request: https://projects.blender.org/blender/blender/pulls/139702
2025-06-04 11:24:20 +02:00
Campbell Barton
6a1fa176ef Cleanup: spelling in comments & duplicate terms (check_spelling.py)
Also minor clarification in doc-string.
2025-06-04 01:51:29 +00:00
Clément Foucault
32c50e35c4 GPU: Add profiling groups for subprocess compilation 2025-06-03 17:57:16 +02:00
Clément Foucault
60f7ca21c3 GPU: Shader: Also move the compilation handle in static shaders
Small oversight.
2025-06-03 17:39:33 +02:00
Clément Foucault
e69762b8dd GPU: Add compilation constants
Compilation constants are constants defined in the create info.
They cannot be changed after the shader is created.
It is a replacement to macros with added type safety.

Reuse most of the logic from Specialization constants.

Pull Request: https://projects.blender.org/blender/blender/pulls/139703
2025-06-03 17:34:04 +02:00
Miguel Pozo
8907567a00 Fix: OpenGL: Hang when subprocess crashes
If the compilation subprocess crashes due to an internal driver error,
the end semaphore is never signaled and leaves Blender hanging.

This replaces the `decrement` calls with `try_decrement` and checks
every second if the subprocess is lost.

Additionally, if the issue comes from a broken binary, the crashes will
happen every time a Blender session tries to load it.
So now we store the shader hash in the shared memory before trying to
load the binary. If the subprocess is lost mid compilation, the main
process will delete the broken cached binary.

Pull Request: https://projects.blender.org/blender/blender/pulls/139747
2025-06-03 15:37:21 +02:00
Jeroen Bakker
e91e8eef41 Refactor: Vulkan: Use VKDevice& in finalize_pipeline_layout
!139630 requires the VKDevice to access the device function pointers.
2025-06-03 10:49:14 +02:00
Jeroen Bakker
3a875b2910 Vulkan: Don't run tests on unsupported platforms 2025-06-03 10:43:36 +02:00
Jeroen Bakker
9bbcbd06e8 Vulkan: Allow NVIDIA layers
Fixes a typo, NVIDIA layers use an abbreviation nowadays.
2025-06-03 10:07:19 +02:00
Jeroen Bakker
b416152cb9 Vulkan: Only load layers that we trust
This PR changes loading of implicit vulkan layers. See #139543 where we
detected that there are vulkan layers installed on systems that try to
impersonate other software, but crashes when used in Blender.
2025-06-03 08:37:48 +02:00
Hans Goudey
77b14f2dcb Cleanup: Grammar: Fallback vs. fall back
The former is a noun or adjective, the latter is a verb.
2025-06-02 17:13:56 -04:00
Hans Goudey
20ca13e4e4 Fix: Compile error in node socket shape shader 2025-06-02 10:10:46 -04:00
quackarooni
0a1ff2b2ff Nodes: add "Power" and "Sign" operations to Vector Math node
This adds "Power" and "Sign" as per-element/channel operations to the Vector Math node.

Pull Request: https://projects.blender.org/blender/blender/pulls/139474
2025-06-02 08:53:13 +02:00
Jacques Lucke
cb795cc13a Cleanup: repeated typo
This changes `ouput`  to `output`.

Pull Request: https://projects.blender.org/blender/blender/pulls/139711
2025-06-02 08:36:43 +02:00
Brecht Van Lommel
becc2fa9cb Fix: Metal parallel shader compilation does not respect -t option
This command line option to control the number of threads was already taken
into account for OpenGL and Vulkan.
2025-05-30 17:50:56 +02:00
Miguel Pozo
045926a305 GPU: Always use MTLShaderCompiler
No reason to use the base compiler on Metal.

Pull Request: https://projects.blender.org/blender/blender/pulls/139638
2025-05-30 17:41:13 +02:00
Jeroen Bakker
cfe0dc2cc1 Refactor: Vulkan: Reuse GHOST VkInstance
This PR will reuse the VkInstance of GHOST_ContextVK when querying for
possible compatible devices. Previously a temporary VkInstance was
created but could trigger an error in the Vulkan loader.

Pull Request: https://projects.blender.org/blender/blender/pulls/139640
2025-05-30 16:03:45 +02:00
Clément Foucault
940ef330c8 Fix: GPU: Make StaticShader::ensure_compile_async request for ready state
This was missing from the initial implementation.

This did not affect any user code path since they were not
checking for completion and only blocking on first `get`.
2025-05-30 15:21:06 +02:00
Clément Foucault
f82673afd9 Fix: GPU: Invalid logic in StaticShader::get()
Simple oversight. Didn't have any effect.
2025-05-30 15:21:06 +02:00
Jeroen Bakker
5e690aa217 Fix: Shader CPP compiler error
Shader CPP compiler broke due to recent shaders not including the
correct resources.
2025-05-30 09:30:42 +02:00
Clément Foucault
c3f4dd27f1 GPU: Add async compilation to StaticShader class
This allow to easily request async compilation
in a safe way for every static shader.

The get function will always wait if async
compilation has been requested.
2025-05-30 09:14:02 +02:00
Clément Foucault
87bab6b425 Fix: GPU: Failling test caused by missing push constant 2025-05-30 09:14:02 +02:00
Campbell Barton
50f3240abd Cleanup: spelling & duplicate terms (check_spelling.py) 2025-05-30 11:03:56 +10:00
Miguel Pozo
2db0b92280 GPU: Add CompilationPriority
Allow adding compilation batches to different priority queues.
Set priorities so static shaders are always compiled first,
then materials, and optimized materials last.

Pull Request: https://projects.blender.org/blender/blender/pulls/139456
2025-05-29 19:43:02 +02:00
Jeroen Bakker
c56a855b9f Fix #139565: PyGPU: Add builtin point shaders
This PR adds builtin shaders for drawing points. Using `FLAT_COLOR`,
`SMOOTH_COLOR`, `UNIFORM_COLOR` can lead to undesired behavior
on Metal and Vulkan backends. To ensure future compatibility this PR
adds `POINT_FLAT_COLOR` and `POINT_UNIFORM_COLOR`.

The point size can be set using `gpu.state.point_size_set`.

Pull Request: https://projects.blender.org/blender/blender/pulls/139583
2025-05-29 14:36:32 +02:00
Jeroen Bakker
cd3bd7774f Fix #139546: Vulkan: Race condition during rendering resulting in a stall
Race condition between the main thread and worker thread. In this case
the worker thread was waiting for a device idle, but the main thread was
waiting on a specific timeline. As long as the timeline didn't pass the
device was locked.

Releaved the race condition to check on queue idle as the timeline event
isn't part of the queue.

On windows drivers could be reset and could lead to other crashes as handles
were not used anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/139579
2025-05-29 12:13:43 +02:00
Jeroen Bakker
c8dd396f54 Cleanup: Vulkan: Silence logging
This change will move some detailed logging to a higher level as it
isn't important for issue tracking.

Pull Request: https://projects.blender.org/blender/blender/pulls/139575
2025-05-29 11:13:25 +02:00
Jeroen Bakker
283a267c13 Fix #139558: Incorrect shader when using edge slide even
In this case a triangle shader was used to render points.

This change entails:
- Using point shaders in this case
- Add support for `GPU_point_size` to update the uniform of the point
  shader.

Pull Request: https://projects.blender.org/blender/blender/pulls/139574
2025-05-29 10:12:33 +02:00
Campbell Barton
479d1f1d16 Cleanup: use doxygen doc-strings, spelling (make check_spelling_*) 2025-05-29 11:00:53 +10:00
Clément Foucault
7245262de8 GPU: Metal: Add --profile-gpu support for CPU timing
The GPU implementation is a bit too complex
to implement for now.

As we are improving shader loading, having the
CPU timings is already helpful.

Note that `Map<size_t, int>` does not compile
on Clang.

This is exposing the `--profile-gpu` option on
all backends as the vulkan backend should follow
shortly.

Pull Request: https://projects.blender.org/blender/blender/pulls/139551
2025-05-28 21:08:38 +02:00
Miguel Pozo
ab3dfba8dd Cleanup: GPU: Simplify GLCompilerWorker management 2025-05-28 16:21:15 +02:00
Christoph Neuhauser
282d703f6b Fix #139443: WM: Clear draw region framebuffers to avoid corruption
This PR adds a clear on creation for draw region framebuffers, which
fixes issue https://projects.blender.org/blender/blender/issues/139443.
When using the "Lock Interface" option, redrawing is disabled until the
rendering process has finished. When the GPU driver does not initialize
framebuffer textures with zero, this means that visual corruption can
be perceived when resizing the main window while rendering.
This fix makes sure that framebuffer textures are initialized with zero
on all GPU platforms.

Pull Request: https://projects.blender.org/blender/blender/pulls/139445
2025-05-28 13:17:37 +02:00
Hans Goudey
b80f1f5322 Geometry Nodes: Socket structure type and display changes
Implementation of #127106.
This is just a visual representation of the field/single/grid
status of sockets to make the workflow more intuitive. With
a visual representation for volume grid sockets, volume features
should be unblocked for further development. The structure type
will also be used to distinguish list sockets in the interface.

Group input nodes now have a "Structure Type" option instead of
the existing "Single Value Only". Usually the auto option should be
enough, but in some cases where the inferencing cannot (yet) make
a clear determination, it can be helpful to choose a specific type.

The new visualization and the group input structure type option
are hidden behind a new experimental option for now.

Pull Request: https://projects.blender.org/blender/blender/pulls/134811
2025-05-28 02:33:47 +02:00
Jeroen Bakker
5d0d54cc81 Fix #139284: Vulkan: Garbage collection not always run when rendering
During rendering when main thread is blocked or all screens are minimized the
garbage collection will not happen resulting in crashes as resources are not freed.

A better solution would be to do garbage collection in a separate thread but that requires a
ref counting system. The specifics of such a system is still unclear.

A possible solution for a Vulkan specific ref counting is to store the ref counts in the
resource tracker. That would only handle images and buffers, but it would solve the most
resource hungry issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/139475
2025-05-27 09:39:54 +02:00
Jeroen Bakker
6b1ef63f4d Fix: Vulkan: Swapchain validation
On selected platforms there were some validation errors. It was caused by
platforms that returned a different number of swapchain images then were
requested. In that case the semaphores can get out of sync.

Current mechanism isn't future proof as the max number of images are
statically defined.

For this change the present semaphores is also separated from the frames
to better support out of order swapchain images.

Pull Request: https://projects.blender.org/blender/blender/pulls/139446
2025-05-26 16:31:02 +02:00
Jeroen Bakker
4f76c75da2 Vulkan: Add ghost.vulkan logging
GHOST backend didn't use logging. This PR adds an initial ghost.vulkan
logging and improves the reporting of logging in vulkan.

logging can be enabled by `blender --log "gpu.vulkan,ghost.vulkan" --log-level 2`
it shows the optional extensions that are enabled and information about swap chain
events.

Pull Request: https://projects.blender.org/blender/blender/pulls/139437
2025-05-26 12:55:00 +02:00
Clément Foucault
8bba1c8056 Fix #139191: GPU: Blender crashes on startup with addons that use pyGPU shader
This was caused by missing `shader->constants`.
Creating an empty `SpecializationConstants` fixes the issue.
2025-05-26 11:09:49 +02:00
Brecht Van Lommel
afad355060 Fix: Properly free Vulkan interop handle for Cycles
Unlike OpenGL and Metal, this handle is not shared, but rather Cycles
has to take ownership of it. This required a fair amount of refactoring
to ensure the handle is closed, ownership is properly transferred, and
the handle is recreated once when the pixel buffer is modified.
2025-05-26 10:59:49 +02:00
Brecht Van Lommel
d2f883d8bc Fix: Cycles Metal graphics interop not working
It needs an MTLBuffer instead of a raw pointer.
2025-05-26 10:59:49 +02:00
Omar Emara
a4502f82c1 Compositor: Add Image Coordinates node
This patch adds a new Image Coordinates node for the compositor. The
Texture Coordinates and Pixel Coordinates outputs were removed from the
Image Info node and were added to the new node instead. Additionally, a
new Normalized Coordinates output was added.

The Pixel Coordinates output now no longer includes half pixel offsets.

Pull Request: https://projects.blender.org/blender/blender/pulls/138935
2025-05-26 08:25:06 +02:00
Oscar Blumberg
aa413a05bf Fix: Vulkan: Threading issue when waiting for submission
Usage of conditional to fix threading and performance delays when
waiting for the submission fence to become valid. The previous
(faulty) implementation didn't work well on WoA devices.
2025-05-26 08:20:09 +02:00
Clément Foucault
8257fcb62f Fix #139354: Metal: AgX turns rendered image into black white
Caused by the initializer list syntax. Using the constructor
explicitly fixes the issue.
2025-05-23 18:28:05 +02:00
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
a44c515844 Cleanup: Vulkan: Use blender::Mutex
Only the queue mutex owned by ghost is still a std::mutex.

Pull Request: https://projects.blender.org/blender/blender/pulls/139344
2025-05-23 14:40:28 +02:00
Jeroen Bakker
9a6ae548a1 Cleanup: Vulkan: Remove unused getters. 2025-05-23 14:19:46 +02:00
Jeroen Bakker
f75e4f4dea Cleanup: Vulkan: Move comment 2025-05-23 08:27:27 +02:00
Campbell Barton
84694bf635 Cleanup: add inline array size comments and minor corrections 2025-05-23 14:03:20 +10:00
Miguel Pozo
e6638d6e5e Refactor: GPU: GPUMaterial & GPUPass compilation
Cleanup and simplification of GPUMaterial and GPUPass compilation.
See #133674 for details/goals.

- Remove the `draw_manage_shader` thread.
  Deferred compilation is now handled by the gpu::ShaderCompiler
  through the batch compilation API.
  Batch management is handled by the `GPUPassCache`.
- Simplify `GPUMaterial` status tracking so it just queries the
  `GPUPass` status.
- Split the `GPUPass` and the `GPUCodegen` code.
- Replaced the (broken) `GPU_material_recalc_flag_get` with the new
  `GPU_pass_compilation_timestamp`.
- Add the `GPU_pass_cache_wait_for_all` and
  `GPU_shader_batch_wait_for_all`, and remove the busy waits from
   EEVEE.
- Remove many unused functions, properties, includes...

Pull Request: https://projects.blender.org/blender/blender/pulls/135637
2025-05-22 17:53:22 +02:00
Clément Foucault
d955ebce30 EEVEE: Default Startup Speedup
Low hanging fruit optimizations for improving default
startup time.

Went from 7.2sec to 4sec on my system.

Pull Request: https://projects.blender.org/blender/blender/pulls/139278
2025-05-22 15:57:41 +02:00
Miguel Pozo
7654be9e88 Fix: GPU: Profiling for compilation contexts 2025-05-22 15:55:27 +02:00