Commit Graph

4933 Commits

Author SHA1 Message Date
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
Clément Foucault
98e465109b EEVEE-Next: Replace lighting tiles by direct stencil setup
This avoid the cost of creating the tiles themselves which uses a lot
texture write. This was a bottleneck on Apple GPUs.

Also the per pixel classification allows us to remove certain checks in
the deferred lighting shader making it faster.

### TODO
- [x] Add gl_FragStencilRefARB support on other backend
- [x] Add workaround for when gl_FragStencilRefARB isnt supported

Pull Request: https://projects.blender.org/blender/blender/pulls/116704
2024-01-08 07:35:05 +01:00
Campbell Barton
2783af45ee Cleanup: trailing newlines 2024-01-08 11:31:43 +11:00
Campbell Barton
617f7b76df Cleanup: comment block formatting 2024-01-08 11:31:43 +11:00
Campbell Barton
0ba83fde1f Cleanup: spelling in comments 2024-01-08 11:24:37 +11:00
Clément Foucault
28356d1f89 Metal: Add debug names to compute pipelines 2024-01-07 22:46:44 +13:00
Clément Foucault
b8b9ed075b Fix: GPU: Crash caused by buffer overflow of name buffer
This was caused by the name buffer not being sized
accordingly. Now counts the specialization constants.
2024-01-07 16:53:56 +13:00
Clément Foucault
8032f85f61 Metal: Allow pretty log for compute shader 2024-01-07 16:48:54 +13:00
Clément Foucault
8dd08d81f4 Fix: GPU: Fix Shader builder
The recent header changes moved the header
containing this function to C++.
2024-01-07 16:48:29 +13:00
Hans Goudey
5b55c1dc10 Cleanup: Move five draw headers to C++ 2024-01-05 13:26:22 -05:00
Hans Goudey
d6cfd7d1f4 Cleanup: Remove unnecessary keywords from C++ headers
- Remove unnecessary `struct`
- Use `using` instead of `typedef`
- Remove `void` from `(void)` as function arguments
2024-01-04 15:07:48 -05:00
Brecht Van Lommel
364beee159 Tests: add option to build one binary per GTest file
Bundling many tests in a single binary reduces build time and disk space
usage, but is less convenient for running individual tests command line
as filter flags need to be used.

This adds WITH_TESTS_SINGLE_BINARY to generate one executable file per
source file. Note that enabling this option requires a significant amount
of disk space.

Due to refactoring, the resulting ctest names are a bit different than
before. The number of tests is also a bit different depending if this
option is used, as one uses gtests discovery and the other is organized
purely by filename, which isn't always 1:1.

Co-authored-by: Sergey Sharybin <sergey@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/114604
2024-01-03 18:35:50 +01:00
Brecht Van Lommel
f63accd3b6 Cleanup: move CMake test utility functions into testing.cmake
Combining functions from macros.cmake and Modules/GTestTesting.cmake.
It was unusual to have Blender specific code in the Modules folder.

Pull Request: https://projects.blender.org/blender/blender/pulls/116719
2024-01-03 14:49:11 +01:00
Brecht Van Lommel
d377ef2543 Clang Format: bump to version 17
Along with the 4.1 libraries upgrade, we are bumping the clang-format
version from 8-12 to 17. This affects quite a few files.

If not already the case, you may consider pointing your IDE to the
clang-format binary bundled with the Blender precompiled libraries.
2024-01-03 13:38:14 +01:00
Jason Fielder
cbcb6abfee Fix #116128: Resolve EEVEE Next deferred light sync in Metal
Render to Render workload depedency not correctly syncing
in Metal. PR adds hard pass break where GPU_memory_barrier's
occur during render workloads to ensure non-pixel-local writes
are visible to subsequent render invocations as needed. This is
required to support full pass dependencies on a tile-based GPU
architecture.

Note that these barriers are therefore expensive, so are skipped
where dependencies are local and fragment execution order is
well-represented via either blend order or explicit
raster_order_groups.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/116656
2024-01-03 05:38:42 +01:00
Brecht Van Lommel
4ce14a639f Revert "Cleanup: move CMake test utility functions into testing.cmake"
This breaks execution of some Windows tests.

This reverts commit 4190a61020.
2024-01-02 19:06:39 +01:00
Brecht Van Lommel
4190a61020 Cleanup: move CMake test utility functions into testing.cmake
Combining functions from macros.cmake and Modules/GTestTesting.cmake.
It was unusual to have Blender specific code in the Modules folder.
2024-01-02 15:34:52 +01:00
Clément Foucault
86d008d112 Metal: Fix missing new line characters
This broke compilation of some shaders
2024-01-01 11:29:04 +13:00
Clément Foucault
1c96d0d861 Metal: Improve shader logging
This adds some `#line` directive between the
source file injection so that the log parser knowns
which file the errors originated from.

This is then followed by a scan over the combined
source to find out the real row number.

This needed some changes in the `Shader::plint_log`
to skip lines to avoid outputing redundant information.
2024-01-01 00:43:09 +13:00
Clément Foucault
1e7a2fe483 GPU: Fix wrong error lines in tests
This was caused by the addition of the
license headers. This is not very
important but allow debugging failling
tests.
2024-01-01 00:34:29 +13:00
Clément Foucault
fa5c9ae0b2 Metal: Remove warning about dummy attribute
This dummy attribute is never in an interface
and is there only to workaround the strict
requirement of a VBO in a GPUBatch.
2023-12-31 18:58:04 +13:00
Jason Fielder
d721dcd767 Metal: Resolve texture atomic compilation issue
Resolves small issue with native texture
atomic support after addition of fallback path.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/116657
2023-12-31 01:07:47 +01:00
Clément Foucault
7d6b8737bf Fix #116623: GL/VK: Specialization constant error
Using defines leads to syntax errors. Use global
constants instead.
2023-12-30 11:09:15 +13:00
Omar Emara
dc082f432a Fix #116522: Compositor incorrectly extrapolates values
The GPU compositor incorrectly extrapolates values of RGBA curves node.
That's because the code introduces a half-pixel offset to the color
values since they will be used to sample the curve maps. Those same
values are then used for extrapolation, which shouldn't take the
half-pixel value into account.

This patch fixes that by computing sampler coordinate in a separate
step.

Pull Request: https://projects.blender.org/blender/blender/pulls/116586
2023-12-28 09:25:11 +01:00
Jason Fielder
335d3a1b75 GPU: Add Shader specialization constant API
Adds API to allow usage of specialization constants in shaders.
Specialization constants are dynamic runtime constants which can
be compiled into a shader pipeline state object (PSO) to improve
runtime performance by reducing shader complexity through
shader compiler constant-folding.

This API allows specialization constant values to be specified
along with a default value if no constant value has been declared.
Each GPU backend is then responsible for caching PSO permutations
against the current specialization configuration.

This patch adds support for specialization constants in the
Metal backend and provides a generalised high-level solution
which can be adopted by other graphics APIs supporting
this feature.

Authored by Apple: Michael Parkin-White
Authored by Blender: Clément Foucault (files in gpu/test folder)

Pull Request: https://projects.blender.org/blender/blender/pulls/115193
2023-12-28 05:34:38 +01:00
Jason Fielder
6692390501 EEVEE: Metal: Enable attachmentless FB support for VSM update FB
Utilise attachmentless framebuffer for atomic shadow update
Path.

Authored by Apple: Michael Parkin-White.

Pull Request: https://projects.blender.org/blender/blender/pulls/116396
2023-12-24 12:19:18 +01:00
Clément Foucault
c0fe51678e Fix #116489: Improper use of enum in GLSL file
Use defines instead.
2023-12-24 20:18:00 +13:00
Clément Foucault
f4275cc4df EEVEE-Next: Gbuffer Optimization
This modify the GBuffer layout to store less bits per closures.
This allows packing all closures into 64 bits or 96 bits.
In turn, this reduces the amount of data stored for most
usual materials.

Moreover, this contain some groundwork for the getting rid of the
hard-coded closure type. But evaluation shaders still use
the hard-coded types.

This adds tests for checking packing and unpacking of the gbuffer
doesn't loose any data.

Related to #115966

Pull Request: https://projects.blender.org/blender/blender/pulls/116476
2023-12-23 05:58:52 +01:00
Jeroen Bakker
ac1c75f3d0 Vulkan: Check Resource Bind Type when Binding
GPU module assumes that image and textures uses different bind
namespaces. In Vulkan this isn't the case, leading that some shaders
generate incorrect bind types, when the state has bindings that are not
used by the shader, but would conflict due to namespace differences.

This PR will only return the binding when after validating it is from
the expected namespace. This removes several validation warnings.

This was done in order to debug EEVEE using modern toolsets. These
toolsets don't support OpenGL and we use Vulkan as a workaround if
possible.

Pull Request: https://projects.blender.org/blender/blender/pulls/116465
2023-12-22 19:02:53 +01:00
Miguel Pozo
e8c5f8dddf Fix #116424: GPU Nodes: UDIM texture user count
Count texture and mapping as a single user.
2023-12-21 18:55:32 +01:00
Aras Pranckevicius
fec8461365 Cleanup: move BKE_colorband.h and BKE_colorcools.h to .hh
Also remove includes of those where not needed

Pull Request: https://projects.blender.org/blender/blender/pulls/116416
2023-12-21 10:10:53 +01:00
Hans Goudey
edf8a776ac Cleanup: Use forward declarations to replace includes of BKE_attribute.hh
Remove most includes of this header inside other headers, to remove unnecessary
indirect includes which can have a impact on compile times. In the future we may
want more dedicated "_fwd.hh" headers, but until then, this sticks with the
solution in existing code.

Unfortunately it isn't yet possible to remove the include from `BKE_geometry_set.hh`.
2023-12-20 13:25:28 -05:00
Hans Goudey
19001c9e6c Cleanup: Move attribute domain enum to C++ header, use enum class
Each value is now out of the global namespace, so they can be shorter
and easier to read. Most of this commit just adds the necessary casting
and namespace specification. `enum class` can be forward declared since
it has a specified size. We will make use of that in the next commit.
2023-12-20 13:25:28 -05:00
Jeroen Bakker
3f33b06dde Fix #116229: Fix EEVEE GLitches on Legacy AMD Platforms
According to the issue not all legacy AMD platforms that required the
high quality normals workaround where enabled. I have not been able to
reproduce the issue due hardware availability.

This PR will enable the workaround for all HD ATI GPUs.

Pull Request: https://projects.blender.org/blender/blender/pulls/116340
2023-12-19 14:35:28 +01:00
Campbell Barton
2b3c379850 Cleanup: use boolean & nullptr literals 2023-12-17 16:04:44 +11:00
Jason Fielder
2db12cc049 Fix #116121: Resolve framebuffer resize issue in Metal
Changing size of framebuffer attachments would
throw an assertion as framebuffer size was not
correctly reset to zero. Zero allows any size
to override the current if there are no set attachments.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/116162
2023-12-14 08:09:03 +01:00