Commit Graph

5724 Commits

Author SHA1 Message Date
Jeroen Bakker
b8d67aa10f Vulkan: Make provoking vertex optional for MoltenVK
Provoking vertex isn't supported by Metal and MoltenVK. As it only has
some minor artefacts we make it optional when using MoltenVK.

Pull Request: https://projects.blender.org/blender/blender/pulls/131815
2024-12-13 09:56:37 +01:00
Jeroen Bakker
c698edcf70 Vulkan: Ensure no gaps between attachments when using MoltenVK
MoltenVK dynamic rendering is built on top of render passes and framebuffers.
This also means that dynamic rendering has the same limitations.

This PR enables the workarounds for gaps between attachments for MoltenVK.

Pull Request: https://projects.blender.org/blender/blender/pulls/131816
2024-12-13 09:55:18 +01:00
Miguel Pozo
b295df7345 Refactor: Overlay: Port "next" shaders declarations to static CreateInfos
Use static CreateInfos for Overlay-Next shaders using a similar approach to Workbench shader variations.

Remove unused infos and shader sources.
Remove the `gpu_shader_create_info_get_unfinalized_copy` workaround.

Pull Request: https://projects.blender.org/blender/blender/pulls/131514
2024-12-12 23:05:00 +01:00
Jason Fielder
81f9df606a Fix #130700: Release Metal resources after each frame when rendering Python animations.
Rendering animations from Python scripts via `bpy.ops.render.opengl()`
did not trigger any of the notifications in the Metal back-end to
indicate a frame had been rendered and that the associated resources
could be released. This adds a call to GPU_render_step() after each
render. For the original asset in the bug report this reduces the high
memory watermark from 30gb to 13gb for 500 frames. 13gb is likely
still too high and therefore it is likely there are additional leaks
that need to be addressed so this should only be considered a partial
fix.

Authored by Apple: James McCarthy

Co-authored-by: James McCarthy <jamesmccarthy@apple.com>
Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/131085
2024-12-12 20:30:18 +01:00
Jeroen Bakker
16a739dc8a GPU: Add unpack row length tests
This PR adds 2 test cases to test uploading sub texture with and
without unpack row length.

Ref #130977

Pull Request: https://projects.blender.org/blender/blender/pulls/131791
2024-12-12 12:58:16 +01:00
Jeroen Bakker
567595e850 Fix: GPU: OpenGL texture tests
Some texture roundtrip tests are not supported on OpenGL. This PR will
skip these tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/131792
2024-12-12 12:57:41 +01:00
Germano Cavalcante
19fee82b72 Fix #131236: 'batch_for_shader' not working with POLYLINE shaders
In Blender 4.4 (since commit 00a8d006fe), polyline shaders stopped
using geometry shaders and now rely on SSBOs.

In C++, workarounds allow these shaders to function as before, albeit
with some limitations.

However, this change broke the `batch_for_shader` function in Python,
as `GPUShader.attrs_info_get()` only reads attributes and does not
support SSBOs.

To address this, the method now treats polyline shaders differently,
accessing SSBO inputs instead of attributes.

fix
2024-12-11 20:39:24 +01:00
Guillermo Venegas
0576f22a67 BLI: allow extending a Vector with another Vector with move-semantics
This enables moving elements form one vector to another.

Usually this is being doing by extending a vector with the content
from the secondary vector and then clearing the secondary vector.
However sometimes this being performed to transfer ownership of managed elements,
if elements are copied from the secondary vector, but not cleared, this could
lead to 2 vectors to share ownership of objects.

Pull Request: https://projects.blender.org/blender/blender/pulls/131560
2024-12-11 17:43:44 +01:00
Campbell Barton
560b6e2831 Cleanup: spelling (make check_spelling_*) 2024-12-11 11:23:51 +11:00
Clément Foucault
f8da7ecfe1 Cleanup: DRW: Move DRW_SHADER_FREE_SAFE and DRW_UBO_FREE_SAFE to GPU 2024-12-11 00:43:32 +01:00
Clément Foucault
e29bda07b3 Fix #131633: GPU: Add Object Tool gizmo does not show correct bounds 2024-12-10 18:18:48 +01:00
Weizhen Huang
0b954d7777 Cleanup: make format 2024-12-10 17:51:29 +01:00
Clément Foucault
94b7035311 Fix: GPU: Broken compilation on Mac 2024-12-10 17:42:13 +01:00
Miguel Pozo
e24eadbb42 GPU: Add assert_framebuffer_shader_compatibility
Ensure all the framebuffer color attachments are written to.

Pull Request: https://projects.blender.org/blender/blender/pulls/130995
2024-12-10 17:13:06 +01:00
Jeroen Bakker
aee24fb6ba Vulkan: Updated NVIDIA/Linux driver support
NVIDIA driver before 550 doesn't work as expected on Linux. The issue is
known on the internet, but no real solutions are provided.

This change will limit the block list of older driver to the Linux
platform only. It has been reported that Windows these driver are
working and would enable older GPUs to work on Windows.

Ref #129160

Pull Request: https://projects.blender.org/blender/blender/pulls/131674
2024-12-10 15:37:38 +01:00
Jeroen Bakker
8c0b2a00dc Revert "Vulkan: Add support for LocalSizeId execution model"
This reverts commit ccab973556.

This change has some issues with Vulkan Validation layers. Reverting it
until it is clear what the cause is.
2024-12-10 13:42:22 +01:00
Jeroen Bakker
ccab973556 Vulkan: Add support for LocalSizeId execution model
Vulkan version 1.2 supports Workgroup execution model. Vulkan 1.3
introduced the LocalSizeId execution model and has been backported in
the VK_KHR_maintenance4 extension. In future SPIR-V versions the
Workgroup execution model will be deprecated.

This PR checks the availability of VK_KHR_maintenance4 extension and
when enabled compile the shaders towards Vulkan 1.3. This would
automatically use the LocalSizeId execution model.

See https://registry.khronos.org/vulkan/specs/latest/man/html/WorkgroupSize.html

Pull Request: https://projects.blender.org/blender/blender/pulls/131663
2024-12-10 11:06:12 +01:00
Jeroen Bakker
5ed49184fe Vulkan: Rebalance pool sizes.
Update the default pool sizes using some metrics from production files.
Adds a tool to check actual used pool sizes which can be enabled at
build time.

Pull Request: https://projects.blender.org/blender/blender/pulls/131661
2024-12-10 10:48:27 +01:00
Jeroen Bakker
1bd8719a7f Vulkan: Add asserts to check attachment usage flags
When using a texture as attachment it must be created witht the
GPU_TEXTURE_USAGE_ATTACHMENT flag. If this is not the case it would lead
to incorrect usage in Vulkan. This change adds asserts to detect
incorrect usage.

Pull Request: https://projects.blender.org/blender/blender/pulls/131656
2024-12-10 09:53:18 +01:00
Jeroen Bakker
500b1f3c69 Vulkan: Add support for clearing depth via GPU_texture_clear
GPU_texture_clear was only used for clearing color textures, but that
changed recently. This PR adds supports for clearing depth/stencil
textures using GPU_texture_clear.

Pull Request: https://projects.blender.org/blender/blender/pulls/131653
2024-12-10 09:06:43 +01:00
Jeroen Bakker
95b9281de1 Vulkan: Add support to clear D24_S8 texture
Depth 24 stencil 8 texture could not be cleared directly. Recently
GPUViewports clear their attachments when created. This resulted into
non consistent behavior between backends.

This change adds support to clear depth 24 stencil 8 textures using
`GPU_texture_clear`. The implementation currently assumes that the input
value is a float.

Pull Request: https://projects.blender.org/blender/blender/pulls/131650
2024-12-10 07:49:49 +01:00
Aras Pranckevicius
074df4ceeb GPU: ensure viewport does not use uninitialized images (#119685 and others)
GPUViewport is creating a bunch of framebuffer textures for itself, but
some space types never initialize/use them. E.g. Sequencer, Nodes etc.
only ever use the "overlay" texture. Eventually when viewport is
"drawn", it combines this uninitialized texture data and then only by
luck it happens that most of the time it is black. But not always!

The textures were only cleared (right now) on Metal backend, under
GPU_clear_viewport_workaround as if it was some driver workaround. Stop
doing that, and just clear them always.

However, there was seemingly a performance issue on OpenGL, when this
clear was being done. At least on my machine (Win10, Geforce RTX
3080Ti), the overhead of doing the clears is measurable, and is caused
by usage of GL4.4 glClearTexImage instead of a framebuffer clear. As if
glClearTexImage makes "pixel data to exist" on the CPU side and then
later on binding this framebuffer sends off that data to the GPU, or
somesuch.

More details in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/131518
2024-12-09 13:23:18 +01:00
Campbell Barton
083b690fb5 Cleanup: spelling in comments 2024-12-09 09:14:44 +11:00
Clément Foucault
7b6cc57215 Metal: Fix race condition in msl_patch_default_get
The string `msl_patch_default` can have been read
partially uninitialized or initialized multiple
time and read uncomplete during multithreaded
compilation.

This should fix the GPU tests randomly failing on mac.

While this would never fail when blender runs from the UI (since
UI shaders are init in single threaded manner and always compile
before EEVEE shaders), this race condition could happen when running
EEVEE through background rendering or running tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/131580
2024-12-08 19:15:56 +01:00
Miguel Pozo
e3c6c2c6fc Cleanup: CMake: De-duplicate with_shader_cpp_compilation code
Move the common setup and function to `macros.cmake`.

Pull Request: https://projects.blender.org/blender/blender/pulls/131391
2024-12-06 21:03:11 +01:00
Jeroen Bakker
09fe07b572 Vulkan: Pre-phase for initial uploading resources
Reduces the number of times a graphic context needs to be paused/resumed.
The scheduler reorders the nodes to put these initial data transfer nodes
to the start of the nodes that are about to be submitted.

Pull Request: https://projects.blender.org/blender/blender/pulls/131502
2024-12-06 15:34:03 +01:00
Omar Emara
1732467bc6 Refactor: Move Blur Gamma Correction to its own algorithm
Move the Gamma Correction pass of blur nodes into its own algorithm to
avoid code duplication and optimize pixel access, since gamma is now
applied for each pixel in the filter window. Gives a 15% improvement.

Pull Request: https://projects.blender.org/blender/blender/pulls/131480
2024-12-06 08:14:26 +01:00
Clément Foucault
52463a5f0b GPU: Remove unused GPUDrawList API
This was only used by the legacy draw manager.
This one has already been removed.
2024-12-05 23:26:29 +01:00
Clément Foucault
3e9a2fbf23 Cleanup: Formating 2024-12-05 23:17:44 +01:00
Clément Foucault
994c43413a Metal: Remove SSBO Vertex Fetch
This API was used as a workaround to the lack of
geometry shader. It has been rendered redundant
since the introduction of #125782.
2024-12-05 22:58:52 +01:00
Jeroen Bakker
55495b6224 Vulkan: Hide devices of failing drivers
Devices reported by failing drivers were still part of the device
selection list. When selected they would never be picked.

This change hides these devices from the UI

Pull Request: https://projects.blender.org/blender/blender/pulls/131431
2024-12-05 13:29:55 +01:00
Jeroen Bakker
475a038fde Fix #131376: Vulkan: Paint cursor nearest vertex incorrect
There were two issues.
- Rendering scope wasn't updated when changed between draw calls.
- GPU matrices were not bound when changed in immediate drawing.

Pull Request: https://projects.blender.org/blender/blender/pulls/131418
2024-12-05 11:36:27 +01:00
Jeroen Bakker
dc6bd96eeb Fix #131315: Vulkan: Provoking vertex incorrect
In OpenGL the last vertex is the provoking vertex. In Vulkan the first
vertex is the provoking vertex. This PR uses `VK_EXT_provoking_vertex`
to use the last vertex as the provoking vertex.

Pull Request: https://projects.blender.org/blender/blender/pulls/131412
2024-12-05 11:03:29 +01:00
Clément Foucault
fb84b21ec4 Cleanup: Selection: Assert legacy selection mode are not used 2024-12-04 19:18:14 +01:00
Miguel Pozo
bd1f4ec23c Fix: GPU: CPP shader errors in VS2019
Continuation of #131332.

Including built-in headers in VS2019 ends up including `corecrt_math.h`
as a side effect, which has many functions that overlap in name with
our stubs.
This puts the conflicting functions inside its own namespace (`glsl`)
and declares macros for them.
(Note this has the side effect of not allowing us to use those as
variable names)

This also removes the `<cassert>` and `<cstdio>` includes.

Pull Request: https://projects.blender.org/blender/blender/pulls/131386
2024-12-04 18:03:42 +01:00
Miguel Pozo
72aaaa0c24 Fix: GPU: Errors and warnings for CPP shaders in MSVC
Pull Request: https://projects.blender.org/blender/blender/pulls/131332
2024-12-04 17:33:12 +01:00
Clément Foucault
a0078b79ff Cleanup: GPU: Remove include of removed directory 2024-12-04 10:06:15 +01:00
Clément Foucault
62897317bd DRW: Remove Basic engine
All remaining shaders were moved to overlay.

The basic engine is not used anymore since
all selection and depth picking happens inside
overlay engine.
2024-12-03 16:11:31 +01:00
Jeroen Bakker
52d3cf8568 Fix #131227: OpenGL: Sequence editor crash on legacy Intel platforms
There seems to be an issue inside Intel OpenGL driver of legacy
platforms that fails to link `gpu_shader_sequencer_strips`.
Uniform locations are used to fix an specialization constants issue.

This PR only adds the uniform location when the shader can be
specialized. It is unclear what is actually failing inside the driver
but there are other issues with the driver.

Pull Request: https://projects.blender.org/blender/blender/pulls/131293
2024-12-03 15:31:10 +01:00
Jeroen Bakker
60d918c297 Fix #131269: Vulkan: Add support for GPU_DATA_UINT_24_8 read back
Add support for GPU_DATA_UINT_24_8 readback. Note that stencil reading/writing
are not supported.

Pull Request: https://projects.blender.org/blender/blender/pulls/131302
2024-12-03 14:56:43 +01:00
Jeroen Bakker
c480b7ffd3 Vulkan: Incorrect image aspect when transferring depth textures
When copying from/to depth stencil images the aspect of the image was
set incorrectly. It pointed to only one aspect of the full image when
building resource links, which could lead to incorrect decisions in the
driver.

Found when researching #131269

Pull Request: https://projects.blender.org/blender/blender/pulls/131298
2024-12-03 12:36:39 +01:00
Clément Foucault
18f3a11955 GPU: Remove remaining metal geometry shader workarounds
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/131267
2024-12-03 10:18:50 +01:00
Clément Foucault
c770b940ae GPU: GLSL C++ Stubs: Use extern variables for buffers and uniforms
Avoid false positive warning about division by zero.
2024-12-02 23:01:12 +01:00
Clément Foucault
e0989d5bd6 Cleanup: GPU: Address unused GLSL variables throughout the codebase 2024-12-02 23:01:12 +01:00
Clément Foucault
01f1e9a2c4 GPU: Silence most GLSL C++ compilation warnings 2024-12-02 23:01:12 +01:00
Clément Foucault
2c3ccdf77a GPU: GLSL compilation as C++ for eevee static shaders
Rel #127983

Pull Request: https://projects.blender.org/blender/blender/pulls/130298
2024-12-02 21:26:15 +01:00
Clément Foucault
3d9ffa5085 Overlay: Remove legacy option and legacy code
This simply removes the old overlay engine.

Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/131155
2024-12-02 19:47:55 +01:00
Clément Foucault
4bfaecc340 Fix #131212: Metal: Non-aligned circular buffer allocation logic
The new buffer size could have been non aligned when using the
fractional growing heuristic. This non aligned allocation
would then trigger an assert at the SSBO constructor.

Aligning the alocation size fixes the issue.
2024-12-02 17:34:35 +01:00
Jeroen Bakker
108a0f2ec0 Vulkan: Share driver check between GPU and GHOST
GPU and GHOST require to have identical checks to remove faulty drivers.
When not done GHOST can still select a device that isn't supported and
lead to freezing interfaces.

Pull Request: https://projects.blender.org/blender/blender/pulls/131241
2024-12-02 14:50:32 +01:00
Jeroen Bakker
33fd027dc5 Cleanup: Remove unused attribute 2024-12-02 08:29:46 +01:00