Commit Graph

5716 Commits

Author SHA1 Message Date
Clément Foucault
2892b494bd Cleanup: DRW: Remove some global access to DRWContext
Rel #136090
2025-03-18 17:48:54 +01:00
Clément Foucault
8c7cb9d3c7 Cleanup: DRW: Flatten global access to DRWContext
Rel #136090
2025-03-18 17:28:00 +01:00
Clément Foucault
0105b33a5f Refactor: DRW: Move some functions to DRWContext
This reduces the API and make it more clear where there
is the global access.

This also removes some of these global access by merging
the `DRW_context_get()` calls.
2025-03-17 17:19:13 +01:00
Clément Foucault
686c571c09 Cleanup: Overlay: Remove DRWContext C-API calls 2025-03-17 16:24:23 +01:00
Clément Foucault
8d8b20f31f Cleanup: EEVEE: Remove workaround for state functions
Now the states are set accordingly inside the init function.
2025-03-17 16:24:23 +01:00
Clément Foucault
894c7fa4e2 EEVEE: Remove EEVEE Next mention inside the code
This only changes file and function names.
The EEVEE identifier is still `BLENDER_EEVEE_NEXT`.

No functional changes.
2025-03-17 15:37:04 +01:00
Clément Foucault
959d82f2ab Merge branch 'blender-v4.4-release' 2025-03-17 14:25:43 +01:00
Clément Foucault
e31bfce08a Fix: Overlay: Broken Shading on Armature envelope
There was a copy paste mistake in the create info refactor
patch commited in b295df7345.
2025-03-17 14:24:31 +01:00
Campbell Barton
5aec1308e6 Cleanup: quiet missing-declarations warnings 2025-03-17 21:44:08 +11:00
Clément Foucault
92968c23fe Refactor: DRW: Make DrawEngine a virtual class
This removes the old `DrawEngineType` and use the new `DrawEngine`
virtual class instead.

This removes a lot of boilerplate functions that were only there for
legacy reason.

To this end, some engines that were based on static functions have been
refactored into `Instance` classes. This was particularly cumbersome
for the Grease pencil engine which needed some more refactoring.

The `Engine` class that is in each namespace is a workaround to isolate
the internal implementation (i.e. the `Instance`) to the engine
modules. Without this, the whole engine is getting included in each
compile unit that includes the `Instance` class. Eventually, if we get
rid of these intricate dependencies, we could remove the `Engine` class.

Pull Request: https://projects.blender.org/blender/blender/pulls/136001
2025-03-17 10:31:22 +01:00
Clément Foucault
626118984e Compositor: Use last_update for ID update
This replaces the deprecated DrawData mechanism by the
usage of the update timestamp `last_update`.

The compositor keeps the `last_update` value of the cached ID
and compares it with the value on the ID at the time of evaluation.

Rel #134690

Pull Request: https://projects.blender.org/blender/blender/pulls/134878
2025-03-14 10:25:32 +01:00
Clément Foucault
4ba3b1985c Overlay: Avoid engine recreation for clipping region toggle
This changes the shader module reference to a pointer and
set it during `init()`
2025-03-13 22:06:56 +01:00
Miguel Pozo
d7efed77b8 Merge branch 'blender-v4.4-release' 2025-03-13 19:59:10 +01:00
Miguel Pozo
08bd2d687d Fix #135848: Selection-Next: Backface culling (2)
Alternative fix for #135848.
Initially fixed by #135867, but broken again by #135917.

This performs the early return manually for the depth prepass.

Pull Request: https://projects.blender.org/blender/blender/pulls/135924
2025-03-13 19:26:15 +01:00
Clément Foucault
e5ae55af88 Cleanup: Overlay: Resolve warning about unused variable with C++ shader 2025-03-13 16:34:13 +01:00
Miguel Pozo
083878c46b Merge branch 'blender-v4.4-release' 2025-03-13 16:14:24 +01:00
Miguel Pozo
ce41fbaefa Revert "Fix #135848: Selection-Next: Backface culling"
This reverts commit
44b64ca9df.
The fix is broken by
04a57dd937.
2025-03-13 16:11:33 +01:00
Clément Foucault
04a57dd937 Fix #135898: Selection: Make selection not depth aware
No depth awareness is wanted during object mode selection.
The hits are depth ordered in some selection mode but none
is supposed to reject based on depth.

Pull Request: https://projects.blender.org/blender/blender/pulls/135917
2025-03-13 15:16:05 +01:00
Miguel Pozo
44b64ca9df Fix #135848: Selection-Next: Backface culling
Allow extending the DRWState on select_bind so backface culling can be used when needed.

Note: There's still a difference in behavior with Overlay Legacy, causing backface culled flat objects to still be selectable at the edges, due to the "MeshFlat" workaround.
Pull Request: https://projects.blender.org/blender/blender/pulls/135867
2025-03-13 14:23:17 +01:00
Jesse Yurkovich
e492794e1e Fix: Resolve several int -> uint conversion shader warnings
Resolves several int -> uint conversion warnings. Warnings like the
following will be printed otherwise:

```
      |
  225 |   uint shadow_type = flags & 0xF;
      |                      ^
      | gpu_shader_text_vert.glsl:17:22: Warning: some implementations
        may not support implicit int -> uint conversions for `&'
        operators; consider casting explicitly for portability
```

Pull Request: https://projects.blender.org/blender/blender/pulls/135890
2025-03-13 14:22:21 +01:00
Clément Foucault
94c7c84bcd Refactor: DRW: Simplify the DRWContext classes and methods
This refactor part of `draw_manager_c.cc` to make it more understandable
and less bug prone.

- Splits the context handing to `draw_gpu_context.cc`
- Rename `draw_manager_c.cc` to `draw_context.cc`
- Merge `DRWContextState` into `DRWContext`
- Merge lots of static functions into `DRWContext` to avoid global access
- Deduplicate code between entry point functions
- Move context init logic to `DRWContext` constructor
- Move resource init logic to `DRWContext::acquire_data`
- Move extraction `TaskGraph` out of `DRWContext`
- Reduce / centralize complexity of enabling draw engines
- Reduce the amount of `drw_get` calls
- Remove unused code

Pull Request: https://projects.blender.org/blender/blender/pulls/135821
2025-03-13 13:47:02 +01:00
Clément Foucault
f7e4fbc636 DRW: Add different mutex for GPUShader critical section
This removes the use of `system_gpu_context_mutex`
which was making render command submission threadsafe.

The only issue is the concurent usage of GPUShader objects.
To fix this, we only guard the submission section which
are the only parts that uses the GPUShaders.

Removing this critical section all together requires some changes
in the GPUShader. See #135406

Rel #134690

Pull Request: https://projects.blender.org/blender/blender/pulls/135595
2025-03-11 12:06:11 +01:00
Clément Foucault
92df5ba10f Fix #135650: Workbench: Missing update changing shading pop-over settings
This was previously taken care of by the `view_update` callback.
Nowadays, the best way is to manually check for changes inside
the engine.
2025-03-10 13:34:41 +01:00
Clément Foucault
86d7f1bcee Merge branch 'blender-v4.4-release' 2025-03-10 13:07:47 +01:00
Clément Foucault
690a165630 Fix #135652: Overlay: Overlays draw in front of mesh in Paint modes
This was caused by a missing prepass.
Only early out if drawing the prepass, otherwise, run all checks.
This is much safer.
2025-03-10 13:07:35 +01:00
Hans Goudey
99fa22a01f Fix #135175: Bounds overlay doesn't include all evaluated geometry
In the report, the bounds didn't include the curves generated from the
original legacy curve object. Generally we need to access the evaluated
geometry bounds here when the object is a geometry object.

This depends on 06f6d77979 for consistent behavior with
curve radii. That's why the fix is limited to main rather than 4.4.

Pull Request: https://projects.blender.org/blender/blender/pulls/135639
2025-03-07 18:23:40 +01:00
Falk David
39ceab03be Merge branch 'blender-v4.4-release' 2025-03-07 16:23:53 +01:00
Falk David
a904d3a1b2 Fix #135539: Grease Pencil: Depth placement not working in rendered mode
The issue was happening because the `is_render_depth_available`
state flag was false leading to the depths being cleared.

When we use `is_depth_only_drawing`, we expect
that the depth is valid because the Grease Pencil
engine will write them.

Pull Request: https://projects.blender.org/blender/blender/pulls/135619
2025-03-07 16:17:15 +01:00
Clément Foucault
4179960ede Overlay: Add DepthOnly GPU debug capture scope
Allow to capture the depth loop.
2025-03-07 11:18:33 +01:00
Clément Foucault
2131ef0a20 DRW: Use depsgraph update count to replace view_update
This avoid having to flush explicitely and the need for syncing.
It also removes a lot of complexity in the process.

These updates are not granular and do not need to so much
boiler plate code.

The depsgraph update counter now becomes atomic to avoid
undefined behavior when a depsgraph is being destroyed and
its memory reused (same thinking as the non-copy-on-eval IDs).

I tested some use cases (object update, sculpt update,
shading update) and they are all working.

Pull Request: https://projects.blender.org/blender/blender/pulls/135580
2025-03-06 19:15:29 +01:00
Miguel Pozo
db053ff8c5 Fix: EEVEE: Avoid double lock in ShaderModule::module_free
Use a separate lock for the module ops.

Pull Request: https://projects.blender.org/blender/blender/pulls/135587
2025-03-06 18:13:18 +01:00
Clément Foucault
f8c23fc793 Cleanup: EEVEE: Unused variables 2025-03-06 16:24:59 +01:00
Clément Foucault
4f909ba6fd DRW: Make DRWContext thread local
The owner of the context is now always the local context.
The `DRWContext` is now a temporary object that owns
no data.

The draw debug API is being put in a non-working state by
this PR as it conflicts with the new lifetime / ownership of
the `DRWContext` class.
A new design with a global (threadsafe) debug module is needed
to add back support for these debug features. Note that these
are not user facing features.

Some parts of EEVEE are still calling the global context and that
caused crashes in the volume probe baking pipeline where
the context is not yet known. Sort circuiting these function
calls in this case fixes the issue, but a more longer term
solution would be to alway have a `DRWContext` available inside
`eevee::Instance`.

I did some testing and didn't find much of a difference in frame time.
However, we should still strive to remove all global access in the future
to avoid potential overhead of `thread_local`.

Pull Request: https://projects.blender.org/blender/blender/pulls/135521
2025-03-06 15:18:02 +01:00
Clément Foucault
e36cc4dcf7 Cleanup: Grease Pencil: Remove uneeded push-constants
All of these push-constants were either redundant or
not used anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/135561
2025-03-06 15:14:05 +01:00
Clément Foucault
bb2d123fbd Cleanup: DRW: Remove ObjectInfos legacy GLSL macros
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/135542
2025-03-06 11:06:26 +01:00
Campbell Barton
2569308200 Cleanup: sort cmake file-lists, indentation 2025-03-06 10:55:26 +11:00
Miguel Pozo
998d84a84b Revert "Fix: EEVEE: Avoid double lock in ShaderModule::module_free"
This reverts commit f96b43cfd4.
2025-03-05 23:19:18 +01:00
Miguel Pozo
f96b43cfd4 Fix: EEVEE: Avoid double lock in ShaderModule::module_free 2025-03-05 22:40:59 +01:00
Miguel Pozo
97055868a3 Merge branch 'blender-v4.4-release' 2025-03-05 16:44:06 +01:00
Miguel Pozo
6c697a48f4 Fix #135325: Overlay-Next: Replicate the old face x-ray behavior
Replicate the Overlay-Legacy behavior for selected face overlays in
X-Ray mode:

Use depth testing for `edit_mesh_faces_ps_` when X-Ray is fully opaque.

X-Ray is always considered fully opaque in Preview/Render mode since
X-Ray transparency is not supported.

Pull Request: https://projects.blender.org/blender/blender/pulls/135524
2025-03-05 16:42:59 +01:00
Clément Foucault
077115e936 Cleanup: DRW: Remove ViewMatrix legacy GLSL macros
Pull Request: https://projects.blender.org/blender/blender/pulls/135416
2025-03-05 15:31:36 +01:00
Clément Foucault
bacc58b142 Cleanup: DRW: Remove duplicated glsl library 2025-03-05 15:31:35 +01:00
Clément Foucault
9bddb57960 Cleanup: DRW: Relace drw_view macros by function calls 2025-03-05 15:31:35 +01:00
Clément Foucault
a92f6ebf13 Cleanup: DRW: Remove ModelMatrix legacy GLSL macros 2025-03-05 15:31:35 +01:00
Clément Foucault
5916c39fa4 Cleanup: DRW: Simplify resource id and custom id 2025-03-05 15:31:35 +01:00
Clément Foucault
580c02c053 Fix #135497: Auto-Depth Operation are affecterd by Retopology offset
Setting the offset to 0 for these cases fixes the issue.
We still want to draw the edit face in this case to a be able
to zoom on the retopo surface. We just don't want the offset.

Pull Request: https://projects.blender.org/blender/blender/pulls/135511
2025-03-05 15:08:12 +01:00
Omar Emara
97ada4f307 Cleanup: Compositor: Remove operation stream cache
This patch removes the operation stream cache code from the compositor.
This code path has been disabled already since 4137fdf555, so this patch
just removes the dead code.

Pull Request: https://projects.blender.org/blender/blender/pulls/135513
2025-03-05 14:01:12 +01:00
Lukas Tönne
1b8185db79 Merge branch 'blender-v4.4-release' 2025-03-05 12:04:12 +01:00
Hans Goudey
b8d547ab1a Fix #134876: Wireframe overlay incorrectly skips some edit mode objects
The detection of when the wireframe is drawn by the edit mode overlays
instead was incorrect and didn't handle recent changes to avoid drawing
edit mode overlay data for invalid evaluated/original edit mesh mappings.
See code comments for more detail.

Pull Request: https://projects.blender.org/blender/blender/pulls/135402
2025-03-05 11:18:26 +01:00
Miguel Pozo
d3ee449ca0 Fix: EEVEE: Handle multiple specialization constants variants
Correctly handle cases where multiple scenes with different
specialization constants are rendered concurrently.

Pull Request: https://projects.blender.org/blender/blender/pulls/135270
2025-03-04 17:41:26 +01:00