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
This commit is contained in:
Jeroen Bakker 2021-09-10 14:26:21 +02:00 committed by Jeroen Bakker
parent a1167e910a
commit 7f1fe10595
Notes: blender-bot 2023-02-13 22:39:58 +01:00
Referenced by commit bb3de31f84, Revert "T78995: Enable keylist threaded drawing."
Referenced by issue #92549, Keyframes Freak Out While Tweaking NLA Strip
Referenced by issue #78995, Poor performance in Timeline, Dope Sheet, etc when at the top of the editor.
1 changed files with 18 additions and 4 deletions

View File

@ -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)