Commit Graph

5203 Commits

Author SHA1 Message Date
Miguel Pozo
2864942dc8 Merge branch 'blender-v4.2-release' 2024-06-06 15:50:42 +02:00
Miguel Pozo
a249e93ad1 GPU: Add missing virtual destructor to ShaderCompiler 2024-06-06 15:50:09 +02:00
Campbell Barton
d98a7a7756 Merge branch 'blender-v4.2-release' 2024-06-06 10:23:16 +10:00
Campbell Barton
7f7648c6ed Cleanup: spelling in code comments & minor edits
- Use uppercase NOTE: tags.
- Correct bNote -> bNode.
- Use colon after parameters.
- Use doxy-style doc-strings.
2024-06-06 09:55:13 +10:00
Lukas Stockner
5891a73785 Merge branch 'blender-v4.2-release' 2024-06-05 20:25:50 +02:00
Hans Goudey
84c4ddbbb9 Cleanup: GPU: Use references for some vertex buffer functions
Pull Request: https://projects.blender.org/blender/blender/pulls/122784
2024-06-05 18:47:22 +02:00
Miguel Pozo
74224b25a5 GPU: Add GPU_shader_batch_create_from_infos
This is the first commit of the several required to support
subprocess-based parallel compilation on OpenGL.
This provides the base API and implementation, and exposes the max
subprocesses setting on the UI, but it's not used by any code yet.

More information and the rest of the code can be found in #121925.

This one includes:
- A new `GPU_shader_batch` API that allows requesting the compilation
  of multiple shaders at once, allowing GPU backed to compile them in
  parallel and asynchronously without blocking the Blender UI.
- A virtual `ShaderCompiler` class that backends can use to add their
  own implementation.
- A `ShaderCompilerGeneric` class that implements synchronous/blocking
  compilation of batches for backends that don't have their own
  implementation yet.
- A `GLShaderCompiler` that supports parallel compilation using
  subprocesses.
- A new `BLI_subprocess` API, including IPC (required for the
  `GLShaderCompiler` implementation).
- The implementation of the subprocess program in
  `GPU_compilation_subprocess`.
- A new `Max Shader Compilation Subprocesses` option in
  `Preferences > System > Memory & Limits` to enable parallel shader
  compilation and the max number of subprocesses to allocate (each
  subprocess has a relatively high memory footprint).

Implementation Overview:
There's a single `GLShaderCompiler` shared by all OpenGL contexts.
This class stores a pool of up to `GCaps.max_parallel_compilations`
subprocesses that can be used for compilation.
Each subprocess has a shared memory pool used for sending the shader
source code from the main Blender process and for receiving the already
compiled shader binary from the subprocess. This is synchronized using
a series of shared semaphores.
The subprocesses maintain a shader cache on disk inside a
`BLENDER_SHADER_CACHE` folder at the OS temporary folder.
Shaders that fail to compile are tried to be compiled again locally for
proper error reports.
Hanged subprocesses are currently detected using a timeout of 30s.

Pull Request: https://projects.blender.org/blender/blender/pulls/122232
2024-06-05 18:45:57 +02:00
Hans Goudey
d1049f6082 Mesh: Draw: Replace extractor abstraction for edge factor buffer
Part of #116901.
The BMesh version of the algorithm was parallelized because BMesh has
edge to face topology lookup available.

This also allows removing `GPU_vertbuf_steal_data`, by just generating
the correct data type in the first place. Removing that should help dealing
with improvements to VBO data ownership in the future.
2024-06-05 14:20:01 +02:00
Aras Pranckevicius
078a737fd6 Format 2024-06-04 22:08:42 +03:00
Aras Pranckevicius
7fdfa47f23 VSE: Rounded corners for timeline strips
VSE timeline strips now have rounded corners. Strip corner rounding radius is
4, 6 or 8px depending on strip height (if strip is too narrow to fit
rounding, then rounding is turned off).

This is achieved with a dedicated GPU shader for drawing most of VSE
strip widget, that it could do proper rounded corner masking.

More details and images in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/122576
2024-06-04 20:05:35 +02:00
Clément Foucault
cc0d12dd20 EEVEE: Remove EEVEE-Legacy
This handles the transition to EEVEE-Next (now EEVEE).

This removes some things that make no sense to keep
even for compatibility.
- Scene.eevee.light_cache_data
- Scene Light cache operators
- Scene Light cache RNA properties

The remaining legacy properties will be removed later
on to avoid python API breakage.

We keep the identifier of EEVEE-Next as `BLENDER_EEVEE_NEXT`
to avoid addons being incorrectly silently made compatible
with the EEVEE-Next where the Python API is different.
This renaming should be done in 5.0 release.

Thank you EEVEE-Legacy, you served us well.

Pull Request: https://projects.blender.org/blender/blender/pulls/122433
2024-06-04 14:17:58 +02:00
Jeroen Bakker
6ec64cb039 Vulkan: Fix sample count when uploading layered textures
When uploading layered textures it was assumed that the data uploaded
had the data for all layers and ignored the given extent.
2024-06-03 13:51:11 +02:00
Jeroen Bakker
8077411d59 Vulkan: Disable barriers when using render graph
Barriers should be automatically extracted from the render graph.
GPU_issue_barrier will become a no-op.
2024-06-03 13:48:56 +02:00
Jeroen Bakker
049d84d36d Vulkan: Texture view clearing
EEVEE-Next requires clearing texture views. This PR adds that.

Pull Request: https://projects.blender.org/blender/blender/pulls/122650
2024-06-03 13:47:15 +02:00
Jeroen Bakker
ac4ab3a209 Vulkan: Debug name for staging buffer
Staging buffers didn't had a name this PR adds a name so they
are easier to track in debug tools.

Pull Request: https://projects.blender.org/blender/blender/pulls/122649
2024-06-03 11:14:27 +02:00
Jeroen Bakker
abcf55d15a Vulkan: Only support device vertex buffers
BLF font rendering isn't compatible with render graph as it
rewrites buffers that are not yet drawn. To work around this issue
the vertex buffers should always be created on device and not
directly altered by CPU code.

Pull Request: https://projects.blender.org/blender/blender/pulls/122648
2024-06-03 10:58:27 +02:00
Clément Foucault
3ed825f981 EEVEE-Next: Use RGB9_E5 encoding for storing direct light buffers
The direct lights are usually much smoother and with
higher dynamic range than indirect lighting. Using
the R11B11G10 float format exhibit color shifts and
banding even in simple setups without a way to mitigate
the issue.

Using RGB9_E5 encoding improve the quality while retaining
the storage benefit of 32bit formats. The added overhead
of the software encoding not perceptible in a full lighting
pass.

This affects direct lights and SSS convolution result.

Fix #121937

Pull Request: https://projects.blender.org/blender/blender/pulls/122515
2024-05-30 20:41:38 +02:00
Clément Foucault
a94b8ade20 GPU: Add library for handling shared exponent format in software
This allows reducing bandwidth at the cost of some instructions
for packing and decoding the texture.

Pull Request: https://projects.blender.org/blender/blender/pulls/122446
2024-05-30 19:59:18 +02:00
Christoph Lendenfeld
f9ea64b0ba Anim: Per bone wire width for custom shapes
The setting adds the "Custom Shape Wire Width"
option to the "Viewport Display/Custom Shape" section of a pose bone.
As the setting says, this controls how thick the wire is drawn in the viewport.

This is done by adding a geometry shader that makes two triangles out of a line.

The Anti-Aliasing is controlled by the setting
Viewport->Quality->Smooth Wires->Overlay in the user preferences.

## Artifacts
When increasing the line width, the lines start to separate at their vertices.
This comes from extruding each edge along the normal of its direction.
This could be solved by adding round caps in a later PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/120176
2024-05-30 15:51:30 +02:00
Clément Foucault
91fee3eca8 Cleanup: EEVEE-Next: Rename lightprobe files
Use new naming convention

Pull Request: https://projects.blender.org/blender/blender/pulls/122405
2024-05-29 11:19:50 +02:00
Vitaljok
14f9ae90c2 EEVEE: fixing vector displacement
Fix for #121890

The image shows testing results with "green" texture. It is expected that
all vectors are displaced along Y axis.
Cases are "no displacement", "tangent", "object" and "world" spaces.

Results are consistent with Cycles.

Pull Request: https://projects.blender.org/blender/blender/pulls/122376
2024-05-28 21:20:54 +02:00
Hoshinova
de6ff6eb0a Fix #121969: Noise texture outputs 0 with coordinates beyond 8.40*10^6
One of the properties of Perlin noise is that it always evaluates to 0.0
when not normalized (or 0.5 when normalized) when the input consists of
only whole integers in all vector components.

Blender's Perlin noise implementation uses single precision floats with
a machine epsilon of 1.19e-07 meaning that for numbers that are greater
than 1/(1.19e-07) = 8.40e6 there mantissa doesn't have any bits left to
store a rational part of the number, effectively meaning that any number
greater than 8.40e6 is a whole integer as far as Blender is concerned.
Therefore when evaluating Perlin noise for any coordinates greater than
that it always results in 0.0 (or 0.5 when normalized).

This fix works as follows: If the original input number is larger than
1.0e6 it is offset by 0.5 after it underwent modulo, which always outputs
numbers in a [0.0, 1.0e5) range leaving the mantissa room for a rational
part. This way the quantization error still persists however the outputs
are random again instead of a constant 0.0.

Pull Request: https://projects.blender.org/blender/blender/pulls/122112
2024-05-27 12:48:15 +02:00
Jeroen Bakker
da4f84a416 Fix: Reduce compilation warnings
Reduces compilation warnings on
- clang
- GCC < 14
- MSVC

Pull Request: https://projects.blender.org/blender/blender/pulls/122298
2024-05-27 10:30:54 +02:00
Campbell Barton
db58cde877 Cleanup: suppress template-id-cdtor GCC warnings
Ignoring from CMake didn't suppress the warnings from GPU sources
that include this header. Suppress the warning using a pragma instead.
2024-05-27 11:58:46 +10:00
Clément Foucault
4624b1a9ae Cleanup: EEVEE-Next: Group BSDF functions to per BSDF type files
The goal of this is to make it easier to add more BSDF
support in the future. Avoids code fragmentation and
allows easy entry points to all algorithms using BSDFs.

Pull Request: https://projects.blender.org/blender/blender/pulls/122255
2024-05-25 23:40:12 +02:00
Jeroen Bakker
e5680542aa GPU: Fix GPUStateMutable size
Current size was to big (9X64 bits) when only (3X64 bits) were
needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/122214
2024-05-24 15:19:59 +02:00
Jason Fielder
f20ad70c08 EEVEE Next: Add imageStore/LoadFast ops to Renderpasses
Add fast image writing and reading variants for render passes.
These variants do not perform range checking on values
and should only be used in cases where the written texel is
guaranteed to be in range. This eliminates additional
branching and simplifies shader logic.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/121116
2024-05-24 12:41:47 +02:00
Jeroen Bakker
94e2880dfb GPU: Fix use after free in draw tests
Pull Request: https://projects.blender.org/blender/blender/pulls/122201
2024-05-24 12:36:30 +02:00
Hans Goudey
da1ea4cdd1 Revert "Draw: Avoid temporary copy for mesh triangulation index buffer"
This reverts commit 108ab1df2d.

This causes issues when duplicating objects that I don't have time
to investigate right now.
2024-05-23 23:43:34 -04:00
Hans Goudey
108ab1df2d Draw: Avoid temporary copy for mesh triangulation index buffer
The mesh triangulation data is stored in CPU memory with the same format
as the triangles GPU index buffer. Because of that we can skip creating a
temporary copied owned by the GPU API. One way to do that is to just
upload the data directly and avoid keeping a reference to it. However, we
can only upload GPU data from the main thread with OpenGL, so instead
reference the data and keep track of whether to free it.

When drawing a mesh with a single material and 1.8 million faces, this
change gives a 12-15% improvement in framerate, from about 32 to 37 FPS.

Part of #116901.

Pull Request: https://projects.blender.org/blender/blender/pulls/122175
2024-05-23 19:59:36 +02:00
Jeroen Bakker
93c69e6b64 Vulkan: Render graph - swapchain handling
This PR implements swapchain handling when using the render graph.

Pull Request: https://projects.blender.org/blender/blender/pulls/122144
2024-05-23 12:00:36 +02:00
Jeroen Bakker
d28474e404 Vulkan: Render graph - VKFramebuffer blitting
Implement framebuffer blitting using the render graph.

Pull Request: https://projects.blender.org/blender/blender/pulls/122143
2024-05-23 11:37:58 +02:00
Jeroen Bakker
5ee46b0ef3 Vulkan: Use macros to reduce code replication
Use macros to reduce code replication.

- `VKRenderGraph::add_node`
- `VKRenderGraphNode::build_commands`
- `VKRenderGraphNode::free_data`

Pull Request: https://projects.blender.org/blender/blender/pulls/122141
2024-05-23 11:21:55 +02:00
Jeroen Bakker
7fb1c4c573 Vulkan: Incorrect memory barrier when presenting
When synchonizing the image for presentation the incorrect access
mask was used. This PR changes the access mask from data transfer
write to memory write. The data transfer write is not allowed to
change the image layout.

Pull Request: https://projects.blender.org/blender/blender/pulls/122138
2024-05-23 10:04:32 +02:00
Jeroen Bakker
c3c4e948b1 Vulkan: Fixing issues in debugging groups
* Debugging groups were not being applied as that part of the code
  wasn't ported to the original patch
* Debugging groups didn't account for nodes that weren't owned by
  any debug group.

Pull Request: https://projects.blender.org/blender/blender/pulls/122136
2024-05-23 09:48:25 +02:00
Hans Goudey
07eac30070 Mesh: Points index buffer improvement
A continuation of #116901. This one doesn't have a performance impact
in my testing. It also adds a bit more code compared to main so it isn't
really obviously "better" like the previous refactors. However it does
get us closer to removing the "extractors" callback iteration loop
(`edit_data` is the only other enabled by default), and I'd argue that
the final code is easier to iterate on in the future since it's more
self-contained.

I made an effort to avoid storing restart indices in the index buffers.
Though this requires a bit more calculation on the CPU (particularly
because the hidden gaps in the IBO need to be compressed out), it
reduces overall CPU->GPU traffic and removes the need to strip the
restart indices on Metal.

Pull Request: https://projects.blender.org/blender/blender/pulls/122084
2024-05-22 16:08:55 +02:00
Jeroen Bakker
488e74a209 Vulkan: Render graph debug groups
This PR implements debug groups in the render graph. Each node contains
a reference to the debug group they belong to. During scheduling the
nodes can be reordered and the correct debug group needs to be
activated.

This is done by keeping track of the current debug group. When a
different debug group is needed, the needed ends/begins are added
to the command buffer.

This mechanism also cleans up debug groups that are not used at all
as they don't have any nodes associated to it.

Pull Request: https://projects.blender.org/blender/blender/pulls/122054
2024-05-21 17:34:55 +02:00
Jeroen Bakker
bce3d363a4 Vulkan: Shader Interface Lifetime
Previously the VKShaderInterface was constructed twice. This was
due to a limitation of the Shader api. Specialization constants
introduced an Shader::init function which allows to pre-initialize
the shader interface before a shader is finalized.

Pull Request: https://projects.blender.org/blender/blender/pulls/122049
2024-05-21 15:17:36 +02:00
Campbell Barton
72627a9d84 CMake: correct GCC's template-id-cdtor warning being suppressed 2024-05-20 10:10:55 +10:00
Clément Foucault
e0b3dee35a EEVEE-Next: Jittered Soft Shadows
Jittered Soft Shadows support.
Improves soft shadow quality at the cost of re-rendering shadow maps every sample.
Disabled by default in the viewport unless enabled in the Scene settings.

| Tracing-only | Jitter-only | Jitter+Over-blur |
| --- | --- | --- |
| ![imagen](/attachments/e5ca6120-0666-4e86-b6e0-3d7512587b86) | ![imagen](/attachments/a72631aa-14f8-4e10-a748-848fc4bd4ab2) | ![imagen](/attachments/07c5de65-61d2-48e7-b78c-9c3cbdcaf844) |

Tracing-only is the method used by default in EEVEE-Next.
Jitter-only is the method used by EEVEE-Legacy Soft Shadows.
Jitter+Over-blur combines both.

Co-authored by Miguel Pozo @pragma37 (initial patch #119753)

Pull Request: https://projects.blender.org/blender/blender/pulls/121836
2024-05-18 17:21:47 +02:00
Clément Foucault
e16a0b869b Cleanup: Metal: Use MTLContext::get() instead of static casts 2024-05-18 14:43:45 +02:00
Jason Fielder
47ada34324 Metal: Remove redundant synchronization operations
Remove both compute barriers and useResource calls
as explicit resources bound via setTexture and
setComputeBuffer are implicitly tracked by the Metal
API anyway, so these calls increase complexity, without
altering correctness

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/121598
2024-05-17 13:38:55 +02:00
Vitaljok
2c1238466d Fixing object index value for EEVEE-Next
EEVEE Next uses different bit representation of object index values pushed
to GPU in contrast to EEVEE (Legacy). The fix accounts both approaches.

Fix #121690.

Pull Request: https://projects.blender.org/blender/blender/pulls/121870
2024-05-16 14:37:32 +02:00
Miguel Pozo
aa37e46152 Draw: Use GPUPass for default material fallback detection
Update #121137 to store the reused GPUPass on its own GPUMaterial,
instead of replacing the GPUMaterial itself.

Pull Request: https://projects.blender.org/blender/blender/pulls/121790
2024-05-15 16:01:05 +02:00
Jeroen Bakker
5d5cbca7ed Vulkan: Refactor image views
Move ownership of image views to VKTexture. VKFramebuffer can request
access to the image views. This allows reconfiguring framebuffers when
the previous configuration is still in use by the render graph.

Pull Request: https://projects.blender.org/blender/blender/pulls/121727
2024-05-14 10:46:12 +02:00
Jeroen Bakker
9b531609bd Vulkan: Fix push constants tests
This fixes several issues with push constants.

Push constants test were failing due to setting incorrect parameters.
The pipeline stage was used as if it was a shader stage.

When using push constants fallback the uniform was loaded to the
descriptor set after the descriptor set was checked.

Suppress updating push constants of non render graph, when render
graph is active.

Pull Request: https://projects.blender.org/blender/blender/pulls/121772
2024-05-14 10:44:10 +02:00
Jeroen Bakker
b1b0f1207c Vulkan: Suppress GCC14 compiler warnings
Although this needs to be fixed before we can move to CPP20.

Pull Request: https://projects.blender.org/blender/blender/pulls/121770
2024-05-14 09:12:47 +02:00
Jeroen Bakker
f625c4e63d Vulkan: Fix compute test cases
Compute tests were failing due to recent changes.
* Incorrect image layout was used for writable image bindings.
* Incorrect pipeline stage was used for indirect command buffers.

Pull Request: https://projects.blender.org/blender/blender/pulls/121744
2024-05-14 08:22:18 +02:00
Iliya Katueshenock
75d17b1db5 Cleanup: Move BKE_node to namespace
Move all header file into namespace.
Unnecessary namespaces was removed from implementations file.
Part of forward declarations in header was moved in the top part
of file just to do not have a lot of separate namespaces.

Pull Request: https://projects.blender.org/blender/blender/pulls/121637
2024-05-13 16:07:12 +02:00
Jeroen Bakker
e0da623d33 Vulkan: Don't record drawlist commands for invalid batches
Overlay engine extra layer can record draw list commands with an
empty index buffer. This would not affect any pixels and should be
ignored.

Issue detected when vulkan validation layers are turned on and loading
default scene.

Pull Request: https://projects.blender.org/blender/blender/pulls/121736
2024-05-13 14:09:37 +02:00