Commit Graph

9882 Commits

Author SHA1 Message Date
Clément Foucault
628a10a9fb GPU: Shader Preprocess: Add basic support for struct methods
This adds the following features:
- `class` keyword support: checked by C++, mutated to struct for shader.
- `private` and `public` keywords: checked by C++, removed for shader.
- `static` methods.
- `const` and non-const methods.

What is not supported:
- Constructors
- Destructors
- operators
- Method definition outside of class definition
- member reference without `this` keyword.

This is implemented using a very simple lexer/parser allowing semantic traversal.

Pull Request: https://projects.blender.org/blender/blender/pulls/144025
2025-08-08 16:49:15 +02:00
Jeroen Bakker
5e2de91654 Fix #142537: Vulkan aliased wireframe occlusion
overlay_wireframe_frag doesn't always set the gl_FragDepth. Depending on
how the driver deals with this it can use uninitialize values or previous
values. This leads to render artifacts as depth testing/storage could be
wrong.

Pull Request: https://projects.blender.org/blender/blender/pulls/144198
2025-08-08 15:51:42 +02:00
Jeroen Bakker
97f1aeb84c Vulkan: Remove support for render passes
Vulkan 1.0 render passes have been replaced by dynamic rendering in 1.2.
Blender Vulkan backend was implemented with dynamic rendering in mind.
All our supported platforms support dynamic rendering. Render pass support
was added to try to work around an issue with legacy drivers. However these
drivers also fail with render passes.

Using render passes had several limitations (blending and some workbench
features were not supported).  As no GPU uses it and it is quite some code
to support it is better to remove it.

Pull Request: https://projects.blender.org/blender/blender/pulls/144149
2025-08-08 08:08:58 +02:00
Campbell Barton
cccc2c77c5 Cleanup: consistent for C-style comment blocks 2025-08-08 07:37:33 +10:00
Miguel Pozo
908fd7ab57 Fix: EEVEE: VolumeProbeModule do_full_update_
`VolumeProbeModule::do_full_update_` can be true while
`irradiance_pool_size_` being already correct and `irradiance_atlas_tx_`
being valid, so `brick_pool_` ends up being "allocated" with
`atlas_col/row_count` being 0.
This can happen if `VolumeProbeModule::init` is called, but the
`VolumeProbeModule::set_view` call is skipped (due to ongoing shader
compilation), so the `do_full_update_` flag is not cleared before the
next `init`.

Pull Request: https://projects.blender.org/blender/blender/pulls/144154
2025-08-07 19:37:09 +02:00
Christoph Lendenfeld
a43359eb88 Anim: Store pose bone visibility flag on pose bone
This PR adds a flag to the pose bone that determines its visibility.
Doing so allows to hide a pose bone and
* don't affect other instances of the same armature
* save the visibility even if the rig is linked

The visibility of the bone in object mode is now also determined by the
pose bone whereas before it was the `Bone`.

**This breaks backwards compatibility** on the Python API since the visibility property,
on the `Bone` behaves differently now as it hides the edit bone instead of the pose bone.

In order to remove all active uses of `BONE_HIDDEN_P` the changes in `armature_skinning.cc` are required.

Part of #138482

Pull Request: https://projects.blender.org/blender/blender/pulls/139167
2025-08-07 15:54:58 +02:00
Jeroen Bakker
4333e070b4 Fix: SubDiv: Out of bound write loose normals
Updating loose normals leads to out of bound writes on the GPU.
The reason is that normals are float3, but the code assumed
they were float4.

Pull Request: https://projects.blender.org/blender/blender/pulls/144128
2025-08-07 15:26:42 +02:00
Clément Foucault
16430b10f1 EEVEE: World Sun Shadow no longer works in 4.5
On some drivers, the GLSL compiler doesn't reflect the omitted
`local_size_*` of a compute shader inside `gl_WorkGroupSize`.

This lead to the 2D size computation of 1D workgroups to become
0 which was bypassing the parallel reduction algorithms.

Ensuring `local_size_*` are always set fixes the issue.

For clarity, also fix the 1D shaders to not use `gl_WorkGroupSize.y`.
This also fix a copy paste error in the Metal backend.

This issue affected AMD drivers on Windows.

Rel #142046

Candidate for backporting to 4.5 LTS.

Pull Request: https://projects.blender.org/blender/blender/pulls/144056
2025-08-07 09:40:57 +02:00
Hans Goudey
3724ebeaa6 Refactor: Extract BMesh attribute lookup function
This is the second time I've needed a function to find an attribute by
name on all attribute domains, with a third time coming soon. It seems
time to put this in a BMesh header.

Pull Request: https://projects.blender.org/blender/blender/pulls/144039
2025-08-06 13:40:51 +02:00
Clément Foucault
b903d3ade3 Fix #143336: Frustum culling is incorrect in Blender 4.5
Caused by a compiler issue with function accessing the same SSBO in
different control flow.

Loading the SSBO data before doing the computation fixes the issue.

Candidate for Backporting to 4.5 LTS.

Pull Request: https://projects.blender.org/blender/blender/pulls/143926
2025-08-06 10:41:23 +02:00
Campbell Barton
e8501d2f54 Cleanup: grammar corrections, minor improvements to wording
Also back-tick quote some code references in comments
to differentiate them from English text.
2025-08-06 00:20:39 +00:00
Hans Goudey
2a8da4c1fa Fix #143952: Broken Grease Pencil edit lines overlay in some cases
Caused by 5f6e94ca58

When there are more than 2^16 points, the GPU index buffer code tries
to compress the indices to uint16 because we passed the incorrect max
index. In general that optimization just isn't worth the complexity
of precalculating the max index in this situation. There are other
potential optimizations here that would be vastly more helpful.
So just pass INT_MAX to disable the compression.
2025-08-05 12:56:26 -04:00
Jeroen Bakker
8bfcb5e509 Fix #142093: Fix crash when entering sculpt mode
In case an image editor is open in the same window, entering sculpt mode
could crash. The cause is that the 3d viewport can request the sculpt
data vbo and its batch. But the image editor doesn't need it and removes
the sculpt data vbo, but doesn't remove the batch. Next frame the batch
could point to invalid data.

This fix will not keep the batch around so it is always being
reconstructed. A better solution needs to be found as the removal of the
vbo is done in a strange part, and the vbo should be checked against the
cd needed over time.

Pull Request: https://projects.blender.org/blender/blender/pulls/144013
2025-08-05 16:26:55 +02:00
Clément Foucault
c0a0962450 Workbench: Change fallback in Attribute color mode to Material
This was a request of the Blender Studio.

The Attribute color mode is used for more correct display of
materials during animation. The assets are created with
a color attribute that mimics the material.
The issue is that this attribute needs to be set up for every
individual object for it to work in Attribute color mode as
the lack of attribute will default the object to Object color mode.

This patch changes the defaulting to Material color mode
just like when using the Texture color mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/143931
2025-08-05 14:48:49 +02:00
Falk David
00a979f2aa Fix #143802: Grease Pencil: Divide blend mode not working in viewport
For the "Divide" layer blend mode to work in the viewport, we need to use
a floating point texture format for rendering.

This changes the format to always use floats for the `color` textures,
but still switches the `reveal_tx` to use integers in the viewport, and
only floating point during final render.

Pull Request: https://projects.blender.org/blender/blender/pulls/143993
2025-08-05 14:23:49 +02:00
Clément Foucault
83c5e81a8b Fix #143857: View3D smooth interpolation produces invalid rv3d.dist values
In the particular case of the report it creates a rv3d with `dist == 0`.

This causes EEVEE to create an invalid projection matrix when
calling `RE_GetWindowMatrixWithOverscan` with a zero `viewplane`.

To avoid this, we check if `rv3d->dist == 0` and don't compute overscan
in this case. This avoid many issues down the line.

Candidate for backporting to 4.5 LTS.

Pull Request: https://projects.blender.org/blender/blender/pulls/143946
2025-08-05 11:01:03 +02:00
Clément Foucault
5b15894d7c Fix #143294: Blended surface not receiving volume properly
The `gl_FragCoord.z` is now containing the reverse Z and
should be passed through the `read` function.

Candidate for backporting to 4.5 LTS.

Pull Request: https://projects.blender.org/blender/blender/pulls/143950
2025-08-05 09:57:13 +02:00
Hans Goudey
bf40023aa4 Fix #143333: Custom bone shape does not include subdivision surface
This was caused by a mismatch in the conditions that enabled GPU
subdivision. The mesh normals domain for meshes with no faces was
reported incorrectly, causing the code to think there are auto-smooth
style split normals when there actually aren't.

Also the GPU subdiv normals extraction had a crash binding a vertex
buffer that doesn't exist when there are no faces. Add an early return
for the wire-only mesh case to avoid that.

Pull Request: https://projects.blender.org/blender/blender/pulls/143961
2025-08-04 23:13:31 +02:00
Casey Bianco-Davis
3e181be081 Fix: Grease Pencil: Hide Bezier handles overlay in Curve selection mode
This makes so `Bezier` handles are not show when in `Curve` selected mode.

This also makes it so that handle are only displayed in edit mode.

Resolves #143928.

Pull Request: https://projects.blender.org/blender/blender/pulls/143868
2025-08-04 14:20:17 +02:00
Iliya Katushenock
0c41f53cf7 Fix #143738: Broken lines overlay in curve overlay
In a58dd0b5c3 sequential overlay segments
writing was replaced by a parallel one. But there was one hidden issue:
each curve knows its number of points and starting offset. If you want
to drop one curves set from domain -- you have to sequentially offset
all other curves. And this was not done. Gap between poly and nurbs
curve ,point indices created for bezier still there. And once it stop
being filled by 0 after 3e8250e60c we meet
all the segments of garbage. Proper fix: lay left handle segments in
space created for bezier segments. This fix: hide issue until proper
fix (non trivial refactor).

Pull Request: https://projects.blender.org/blender/blender/pulls/143858
2025-08-03 17:36:23 +02:00
Casey Bianco-Davis
dfeeaa98fd Grease Pencil: Use Curve overlay for Bezier handles
This makes it so that Grease Pencil Bezier handles use the same colors and shaders as `Curves` Objects.

This also makes the handles follow `handle_display` and add the option the the edit mode overlay.

Pull Request: https://projects.blender.org/blender/blender/pulls/141524
2025-08-02 15:37:59 +02:00
Campbell Barton
2c27d2be54 Cleanup: grammar corrections, minor improvements to wording 2025-08-01 21:41:24 +10:00
Damien Picard
f6771d8e21 UI: Improve running jobs labels
Use the form "Processing something..." (gerund, sentence case,
ellipsis) for running jobs progress label, according to Blender's
Human Interface Guidelines.

Pull Request: https://projects.blender.org/blender/blender/pulls/141573
2025-07-31 16:32:41 +02:00
Miguel Pozo
4a87a7e290 Fix #142800: Broken selection with Clipping Regions
Add missing DRW_CLIPPING_UBO_SLOT UBO.

(4.5 backport candidate)

Pull Request: https://projects.blender.org/blender/blender/pulls/143493
2025-07-30 15:23:38 +02:00
Campbell Barton
f281f5a500 Cleanup: header grouping
Group includes, this is mostly being done already but had become mixed
up in some areas.
2025-07-30 14:22:06 +10:00
Clément Foucault
55a0e427c5 GPU: Remove mip render workaround and recursive downsample
Recursive downsample was only used by workbench DoF
which can be expressed using mip view instead.

The mip render workaround was creating GL error on startup
and is not needed anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/143246
2025-07-28 19:05:36 +02:00
Sergey Sharybin
07bf1bd87b OpenSubdiv: Switch away from GLSL on Apple
Use MTLPatchShaderSource to provide the patch basis shader source on
all Apple platforms. The immediate advantage of this change is ability
to use GPU subdivision on iOS. Another advantage is that it moves us
further away from frameworks which got deprecated by Apple and it might
save us some headache in the future.

Also tweak backend-specific defines to match definitions from OpenSubdiv.
The annoying difference is that OSD_PATCH_BASIS_METAL is defined by the
OpenSubdiv as 1 in the very beginning of the base code, which is not done
for the OSD_PATCH_BASIS_GLSL is not defined by the OpenSubdiv at all.

Ref #143445

---

TODO:
- [X] Check it works correctly on macOS
- [x] Check it works correctly on Linux

Pull Request: https://projects.blender.org/blender/blender/pulls/143462
2025-07-28 16:54:10 +02:00
Habib Gahbiche
445eceb02a Nodes: Remove "Use Nodes" in Shader Editor for World
Part of https://projects.blender.org/blender/blender/pulls/141278

Blend files compatibility:
If a World exists and "Use Nodes" is disabled, we add new nodes to the
existing node tree (or create one if it doesn't) that emulates the
behavior of a world without a node tree. This ensures backward and
forward compatibility.

Python API compatibility:
- `world.use_nodes` was removed from Python API => **Breaking change**
- `world.color` is still being used by Workbench, so it stays there,
although it has no effect anymore when using Cycles or EEVEE.

Python API changes:
Creating a World using `bpy.data.worlds.new()` now creates a World with
 an empty (embedded) node tree. This was necessary to enable Python
scripts to add nodes without having to create a node tree (which is
currently not possible, because World node trees are embedded).

Pull Request: https://projects.blender.org/blender/blender/pulls/142342
2025-07-28 14:06:08 +02:00
Omar Emara
6f426f498a Refactor: Move pass name aliasing to context implementation
This patch moves the rules that alias Image to Combined for pass names
to the context implementations. This is because this only makes sense
for contexts that deal with passes, while it wouldn't make much sense
for other possible contexts like VSE modifiers.

Pull Request: https://projects.blender.org/blender/blender/pulls/143419
2025-07-28 10:00:20 +02:00
Omar Emara
ed8c072933 Refactor: Add default implementation for render_data
This patch adds a default implementation for the render_data method of
the compositor context. It defaults to the scene render_data.

Pull Request: https://projects.blender.org/blender/blender/pulls/143205
2025-07-28 07:55:46 +02:00
Campbell Barton
e8f9e2d1d1 Cleanup: use UTF8 string functions in editors & related logic
Use UTF8 aware functions unless raw bytes are expected.
2025-07-27 16:41:19 +10:00
Campbell Barton
e93e9db6b7 Cleanup: UTF8 string functions for color-space & imbuf strings
Use UTF8 aware functions unless raw bytes are expected.
2025-07-27 04:34:04 +00:00
Campbell Barton
649b89781e Cleanup: ensure UTF8 string copy for DNA & screen data
Use `BLI_strncpy_utf8` & `BLI_snprintf_utf8` for fixed size buffers in
DNA and screen data structures such as panels, menus & operators.

This could be considered a fix as copying a UTF8 string into a smaller
buffer without proper truncation can create an invalid UTF8 sequence.
However identifying which of these users are likely to run into would
be time consuming and not especially useful.
2025-07-26 12:33:15 +00:00
Hans Goudey
44e6822191 Cleanup: Remove debug code accidentally included in previous commit 2025-07-25 17:26:22 -04:00
Hans Goudey
33b430892c Fix #143218: Uninitialized VBO data using multiple UV tangents
Caused by b19696c0b8.

I misunderstood the meaning of the vertex buffer allocation size.
Even though the attributes aren't interleaved, the fact that there
are multiple attributes is still included in the "element size" that's
multiplied with the size argument to `GPU_vertbuf_data_alloc`.

Also switch to spans and indices rather than incrementing raw pointers,
which would have made this much faster to debug.
2025-07-25 17:00:47 -04:00
Miguel Pozo
33d9e00f4a Fix #142738, #136688: Workbench: Inconsistent matcap rendering
Use `bool32_t` to work around C++/GLSL bool differences.

Pull Request: https://projects.blender.org/blender/blender/pulls/143233
2025-07-25 19:45:28 +02:00
Omar Emara
2582630702 Refactor: Use Bounds for compositing region
This patch uses the new C++ Bounds structure for the composition region
returned by the compositor context.

Pull Request: https://projects.blender.org/blender/blender/pulls/143199
2025-07-25 15:40:45 +02:00
Omar Emara
8cb7aafae2 Refactor: Use generic name for compositor context IO methods
This patch renames some IO methods in the compositor context to be more
generic. This is in preparation for more generic use of the compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/143193
2025-07-25 14:40:17 +02:00
Omar Emara
b92b47f628 Refactor: Reduce compositor context pure virtual methods
The compositor context has a number of pure virtual methods that could
be optional or removed altogether, so this patch refactors that by
reducing unnecessary pure virtual methods.

Pull Request: https://projects.blender.org/blender/blender/pulls/143091
2025-07-25 07:50:52 +02:00
Germano Cavalcante
cb51fc5471 Fix #141741: Combed particles are affected by occlusion of other particles
Caused by 7688677e29, which replaced `DRW_draw_depth_object` with
`DRW_draw_depth_loop`.

`DRW_draw_depth_object` simply rendered the object without actually
using the DRW manager capabilities.

Now, with `DRW_draw_depth_loop`, the depth is rendered based on what
the engine sees with overlays disabled, which doesn't hide the
particles.

The solution to this issue is to skip particle rendering in the overlay
engine in `DRW_draw_depth_loop`.

Co-authored-by: Miguel Pozo <pragma37@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/141981
2025-07-24 16:24:19 +02:00
Hans Goudey
9c9695b103 Refactor: Move ReportList definition from DNA to blenkernel
Ever since [0], ReportList is not actually used in any DNA structs.
That makes sense, since reports are conceptually only necessary
at runtime. Move the definition of the struct to BKE_report.hh, and
fix a bunch of include errors where types were previously available
transitively. Besides adding some clarity, theoretically this change
could reduce compile times because of less header parsing.

[0]: 1bf6d8b0b9

Pull Request: https://projects.blender.org/blender/blender/pulls/138872
2025-07-24 15:59:52 +02:00
Omar Emara
e34e6373b6 Compositor: Replace Composite node with Group Output node
This patch replaces the Composite node with the Group Output node as the
primary compositor output. The old node was removed and versioned. This
was done for consistency with Geometry Nodes and in preparation for more
generic use of the compositor in VSE modifiers, layered compositing, NPR
multi-stage compositing, and more.

The Group Output node relies on the node tree interface, so we now have
a default interface of a single input and a single output. For now, only
the first input is considered while the rest are ignored, just like the
Geometry Nodes design. Furthermore, the input is required to be of type
color. Warnings and errors are issues if any of those are not met, also
similar to Geometry Nodes.

This introduces a new limitation: Composite outputs can no longer exist
in node groups, since they obviously then act as their respective group
outputs.

A refactor for the compositor scheduler is needed to simplify the logic
after this change, but this will be done in a separate patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/142232
2025-07-24 13:41:56 +02:00
Clément Foucault
50e876f21d EEVEE: Add correct volumetric support for point clouds
Since 4.5 the point clouds are out of experimental.

The drawing of pointcloud did not allow for correct volume
estimation as the shape are not rendered as closed objects
(i.e. the backfaces were not rendered).

This patch renders the backfaces for the volume occupancy
pass by rendering the pointcloud twice and flipping the
shape alignment matrix. This reverse the winding and
does a backface hit as it would do for a sphere primitive.

This solution even if not perfect avoids adding more
geometry in the Index Buffer. The geometry approach might
be preferable in the future if we find a way to render
the spheres without an IBO or with a JIT generated IBO.

Rel  #141490

Pull Request: https://projects.blender.org/blender/blender/pulls/142095
2025-07-24 12:05:29 +02:00
Clément Foucault
34e176d255 Fix #138191: EEVEE: Bump is incorrect with pixel size greater than 1x
This was caused by the hardware derivatives output being affected
by render resolution. Scaling them back to the full resolution
value fixes the issue.

This also fixes the Wireframe node that also relies on derivatives.

Pull Request: https://projects.blender.org/blender/blender/pulls/142101
2025-07-24 12:04:15 +02:00
Hans Goudey
d6252aa59a Mesh: Slightly optimize edit UV triangles index buffer full selection
It's simple to skip some work when all the triangles will be rendered
in the UV editor (though theoretically the best option would be to
share the non-UV triangle index buffer in this case).
2025-07-23 10:49:01 -04:00
Hans Goudey
e53e736453 Mesh: Parallelize edit UV triangle index buffer creation
Avoid function call overhead, add consistency between BMesh
and Mesh, parallelize filling the data and calculating the selection,
and avoid over-allocation in the cases where not all triangles will
be rendered.

Pull Request: https://projects.blender.org/blender/blender/pulls/142880
2025-07-23 15:24:30 +02:00
Hans Goudey
61cf76071b Fix #142785: Sculpt mode multires fast navigate artifacts
Part of the index buffer was uninitialized. Don't upload that part.
Similar to d84f10f2a0.

Pull Request: https://projects.blender.org/blender/blender/pulls/142891
2025-07-23 14:38:10 +02:00
Campbell Barton
5e3db5fbb0 Cleanup: consistent use of back-ticks in code-comments 2025-07-23 20:59:16 +10:00
Hans Goudey
beb062949b Fix #142814: Incorrect object mode UV overlay with GPU subdivision
Same problem as d84f10f2a0
2025-07-22 10:55:29 -04:00
Clément Foucault
32d64d35bb Refactor: GPU: Texture: Replace eGPUTextureFormat by TextureFormat
This offers better semantic and safety of the API.

Part of #130632

Pull Request: https://projects.blender.org/blender/blender/pulls/142818
2025-07-22 14:58:54 +02:00