Commit Graph

4968 Commits

Author SHA1 Message Date
Jeroen Bakker
efc37b2573 GPU: Fixed Assert when running Specialization Constants test
Specialization constants tests use points render primitives, but the
shader isn't capable of point rendering. For the test results it doesn't
matter as it only validates the vertex output, but it would trigger an
assert when using Vulkan backend. The vulkan backend is more strict and
currently signals these common errors.
2024-02-01 14:28:02 +01:00
Clément Foucault
581c6e9f1f Cleanup: GPU: Fix shader builder compilation warning
The function signature changed recently.
2024-02-01 12:10:06 +01:00
Jeroen Bakker
958ec9f37f Vulkan: Use Generic Buffer to Store DrawList Commands
Previously a storage buffer was used to store draw list commands as it
matches already existing APIs. Unfortunately StorageBuffers prefers to
be stored on the GPU device and would reduce the benefit of a dynamic
draw list.

This PR replaces the storage buffer with a regular buffer, which keeps
more control where to store the buffer.

Pull Request: https://projects.blender.org/blender/blender/pulls/117712
2024-02-01 10:03:47 +01:00
Hans Goudey
fac27b1b6b Cleanup: Replace most used of SWAP macro with std::swap
Also remove / replace use of the math vector double swapping functions.
2024-01-31 21:12:16 -05:00
Clément Foucault
c0c3565714 GL: Remove geometry shader invocations workaround
# Conflicts:
#	source/blender/gpu/opengl/gl_backend.cc

# Conflicts:
#	source/blender/gpu/opengl/gl_shader.cc

Pull Request: https://projects.blender.org/blender/blender/pulls/116600
2024-01-31 18:13:02 +01:00
Clément Foucault
1ddc35ac88 GL: Remove texture gather workaround
# Conflicts:
#	source/blender/gpu/opengl/gl_backend.cc

# Conflicts:
#	source/blender/gpu/opengl/gl_shader.cc
2024-01-31 18:12:59 +01:00
Clément Foucault
749a3880de GL: Remove cube map array workaround 2024-01-31 18:12:59 +01:00
Clément Foucault
856daa13a5 GL: Remove texture storage workaround
# Conflicts:
#	source/blender/gpu/opengl/gl_backend.cc
2024-01-31 18:12:59 +01:00
Clément Foucault
0673ad344c GL: Remove vertex attrib binding workaround
# Conflicts:
#	source/blender/gpu/opengl/gl_backend.cc
2024-01-31 18:12:59 +01:00
Clément Foucault
a1c5a6b077 GL: Remove copy image workaround
# Conflicts:
#	source/blender/gpu/opengl/gl_backend.cc
2024-01-31 18:12:59 +01:00
Clément Foucault
71904d7fb3 GL: Remove image load/store workaround
# Conflicts:
#	source/blender/gpu/opengl/gl_backend.cc
2024-01-31 18:12:59 +01:00
Clément Foucault
64d1f065e3 GL: Remove base instance workaround 2024-01-31 18:12:59 +01:00
Clément Foucault
6722d40fd5 GL: Remove fixed restart index workaround 2024-01-31 18:12:59 +01:00
Clément Foucault
8c02b6eb24 EEVEE-Next: Add normal layer reuse
This allows to save some space in the gbuffer
and improve write performance.

Pull Request: https://projects.blender.org/blender/blender/pulls/117131
2024-01-31 15:36:42 +01:00
Omar Emara
51aac62006 Fix: Output of Color Ramp node is slightly off
The output of the Color Ramp node in the GPU compositor and EEVEE is
slightly off. That's because the factor is evaluated directly at the
sampler without proper half pixel offsets to account for the sampler's
linear interpolation, which this patch adds.

Pull Request: https://projects.blender.org/blender/blender/pulls/117677
2024-01-31 10:48:46 +01:00
Pierrick Bouvier
a3d915310b Build: Fix some excessive Visual Studio compile times
While investigating Blender compilation time for windows-arm64, we
identified two compilation units that were taking a long time to compile
(~1h each). This affects windows-x64 builds as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/117534
2024-01-28 12:12:52 +01:00
Jeroen Bakker
ec80264d09 Vulkan: Bundle Calls in DrawList
A draw list bundles multiple draw commands for the same geometry
and sends the draw commands in a single command. This reduces
the overhead of pipeline checking, resource validation and can
keep the load higher on the gpu as more work needs to be done.

Previously the draw list didn't bundle any commands and would still
send each call separately to the GPU. This PR implements the bundling
of the commands.

Pull Request: https://projects.blender.org/blender/blender/pulls/117548
2024-01-26 17:45:18 +01:00
Brecht Van Lommel
ae27daf834 Fix: only use preserveInvariance for Z fighting when supported by macOS
Pull Request: https://projects.blender.org/blender/blender/pulls/117484
2024-01-24 18:30:26 +01:00
Jason Fielder
6498809dfd Metal: Fix Z-fighting in EEVEE Next
Small change to always opt-in to using
invariant position in the vertex shader.
This ensures precision between position
calculations from different shaders which
need to produce the exact same result, by
disabling fastMath on only those instructions.

After benchmarking, the impact of this change
does not appear to affect performance bottlenecks
but will reduce the need for additional bias calculations.

Authored by Apple: Michael Parkin-White.

Pull Request: https://projects.blender.org/blender/blender/pulls/117478
2024-01-24 14:42:14 +01:00
Jason Fielder
190567f941 EEVEE Next: Optimize HiZ with fast image load store routines
Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/116953
2024-01-24 09:36:25 +01:00
Jeroen Bakker
cd756143cf OpenGL: Fix Shader Linking Error
When a shader performs a geometry shader injectoin to work around
features that are not supported natively on the GPU (viewport,
barycentric coordinates, layered rendering), linking would fail.

The reason was that the geometry shader was stored in a slot that was
patched by the specialization constants, resulting in an empty geometry
shader. An empty shader can be compiled, but doesn't match the interface
with other stages, so the linking would fail.

This fixes the issue that EEVEE crashed on Intel iGPUs. These GPUs
don't support viewports.

Pull Request: https://projects.blender.org/blender/blender/pulls/117440
2024-01-23 11:12:30 +01:00
Hans Goudey
0618de49ad Cleanup: Replace MIN/MAX macros with C++ functions
Use `std::min` and `std::max` instead. Though keep MIN2 and MAX2
just for C code that hasn't been moved to C++ yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/117384
2024-01-22 15:58:18 +01:00
Jeroen Bakker
18b5b0812b Cleanup: OpenGL program creation and linking
This PR improves the place when shader stages are attached to glPrograms.
Previously it was done when shaders stages where created, in the function
create_shader_stage.

This PR will attach the shader stages inside link program.
Ensuring that create_shader_stage doesn't alter the program, which isn't
clear in its name.

Pull Request: https://projects.blender.org/blender/blender/pulls/117407
2024-01-22 14:50:42 +01:00
Omar Emara
0adf01e79e Fix: Compile errors in GPU shader builder stubs
IMB module is now C++, so adjust the linkage of the stubs.
2024-01-22 12:27:19 +02:00
Aras Pranckevicius
a705259b4b Cleanup: move imbuf .h files to .hh 2024-01-19 20:29:38 +01:00
Hans Goudey
21407901f8 Cleanup: Various clang tidy changes 2024-01-19 12:08:48 -05:00
Jacques Lucke
4b47b46f9c Cleanup: rename PIL to BLI
The term `PIL` stands for "platform independent library." It exists since the `Initial Revision`
commit from 2002. Nowadays, we generally just use the `BLI` (blenlib) prefix for such code
and the `PIL` prefix feels more confusing then useful. Therefore, this patch renames the
`PIL` to `BLI`.

Pull Request: https://projects.blender.org/blender/blender/pulls/117325
2024-01-19 14:32:28 +01:00
Miguel Pozo
b5743dcf0a Fix #117159: GPU: Specialization constants binding deleted programs
The lack of a move constructor in GLProgram was causing Map reallocations
to delete their owned shaders/programs.
2024-01-18 17:12:24 +01:00
Miguel Pozo
ef6b6031de Fix #117123: EEVEE: Broken Specular BSDF
Add missing disable sss flag
2024-01-15 16:57:18 +01:00
Miguel Pozo
333a5b513b GPU: Assert framebuffer operations match attachment layout
Ensure attachment states and load/store configs don't get out of sync
with the framebuffer layout.
In theory, a Framebuffer could have empty attachments interleaved with
valid ones so checking just the attachments "length" is not enough.
What this does instead is to ensure that valid attachments have a valid
config and that null attachments either don't have a matching config or
have an IGNORE/DONT_CARE one.

Pull Request: https://projects.blender.org/blender/blender/pulls/117073
2024-01-15 13:25:20 +01:00
Jeroen Bakker
f4632e1da0 Fix: EEVEE: Potential Read From Unallocated Memory
Generated copies of GLSL sources are kept in a std::string and
it was always accessed by a long living StringRefNull which lead
to potential read from unallocated memory as std::strings are
not null terminated.

Pull Request: https://projects.blender.org/blender/blender/pulls/117120
2024-01-15 08:27:17 +01:00
Campbell Barton
fb532784e1 Docs: add doc-strings for some GPU_matrix functions
Also note the use of flat-array length for PyRNA foreach get/set.
2024-01-15 14:28:37 +11:00
Campbell Barton
4e898dd944 Cleanup: spelling in comments 2024-01-14 11:42:50 +11:00
Clément Foucault
df8dea9287 Cleanup: GPU: Remove warning about unused parameter 2024-01-13 20:37:11 +13:00
Jason Fielder
dd0482da76 Metal: GPU: Add support for custom shader tuning parameters
Allows specification of per-shader threadgroup memory tuning
to optimise performance through increase of GPU occupancy.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/115238
2024-01-12 22:07:46 +01:00
Jeroen Bakker
d6f98dbd3f Cleanup: Make format 2024-01-12 15:14:00 +01:00
Jason Fielder
7eee954d9d Fix #116216: Only support Memoryless texture flag on TBDR GPUs
Change limits MTLStorageModeMemoryless to device which
support this feature.

Authored by Apple: Michael Parkin-White
Pull Request: https://projects.blender.org/blender/blender/pulls/116250
2024-01-12 15:08:46 +01:00
Jeroen Bakker
4ac0267567 OpenGL: Specialization Constants
This PR adds support for specialization constants for the OpenGL
backend. The minimum OpenGL version we are targetting doesn't
have native support for specialization constants. We simulate this
by keeping track of shader programs for each set of specialization
constants that are being used.

Specialization constants can be used to reduce shader complexity
and improve performance as less registry and/or spilling is done.

This requires the ability to recompile GLShaders. In order to do this
we need to keep track of the sources that are used when the shader
was compiled. For static sources we only store references
(`GLSource::source_ref`), for dynamically generated sources we keep
a copy of the source (`GLSource::source`).

When recompiling the shader GLSL source-code is generated for the
constants stored in `Shader::constants`. When compiling the previous
GLSource that contains specialization constants is then replaced
by the new version.

Pull Request: https://projects.blender.org/blender/blender/pulls/116926
2024-01-12 14:28:50 +01:00
Hans Goudey
6438d0ad1f Cleanup: Grammar in comments 2024-01-11 11:01:50 -05:00
Jeroen Bakker
69ac64df54 GPU: Shader Builder CMake Fixes
This PR cleans up shader builder CMake files and fixes vulkan includes
that could not be found on all platforms.

* Reduce code duplication
* Use private var for MANIFEST on windows
* Add system includes when compiling

Pull Request: https://projects.blender.org/blender/blender/pulls/115889
2024-01-11 13:42:17 +01:00
Jeroen Bakker
6e17b9c640 Vulkan: Fix: DEPTH_COMPONENT24
Tests for DEPTH_COMPONENT24 crash, so add an implementation to support it.

Co-authored-by: vnapdv <kaz380@hotmail.co.jp>
Pull Request: https://projects.blender.org/blender/blender/pulls/117026
2024-01-11 12:55:33 +01:00
Jeroen Bakker
cd8218d9e4 Vulkan: Fix Image Range Validation Error
Co-authored-by: vnapdv <kaz380@hotmail.co.jp>
Pull Request: https://projects.blender.org/blender/blender/pulls/117024
2024-01-11 12:47:11 +01:00
Jeroen Bakker
6e26249671 Vulkan: Fix vkCmdCopyBufferToImage validation error
Fixes validation error {0xbd041cbe}VUID-VkBufferImageCopy-aspectMask-00212.

Co-authored-by: vnapdv <kaz380@hotmail.co.jp>
Pull Request: https://projects.blender.org/blender/blender/pulls/117021
2024-01-11 11:47:45 +01:00
Jeroen Bakker
46a79ba5a2 Vulkan: Fix Samplers Extend mode
Patch provided by @vnapdv

Pull Request: https://projects.blender.org/blender/blender/pulls/117020
2024-01-11 11:41:35 +01:00
Jeroen Bakker
72d6ca3aff Vulkan: Fix Anisotropic Filtering Validation Error
When anisotropic filtering is enabled on a sampler its value must be
between 1 and 16. In blender it is possible to set a value lower than 1.
0 actually means that anisotropic filtering is disabled in Blender.
This would trigger a validation error in Vulkan.

Pull Request: https://projects.blender.org/blender/blender/pulls/117018
2024-01-11 11:12:35 +01:00
Campbell Barton
7a4f7a1d51 Cleanup: spelling in comments, comment blocks 2024-01-11 16:46:46 +11:00
Miguel Pozo
31d8a6514f Fix: EEVEE(Legacy): Broken dielectric material shading
sss_radius r and g are already used for occlussion workarounds.
Use only sss_radius.b for flagging sss as disabled.
Regression from 2942147079.
2024-01-10 17:59:20 +01:00
Jeroen Bakker
5b969f54ca Vulkan: Fix Shader Compilation Issue
The Specialization Shader workaround generated code that wasn't Vulkan
GLSL compliant. The uintBitsToFloat cannot be used during global const
initialization.

This is a temporary work around until we implement the Specialization
Constants for Vulkan.

Pull Request: https://projects.blender.org/blender/blender/pulls/116942
2024-01-09 14:55:02 +01:00
Clément Foucault
ea989ebf94 EEVEE/EEVEE-Next: Split Diffuse and Subsurface closure
Even if related, they don't have the same performance
impact.

To avoid any performance hit, we replace the Diffuse
by a Subsurface Closure for legacy EEVEE and
use the subsurface closure only where needed for
EEVEE-Next leveraging the random sampling.

This increases the compatibility with cycles that
doesn't modulate the radius of the subsurface anymore.
This change is only present in EEVEE-Next.

This commit changes the principled BSDF code so that
it is easier to follow the flow of data.

For legacy EEVEE, the SSS switch is moved to a
`radius == -1` check.
2024-01-09 16:39:17 +13:00
Campbell Barton
7f6e4c6866 Cleanup: sort cmake file lists 2024-01-09 12:17:12 +11:00