Commit Graph

4953 Commits

Author SHA1 Message Date
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
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