PBVH Draw Refactor #88586

Open
opened 2021-05-26 07:11:51 +02:00 by Joseph Eagar · 6 comments
Member

When I first started refactoring DynTopo I naively thought I was supposed to get PBVH drawing working in EEVEE. This involved quite a lot of work, but resulted in a major speedup. Here's a test video showing the difference in performance:

https://www.youtube.com/watch?v=qinjgVZ6Evo

The purpose of this task is to lay out the next steps.

Draw cache should provide API to convert and upload customdata layers

Once the dyntopo improvements are merged sculpt mode will support customdata properly for all three PBVH types. Combine this with the geometry nodes project and I think it's safe to say Blender users are going to be creating a lot of attribute layers in the future.

It would be nice if the draw cache system provided an API that took customdata data and converted it to (an arbitrary) GPU vertex data type. I prototyped a very basic system in my branch (it's the code inside the #ifdef NEW_ATTR_SYSTEM blocks):

https://developer.blender.org/diffusion/B/browse/temp_bmesh_multires/source/blender/gpu/intern/gpu_buffers.c

Note that this is not a candidate for the draw cache API. It's a placeholder so I can clean up the PBVH draw builder code and get PBVH_FACES/PBVH_GRIDS to work in EEVEE mode too. This sort of thing should really be written in C++ and use the attribute classes for conversion.

Add proper uv/color support to PBVH_FACES and PBVH_GRIDS

See above

Generate index buffers split by UV islands

Indexed drawing can be quite a bit faster (in my tests it's about 40-50% faster). For DynTopo
indexed drawing currently happens when "Draw Smooth" is enabled and there are no UV layers.

We could split the index buffers by UV islands. I'm thinking of using meshoptimizer for this.

Add support for fragment-based flat shading to viewport drawing

The downside of indexed drawing is that the only way to support flat shading for faces (without
losing all the benefits of indexing) is derive plane normals in the fragment shader. It would be
nice if the viewport devs could implement this though it's not a high priority.

Add support for partial or full deinterleaving to draw cache code

I talked to the meshoptimizer devs and they recommended we look at either partial or full vertex attribute deinterleaving. The idea is to put position (and I guess normals) in one gpu buffer, and everything else in another. This isn't a high priority but it would be nice to have, and could provide a hefty speedup for some meshes.

When I first started refactoring DynTopo I naively thought I was supposed to get PBVH drawing working in EEVEE. This involved quite a lot of work, but resulted in a major speedup. Here's a test video showing the difference in performance: https://www.youtube.com/watch?v=qinjgVZ6Evo The purpose of this task is to lay out the next steps. ## Draw cache should provide API to convert and upload customdata layers Once the dyntopo improvements are merged sculpt mode will support customdata properly for all three PBVH types. Combine this with the geometry nodes project and I think it's safe to say Blender users are going to be creating a *lot* of attribute layers in the future. It would be nice if the draw cache system provided an API that took customdata data and converted it to (an arbitrary) GPU vertex data type. I prototyped a very basic system in my branch (it's the code inside the #ifdef NEW_ATTR_SYSTEM blocks): https://developer.blender.org/diffusion/B/browse/temp_bmesh_multires/source/blender/gpu/intern/gpu_buffers.c **Note that this is not a candidate for the draw cache API**. It's a placeholder so I can clean up the PBVH draw builder code and get PBVH_FACES/PBVH_GRIDS to work in EEVEE mode too. This sort of thing should really be written in C++ and use the attribute classes for conversion. ## Add proper uv/color support to PBVH_FACES and PBVH_GRIDS See above ## Generate index buffers split by UV islands Indexed drawing can be quite a bit faster (in my tests it's about 40-50% faster). For DynTopo indexed drawing currently happens when "Draw Smooth" is enabled *and* there are no UV layers. We could split the index buffers by UV islands. I'm thinking of using [meshoptimizer ](https://github.com/zeux/meshoptimizer) for this. ## Add support for fragment-based flat shading to viewport drawing The downside of indexed drawing is that the only way to support flat shading for faces (without losing all the benefits of indexing) is derive plane normals in the fragment shader. It would be nice if the viewport devs could implement this though it's not a high priority. # Add support for partial or full deinterleaving to draw cache code I talked to the meshoptimizer devs and they recommended we look at either partial or full vertex attribute deinterleaving. The idea is to put position (and I guess normals) in one gpu buffer, and everything else in another. This isn't a high priority but it would be nice to have, and could provide a hefty speedup for some meshes.
Author
Member

Added subscriber: @JosephEagar

Added subscriber: @JosephEagar

Added subscriber: @GeorgiaPacific

Added subscriber: @GeorgiaPacific

Added subscriber: @TheRedWaxPolice

Added subscriber: @TheRedWaxPolice

Added subscriber: @BertVandenBosch

Added subscriber: @BertVandenBosch
Member

Added subscriber: @JulienKaspar

Added subscriber: @JulienKaspar
Member

@JosephEagar How much does this task relate to the recent PBVH Draw Refactor patch? Are there still to do's left over from here?

@JosephEagar How much does this task relate to the recent PBVH Draw Refactor patch? Are there still to do's left over from here?
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:50 +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
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#88586
No description provided.