Commit Graph

5599 Commits

Author SHA1 Message Date
Clément Foucault
654cc9ed36 GPU: Fix printf force injection logic and limit it to material shader
This fixes backend error caused by missing resource.
2024-11-08 20:20:07 +01:00
Clément Foucault
93a10cbf7e GPU: Enable printf only between render boundaries and use a stack
Printf buffer read needs to be inside render boundaries
to work. Since render boundaries can be nested, use a stack.

Fixes assert when quitting blender.
2024-11-08 20:01:08 +01:00
Clément Foucault
510f97865a Fix: Metal: Address ASAN errors
Fix several error reported by asan when just launching blender.
2024-11-08 16:09:09 +01:00
Clément Foucault
72b24fa336 Cleanup: Metal: Simplify mtl_convert_vertex_format
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/130036
2024-11-08 16:07:58 +01:00
Jeroen Bakker
4a9d53f9f3 Merge branch 'blender-v4.3-release' 2024-11-08 12:30:33 +01:00
Jeroen Bakker
b86ed45fcb Fix unreported: Vulkan: Empty device list
The list of vulkan devices is empty. This regression was introduced by
91960b07db. Vulkan needs to initialize the
platform twice. Once when the backend starts, and the second time when
the device is selected. The device list is added when the backend
starts, but was cleared when the device was initialized, making the list
empty.

Pull Request: https://projects.blender.org/blender/blender/pulls/130020
2024-11-08 12:29:23 +01:00
Jeroen Bakker
b2e1677b36 Fix: Vulkan: Incorrect depth on ARM devices
When gl_FragDepth is defined in the fragment shader and the depth isn't
written to the driver would reset the value to 0. This PR fixes this by
not putting the gl_FragDepth in the shader when it uses the
`depth_unchanged` qualifier or doesn't find any usage in the GLSL.

Pull Request: https://projects.blender.org/blender/blender/pulls/130016
2024-11-08 12:27:46 +01:00
Clément Foucault
4416e27b14 GPU: GLSL C++ stubs: Add support for depth and buffer sampler fetch 2024-11-08 00:28:59 +01:00
Clément Foucault
0a3008172b Cleanup: GPU: Silence shader warnings 2024-11-08 00:28:08 +01:00
Bastien Montagne
e156a422cd Merge branch 'blender-v4.3-release' 2024-11-07 16:01:04 +01:00
Jason Fielder
658700ddff Fix #126364: Metal: modified texture usage flags causing cache misses
For Metal we can change the texture usage flags to get more optimal
behaviour - one example is adding the attachment flag so we can utilise
renders to do texture clears. However these usage flags are used as the
part of the match-criteria when trying to reuse released textures in
the texture pool.

The modifications means a request for the same type of texture will
fail causing a cache miss. When we render to an
image-view the texture pool is not released until the final sample has
been rendered as we consider the entire render to be a single frame
(as opposed to normal viewport rendering when we are presenting the
intermediate results).

This causes the texture pool to grow and grow and grow hence the large
memory usage. This fix splits the usage flags
into two sets, the internal ones we use to create the MTLTexture (which
we may modify) and the originally requested ones. The originally requested
ones are used for the texture pool matching.

This fix also improves memory efficiency for normal viewport rendering.

Mr Elephant Scene
Before -> After
Load scene in viewport: 13.04Gb ->  9.15 Gb
Viewport Render Image: 78.69Gb -> 16.61Gb

Authored by Apple: James McCarthy

Pull Request: https://projects.blender.org/blender/blender/pulls/129951
2024-11-07 15:53:09 +01:00
Jeroen Bakker
a4529f0e17 Merge branch 'blender-v4.3-release' 2024-11-07 14:01:32 +01:00
Jacques Lucke
3688a2919b Merge branch 'blender-v4.3-release' 2024-11-07 14:00:52 +01:00
Jeroen Bakker
da767bcbdc Fix: Vulkan: Enable interleaved tests
Interleaved tests where disabled for Vulkan, but interleaving has been
implemented. This PR enabled these tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/129957
2024-11-07 14:00:51 +01:00
Jeroen Bakker
e0f699abdb Fix: Vulkan: Read & write outside of bounds
When running test cases
`test_texture_roundtrip__GPU_DATA_10_11_11_REV__GPU_R11F_G11F_B10F`
would read and write outside of allocated memory. This is an error in
the test case itself the GPU API doesn't have a public function to get
the desired byte and component size.

Pull Request: https://projects.blender.org/blender/blender/pulls/129958
2024-11-07 13:59:53 +01:00
Jeroen Bakker
91960b07db Fix unreported: Vulkan: Memory leak
When exiting Blender the list of devices was not freed, leading
to a memory leak.

Pull Request: https://projects.blender.org/blender/blender/pulls/129956
2024-11-07 13:59:07 +01:00
Jeroen Bakker
acb49ee889 Merge branch 'blender-v4.3-release' 2024-11-07 10:30:53 +01:00
Jeroen Bakker
f3342fa680 Fix #129708: Vulkan: Add limit checks when creating images
Drivers should perform a limit check when creating images and return
`VK_ERROR_OUT_OF_DEVICE_MEMORY`. However there are drivers where this
check is a pass-through and leads to `VK_ERROR_DEVICE_LOST`.

This issue was introduced !128877 and only shows up on official NVIDIA
drivers.

Pull Request: https://projects.blender.org/blender/blender/pulls/129939
2024-11-07 10:29:40 +01:00
Clément Foucault
5c80fb17e0 GPU: Add support for shader assert
This allows to use `assert()` directly inside shader source.

The current implementation is just replacing it with a printf
that gives some information about the location of the assert.

It is not that much more helpful than a printf with a condition.
What is useful is that they are disabled by default. So they
can be sprinkle around and only turned on during debugging.

Adding shader name inside the assert report is not trivial and
could be added later (the shader name is only known at compile
time which is too late for string parsing).

Adding which drawcall produced the assert isn't trivial either.
It would require flushing the printf buffer for each drawcall
which might force synchronization and remove bugs.

Pull Request: https://projects.blender.org/blender/blender/pulls/129728
2024-11-06 20:29:01 +01:00
Clément Foucault
22c514b95c Merge branch 'blender-v4.3-release' 2024-11-06 13:03:48 +01:00
Clément Foucault
dd01858959 GPU: Avoid assert caused by overlapping attribute in material shaders
This was caused by `drw_ResourceID` taking one vertex input
(at slot 15) which was then also used by material shaders.

Starting material shaders at 14 in this case avoid the overlap.

Note that this reduces the amount of supported attribute when
using the workarounds by one.
2024-11-06 13:03:32 +01:00
Clément Foucault
8c0bd61342 Merge branch 'blender-v4.3-release' 2024-11-05 17:40:49 +01:00
Clément Foucault
750a9af518 Fix #129705: EEVEE: Light Probe RAM Pool Crash on MacOS
Crash manifested after the inclusion of #128877.
The very tall 3D texture tested by the new code
were not supported / tested by the Metal Backend.

Simply adding the appropriate upfront checks fixes
the issue.

Needs to be backported to 4.2
2024-11-05 17:37:02 +01:00
Clément Foucault
43b5e2d0ed Fix: EEVEE: Add buffer workaround for stencil classification
Adding a dummy storage buffer to the classification shader
seems to fix the issue on Qualcomm drivers (WoA).

The workaround is added to the force workaround option to
allow other platforms to test the fix.

Rel #122837

Pull Request: https://projects.blender.org/blender/blender/pulls/129857
2024-11-05 17:12:28 +01:00
Clément Foucault
118ca96c8a GPU: Enable shader interface check for geometry shader fallback 2024-11-05 15:07:56 +01:00
Jeroen Bakker
e5dcb019a9 Merge branch 'blender-v4.3-release' 2024-11-05 13:23:05 +01:00
Jeroen Bakker
fe8bc5100d Cleanup: Remove compilation warning
Introduced by !129775

Pull Request: https://projects.blender.org/blender/blender/pulls/129855
2024-11-05 13:22:18 +01:00
Campbell Barton
8bf245ad51 Merge branch 'blender-v4.3-release' 2024-11-05 23:05:43 +11:00
Campbell Barton
b53c20db25 EEVEE: remove DNA/RNA for values that are no longer in use
Remove values from EEVEE which are no longer used.

Ref !129832
2024-11-05 23:00:29 +11:00
Jeroen Bakker
66c7c6959a Merge branch 'blender-v4.3-release' 2024-11-05 12:45:01 +01:00
Jeroen Bakker
b18a460ad7 Fix #129265: Clearing depth attachments on AMD official driver
When using AMD official driver clearing depth attachments can fail.
I assume it is related to previous pipeline states and dynamic rendering
that don't require the correct pipeline state for clearing depth
attachments.

![image](/attachments/e5b97c3b-2551-4600-8cbe-4c8fc71d9feb)

Co-authored-by: jeroen@blender.org <Jeroen Bakker>
Pull Request: https://projects.blender.org/blender/blender/pulls/129852
2024-11-05 12:44:17 +01:00
Jeroen Bakker
a08151f0f4 Merge branch 'blender-v4.3-release' 2024-11-05 08:07:55 +01:00
Jeroen Bakker
f76410329b Vulkan: Disable Optimizations for Qualcomm
Qualcomm driver can not handle the optimized SPIR-V that Blender
creates. According to their driver engineers this is an issue in
shaderc. As we are late in the release process they asked us to disable
the optimizations.

In Blender 4.4 we are planning to update shaderc what might fix the
issue. This should be retested after the update.

Pull Request: https://projects.blender.org/blender/blender/pulls/129775
2024-11-05 08:05:42 +01:00
Clément Foucault
94a5f541c3 GPU: Improve GLSL-C++ compatibility
Add a few missing operator/functions and fix some argument
type deduction problems.
2024-11-05 00:39:10 +01:00
Hans Goudey
aa62c1b5d1 Fix #129741: Two issues creating GPU shader from Python
1. Log printing casted a span of `StringRefNull` to a span of `char **`
2. Creating the shader tried to create `StringRefNull` from `nullptr`.
2024-11-03 10:49:16 +01:00
Clément Foucault
afaa315418 GPU: Printf: Print buffer content even in case of overflow
The start of the buffer is ensured to be correct. So there
is no downside in printing the content of the overflowed
buffer.

At least, we get a feedback at which command is flooding it.
2024-11-02 21:51:26 +01:00
Campbell Barton
15c207a294 Merge branch 'blender-v4.3-release' 2024-11-02 17:34:00 +11:00
Campbell Barton
4df285ccd5 Cleanup: move function comments into headers or implementation notes
For C/C++ doc-strings should be located in headers,
move function comments into the headers, in some cases merging
with existing doc-strings, in other cases, moving implementation
notes into the function body.
2024-11-02 17:27:09 +11:00
Campbell Barton
e46c58df7c Merge branch 'blender-v4.3-release' 2024-11-02 15:44:22 +11:00
Campbell Barton
99387c0749 Cleanup: spelling in comments, docs & error 2024-11-02 15:43:27 +11:00
Clément Foucault
d9ff375e7e GPU: GLSL-C++ Stubs: Make compilation possible
- Add `main` workaournd.
- Define out create info class when compiling with stubs.
- Move interfaces and info namespace to global namespace.
2024-11-01 23:38:22 +01:00
Clément Foucault
01236be188 Cleanup: GPU: Remove unused shader files
These shaders have not been used for a long time.
2024-11-01 23:36:45 +01:00
Clément Foucault
e311c6dd4f Cleanup: Metal: Fix clang tidy warnings
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/129656
2024-11-01 20:23:18 +01:00
Hans Goudey
9b97ba1462 Cleanup: GPU: Avoid raw pointers for shader API strings
Avoid measuring the length of strings repeatedly by passing their
length along with their data with `StringRefNull`. Null termination
seems to be necessary still for passing the shader sources to OpenGL.
Though I doubt this is a bottleneck, it's still nice to avoid overhead from
string operations and this helps move in that direction.

Pull Request: https://projects.blender.org/blender/blender/pulls/127702
2024-11-01 20:00:31 +01:00
Clément Foucault
9ee81411bf GPU: Multithread compilation of shaders during tests 2024-11-01 18:57:22 +01:00
Clément Foucault
d2c378984d Cleanup: GPU: Avoid glsl functions with only one void argument 2024-11-01 18:57:22 +01:00
Clément Foucault
47f7aaa2cc Merge branch 'blender-v4.3-release' 2024-11-01 12:16:38 +01:00
Jason Fielder
7fbc9e9428 Fix: Metal: Memory leaks identified by Instruments and Xcode memory graph.
Running Xcode memory graphs and the Instruments tools revealed
memory leaks caused, in the main, by over-retained objects.
This removes the unnecessary 'retains' and adds some asserts
to guard against over-retaining in the future.

There are a few memory leaks remaining involving PyUnicode_DecodeUTF8
but I am unable to identify the cause of these at this time.

Authored by Apple: James McCarthy

Pull Request: https://projects.blender.org/blender/blender/pulls/129117
2024-11-01 11:56:51 +01:00
Clément Foucault
324517fd78 Cleanup: GPU: Fix clang tidy warnings
Removes some other things like:
- `TRUST_NO_ONE` which was the same as `#ifndef NDEBUG`.
- Replace `reinterpret_cast` by `unwrap`

Pull Request: https://projects.blender.org/blender/blender/pulls/129631
2024-10-31 15:18:29 +01:00
Clément Foucault
09fb4b498a GPU: Add more stubs for C++ shader compilation 2024-10-31 13:13:15 +01:00