Overlay-Next #102179

Open
opened 2022-10-31 12:28:17 +01:00 by Jeroen Bakker · 9 comments
Member

Update Overlay engine to leverage the new capabilities of the new draw manager.

The motivations for this are:

  • Remove most of the globals access, which will unlock parallel rendering for EEVEE in the future.
  • Improve selection speed and consistency (see #102177).
  • Reduce complexity to ease other projects (e.g. Grease Pencil).
  • Port most (if not all) geometry shader used by overlays to the primitive expansion API to avoid shader duplication for Metal.

Requires #102177 (Draw: Selection Next)

Testing

Overlay Next code can be tested by enabling the associated experimental feature.
For testing selection, restarting after enabling the experimental feature is required. Otherwise it produces a crash because of shader sharing with legacy overlay.

Tasks

Meta:

  • In-Front
  • Alt-B Clipping
  • Xray

Optimization

  • Dupli Optimization
  • Unique Resource handle per object

Complex:

  • Armature
    • Sphere (joints)
    • Octahedral
    • BBones
    • Custom Shapes
    • Envelopes
    • Stick
    • Wire
    • Degrees Of Freedom
  • Edit Mesh
    • Vertex Weight
  • Edit Curve
  • Edit Uv
  • Gpencil
    • Wireframe
    • Edit Mode
    • Grid
  • Selection Outlines
  • Wireframe

Medium:

  • Line Anti-Aliasing
  • Fluid
  • Particles
    • Hair Wireframe
    • Edit Mode
  • Prepass
    • Mesh
    • Volume
    • PointCloud
    • Gpencil
    • Custom conservative raster
  • Sculpt
    • Mesh
    • Curves
  • Texture Paint
  • Vertex Paint
  • Weight Paint
  • Xray Fade

Easy:

  • Attribute Viewer
  • Background
  • Bounds
  • Curves
  • Camera
  • Motion Tracking
  • Camera Background Images
  • Edit Text
  • Edit Mesh Measurements
  • Empties
  • Facing
  • Fade
  • Force Fields
  • 3D Grid
  • 2D Grid
  • Pose bone select
  • Lattice
  • Lights
  • Light Probes
  • Relation Lines
  • Speaker

Bug:

  • Wireframe object display mode doesn't work correctly (seen in Quick smoke setup).
  • Wireframe not updated / working in sculpt mode.
  • Wireframe overlay is aliased (missing bias?)
  • 2D grid has wrong draw order. Should be drawn at the back and not at the front.

Follow up:

  • Fluid Grid overlay UX is really poor and should be improved by small easy tweaks.
  • Add abstract class that document the sync / draw function as an API (see sybren's comment)
  • Cleanup legacy members of Armatures::DrawContext by renaming them with legacy_ prefix.
  • Change select_invalid_id to select::ID::invalid()
  • Discuss naming of curves sculpt "cage" overlay feature and mask overlay consistency with sculpt mode.
  • Vertex Selection in paint mode have transparent points when verts unselected.
  • Vertex and Texture Paint overlays / display is not working in Wireframe view.
Update Overlay engine to leverage the new capabilities of the new draw manager. The motivations for this are: - Remove most of the globals access, which will unlock parallel rendering for EEVEE in the future. - Improve selection speed and consistency (see #102177). - Reduce complexity to ease other projects (e.g. Grease Pencil). - Port most (if not all) geometry shader used by overlays to the primitive expansion API to avoid shader duplication for Metal. Requires #102177 (Draw: Selection Next) #### Testing Overlay Next code can be tested by enabling the associated experimental feature. For testing selection, restarting after enabling the experimental feature is required. Otherwise it produces a crash because of shader sharing with legacy overlay. ### Tasks #### Meta: - [x] In-Front - [x] Alt-B Clipping - [ ] Xray #### Optimization - [ ] Dupli Optimization - [ ] Unique Resource handle per object #### Complex: - [x] Armature - [x] Sphere (joints) - [x] Octahedral - [x] BBones - [x] Custom Shapes - [x] Envelopes - [x] Stick - [x] Wire - [x] Degrees Of Freedom - [x] Edit Mesh - [ ] Vertex Weight - [x] Edit Curve - [x] Edit Uv - [x] Gpencil - [x] Wireframe - [x] Edit Mode - [x] Grid - [x] Selection Outlines - [x] Wireframe #### Medium: - [x] Line Anti-Aliasing - [x] Fluid - [x] Particles - [x] Hair Wireframe - [ ] Edit Mode - [x] Prepass - [x] Mesh - [x] Volume - [x] PointCloud - [x] Gpencil - [x] Custom conservative raster - [x] Sculpt - [x] Mesh - [x] Curves - [x] Texture Paint - [x] Vertex Paint - [x] Weight Paint - [x] Xray Fade #### Easy: - [ ] Attribute Viewer - [x] Background - [x] Bounds - [ ] Curves - [x] Camera - [x] Motion Tracking - [x] Camera Background Images - [ ] Edit Text - [x] Edit Mesh Measurements - [x] Empties - [x] Facing - [x] Fade - [x] Force Fields - [x] 3D Grid - [x] 2D Grid - [x] Pose bone select - [x] Lattice - [x] Lights - [x] Light Probes - [x] Relation Lines - [x] Speaker #### Bug: - Wireframe object display mode doesn't work correctly (seen in Quick smoke setup). - Wireframe not updated / working in sculpt mode. - Wireframe overlay is aliased (missing bias?) - 2D grid has wrong draw order. Should be drawn at the back and not at the front. #### Follow up: - Fluid Grid overlay UX is really poor and should be improved by small easy tweaks. - Add abstract class that document the sync / draw function as an API (see [sybren's comment](https://projects.blender.org/blender/blender/pulls/126474#issuecomment-1281807)) - Cleanup legacy members of `Armatures::DrawContext` by renaming them with `legacy_` prefix. - Change `select_invalid_id` to `select::ID::invalid()` - Discuss naming of curves sculpt "cage" overlay feature and mask overlay consistency with sculpt mode. - Vertex Selection in paint mode have transparent points when verts unselected. - Vertex and Texture Paint overlays / display is not working in Wireframe view.
Author
Member

Added subscriber: @Jeroen-Bakker

Added subscriber: @Jeroen-Bakker
Philipp Oeser removed the
Interest
Viewport & EEVEE
label 2023-02-09 15:12:10 +01:00
Clément Foucault added this to the Viewport & EEVEE project 2023-02-11 02:01:15 +01:00
Clément Foucault changed title from Draw: Overlay-Next to Overlay-Next 2023-02-12 01:44:34 +01:00

The engine design is now complete. Help with the port is welcomed.

Porting requires a bit of work but everything is clearer than the old implementation:

  • DRWCallBuffer are replaced by ShapeInstanceBuf with the data type declared in overlay_shader_shared.hh.
  • The GPUBatch for each shape (not object geometry) should be ported from draw_cache.c to overlay_shape.hh.
  • The GPUShader creation used must be ported to overlay_shader.cc to overlay_shader.hh.
  • The shader code needs to be patched to add support for selection (see these shaders for example)

Look overlay_empty.hh drawing for a simple example of shape drawing.
Look overlay_prepass.hh drawing for a simple example of object drawing.

I have sorted the list of task by degrees of complexity.

  • Complex ones are better handled by an EEVEE&Viewport module developer as they might require some tweaks along the port.
  • Medium ones can be handled by experimented developers.
  • Easy ones is just about copy pasting the logic with little room for errors.

Try to stick to the level of code quality this rewrite is at. Use float4x4 and the blender vector types instead of blender C vector/matrix API when possible.

Note that the Basic engine is going to be merged to the overlay engine for selection purpose. This means the basic engine features (such as conservative raster for selection) need to be ported.

The engine design is now complete. Help with the port is welcomed. Porting requires a bit of work but everything is clearer than the old implementation: - `DRWCallBuffer` are replaced by `ShapeInstanceBuf` with the data type declared in `overlay_shader_shared.hh`. - The `GPUBatch` for each shape (not object geometry) should be ported from `draw_cache.c` to `overlay_shape.hh`. - The `GPUShader` creation used must be ported to `overlay_shader.cc` to `overlay_shader.hh`. - The shader code needs to be patched to add support for selection (see [these shaders for example](https://projects.blender.org/fclem/blender/commit/ea66898bbe7320ddf91a90b09a345c702066fdd4#diff-b7746b348d960614d7231c9f808c8f19a1d2b732)) Look `overlay_empty.hh` drawing for a simple example of shape drawing. Look `overlay_prepass.hh` drawing for a simple example of object drawing. I have sorted the list of task by degrees of complexity. - Complex ones are better handled by an EEVEE&Viewport module developer as they might require some tweaks along the port. - Medium ones can be handled by experimented developers. - Easy ones is just about copy pasting the logic with little room for errors. Try to stick to the level of code quality this rewrite is at. Use `float4x4` and the blender vector types instead of blender C vector/matrix API when possible. Note that the Basic engine is going to be merged to the overlay engine for selection purpose. This means the basic engine features (such as conservative raster for selection) need to be ported.
Brecht Van Lommel removed the
Severity
Normal
Status
Needs Triage
labels 2023-06-14 13:10:31 +02:00
Clément Foucault added the
Interest
Overlay
label 2023-10-02 12:54:54 +02:00
Member

Ah I was looking at doing edit overlay for GPv3 but looks like it is giving me too many shader errors for now 🤔 so maybe not at the moment, but I'll keep an eye on this :D

Ah I was looking at doing edit overlay for GPv3 but looks like it is giving me too many shader errors for now 🤔 so maybe not at the moment, but I'll keep an eye on this :D

@ChengduLittleA What shader errors? Related to the current main? or related to your branch? Yesterday I found out there were some GL errors but not shader errors. Please report them in the chat.

@ChengduLittleA What shader errors? Related to the current main? or related to your branch? Yesterday I found out there were some GL errors but not shader errors. Please report them in the chat.
Member

@fclem current main.

Reproducible via:

  • Open Blender
  • Enable Overlay Next
  • Try selecting the default cube
  • Gives out such errors (However if I restart the program with overlay next preference saved, it won't give errors):
ERROR (gpu.shader): overlay_armature_sphere_outline FragShader: | 1320 | if (select_info_buf.mode == SELECT_ALL) { | | select_lib.glsl:27:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:27:0: Error: C1503: undefined variable "SELECT_ALL" | 1322 | atomicOr(out_select_buf[id / 32u], 1u << (uint(id) % 32u)); | | select_lib.glsl:29:0: Error: C1503: undefined variable "out_select_buf" | 1324 | else if (select_info_buf.mode == SELECT_PICK_ALL) { | | select_lib.glsl:31:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:31:0: Error: C1503: undefined variable "SELECT_PICK_ALL" | 1326 | atomicMin(out_select_buf[id], floatBitsToUint(gl_FragCoord.z)); | | select_lib.glsl:33:0: Error: C1503: undefined variable "out_select_buf" | 1328 | else if (select_info_buf.mode == SELECT_PICK_NEAREST) { | | select_lib.glsl:35:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:35:0: Error: C1503: undefined variable "SELECT_PICK_NEAREST" | 1332 | ivec2 coord = abs(ivec2(gl_FragCoord.xy) - select_info_buf.cursor); | | select_lib.glsl:39:0: Error: C1503: undefined variable "select_info_buf" | 1340 | atomicMin(out_select_buf[id], (depth << 8u) | dist); | | select_lib.glsl:47:0: Error: C1503: undefined variable "out_select_buf" | 1357 | select_id_output(select_id); | | overlay_armature_wire_frag.glsl:12:0: Error: C1503: undefined variable "select_id"

ERROR (gpu.shader): overlay_extra VertShader:
|
1598 | select_id = id;
|
| select_lib.glsl:15:0: Error: C1503: undefined variable "select_id"
|
1683 | select_id_set(in_select_buf[gl_InstanceID]);
|
| overlay_extra_vert.glsl:48:0: Error: C1503: undefined variable "in_select_buf"

ERROR (gpu.shader): overlay_extra FragShader:
|
1565 | if (select_info_buf.mode == SELECT_ALL) {
|
| select_lib.glsl:27:0: Error: C1503: undefined variable "select_info_buf"
| select_lib.glsl:27:0: Error: C1503: undefined variable "SELECT_ALL"
|
1567 | atomicOr(out_select_buf[id / 32u], 1u << (uint(id) % 32u));
|
| select_lib.glsl:29:0: Error: C1503: undefined variable "out_select_buf"
|
1569 | else if (select_info_buf.mode == SELECT_PICK_ALL) {
|
| select_lib.glsl:31:0: Error: C1503: undefined variable "select_info_buf"
| select_lib.glsl:31:0: Error: C1503: undefined variable "SELECT_PICK_ALL"
|
1571 | atomicMin(out_select_buf[id], floatBitsToUint(gl_FragCoord.z));
|
| select_lib.glsl:33:0: Error: C1503: undefined variable "out_select_buf"
|
1573 | else if (select_info_buf.mode == SELECT_PICK_NEAREST) {
|
| select_lib.glsl:35:0: Error: C1503: undefined variable "select_info_buf"
| select_lib.glsl:35:0: Error: C1503: undefined variable "SELECT_PICK_NEAREST"
|
1577 | ivec2 coord = abs(ivec2(gl_FragCoord.xy) - select_info_buf.cursor);
|
| select_lib.glsl:39:0: Error: C1503: undefined variable "select_info_buf"
|
1585 | atomicMin(out_select_buf[id], (depth << 8u) | dist);
|
| select_lib.glsl:47:0: Error: C1503: undefined variable "out_select_buf"
|
1603 | select_id_output(select_id);
|
| overlay_extra_frag.glsl:13:0: Error: C1503: undefined variable "select_id"

ERROR (gpu.shader): overlay_extra_wire VertShader:
|
1601 | select_id = id;
|
| select_lib.glsl:15:0: Error: C1503: undefined variable "select_id"
|
1654 | select_id_set(drw_CustomID);
|
| overlay_extra_wire_vert.glsl:16:0: Error: C1503: undefined variable "drw_CustomID"

ERROR (gpu.shader): overlay_extra_wire FragShader:
|
1570 | if (select_info_buf.mode == SELECT_ALL) {
|
| select_lib.glsl:27:0: Error: C1503: undefined variable "select_info_buf"
| select_lib.glsl:27:0: Error: C1503: undefined variable "SELECT_ALL"
|
1572 | atomicOr(out_select_buf[id / 32u], 1u << (uint(id) % 32u));
|
| select_lib.glsl:29:0: Error: C1503: undefined variable "out_select_buf"
|
1574 | else if (select_info_buf.mode == SELECT_PICK_ALL) {
|
| select_lib.glsl:31:0: Error: C1503: undefined variable "select_info_buf"
| select_lib.glsl:31:0: Error: C1503: undefined variable "SELECT_PICK_ALL"
|
1576 | atomicMin(out_select_buf[id], floatBitsToUint(gl_FragCoord.z));
|
| select_lib.glsl:33:0: Error: C1503: undefined variable "out_select_buf"
|
1578 | else if (select_info_buf.mode == SELECT_PICK_NEAREST) {
|
| select_lib.glsl:35:0: Error: C1503: undefined variable "select_info_buf"
| select_lib.glsl:35:0: Error: C1503: undefined variable "SELECT_PICK_NEAREST"
|
1582 | ivec2 coord = abs(ivec2(gl_FragCoord.xy) - select_info_buf.cursor);
|
| select_lib.glsl:39:0: Error: C1503: undefined variable "select_info_buf"
|
1590 | atomicMin(out_select_buf[id], (depth << 8u) | dist);
|
| select_lib.glsl:47:0: Error: C1503: undefined variable "out_select_buf"
|
1631 | select_id_output(select_id);
|
| overlay_extra_wire_frag.glsl:36:0: Error: C1503: undefined variable "select_id"

ERROR (gpu.shader): overlay_extra_wire VertShader:
|
1355 | select_id = id;
|
| select_lib.glsl:15:0: Error: C1503: undefined variable "select_id"
|
1408 | select_id_set(drw_CustomID);
|
| overlay_extra_wire_vert.glsl:16:0: Error: C1503: undefined variable "drw_CustomID"

ERROR (gpu.shader): overlay_extra_wire FragShader:
|
1321 | if (select_info_buf.mode == SELECT_ALL) {
|
| select_lib.glsl:27:0: Error: C1503: undefined variable "select_info_buf"
| select_lib.glsl:27:0: Error: C1503: undefined variable "SELECT_ALL"
|
1323 | atomicOr(out_select_buf[id / 32u], 1u << (uint(id) % 32u));
|
| select_lib.glsl:29:0: Error: C1503: undefined variable "out_select_buf"
|
1325 | else if (select_info_buf.mode == SELECT_PICK_ALL) {
|
| select_lib.glsl:31:0: Error: C1503: undefined variable "select_info_buf"
| select_lib.glsl:31:0: Error: C1503: undefined variable "SELECT_PICK_ALL"
|
1327 | atomicMin(out_select_buf[id], floatBitsToUint(gl_FragCoord.z));
|
| select_lib.glsl:33:0: Error: C1503: undefined variable "out_select_buf"
|
1329 | else if (select_info_buf.mode == SELECT_PICK_NEAREST) {
|
| select_lib.glsl:35:0: Error: C1503: undefined variable "select_info_buf"
| select_lib.glsl:35:0: Error: C1503: undefined variable "SELECT_PICK_NEAREST"
|
1333 | ivec2 coord = abs(ivec2(gl_FragCoord.xy) - select_info_buf.cursor);
|
| select_lib.glsl:39:0: Error: C1503: undefined variable "select_info_buf"
|
1341 | atomicMin(out_select_buf[id], (depth << 8u) | dist);
|
| select_lib.glsl:47:0: Error: C1503: undefined variable "out_select_buf"
|
1382 | select_id_output(select_id);
|
| overlay_extra_wire_frag.glsl:36:0: Error: C1503: undefined variable "select_id"

ERROR (gpu.shader): overlay_extra_groundline VertShader:
|
1351 | select_id = id;
|
| select_lib.glsl:15:0: Error: C1503: undefined variable "select_id"
|
1399 | select_id_set(in_select_buf[gl_InstanceID]);
|
| overlay_extra_groundline_vert.glsl:11:0: Error: C1503: undefined variable "in_select_buf"

ERROR (gpu.shader): overlay_extra_groundline FragShader:
|
1319 | if (select_info_buf.mode == SELECT_ALL) {
|
| select_lib.glsl:27:0: Error: C1503: undefined variable "select_info_buf"
| select_lib.glsl:27:0: Error: C1503: undefined variable "SELECT_ALL"
|
1321 | atomicOr(out_select_buf[id / 32u], 1u << (uint(id) % 32u));
|
| select_lib.glsl:29:0: Error: C1503: undefined variable "out_select_buf"
|
1323 | else if (select_info_buf.mode == SELECT_PICK_ALL) {
|
| select_lib.glsl:31:0: Error: C1503: undefined variable "select_info_buf"
| select_lib.glsl:31:0: Error: C1503: undefined variable "SELECT_PICK_ALL"
|
1325 | atomicMin(out_select_buf[id], floatBitsToUint(gl_FragCoord.z));
|
| select_lib.glsl:33:0: Error: C1503: undefined variable "out_select_buf"
|
1327 | else if (select_info_buf.mode == SELECT_PICK_NEAREST) {
|
| select_lib.glsl:35:0: Error: C1503: undefined variable "select_info_buf"
| select_lib.glsl:35:0: Error: C1503: undefined variable "SELECT_PICK_NEAREST"
|
1331 | ivec2 coord = abs(ivec2(gl_FragCoord.xy) - select_info_buf.cursor);
|
| select_lib.glsl:39:0: Error: C1503: undefined variable "select_info_buf"
|
1339 | atomicMin(out_select_buf[id], (depth << 8u) | dist);
|
| select_lib.glsl:47:0: Error: C1503: undefined variable "out_select_buf"
|
1357 | select_id_output(select_id);
|
| overlay_extra_frag.glsl:13:0: Error: C1503: undefined variable "select_id"

@fclem current main. Reproducible via: - Open Blender - Enable Overlay Next - Try selecting the default cube - Gives out such errors (However if I restart the program with overlay next preference saved, it won't give errors): <details> ERROR (gpu.shader): overlay_armature_sphere_outline FragShader: | 1320 | if (select_info_buf.mode == SELECT_ALL) { | | select_lib.glsl:27:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:27:0: Error: C1503: undefined variable "SELECT_ALL" | 1322 | atomicOr(out_select_buf[id / 32u], 1u << (uint(id) % 32u)); | | select_lib.glsl:29:0: Error: C1503: undefined variable "out_select_buf" | 1324 | else if (select_info_buf.mode == SELECT_PICK_ALL) { | | select_lib.glsl:31:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:31:0: Error: C1503: undefined variable "SELECT_PICK_ALL" | 1326 | atomicMin(out_select_buf[id], floatBitsToUint(gl_FragCoord.z)); | | select_lib.glsl:33:0: Error: C1503: undefined variable "out_select_buf" | 1328 | else if (select_info_buf.mode == SELECT_PICK_NEAREST) { | | select_lib.glsl:35:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:35:0: Error: C1503: undefined variable "SELECT_PICK_NEAREST" | 1332 | ivec2 coord = abs(ivec2(gl_FragCoord.xy) - select_info_buf.cursor); | | select_lib.glsl:39:0: Error: C1503: undefined variable "select_info_buf" | 1340 | atomicMin(out_select_buf[id], (depth << 8u) | dist); | | select_lib.glsl:47:0: Error: C1503: undefined variable "out_select_buf" | 1357 | select_id_output(select_id); | | overlay_armature_wire_frag.glsl:12:0: Error: C1503: undefined variable "select_id" ERROR (gpu.shader): overlay_extra VertShader: | 1598 | select_id = id; | | select_lib.glsl:15:0: Error: C1503: undefined variable "select_id" | 1683 | select_id_set(in_select_buf[gl_InstanceID]); | | overlay_extra_vert.glsl:48:0: Error: C1503: undefined variable "in_select_buf" ERROR (gpu.shader): overlay_extra FragShader: | 1565 | if (select_info_buf.mode == SELECT_ALL) { | | select_lib.glsl:27:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:27:0: Error: C1503: undefined variable "SELECT_ALL" | 1567 | atomicOr(out_select_buf[id / 32u], 1u << (uint(id) % 32u)); | | select_lib.glsl:29:0: Error: C1503: undefined variable "out_select_buf" | 1569 | else if (select_info_buf.mode == SELECT_PICK_ALL) { | | select_lib.glsl:31:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:31:0: Error: C1503: undefined variable "SELECT_PICK_ALL" | 1571 | atomicMin(out_select_buf[id], floatBitsToUint(gl_FragCoord.z)); | | select_lib.glsl:33:0: Error: C1503: undefined variable "out_select_buf" | 1573 | else if (select_info_buf.mode == SELECT_PICK_NEAREST) { | | select_lib.glsl:35:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:35:0: Error: C1503: undefined variable "SELECT_PICK_NEAREST" | 1577 | ivec2 coord = abs(ivec2(gl_FragCoord.xy) - select_info_buf.cursor); | | select_lib.glsl:39:0: Error: C1503: undefined variable "select_info_buf" | 1585 | atomicMin(out_select_buf[id], (depth << 8u) | dist); | | select_lib.glsl:47:0: Error: C1503: undefined variable "out_select_buf" | 1603 | select_id_output(select_id); | | overlay_extra_frag.glsl:13:0: Error: C1503: undefined variable "select_id" ERROR (gpu.shader): overlay_extra_wire VertShader: | 1601 | select_id = id; | | select_lib.glsl:15:0: Error: C1503: undefined variable "select_id" | 1654 | select_id_set(drw_CustomID); | | overlay_extra_wire_vert.glsl:16:0: Error: C1503: undefined variable "drw_CustomID" ERROR (gpu.shader): overlay_extra_wire FragShader: | 1570 | if (select_info_buf.mode == SELECT_ALL) { | | select_lib.glsl:27:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:27:0: Error: C1503: undefined variable "SELECT_ALL" | 1572 | atomicOr(out_select_buf[id / 32u], 1u << (uint(id) % 32u)); | | select_lib.glsl:29:0: Error: C1503: undefined variable "out_select_buf" | 1574 | else if (select_info_buf.mode == SELECT_PICK_ALL) { | | select_lib.glsl:31:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:31:0: Error: C1503: undefined variable "SELECT_PICK_ALL" | 1576 | atomicMin(out_select_buf[id], floatBitsToUint(gl_FragCoord.z)); | | select_lib.glsl:33:0: Error: C1503: undefined variable "out_select_buf" | 1578 | else if (select_info_buf.mode == SELECT_PICK_NEAREST) { | | select_lib.glsl:35:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:35:0: Error: C1503: undefined variable "SELECT_PICK_NEAREST" | 1582 | ivec2 coord = abs(ivec2(gl_FragCoord.xy) - select_info_buf.cursor); | | select_lib.glsl:39:0: Error: C1503: undefined variable "select_info_buf" | 1590 | atomicMin(out_select_buf[id], (depth << 8u) | dist); | | select_lib.glsl:47:0: Error: C1503: undefined variable "out_select_buf" | 1631 | select_id_output(select_id); | | overlay_extra_wire_frag.glsl:36:0: Error: C1503: undefined variable "select_id" ERROR (gpu.shader): overlay_extra_wire VertShader: | 1355 | select_id = id; | | select_lib.glsl:15:0: Error: C1503: undefined variable "select_id" | 1408 | select_id_set(drw_CustomID); | | overlay_extra_wire_vert.glsl:16:0: Error: C1503: undefined variable "drw_CustomID" ERROR (gpu.shader): overlay_extra_wire FragShader: | 1321 | if (select_info_buf.mode == SELECT_ALL) { | | select_lib.glsl:27:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:27:0: Error: C1503: undefined variable "SELECT_ALL" | 1323 | atomicOr(out_select_buf[id / 32u], 1u << (uint(id) % 32u)); | | select_lib.glsl:29:0: Error: C1503: undefined variable "out_select_buf" | 1325 | else if (select_info_buf.mode == SELECT_PICK_ALL) { | | select_lib.glsl:31:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:31:0: Error: C1503: undefined variable "SELECT_PICK_ALL" | 1327 | atomicMin(out_select_buf[id], floatBitsToUint(gl_FragCoord.z)); | | select_lib.glsl:33:0: Error: C1503: undefined variable "out_select_buf" | 1329 | else if (select_info_buf.mode == SELECT_PICK_NEAREST) { | | select_lib.glsl:35:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:35:0: Error: C1503: undefined variable "SELECT_PICK_NEAREST" | 1333 | ivec2 coord = abs(ivec2(gl_FragCoord.xy) - select_info_buf.cursor); | | select_lib.glsl:39:0: Error: C1503: undefined variable "select_info_buf" | 1341 | atomicMin(out_select_buf[id], (depth << 8u) | dist); | | select_lib.glsl:47:0: Error: C1503: undefined variable "out_select_buf" | 1382 | select_id_output(select_id); | | overlay_extra_wire_frag.glsl:36:0: Error: C1503: undefined variable "select_id" ERROR (gpu.shader): overlay_extra_groundline VertShader: | 1351 | select_id = id; | | select_lib.glsl:15:0: Error: C1503: undefined variable "select_id" | 1399 | select_id_set(in_select_buf[gl_InstanceID]); | | overlay_extra_groundline_vert.glsl:11:0: Error: C1503: undefined variable "in_select_buf" ERROR (gpu.shader): overlay_extra_groundline FragShader: | 1319 | if (select_info_buf.mode == SELECT_ALL) { | | select_lib.glsl:27:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:27:0: Error: C1503: undefined variable "SELECT_ALL" | 1321 | atomicOr(out_select_buf[id / 32u], 1u << (uint(id) % 32u)); | | select_lib.glsl:29:0: Error: C1503: undefined variable "out_select_buf" | 1323 | else if (select_info_buf.mode == SELECT_PICK_ALL) { | | select_lib.glsl:31:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:31:0: Error: C1503: undefined variable "SELECT_PICK_ALL" | 1325 | atomicMin(out_select_buf[id], floatBitsToUint(gl_FragCoord.z)); | | select_lib.glsl:33:0: Error: C1503: undefined variable "out_select_buf" | 1327 | else if (select_info_buf.mode == SELECT_PICK_NEAREST) { | | select_lib.glsl:35:0: Error: C1503: undefined variable "select_info_buf" | select_lib.glsl:35:0: Error: C1503: undefined variable "SELECT_PICK_NEAREST" | 1331 | ivec2 coord = abs(ivec2(gl_FragCoord.xy) - select_info_buf.cursor); | | select_lib.glsl:39:0: Error: C1503: undefined variable "select_info_buf" | 1339 | atomicMin(out_select_buf[id], (depth << 8u) | dist); | | select_lib.glsl:47:0: Error: C1503: undefined variable "out_select_buf" | 1357 | select_id_output(select_id); | | overlay_extra_frag.glsl:13:0: Error: C1503: undefined variable "select_id" </details>

I was a bit surprised that the drawing performance was worse in very simple scene on a M1 iMac. So I dig into some performance profiling. These insights should also apply to all "Next" engines.

Clear operation

The clear operation on overlay_line_fb at the start is suboptimal. It is better to selectively clear the color on the first framebuffer that uses the overlay color. However, this mean we have to clear the line buffer somewhere else (since it is only used later on). We need to figure out the best framebuffer / draw order. Ideally, we should draw to the line buffer first.

PassMain Compute

The dispatch issued from PassMain create bubbles and pipeline stall for some reasons. Best avoid using PassMain when possible. Since it is required in some cases, we need to find a system that dispatch all culling and command finalize dispatch at the start of the engine when the passes are known to be finished. Maybe having a Manager::warm(PassMain, View) and calling all that on all passes that needs it.

It should be noted that even passes that are empty currently dispatch some compute shader work. That should also be fixed.

GPU debug overhead

When profiling, one must disable draw::Texture::debug_clear(). It introduces a lot of clear operations that are not existing in the legacy API (thus, not there in Overlay Legacy).

I was a bit surprised that the drawing performance was worse in very simple scene on a M1 iMac. So I dig into some performance profiling. These insights should also apply to all "Next" engines. ### Clear operation The clear operation on overlay_line_fb at the start is suboptimal. It is better to selectively clear the color on the first framebuffer that uses the overlay color. However, this mean we have to clear the line buffer somewhere else (since it is only used later on). We need to figure out the best framebuffer / draw order. Ideally, we should draw to the line buffer first. ### PassMain Compute The dispatch issued from `PassMain` create bubbles and pipeline stall for some reasons. Best avoid using `PassMain` when possible. Since it is required in some cases, we need to find a system that dispatch all culling and command finalize dispatch at the start of the engine when the passes are known to be finished. Maybe having a `Manager::warm(PassMain, View)` and calling all that on all passes that needs it. It should be noted that even passes that are empty currently dispatch some compute shader work. That should also be fixed. ### GPU debug overhead When profiling, one must disable `draw::Texture::debug_clear()`. It introduces a lot of clear operations that are not existing in the legacy API (thus, not there in Overlay Legacy).
Contributor

@fclem
What needs to be done for "Curves"? In object mode they are already drawn;
What is meant by "Pose bone select" and "Fade"?

@fclem What needs to be done for "Curves"? In object mode they are already drawn; What is meant by "Pose bone select" and "Fade"?

@laurynas

  • "Pose bone select" is drawn by OVERLAY_pose_draw.
  • "Fade" is drawn by OVERLAY_fade_draw
@laurynas - "Pose bone select" is drawn by `OVERLAY_pose_draw`. - "Fade" is drawn by `OVERLAY_fade_draw`

I was investigating crash when switching to shading workspace, and realized this happens with overlay next. Don't see this mentioned here, so in case you are not aware, here is trace:

Trace

draw::overlay::State::rv3d was null in

blender::draw::overlay::State::view_dist_get(const blender::draw::overlay::State * const this, const blender::float4x4 & winmat) (/home/me/blender-git/1/source/blender/draw/engines/overlay/overlay_next_private.hh:64)
blender::draw::overlay::Meshes::begin_sync(blender::draw::overlay::Meshes * const this, blender::draw::overlay::Resources & res, const blender::draw::overlay::State & state, const blender::draw::View & view) (/home/me/blender-git/1/source/blender/draw/engines/overlay/overlay_next_mesh.hh:67)
operator()(const struct {...} * const __closure, blender::draw::overlay::Instance::OverlayLayer & layer) (/home/me/blender-git/1/source/blender/draw/engines/overlay/overlay_next_instance.cc:98)
blender::draw::overlay::Instance::begin_sync(blender::draw::overlay::Instance * const this) (/home/me/blender-git/1/source/blender/draw/engines/overlay/overlay_next_instance.cc:103)
OVERLAY_next_cache_init(void * vedata) (/home/me/blender-git/1/source/blender/draw/engines/overlay/overlay_next_engine.cc:55)
drw_engines_cache_init() (/home/me/blender-git/1/source/blender/draw/intern/draw_manager_c.cc:1056)
DRW_draw_render_loop_2d_ex(Depsgraph * depsgraph, ARegion * region, GPUViewport * viewport, const bContext * evil_C) (/home/me/blender-git/1/source/blender/draw/intern/draw_manager_c.cc:2250)
DRW_draw_view(const bContext * C) (/home/me/blender-git/1/source/blender/draw/intern/draw_manager_c.cc:1653)
image_main_region_draw(const bContext * C, ARegion * region) (/home/me/blender-git/1/source/blender/editors/space_image/space_image.cc:644)
ED_region_do_draw(bContext * C, ARegion * region) (/home/me/blender-git/1/source/blender/editors/screen/area.cc:528)
wm_draw_window_offscreen(bContext * C, wmWindow * win, bool stereo) (/home/me/blender-git/1/source/blender/windowmanager/intern/wm_draw.cc:1006)
wm_draw_window(bContext * C, wmWindow * win) (/home/me/blender-git/1/source/blender/windowmanager/intern/wm_draw.cc:1173)
wm_draw_update(bContext * C) (/home/me/blender-git/1/source/blender/windowmanager/intern/wm_draw.cc:1574)
WM_main(bContext * C) (/home/me/blender-git/1/source/blender/windowmanager/intern/wm.cc:643)
main(int argc, const char ** argv) (/home/me/blender-git/1/source/creator/creator.cc:596)

Feel free to repoen #127477 if this should be reported on tracker already.

I was investigating crash when switching to shading workspace, and realized this happens with overlay next. Don't see this mentioned here, so in case you are not aware, here is trace: <details><summary>Trace</summary> `draw::overlay::State::rv3d` was null in ``` blender::draw::overlay::State::view_dist_get(const blender::draw::overlay::State * const this, const blender::float4x4 & winmat) (/home/me/blender-git/1/source/blender/draw/engines/overlay/overlay_next_private.hh:64) blender::draw::overlay::Meshes::begin_sync(blender::draw::overlay::Meshes * const this, blender::draw::overlay::Resources & res, const blender::draw::overlay::State & state, const blender::draw::View & view) (/home/me/blender-git/1/source/blender/draw/engines/overlay/overlay_next_mesh.hh:67) operator()(const struct {...} * const __closure, blender::draw::overlay::Instance::OverlayLayer & layer) (/home/me/blender-git/1/source/blender/draw/engines/overlay/overlay_next_instance.cc:98) blender::draw::overlay::Instance::begin_sync(blender::draw::overlay::Instance * const this) (/home/me/blender-git/1/source/blender/draw/engines/overlay/overlay_next_instance.cc:103) OVERLAY_next_cache_init(void * vedata) (/home/me/blender-git/1/source/blender/draw/engines/overlay/overlay_next_engine.cc:55) drw_engines_cache_init() (/home/me/blender-git/1/source/blender/draw/intern/draw_manager_c.cc:1056) DRW_draw_render_loop_2d_ex(Depsgraph * depsgraph, ARegion * region, GPUViewport * viewport, const bContext * evil_C) (/home/me/blender-git/1/source/blender/draw/intern/draw_manager_c.cc:2250) DRW_draw_view(const bContext * C) (/home/me/blender-git/1/source/blender/draw/intern/draw_manager_c.cc:1653) image_main_region_draw(const bContext * C, ARegion * region) (/home/me/blender-git/1/source/blender/editors/space_image/space_image.cc:644) ED_region_do_draw(bContext * C, ARegion * region) (/home/me/blender-git/1/source/blender/editors/screen/area.cc:528) wm_draw_window_offscreen(bContext * C, wmWindow * win, bool stereo) (/home/me/blender-git/1/source/blender/windowmanager/intern/wm_draw.cc:1006) wm_draw_window(bContext * C, wmWindow * win) (/home/me/blender-git/1/source/blender/windowmanager/intern/wm_draw.cc:1173) wm_draw_update(bContext * C) (/home/me/blender-git/1/source/blender/windowmanager/intern/wm_draw.cc:1574) WM_main(bContext * C) (/home/me/blender-git/1/source/blender/windowmanager/intern/wm.cc:643) main(int argc, const char ** argv) (/home/me/blender-git/1/source/creator/creator.cc:596) ``` </details> Feel free to repoen #127477 if this should be reported on tracker already.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#102179
No description provided.