Commit Graph

5225 Commits

Author SHA1 Message Date
Campbell Barton
f646956149 Cleanup: spelling in comments 2024-06-23 12:25:22 +10:00
Campbell Barton
7632c528de Docs: remove references to "above" in code comments & corrections
Reference identifiers instead of "above" in code comments as these
tends to become outdated. Even when declarations are removed it's at
least clear that the reference no longer exists instead of referring to
whatever is currently above the declaration.
It's also straightforward to search history for a removed identifier.

Corrected 4 cases of references to things that were no longer above
the doc-strings. Noticed other references which look to be incorrect
but need further investigation.
2024-06-23 12:14:19 +10:00
Miguel Pozo
33005ad716 GPU: Non-blocking specialization constants compilation
Update the batch specializations compilation to allow using it in an
async way.

The implementation has 2 main limitations:
- Only one batch at a time can be processed, extra batches will be
  added to a queue.
- Binding a specialization variant that is still being compiled will fail.

Pull Request: https://projects.blender.org/blender/blender/pulls/123015
2024-06-20 18:02:44 +02:00
Aras Pranckevicius
b76a95b8b4 Fix: VSE timeline strip outline readability
With selected strips, it is not clear where one of them begins and another
ends since their outlines are right next to each other.

This changes strip look so that:
- All strips have consistent dark 1pt outline at the outer edge.
- Selected strips have 2pt highlight inside said outer edge.
- Selected strips also have a 1pt wide 33% opacity darker line inside the
  selection highlight (and inside possible handles). To improve readability
  in case strip content happens to be similar to selection/active color.

Images in PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/123431
2024-06-20 13:01:26 +02:00
Aras Pranckevicius
7e61f14a88 Fix #123332: VSE strip transform handles look tweaks
Current look of VSE timeline view strip transformation handles makes them
somewhat "too narrow", especially after recent changes that made them
more narrow than before (handle tweaking feature) and a strip visual change
that made strip outline not go outside of strip bounds. They are now just
2px wide, effectively.

This changes their look as outlined in #123332 design task:
- The inset dark line is no longer over the handles, but rather "inside"
  of them (except when handles are semitransparent, i.e. for strips that
  are not selected).
- The handles themselves have rounded corners.

Pull Request: https://projects.blender.org/blender/blender/pulls/123391
2024-06-19 11:49:20 +02:00
Aras Pranckevicius
189410e1ff Fix #123333: VSE strip outline width now takes DPI/line width setting into account
Now the strip outline (1 point for unselected strips, 2 point outline +
1 pt dark inset) takes monitor DPI / user preference line width into
account, via the usual U.pixelsize machinery.

Pull Request: https://projects.blender.org/blender/blender/pulls/123369
2024-06-19 11:19:15 +02:00
Clément Foucault
ff03ab4d08 Fix: EEVEE: Overblur of textures because of TAA
This was a missing block of the TAA implementation.
TAA jitter and reprojection have a tedency to soften
the texture. Add a 1.5 bias to make them a bit sharper.

Note that this is a bit different than the usual TAA
blurring. In final render we don't do reprojection
so it is only because the texture filter (box filter
from the LOD) is applied at the same time than our pixel
filter (blackmann-harris). It is less noticeable than
the normal TAA blur, but still blurs ~2px instead of
1.5px.
2024-06-18 19:31:47 +02:00
Miguel Pozo
feed10a4c2 Fix: GPU: Workaround for validation errors on replaced passes 2024-06-18 18:36:09 +02:00
Clément Foucault
979e142965 Fix: EEVEE: Object holdout not working
This implement the holdout flag by switching to
the holdout case in the shader. This has a few benefits:
- Doesn't recompile the shaders.
- Makes the object infos mandatory (already the case in
  practice)
- Handle transparent materials properly, keeping the
  transparency working.

Fix #123284

Pull Request: https://projects.blender.org/blender/blender/pulls/123315
2024-06-18 15:35:04 +02:00
Jeroen Bakker
c525c0354f EEVEE: Film accumulation workaround for Metal/Intel iGPUs
EEVEE Film accumulation workaround for Metal/Intel iGPUs.

On Metal the Intel iGPUs do not support image read write
on array textures. However this limitation doesn't show
any artifacts when using the compute shader.

This PR is a work around that uses the film_comp shader
to process the film samples, but uses a separate film_copy_frag
shader to read the result and copy them to the frame buffer.

I deliberately didn't include the fix to the film_frag shader
as that would change the read/write resources and could lead
to performance issues for other platforms. Writable resources
are typically slower compared to read only resources.

Some code needed to be duplicated (and not added to `*_lib.glsl`)
as compilers would still raise compilation errors due to imageStore/Load
on incompatible resource access.

The Metal/Intel iGPU is also marked to have limited support as
raytracing and probes still produces big artifacts.

This workaround can be tested on any platform just by setting
`use_compute_ = true` in `Film::sync`

Related to #122361

Pull Request: https://projects.blender.org/blender/blender/pulls/123330
2024-06-18 10:53:53 +02:00
Miguel Pozo
50a83d3e0b Fix: BLI_SUBPROCESS_SUPPORT check
Fix compilation on platforms with OpenGL but not BLI_subprocess support.
2024-06-17 19:35:51 +02:00
Clément Foucault
6d375cf7f0 Fix: EEVEE: Wrong thickness for rotated objects
The previous code was using matrix multiplication to
get the local thickness to world thickness.

The correct way is to multiply the local thickness
by the scale of the object (length of each columns
of the object_to_world matrix).
2024-06-17 19:12:24 +02:00
Miguel Pozo
a22a4810c7 GPU: Use size_t for GPU buffer sizes
Update all GPU buffer size-related functions to use `size_t` for
consistency.

Pull Request: https://projects.blender.org/blender/blender/pulls/123240
2024-06-14 19:27:33 +02:00
Brecht Van Lommel
bda53799d5 Cleanup: make format 2024-06-14 15:47:49 +02:00
Aras Pranckevicius
d61db84153 Fix #123136: Very narrow VSE strips flicker when zoomed out
Make sure they are at least 1px wide when evaluating the rounded rectangle SDF.

Pull Request: https://projects.blender.org/blender/blender/pulls/123221
2024-06-14 11:19:43 +02:00
Miguel Pozo
f251452a4b Fix #123014: Hundreds of empty folders in the %temp% directory
Use BLI_temp_directory_path_get instead of
BKE_tempdir_base.
2024-06-13 15:53:40 +02:00
Campbell Barton
91d45db8bb Remove use of potentially unsafe strncat & strcpy 2024-06-12 10:52:09 +10:00
Aras Pranckevicius
c38951d0f5 Fix #123016: inconsistent VSE timeline strip pixel grid rounding
Previous commit that made VSE strip controls not be blurry (91fa37fecb)
applied "snap to pixel grid" in a wrong place - the rectangle corners
should be snapped, not the center and half-size of it.

Pull Request: https://projects.blender.org/blender/blender/pulls/123065
2024-06-11 18:12:32 +02:00
Miguel Pozo
fb5faf3305 FIx #122915: Diffuse normal input isn't normalized automatically 2024-06-11 16:51:04 +02:00
Jeroen Bakker
af34a8a952 GPU: Fix GLSL compilation error on legacy NVIDIA drivers
Somehow the 16K inside a string is parsed as being an integer, leading
to error messages about the `K` suffix.

```
ERROR (gpu.shader): gpu_shader_icon_multi VertShader:
      |
    1 | #version 430
      |
      | Error: C0159: invalid char 'K' in integer constant suffix
```

Fixed by changing the 16K to the actual number.

Related to #122977 With this PR blender will start, but EEVEE will render pink.

Pull Request: https://projects.blender.org/blender/blender/pulls/123071
2024-06-11 14:07:57 +02:00
Aras Pranckevicius
57f1d11163 Fix: VSE strip shape is not rounded when dragging file into timeline area
Strips still have sharp corners when you're dragging them from file browser and
switch to rounded when dropped. Fix by using the same drawing code (and shader)
as regular timeline drawing path.

Pull Request: https://projects.blender.org/blender/blender/pulls/123013
2024-06-11 11:55:49 +02:00
Campbell Barton
2e00df3ee2 Cleanup: spelling in comments 2024-06-11 19:21:56 +10:00
Miguel Pozo
22652b305e GPU: Add GPU_shaders_precompile_specializations
Allow precompiling specialization constants variations in parallel.
Only supported in OpenGL as the rest of the batch compilation API,
on the other backends the function is a no-op.
This also moves the `SpecializationConstant` from
`gpu_shader_create_info` (private API) into`GPU_common_types`
(public API).

Pull Request: https://projects.blender.org/blender/blender/pulls/122796
2024-06-07 18:45:31 +02:00
Aras Pranckevicius
73d4872f5a Fix: VSE strip outline no longer extends outside of strip bounds
Previously selected strips in VSE timeline were drawing their outline
1px outside of the strip boundaries. This makes outlines of the strips
overlap each other when neighboring strips are selected.

Now the selected outline is fully within regular strip shape.

Pull Request: https://projects.blender.org/blender/blender/pulls/122890
2024-06-07 17:41:56 +02:00
Aras Pranckevicius
91fa37fecb Fix: VSE timeline strip rounded corner outlines not pixel correct
PR #122576 added rounded corners to VSE timeline strips, but they were not
"snapped" to pixel grid so the outline that is normally 1px was sometimes
falling in between pixels and was blurred out.

Fix by rounding all SDF related coordinates inside the shader to the pixel
grid.

Pull Request: https://projects.blender.org/blender/blender/pulls/122764
2024-06-07 16:18:09 +02:00
Miguel Pozo
fb98edf322 GPU: Add GPU_material_batch_compile
Add `GPU_material_batch` API.
It uses the new `GPU_shader_batch` from #122232 internally and it
works in the same way.

Note: This doesn't implement parallel material optimizations.

Pull Request: https://projects.blender.org/blender/blender/pulls/122793
2024-06-07 16:11:50 +02:00
Miguel Pozo
ec0dd18de5 GPU: OpenGL: Support parallel geometry and compute shader compilation
Support parallel compilation of geometry and compute shaders when
using the `GPU_shader_batch` API.

Pull Request: https://projects.blender.org/blender/blender/pulls/122792
2024-06-07 16:10:43 +02:00
Miguel Pozo
a249e93ad1 GPU: Add missing virtual destructor to ShaderCompiler 2024-06-06 15:50:09 +02: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
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
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