Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jbakker>2021-09-10 15:26:21 +0300
committerJeroen Bakker <jeroen@blender.org>2021-09-10 15:31:00 +0300
commit7f1fe10595065128aab2a4aea4bc9c46e155053c (patch)
tree67c1079b40d14d3958ecd61b45b8f640abf4c0db
parenta1167e910a22077a6738edc3ee8e57ab4d5d62dd (diff)
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
-rw-r--r--source/blender/editors/animation/keyframes_draw.c22
1 files changed, 18 insertions, 4 deletions
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)