Page MenuHome

DrawManager: Graph Task Scheduling
ClosedPublic

Authored by Jeroen Bakker (jbakker) on May 4 2020, 3:33 PM.

Details

Summary

This patch uses a graph flow scheduler for creating all mesh batches.
On a Ryzen 1700 the framerate of Spring/020_02A.anim.blend went from 10 fps to 11.5 fps.

Flame graph before applying patch

Flame graph after applying patch

For each mesh where batches needs to be updated a sub-graph will be added to the task_graph.
This sub-graph starts with an extract_render_data_node. This fills/converts the required data
from Mesh.

Small extractions and extractions that can't be multi-threaded are grouped in a single
extract_single_threaded_task_node.

Other extractions will create a node for each loop exceeding 4096 items. these nodes are
linked to the user_data_init_task_node. the user_data_init_task_node prepares the userdata
needed for the extraction based on the data extracted from the mesh.

Note: If the lines and lines_loose are requested, the lines_loose sub-buffer is created
as part of the lines extraction. When the lines_loose is only requested the sub-buffer is
created from the existing lines buffer. It is assumed that the lines buffer is always
requested before or together with the lines_loose what is always the case (see
DRW_batch_requested(cache->batch.loose_edges, GPU_PRIM_LINES) in draw_cache_impl_mesh.c).

Diff Detail

Repository
rB Blender

Event Timeline

Jeroen Bakker (jbakker) requested review of this revision.May 4 2020, 3:33 PM
Jeroen Bakker (jbakker) created this revision.
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)May 7 2020, 3:55 PM
  • Updated with latest chanhes of 'T76255'
  • Merge branch 'master' into arcpatch-D7618
  • Merge branch 'master' into arcpatch-D7618
Jeroen Bakker (jbakker) retitled this revision from [WIP] DrawManager: Graph Task Scheduling to DrawManager: Graph Task Scheduling.May 25 2020, 1:39 PM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)May 25 2020, 2:27 PM
  • Added documentation and clean-up the code

I think the patch is fine. I just have some minor questions / style comments.

source/blender/draw/intern/draw_cache_extract_mesh.c
4813–4820

Why is this? why must you separate into 2 allocations?

4921

style: check for NULL. I believe the cast can make bool != (1|0) which is not an issue here but just better in some cases.

source/blender/draw/intern/draw_cache_impl_mesh.c
1181

left over comments?

source/blender/editors/uvedit/uvedit_draw.c
210–213

Is the taskgraph creation almost free? This function runs every redraw for the UV editor.

This revision is now accepted and ready to land.Jun 2 2020, 11:54 AM
Jeroen Bakker (jbakker) marked 3 inline comments as done.
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)

Code review

  • Added comments
  • Missed uncomment debug code
Jeroen Bakker (jbakker) marked an inline comment as done.Jun 2 2020, 3:44 PM
Jeroen Bakker (jbakker) added inline comments.
source/blender/draw/intern/draw_cache_extract_mesh.c
4813–4820

I will document.
The taskdata->user_data->user_data contains the counters that must be shared with the extract iterations. The ExtractTaskData can be copied deallocation needs to happen once.
This structure makes sure that when extract_init is called, that the user data of all iterations are updated.

source/blender/editors/uvedit/uvedit_draw.c
210–213

It is very cheap. MEM_alloc + cpp template initialization.

This revision was automatically updated to reflect the committed changes.
Jeroen Bakker (jbakker) marked an inline comment as done.