Commit Graph

9252 Commits

Author SHA1 Message Date
Brecht Van Lommel
4786fbe774 Refactor: Remove extern "C" from most headers
The only remaining code in source/blender that must be compiled as C
is now datatoc generated code and the DNA defaults that use designated
initializers.

Pull Request: https://projects.blender.org/blender/blender/pulls/134469
2025-02-13 18:58:08 +01:00
Campbell Barton
640e70b6e8 Cleanup: various non-functional changes for C++ 2025-02-13 13:33:09 +11:00
Brecht Van Lommel
c7a33a62a2 Cleanup: Directly include DNA_userdef_types.h and BLI_listbase.h
Instead of relying on them being included indirectly.

Pull Request: https://projects.blender.org/blender/blender/pulls/134406
2025-02-12 23:01:08 +01:00
Harley Acheson
ac764ea5a0 Merge branch 'blender-v4.4-release' 2025-02-12 12:36:23 -08:00
Pratik Borhade
0a7b765eb0 Fix #134362: Grease Pencil canvas settings don't do anything
This is due to hardcoded color and subdivision value. Also scale and
offset properties stored in overlay stuct was not considered. Now
multiply the transform matrix with `grid_mat` to make use of these
properties.

Pull Request: https://projects.blender.org/blender/blender/pulls/134382
2025-02-12 18:51:03 +01:00
Clément Foucault
15437344ef Cleanup: DRW: Replace DRW_stats with GPU_debug
The former is not useful anymore and is being replaced
by the later.

Pull Request: https://projects.blender.org/blender/blender/pulls/134455
2025-02-12 17:14:48 +01:00
Omar Emara
89e0472e49 Compositor: Use gpu::TexturePool instead of DRW pool
This patch removes the compositor texture pool implementation which
relies on the DRW texture pool, and replaces it with the new texture
pool implementation from the GPU module.

Since the GPU module texture pool does not rely on the global DST, we
can use it for both the viewport compositor engine and the GPU
compositor, so the virtual texture pool implementation is removed and
the GPU texture pool is used directly.

The viewport compositor engine does not need to reset the pool because
that is done by the draw manager. But the GPU compositor needs to reset
the pool every evaluation. The pool is deleted directly after rendering
using the render pipeline or through RE_FreeUnusedGPUResources for the
interactive compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/134437
2025-02-12 15:59:45 +01:00
Clément Foucault
db2610f2e4 DRW: Use new gpu::TexturePool inside TextureFromPool
Follow up to #134403.
2025-02-11 19:00:43 +01:00
Omar Emara
13733423df Merge branch 'blender-v4.4-release' 2025-02-11 16:37:30 +02:00
Omar Emara
4137fdf555 Fix #134259: Compositor crash when passes are used
In certain setups where passes are used in the viewport compositor,
blender will crash. This happens because passes may not be available
when the compositor first run but then become available in later runs.
Possibly because EEVEE is still compiling shaders. This is problematic
for the compositor because it caches the result of node tree compilation
for the specific data available, like passes, and the compositor does
not get informed when data becomes available like in the case of EEVEE
to invalidate the cached node tree compilation result.

Caching of node tree compilation was always a source of bugs but we
managed to workaround them in the past, so before we work on a fix for
this crash, we first evaluate the removal of caching to see if we can
live without it. Especially since a fix will be rather involved for the
release branch at this stage.

The time it takes to compile the node tree is:

- Small Tree (~10 nodes): 0.3ms.
- Medium Tree (~50 nodes): 0.6ms.
- Huge Tree (~300 nodes): 3ms.

The difference is not noticeable to the eye, probably since as the tree
becomes bigger, the evaluation time becomes more dominant, and small
trees are fast to compile.

It should be noted that we intended to remove caching in the future to
support things like lazy evaluation of node inputs, but we though a few
optimization needs to be done on the GPUMaterial compiler side to make
compilation faster, since it is the main bottleneck during compilation.

So considering this, I think it is acceptable to disable caching of node
tree compilations for the time being. I intend to optimize it such that
it always becomes less than 1ms, but we will have to delay that to 4.5.

Pull Request: https://projects.blender.org/blender/blender/pulls/134394
2025-02-11 15:35:41 +01:00
Clément Foucault
144045cf63 Cleanup: DRW: Remove unused options 2025-02-11 13:03:00 +01:00
Clément Foucault
9bded245cc Cleanup: DRW: Remove global access function DRW_viewport_pixelsize_get 2025-02-11 13:02:54 +01:00
Clément Foucault
09e7e878e6 Cleanup: DRW: Remove unused legacy DRWViewport*List 2025-02-11 12:58:32 +01:00
Clément Foucault
ff34648011 Grease Pencil: Merge GPENCIL_PrivateData into GPENCIL_Instance
No functional change. Simplify architecture.
2025-02-11 12:56:00 +01:00
Clément Foucault
95305b2dc5 Fix: SelectID: Broken shader compilation on Metal 2025-02-11 12:19:23 +01:00
Clément Foucault
a961c9050d Cleanup: GPU: Remove dependency on legacy common_math_lib.glsl
Replace usage of `common_math_lib.glsl` (deprecated) with gpu shader libs.

Pull Request: https://projects.blender.org/blender/blender/pulls/131579
2025-02-10 18:14:50 +01:00
Clément Foucault
86b70143d5 Cleanup: GPU: Remove unused Transform Feedback implementation
Most of the cleanup is inside the metal backend.

Pull Request: https://projects.blender.org/blender/blender/pulls/134349
2025-02-10 17:30:42 +01:00
Clément Foucault
96174e76ed Merge branch 'blender-v4.4-release' 2025-02-10 16:17:38 +01:00
Clément Foucault
aad0bd2148 Fix #132889: EEVEE: Volumetric emission on zero scale mesh breaks render
The root cause is still unknown. But this patch disables
rendering of objects that will produce no volumetric effect.
This does fix the issue reported.
2025-02-10 16:17:15 +01:00
Clément Foucault
6e0bd843d8 Merge branch 'blender-v4.4-release' 2025-02-10 15:22:39 +01:00
Clément Foucault
52e87d0fa3 Fix #134320: EEVEE: Crashes when leaving camera view back to orthographic
This happened because the interpolated winmat was degenerate.
Using a fallback matrix in this case to avoid a crash.
2025-02-10 15:21:51 +01:00
Clément Foucault
9c5624e3b6 Merge branch 'blender-v4.4-release' 2025-02-10 11:29:28 +01:00
Clément Foucault
5ccc02bbf4 Fix #78484: Overlay: No Wireframes in Edit Mode when Overlays are off
Added a mode check bypass for this particular case.
Added comments to explain reasoning.
2025-02-10 11:29:06 +01:00
Miguel Pozo
44d5d1b0f3 Fix #133638: Overlay-Next: X-Ray + Overlays
Alternative (cleaner) version of #134069.

Pull Request: https://projects.blender.org/blender/blender/pulls/134243
2025-02-10 10:48:59 +01:00
Campbell Barton
677a643046 Merge branch 'blender-v4.4-release' 2025-02-10 19:53:53 +11:00
Campbell Barton
4276437f05 Cleanup: quiet check_spelling_* warnings 2025-02-10 19:48:42 +11:00
Campbell Barton
e659e87a67 Cleanup: cmake formatting, sort file lists 2025-02-10 19:40:06 +11:00
Miguel Pozo
971c55202a Revert "Fix #133638: Overlay Next: Some overlays not displayed in X-Ray mode"
This reverts commit f64641ad30.
2025-02-07 19:00:15 +01:00
Miguel Pozo
f64641ad30 Fix #133638: Overlay Next: Some overlays not displayed in X-Ray mode
Ensure overlay object modes/x-ray/wireframe combinations match 4.3
behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/134069
2025-02-07 18:12:25 +01:00
Clément Foucault
5fcfc57103 Fix: DRW: Avoid division by zero in frustum_culling_planes_calc
This doesn't fix the float precision issue, just making sure we
don't hit undefined behavior.
2025-02-07 14:42:56 +01:00
Jeroen Bakker
a475678701 Cleanup: Subdiv: Move shaders to draw_shader
Subdivision had its own store of shaders. Best to move them to
`draw_shader.cc` where all draw manager related shaders are stored.

Includes some small tweaks:

- Use enum class for shader types
- patch evaluation must now be retrieved via the
  `DRW_shader_subdiv_get`. Previously there were 2 ways to retrieve
  them, and one didn't support all the variations.
- Use strongly types when possible (`GPUVertCompType`).

Pull Request: https://projects.blender.org/blender/blender/pulls/134213
2025-02-07 10:53:29 +01:00
Jeroen Bakker
d496e69eca Cleanup: Subdiv: Remove common_ prefix
The `common_` prefix can be confusing as there are other common_ files as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/134184
2025-02-07 07:48:49 +01:00
Clément Foucault
59db8d427f Fix #132663: Selection: Object selection is broken on Intel Macs
Copy the fix that is used by EEVEE shadow code.
2025-02-06 19:30:41 +01:00
Clément Foucault
7a98a459ef Fix #134011: Overlay: Loose wires object color in selection not visible
The changes from 29356e2bf7
fixed a readability issue with loose wire not being as prominent as
regular surface wireframe.

But also added a regression where the object color wireframe mode
made the object color imperceivable when the object is selected.

This commit fixes the issue by setting the facing factor to 0.5 for
loose wires. This way, both the theme color and object color wireframe
more are blended enough to be distinguishable and still retain the
object color hint.
2025-02-05 14:25:46 +01:00
Weizhen Huang
d2db9927ed Fix #86648: reduce ray differentials size for bump mapping
Use sub-pixel differentials for bump mapping helps with reducing
artifacts when objects are moving or when textures have high frequency
details.

Currently we scale it by 0.1 because it seems to work good in practice,
we can adjust the value in the future if it turns out to be impractical.

Ref: #122892

Pull Request: https://projects.blender.org/blender/blender/pulls/133991
2025-02-05 13:39:27 +01:00
Campbell Barton
df3d1bf506 Cleanup: use const arguments & variables where appropriate 2025-02-05 14:38:56 +11:00
Clément Foucault
6f9dedcdc4 Fix #134011: Overlay: Wireframe with object color isn't shown selected
This was an oversight and the shader was using the old API.
2025-02-04 19:19:55 +01:00
Jeroen Bakker
d486c8f655 Fix: Image Engine: Incorrect size push constant
Detected when running OpenGL compositor tests. The far near distances
push constant only attached a single float in stead of two. Fixed by
using float2.

Pull Request: https://projects.blender.org/blender/blender/pulls/134019
2025-02-04 09:50:01 +01:00
Omar Emara
e53ac805af Compositor: Avoid redundant output computations
This patch allows the compositor context to specify exactly which
outputs it needs, selecting from: Composite, Viewer, File Output, and
Previews. Previously, the compositor fully executed if any of those were
needed, without granular control on which outputs are needed exactly.

For the viewport compositor engine, it requests Composite and Viewer,
with no Previews or File Outputs.

For the render pipeline, it requests Composite and File Output, with
node Viewer or Previews.

For the interactive compositor, it requests Viewer if the backdrop is
visible or an image editor with the viewer image is visible, it requests
Compositor if an image editor with the render result is visible, it
requests Previews if a node editor has previews overlay enabled. File
outputs are never requested.

Pull Request: https://projects.blender.org/blender/blender/pulls/133960
2025-02-04 08:34:48 +01:00
Campbell Barton
95393726b0 Cleanup: quiet check_spelling_* warnings 2025-02-04 14:43:20 +11:00
Clément Foucault
7bdafde54c Fix #133138: Overlay: Assert displaying subdiv surface modifier in edit-mode
The cause was that the shader was expecting both `pos` and `nor`
attribute but only one would be extracted.
This is because the mesh has cage display on but the batch cache
wouldn't extract the `vbo.vnor`.

This patch just make sure the vertex normal just follow the same
condition as the other edit normals batches.
2025-02-03 19:04:05 +01:00
Clément Foucault
b0980a1419 Fix: Overlay: Edit Mesh: Fix normal display with GPU subdivision
Make sure the gpu subdiv shader variant is only used if there
is no cages as the requested batch has a different layout in
this case.

Also add the missing shader variant for vertex normal display
with GPU subdiv.
2025-02-03 19:04:05 +01:00
Clément Foucault
724a065cdc Fix: Overlay: Edit mesh normals display not writting to line buffer
Shader was missing a framebuffer output.
Similar to 58cb2e43a1
2025-02-03 19:04:05 +01:00
Clément Foucault
f4a214166e Fix #133754: Overlay: Geometry Nodes viewer displays blue color for instances
Shader was missing a framebuffer output.
Similar to 58cb2e43a1

On top of that was that the push constant was not
using the right overload.
2025-02-03 15:00:08 +01:00
Clément Foucault
3929a37786 Fix #131506: EEVEE: GP disappear when resolution scale > 1
Now EEVEE outputs the in-progress render depth buffer
for GPencil to intersect with.

The overlays will clear the depth buffer in such situation
and still do the depth prepass for correct intersection.

Moreover, this patch makes overlay engine not requiring
a depth prepass when run with EEVEE at 1:1 render resolution.
This avoids significant overhead of the depth prepass.

Pull Request: https://projects.blender.org/blender/blender/pulls/133971
2025-02-03 14:45:46 +01:00
Clément Foucault
aa8769599c Fix #133775: Overlay: curve attribute is not showing any color in viewport
The curves wireframes should not have any offset applied to them.
This avoid the attribute overlay failling the equal depth tests.
2025-02-03 14:25:00 +01:00
Clément Foucault
58cb2e43a1 Fix #133680: Overlay: Poor wireframe quality in Edit mode for NURBS Surface
`lineOutput` was missing from some shaders.

Pull Request: https://projects.blender.org/blender/blender/pulls/133974
2025-02-03 13:58:25 +01:00
Brecht Van Lommel
c7eb2f4204 Refactor: Remove _DEBUG, use WITH_DRAW_DEBUG instead
The `_DEBUG` flag is interfering with oneTBB, and now that there is a
`WITH_DRAW_DEBUG` option this is more appropriate.

See #115774 for more context.

Pull Request: https://projects.blender.org/blender/blender/pulls/133950
2025-02-03 12:32:04 +01:00
Campbell Barton
4cd827870d Cleanup: quiet check_spelling_* targets
Also correct outdated references to `ghash`.
2025-02-02 13:58:34 +11:00
Hans Goudey
abc8796cab Curves: Optimize edit/sculpt mode index buffer creation
Avoid function call overhead and parallelize the creation of the edit
and sculpt mode lines index buffers. Also, remove an extra index that
was added for each curve when there are no cyclic curves.

Though ideally these index buffers would be generated on the GPU, this
simple change makes this part of the GPU data building almost 5x faster
(from 1.23 ms to 0.25 ms for curves with 80 thousand points).

Pull Request: https://projects.blender.org/blender/blender/pulls/133897
2025-01-31 21:47:16 +01:00