Commit Graph

5535 Commits

Author SHA1 Message Date
Clément Foucault
f38827802a Fix: GPU: Broken shader printf support
Was using wrong type of data offset and not removing
the quote when outputing the strings.
2024-10-16 17:01:17 +02:00
Campbell Barton
5a561c6aeb Cleanup: spelling in comments 2024-10-16 21:10:49 +11:00
Campbell Barton
10960b99c9 Merge branch 'blender-v4.3-release' 2024-10-16 21:08:15 +11:00
Clément Foucault
c91baf1cdd GPU: GLSL Preprocess: Avoid parsing includes as string
Remove them before string parsing
2024-10-16 10:30:35 +02:00
Falk David
30adc33730 Fix #128827: GPv3: Bucket fill doesn't work on macOS
The issue was that the shader `gpu_shader_gpencil_stroke_vert_no_geom.glsl`
assumed a wrong format of the color attribute (`uchar4`  instead of `float4`).

The fix uses `vertex_fetch_attribute` with `float4`.

Pull Request: https://projects.blender.org/blender/blender/pulls/129072
2024-10-16 10:29:07 +02:00
Clément Foucault
4ba944b15a GPU: GLSL Preprocess: Always remove quotes
We cannot do this for the MSL files. Also
they are written in MSL which should not be
processed. So use datatoc for them.

Also add quote linting for GLSL files.
2024-10-16 09:08:51 +02:00
Clément Foucault
7110890b09 GPU: GLSL preprocessor: Only do function parsing on library files 2024-10-16 09:08:51 +02:00
Clément Foucault
fcae6f2fc4 Fix: GPU: GLSL preprocessor not using binary output stream
This was adding a lot of CLRF newlines on windows which
in turn caused the new runtime parsing to fail.
2024-10-15 22:56:32 +02:00
Clément Foucault
39d5013c6e GPU: Use filename hash for line directive instead of path
This ensures same values on all systems.
2024-10-15 22:26:08 +02:00
Clément Foucault
f15227946a GPU: Improve dependency error logging 2024-10-15 22:26:08 +02:00
Clément Foucault
c1f4394b14 GPU: Use 32bit hash in static_strings_suffix
Also make sure to use stoul for parsing it.
2024-10-15 22:26:08 +02:00
Clément Foucault
c41326a296 Cleanup: GPU: GLSL Preprocessor: Use raw strings and remove template 2024-10-15 20:16:45 +02:00
Clément Foucault
cf9da6f642 GPU: Move global scope constant linting to preprocessor
# Conflicts:
#	source/blender/gpu/glsl_preprocess/glsl_preprocess.hh
2024-10-15 20:16:45 +02:00
Clément Foucault
d712be0662 GPU: Change global scope variable to defines to avoid overhead on Metal 2024-10-15 20:06:46 +02:00
Clément Foucault
62826931b0 GPU: Move more linting and processing of GLSL to compile time
The goal is to reduce the startup time cost of
all of these parsing and string replacement.

All comments are now stripped at compile time.
This comment check added noticeable slowdown at
startup in debug builds and during preprocessing.

Put all metadatas between start and end token.
Use very simple parsing using `StringRef` and
hash all identifiers.

Move all the complexity to the preprocessor that
massagess the metadata into a well expected input
to the runtime parser.

All identifiers are compile time hashed so that no string
comparison is made at runtime.

Speed up the source loading:
- from 10ms to 1.6ms (6.25x speedup) in release
- from 194ms to 6ms (32.3x speedup) in debug

Follow up #129009

Pull Request: https://projects.blender.org/blender/blender/pulls/128927
2024-10-15 19:47:30 +02:00
Clément Foucault
86f442df95 GPU: Make create info list not runtime generated
This avoid cmake shenanigans to try to make proper
dependency tracking.

The previous code was not tracking changes inside
the create info files.

There is no real benefit for having these headers listed in
the cmakefile itself.

Pull Request: https://projects.blender.org/blender/blender/pulls/129027
2024-10-15 16:31:37 +02:00
Jeroen Bakker
791f90ab8d Vulkan: Remove guardedalloc option
WITH_VULKAN_GUARDEDALLOC is a development option to use Blenders guarded
allocator when allocating internal vulkan driver resources. It does not provide any benefits
as this should be covered by vulkan validation and drivers are often ignoring this. This
change will remove the option from cmake and source code.

Pull Request: https://projects.blender.org/blender/blender/pulls/129039
2024-10-15 13:46:00 +02:00
Jeroen Bakker
8c441ac937 Merge branch 'blender-v4.3-release' 2024-10-15 13:44:46 +02:00
Jeroen Bakker
6f6efb6ec0 Vulkan: Disable Intel 10th gen and lower on Windows
Intel Windows drivers for 10th gen and lower has some strange behavior
when using dynamic rendering. It requires pipeline conditions to be met,
when beginning a new rendering scope. This is strange as specs + VVL
notes that these conditions should be met during vkCmdDraw* commands.

Pull Request: https://projects.blender.org/blender/blender/pulls/129055
2024-10-15 13:44:05 +02:00
Jeroen Bakker
cdef54a5ce Vulkan: Workaround for unused attachment extension
This change makes unused attachments extension optional.
This extension is fairly new and not all drivers have support for it.

The workaround will create additional pipelines when attachments are
not set.

Pull Request: https://projects.blender.org/blender/blender/pulls/129046
2024-10-15 13:43:21 +02:00
Campbell Barton
aa6742897e Cleanup: spelling in comments 2024-10-15 16:22:38 +11:00
Jason Fielder
6da42e9c95 Fix: Metal: GPU_finish() not syncing when there's no (current) command buffer to sync on
Reported by @fclem.  On Metal GPU_finish enacts a CPU<-> GPU sync by
submitting a command buffer and waiting on the completion event.
However if there was no command buffer to submit then the call was
returning immediately, regardless of any outstanding GPU work.
This fixes that case by keeping track of all outstanding work and
blocking on that.

Authored by Apple: James McCarthy

Co-authored-by: James McCarthy <jamesmccarthy@apple.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/128987
2024-10-14 17:12:03 +02:00
Jeroen Bakker
399060aa0e Merge branch 'blender-v4.3-release' 2024-10-14 15:45:34 +02:00
Jeroen Bakker
ceb61ac921 Fix: Vulkan: Strict extension test
VK_EXT_dynamic_rendering_unused_attachments is required for correct working.
Renderdoc hides this extension, but most platforms do work. However the
Windows Intel driver crashes when using iGPUs; they don't support this
extension at all.

This change does a more strict extension test so drivers that do not
support this extension will fallback to OpenGL. When using renderdoc it
is now allowed to compile blender with `WITH_RENDERDOC=On`.

Future developments are needed to add support for Intel iGPUs on
Windows.

Pull Request: https://projects.blender.org/blender/blender/pulls/128986
2024-10-14 15:43:41 +02:00
Jeroen Bakker
d35cd15e12 Fix #128608: Vulkan: Sync issues when sharing context between threads
Resources are shared, when running multiple contexts on the same thread.
Cycles uses the same context on multiple threads and expected same resources.

This change will introduce a single render graph per context and an updated
resource management. Render graphs are not shared anymore; Resource pools
are still shared, but garbage collection depends on the thread and if
background rendering is used.

Pull Request: https://projects.blender.org/blender/blender/pulls/128983
2024-10-14 15:42:46 +02:00
Jeroen Bakker
fb862d082a Fix: Vulkan: Sync issue command buffers
Cycles uses multiple threads to send commands to the GPU. The current
command buffer structure assumed that all commands from the same context
were send via the same thread. This wasn't the case and could lead to
recording commands to command buffers that are still pending (preparing
commands to send to GPU).

This is fixed by creating a command buffer each time a render graph
submits its work.

Detected when researching #128608

Pull Request: https://projects.blender.org/blender/blender/pulls/128978
2024-10-14 15:41:30 +02:00
Jeroen Bakker
3b7dd61e01 Fix: Vulkan: Incorrect Host Visibility Allocation
When allocating a host visible buffer it could be that the returned
buffer was not host visible and access to the buffer would write to
unallocated memory.

Detected when researching #128608

Pull Request: https://projects.blender.org/blender/blender/pulls/128977
2024-10-14 15:39:27 +02:00
Jeroen Bakker
acb205763e Fix: Vulkan: Cycles CPU Synchronization
When using cycles in the viewport there it uses render threads and
workers to update the viewport. All threads can record commands to the
queue and needs to be synchronized. This didn't happen leading to
incorrect renders.

Detected when researching #128608

Pull Request: https://projects.blender.org/blender/blender/pulls/128975
2024-10-14 15:38:22 +02:00
Jeroen Bakker
af151e89a7 Fix: Vulkan: Unguarded Access Device Queues
Multiple threads can access the same device queue from different
threads. This could happen when doing a cycles preview render, baking
eevee volume probes or generating material previews.

This PR adds a mutex around access to the device queues.

Detected when researching #128608

Pull Request: https://projects.blender.org/blender/blender/pulls/128974
2024-10-14 15:30:11 +02:00
Campbell Barton
bd299cad72 Cleanup: quiet unused argument warnings 2024-10-14 12:12:20 +11:00
Clément Foucault
191b347f58 Cleanup: GPU: Use function parameters instead of template 2024-10-12 14:21:51 +02:00
Clément Foucault
d9aad850b0 GPU: GLSL preprocess: Remove invalidly processed header
Add assert in the preprocessor that these file don't get
processed.
2024-10-12 14:21:51 +02:00
Clément Foucault
1c0247c871 Cleanup: GPU: Preprocessor: Use report callback on processing functions 2024-10-11 18:52:34 +02:00
Clément Foucault
300ea9f083 GPU: GLSL: Strip comment at compile time
This speeds up the preprocessor and
will allow for faster load time.

# Conflicts:
#	source/blender/gpu/glsl_preprocess/glsl_preprocess.cc
2024-10-11 11:15:52 +02:00
Jeroen Bakker
318d61756f Merge branch 'blender-v4.3-release' 2024-10-10 12:17:11 +02:00
Jeroen Bakker
9bcba25bc2 Fix #128282: EEVEE: Unable to compile displacement
When using vertex displacement EEVEE didn't compile the generated
functions into the vertex shader. This could result in errors when
compiling materials.

**Notes**

- Should be back-ported to Blender 4.2

Pull Request: https://projects.blender.org/blender/blender/pulls/128525
2024-10-10 12:16:28 +02:00
Campbell Barton
f3c2deac3e Cleanup: replace U+00A0 with space
Using ASCII space is sufficient in source.
2024-10-09 16:34:39 +11:00
Jeroen Bakker
70590d1bd9 Merge branch 'blender-v4.3-release' 2024-10-08 11:33:14 +02:00
Jeroen Bakker
27932162d8 Fix: Cache files location
Adds an additional precheck to identify if the app cache dir is correct.
Reduces placing cache files all over the place when the app dir isn't
correct.
2024-10-08 11:32:41 +02:00
Jeroen Bakker
c15cda2bf1 Merge branch 'blender-v4.3-release' 2024-10-08 10:55:38 +02:00
Jeroen Bakker
3cd579208b Vulkan: SPIR-V Caching
Adds a SPIR-V cache that skips frontend compilation for shaders
that are already compiled in a previous run of Blender.

Initially this was postponed to 4.4 but it was observed that
the vulkan backend didn't perform well on Windows in debug
builds. The reason is that the compiler would also be a debug
build which makes compiling a shader really slow. Starting
Blender on a debug build could take minutes.

So the decision was made to give this task a higher priority so
the vulkan backend would become more usable to developers
as well.

The cache is stored in the application cache dir. The SPIR-V
binaries can be used by different Blender versions so there
is no version specific cache folder.

**Sidecar**: SPIR-V files are a stream of bytes. There is no
header information that allow us to validate the stream. To
add basic validations we could add our custom header or
a sidecar. It was chosen to use a sidecar as having the SPIR-V
files unmodified allows us to load them directly in
debug tools for analyzing.

**Retention**: Shaders that are not used are automatically
removed with a retention period of 30 days.

**Shader builder**: Shader builder cannot use the SPIR-V
cache as it uses stubs that returns invalid cache directories.
This would load/save the cache to the location where you
started the build.

Pull Request: https://projects.blender.org/blender/blender/pulls/128741
2024-10-08 10:55:10 +02:00
Campbell Barton
2e881eacd1 Cleanup: spelling in comments 2024-10-08 09:54:29 +11:00
Jacques Lucke
226f1b4f01 Merge branch 'blender-v4.3-release' 2024-10-08 00:22:00 +02:00
Campbell Barton
8c3ef77a35 Cleanup: spelling in comments 2024-10-08 09:03:49 +11:00
Clément Foucault
f877f705c6 Revert "DRW: Rename draw_debug_info.hh to avoid conflict with main branch"
This reverts commit 301c853b9c.
2024-10-07 16:19:55 +02:00
Clément Foucault
0ab5b400b3 Merge branch 'blender-v4.3-release' 2024-10-07 16:17:28 +02:00
Clément Foucault
301c853b9c DRW: Rename draw_debug_info.hh to avoid conflict with main branch
Between 0bfd5e3536
and b1cbd9c889
the main branch is incorrectly processing the file
`draw_debug_info.hh` as GLSL and does some string
preprocessing on it. But the output filename matches
the name of the header source file used for compiling
the gpu module. This file not having been updated
since a long time doesn't get copied from the source
folder when switching to other branch and make compilation
fail.

In order to avoid breaking the buildbot longer, we
rename the incriminating file to force recreate it
when building the release branch.
2024-10-07 16:11:09 +02:00
Clément Foucault
597388a65e Fix: GPU: GLSL-C++ stubs GPU_SHADER_INTERFACE_INFO macro error
The macro should take only one parameter.
2024-10-07 15:55:29 +02:00
Clément Foucault
9c0321ae9b Metal: Simplify MSL translation
Move most of the string preprocessing used for MSL
compatibility to `glsl_preprocess`.

Enforce some changes like matrix constructor and
array constructor to the GLSL codebase. This is
for C++ compatibility.

Additionally reduce the amount of code duplication
inside the compatibility code.

Pull Request: https://projects.blender.org/blender/blender/pulls/128634
2024-10-07 12:54:10 +02:00
Clément Foucault
42e8cbb921 GPU: Make use of the C++ stubs in some shaders 2024-10-07 12:35:47 +02:00