Use threading for simple gpu buffer mesh extractions. #88350

Open
opened 2021-05-17 14:46:58 +02:00 by Jeroen Bakker · 2 comments
Member

When using smaller meshes threading adds overhead. For this reason simple extractions are run single threaded.
At a point a mesh can so large that it benefits using threading.

In file draw_cache_extract_mesh.c several batch extractions are defined. The extractions that don't use threading are:

  • extract_tris
  • extract_lines
  • extract_lines_with_lines_loose
  • extract_points
  • extract_fdots
  • extract_lines_paint_mask
  • extract_lines_adjacency
  • extract_edituv_tris
  • extract_edituv_lines
  • extract_edituv_points
  • extract_edituv_fdots
  • extract_uv
  • extract_tan/hq
  • extract_sculpt_data
  • extract_vcol
  • extract_edge_fac
  • extract_edituv_stretch_area
  • extract_edituv_stretch_angle
  • extract_mesh_analysis
  • extract_fdots_nor/hq
  • extract_skin_roots

This task should find out the reason why threading is disabled on them. Document the reason why threading is disabled.

Proof

Using D11255: Performance: GPU Batch Baseline TestCase. the baseline takes between 1111ms and 1180ms.
When changing extract_points to use threading between 1089ms and 1100ms.

Using similar tests when using small meshes (1000 faces) 622ms (not threaded vs 625ms using threading)

diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c
index f167ea3d540..dcacbf104dc 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.c
@@ -1248,7 +1248,7 @@ static const MeshExtract extract_points = {
     .iter_lvert_mesh = extract_points_iter_lvert_mesh,
     .finish = extract_points_finish,
     .data_flag = 0,
-    .use_threading = false,
+    .use_threading = true,
 };
 
 /** \} */
@@ -1329,7 +1329,7 @@ static const MeshExtract extract_fdots = {
     .iter_poly_mesh = extract_fdots_iter_poly_mesh,
     .finish = extract_fdots_finish,
     .data_flag = 0,
-    .use_threading = false,
+    .use_threading = true,
 };
 
 /** \} */

Edit mode batches and their threading state:

  • vbo.pos_nor (threaded)
  • vbo.lnor (threaded)
  • vbo.edit_data (threaded)
  • vbo.fdots_pos (threaded)
  • vbo.fdots_nor/hq (not threaded): Whole batch creation is done during finish with the clarification that it is faster. Would like to see both implementations and compare both. I don't see any issues makeing this multithreaded.
  • ibo.tris (not threaded): Current implementation also sorts the faces on its material number. This might need more changes to be threaded. (thread per material, or special implementation when using one material. We could also consider a different tris when material sorting isn't needed.
  • ibo.points (not threaded): Don't see any reason why this one cannot be threaded.
  • ibo.fdots (not threaded): Don't see any reason why this one cannot be threaded. Didn't see that much of performance differences.

Conclusion

  • make points and fdots threaded. #88351
  • research threading for ibo.tris #88352
  • research threading for ibo.fdots_nor #88353
When using smaller meshes threading adds overhead. For this reason simple extractions are run single threaded. At a point a mesh can so large that it benefits using threading. In file `draw_cache_extract_mesh.c` several batch extractions are defined. The extractions that don't use threading are: * extract_tris * extract_lines * extract_lines_with_lines_loose * extract_points * extract_fdots * extract_lines_paint_mask * extract_lines_adjacency * extract_edituv_tris * extract_edituv_lines * extract_edituv_points * extract_edituv_fdots * extract_uv * extract_tan/hq * extract_sculpt_data * extract_vcol * extract_edge_fac * extract_edituv_stretch_area * extract_edituv_stretch_angle * extract_mesh_analysis * extract_fdots_nor/hq * extract_skin_roots This task should find out the reason why threading is disabled on them. Document the reason why threading is disabled. ## Proof Using [D11255: Performance: GPU Batch Baseline TestCase.](https://archive.blender.org/developer/D11255) the baseline takes between 1111ms and 1180ms. When changing extract_points to use threading between 1089ms and 1100ms. Using similar tests when using small meshes (1000 faces) 622ms (not threaded vs 625ms using threading) ``` diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c index f167ea3d540..dcacbf104dc 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh.c @@ -1248,7 +1248,7 @@ static const MeshExtract extract_points = { .iter_lvert_mesh = extract_points_iter_lvert_mesh, .finish = extract_points_finish, .data_flag = 0, - .use_threading = false, + .use_threading = true, }; /** \} */ @@ -1329,7 +1329,7 @@ static const MeshExtract extract_fdots = { .iter_poly_mesh = extract_fdots_iter_poly_mesh, .finish = extract_fdots_finish, .data_flag = 0, - .use_threading = false, + .use_threading = true, }; /** \} */ ``` Edit mode batches and their threading state: * vbo.pos_nor (threaded) * vbo.lnor (threaded) * vbo.edit_data (threaded) * vbo.fdots_pos (threaded) * vbo.fdots_nor/hq (not threaded): Whole batch creation is done during `finish` with the clarification that it is faster. Would like to see both implementations and compare both. I don't see any issues makeing this multithreaded. * ibo.tris (not threaded): Current implementation also sorts the faces on its material number. This might need more changes to be threaded. (thread per material, or special implementation when using one material. We could also consider a different tris when material sorting isn't needed. * ibo.points (not threaded): Don't see any reason why this one cannot be threaded. * ibo.fdots (not threaded): Don't see any reason why this one cannot be threaded. Didn't see that much of performance differences. ## Conclusion * make points and fdots threaded. #88351 * research threading for ibo.tris #88352 * research threading for ibo.fdots_nor #88353
Jeroen Bakker self-assigned this 2021-05-17 14:46:58 +02:00
Author
Member
Added subscribers: @Jeroen-Bakker, @machieb, @warcanin, @fclem, @GeorgiaPacific, @kioku, @JorgeBernalMartinez, @elias.andersson92, @TheRedWaxPolice, @JacobMerrill-1, @ideasman42
Author
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Jeroen Bakker removed their assignment 2021-05-17 15:02:49 +02:00
Philipp Oeser removed the
Interest
EEVEE & Viewport
label 2023-02-09 15:13:40 +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 project
No Assignees
1 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#88350
No description provided.