[Bf-blender-cvs] [7f1fe105950] master: T78995: Enable keylist threaded drawing.

Jeroen Bakker noreply at git.blender.org
Fri Sep 10 14:31:37 CEST 2021


Commit: 7f1fe10595065128aab2a4aea4bc9c46e155053c
Author: Jeroen Bakker
Date:   Fri Sep 10 14:26:21 2021 +0200
Branches: master
https://developer.blender.org/rB7f1fe10595065128aab2a4aea4bc9c46e155053c

T78995: Enable keylist threaded drawing.

This enabled multithreaded building of the keys that needs to be drawn
in the timeline (and other action editors).

On an AMD Ryzen 3800 using a mocap data test file (available in patch)
the performance went from 2fps to 8fps. The performance increase depends
on the number of rows of keyframes that is shown in for example the
timeline editor.

Each row will be using a different thread. Currently the bottleneck is
the summary channel that we could split up in the future even more (
although that is a complex refactoring work).

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D12198

===================================================================

M	source/blender/editors/animation/keyframes_draw.c

===================================================================

diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 8a884c0bd5b..d9a22c47242 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -30,6 +30,7 @@
 #include "BLI_dlrbTree.h"
 #include "BLI_listbase.h"
 #include "BLI_rect.h"
+#include "BLI_task.h"
 
 #include "DNA_anim_types.h"
 #include "DNA_gpencil_types.h"
@@ -504,12 +505,25 @@ AnimKeylistDrawList *ED_keylist_draw_list_create(void)
   return MEM_callocN(sizeof(AnimKeylistDrawList), __func__);
 }
 
+static void ED_keylist_draw_list_elem_build_task(void *__restrict UNUSED(userdata),
+                                                 void *item,
+                                                 int UNUSED(index),
+                                                 const TaskParallelTLS *__restrict UNUSED(tls))
+{
+  AnimKeylistDrawListElem *elem = item;
+  ED_keylist_draw_list_elem_build_keylist(elem);
+  ED_keylist_draw_list_elem_prepare_for_drawing(elem);
+}
+
 static void ED_keylist_draw_list_build_keylists(AnimKeylistDrawList *draw_list)
 {
-  LISTBASE_FOREACH (AnimKeylistDrawListElem *, elem, &draw_list->channels) {
-    ED_keylist_draw_list_elem_build_keylist(elem);
-    ED_keylist_draw_list_elem_prepare_for_drawing(elem);
-  }
+  TaskParallelSettings settings;
+  BLI_parallel_range_settings_defaults(&settings);
+  /* Create a thread per item, a single item is complex enough to deserve its own thread. */
+  settings.min_iter_per_thread = 1;
+
+  BLI_task_parallel_listbase(
+      &draw_list->channels, NULL, ED_keylist_draw_list_elem_build_task, &settings);
 }
 
 static void ED_keylist_draw_list_draw_blocks(AnimKeylistDrawList *draw_list, View2D *v2d)



More information about the Bf-blender-cvs mailing list