Sculpt & Pbvh Drawing Speedup #97665

Open
opened 2022-04-27 22:16:58 +02:00 by Clément Foucault · 1 comment

Problem overview:

Sculpted meshes are drawn as little chunks of geometry. Each leaf node inside the PBVH (sculpt acceleration structure) produces one draw call with a dedicated vertex buffer. These leaf nodes are currently frustum culled on CPU for each draw pass.

The main issues are:
1 - CPU culling overhead of high leaf nodes counts. Not a real problem but if we want better culling, higher node count will help.
2 - No advanced culling of completely facing away leaf nodes.
3 - Driver overhead caused by high VAO/VBO switching. Also sub-optimal data layout for transfer.
4 - Overhead of using flat normals (cannot shared vertices between tris).

Proposed improvements:
1 - Port culling on the GPU using compute and multi indirect drawcalls. Could cull subpixel nodes if they are not visible.
2 - Use visible cone culling [TODO add link to resource here]. The cone could be computed by a compute shader and cached.
3 - Merge all VBOs into 1 that can be updated using range mapping. Simplify data layout.
4 - Implement a global fallback in fragment shader when N == vec3(0) to use Ng (geometric normal generated from derivatives).

Note that all these are independent from each others and can be implemented in any order.

Requirements:

1 - Requires that we wrap a GPUDrawList buffer inside a GPUBatch. This way the draw is issued on CPU but computed on GPU.
2 - Have the same requirements as 1.
3 - Implement mapping with range in VBO/IBO.
4 - No requirements.

Further investigation:

  • Use occlusion culling? Could use an approach similar to Nanite [TODO add link to resource here]. Downside: we need per views cache and HiZ. Seems hard to pull off.
  • Use fast-path no-fragment shader. Could be a special draw path for workbench (because simpler pipeline). Normals are derived later from a fullscreen pass using very fine derivative (9 samples or 5 gathers). Fast path disabled if different materials are needed (or use the stencil mask for a maximum of 255 different materials?) or if any vertex attributes are needed (smooth normals, uvs for texturing, vertex colors). This would fix the performance issue of quad overdraw.
  • Bake triangle stripe topology or sort triangles to improve vertex cache hit (on nodes that are not being updated).
## Problem overview: Sculpted meshes are drawn as little chunks of geometry. Each leaf node inside the PBVH (sculpt acceleration structure) produces one draw call with a dedicated vertex buffer. These leaf nodes are currently frustum culled on CPU for each draw pass. The main issues are: 1 - CPU culling overhead of high leaf nodes counts. Not a real problem but if we want better culling, higher node count will help. 2 - No advanced culling of completely facing away leaf nodes. 3 - Driver overhead caused by high VAO/VBO switching. Also sub-optimal data layout for transfer. 4 - Overhead of using flat normals (cannot shared vertices between tris). **Proposed improvements:** 1 - Port culling on the GPU using compute and multi indirect drawcalls. Could cull subpixel nodes if they are not visible. 2 - Use visible cone culling [TODO add link to resource here]. The cone could be computed by a compute shader and cached. 3 - Merge all VBOs into 1 that can be updated using range mapping. Simplify data layout. 4 - Implement a global fallback in fragment shader when `N == vec3(0)` to use `Ng` (geometric normal generated from derivatives). Note that all these are independent from each others and can be implemented in any order. ### Requirements: 1 - Requires that we wrap a `GPUDrawList` buffer inside a GPUBatch. This way the draw is issued on CPU but computed on GPU. 2 - Have the same requirements as 1. 3 - Implement mapping with range in VBO/IBO. 4 - No requirements. ### Further investigation: - Use occlusion culling? Could use an approach similar to Nanite [TODO add link to resource here]. Downside: we need per views cache and HiZ. Seems hard to pull off. - Use fast-path no-fragment shader. Could be a special draw path for workbench (because simpler pipeline). Normals are derived later from a fullscreen pass using very fine derivative (9 samples or 5 gathers). Fast path disabled if different materials are needed (or use the stencil mask for a maximum of 255 different materials?) or if any vertex attributes are needed (smooth normals, uvs for texturing, vertex colors). This would fix the performance issue of quad overdraw. - Bake triangle stripe topology or sort triangles to improve vertex cache hit (on nodes that are not being updated).

1 - Port culling on the GPU using compute and multi indirect drawcalls. Could cull subpixel nodes if they are not visible.

is the better solution for my opinion.

1 - Port culling on the GPU using compute and multi indirect drawcalls. Could cull subpixel nodes if they are not visible. is the better solution for my opinion.
Julien Kaspar added this to the Sculpt, Paint & Texture project 2023-02-08 10:20:48 +01:00
Philipp Oeser removed the
Interest
Sculpt, Paint & Texture
label 2023-02-10 09:11:29 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
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
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
2 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#97665
No description provided.