VSE: Faster timeline retiming keys drawing
Previous change in there (d0cf4a4a8b, in 4.3 only) reverted
retiming keys to have one draw call per strip again. Which gets fairly
expensive if many strips have retiming keys.
However! All the strips are already drawn in two parts: all the regular
strips first, and then all the strips that are being "dragged over"
the other strips. So we can totally draw retiming keys for the whole
batch of strips at once, and it will just work out fine.
Viewing whole Sprite Fright Edit v135 timeline, on PC (Ryzen 5950X,
Win10/VS2022): draw_timeline_seq 7.4ms -> 5.8ms
(sequencer_retiming_keys_draw part 1.7ms -> 0.3ms)
Pull Request: https://projects.blender.org/blender/blender/pulls/128170
This commit is contained in:
committed by
Aras Pranckevicius
parent
590123d2e5
commit
f095f41c4a
@@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "BLI_map.hh"
|
||||
#include "BLI_span.hh"
|
||||
#include "BLI_utility_mixins.hh"
|
||||
#include "BLI_vector.hh"
|
||||
#include "BLI_vector_set.hh"
|
||||
@@ -367,7 +368,7 @@ int sequencer_retiming_box_select_exec(bContext *C, wmOperator *op);
|
||||
void sequencer_retiming_draw_continuity(const TimelineDrawContext *timeline_ctx,
|
||||
const StripDrawContext &strip_ctx);
|
||||
void sequencer_retiming_keys_draw(const TimelineDrawContext *timeline_ctx,
|
||||
const StripDrawContext &strip_ctx);
|
||||
blender::Span<StripDrawContext> strips);
|
||||
void sequencer_retiming_speed_draw(const TimelineDrawContext *timeline_ctx,
|
||||
const StripDrawContext &strip_ctx);
|
||||
void realize_fake_keys(const Scene *scene, Sequence *seq);
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_span.hh"
|
||||
|
||||
#include "DNA_sequence_types.h"
|
||||
|
||||
@@ -19,6 +18,7 @@
|
||||
#include "BLF_api.hh"
|
||||
|
||||
#include "GPU_batch.hh"
|
||||
#include "GPU_matrix.hh"
|
||||
#include "GPU_state.hh"
|
||||
|
||||
#include "WM_api.hh"
|
||||
@@ -396,16 +396,19 @@ static bool fake_keys_draw(const TimelineDrawContext *timeline_ctx,
|
||||
}
|
||||
|
||||
void sequencer_retiming_keys_draw(const TimelineDrawContext *timeline_ctx,
|
||||
const StripDrawContext &strip_ctx)
|
||||
blender::Span<StripDrawContext> strips)
|
||||
{
|
||||
if (!can_draw_retiming(timeline_ctx, strip_ctx)) {
|
||||
if (strips.is_empty()) {
|
||||
return;
|
||||
}
|
||||
if (timeline_ctx->ed == nullptr || !retiming_keys_can_be_displayed(timeline_ctx->sseq)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GPU_matrix_push_projection();
|
||||
wmOrtho2_region_pixelspace(timeline_ctx->region);
|
||||
|
||||
const View2D *v2d = timeline_ctx->v2d;
|
||||
const Sequence *seq = strip_ctx.seq;
|
||||
|
||||
GPUVertFormat *format = immVertexFormat();
|
||||
KeyframeShaderBindings sh_bindings;
|
||||
@@ -426,26 +429,33 @@ void sequencer_retiming_keys_draw(const TimelineDrawContext *timeline_ctx,
|
||||
int point_counter = 0;
|
||||
immBeginAtMost(GPU_PRIM_POINTS, MAX_KEYS_IN_BATCH);
|
||||
|
||||
if (fake_keys_draw(timeline_ctx, strip_ctx, sh_bindings)) {
|
||||
point_counter += 2;
|
||||
}
|
||||
for (const StripDrawContext &strip_ctx : strips) {
|
||||
if (!can_draw_retiming(timeline_ctx, strip_ctx)) {
|
||||
continue;
|
||||
}
|
||||
if (fake_keys_draw(timeline_ctx, strip_ctx, sh_bindings)) {
|
||||
point_counter += 2;
|
||||
}
|
||||
|
||||
for (const SeqRetimingKey &key : SEQ_retiming_keys_get(seq)) {
|
||||
retime_key_draw(timeline_ctx, strip_ctx, &key, sh_bindings);
|
||||
point_counter++;
|
||||
for (const SeqRetimingKey &key : SEQ_retiming_keys_get(strip_ctx.seq)) {
|
||||
retime_key_draw(timeline_ctx, strip_ctx, &key, sh_bindings);
|
||||
point_counter++;
|
||||
|
||||
/* Next key plus possible two fake keys for next sequence would need at
|
||||
* most 3 points, so restart the batch if we're close to that. */
|
||||
if (point_counter + 3 >= MAX_KEYS_IN_BATCH) {
|
||||
immEnd();
|
||||
immBeginAtMost(GPU_PRIM_POINTS, MAX_KEYS_IN_BATCH);
|
||||
point_counter = 0;
|
||||
/* Next key plus possible two fake keys for next sequence would need at
|
||||
* most 3 points, so restart the batch if we're close to that. */
|
||||
if (point_counter + 3 >= MAX_KEYS_IN_BATCH) {
|
||||
immEnd();
|
||||
immBeginAtMost(GPU_PRIM_POINTS, MAX_KEYS_IN_BATCH);
|
||||
point_counter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
immEnd();
|
||||
GPU_program_point_size(false);
|
||||
immUnbindProgram();
|
||||
|
||||
GPU_matrix_pop_projection();
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -1550,10 +1550,9 @@ static void draw_seq_strips(TimelineDrawContext *timeline_ctx,
|
||||
draw_handle_transform_text(timeline_ctx, &strip_ctx, SEQ_HANDLE_LEFT);
|
||||
draw_handle_transform_text(timeline_ctx, &strip_ctx, SEQ_HANDLE_RIGHT);
|
||||
draw_seq_text_overlay(timeline_ctx, &strip_ctx);
|
||||
sequencer_retiming_keys_draw(timeline_ctx, strip_ctx);
|
||||
sequencer_retiming_speed_draw(timeline_ctx, strip_ctx);
|
||||
}
|
||||
|
||||
sequencer_retiming_keys_draw(timeline_ctx, strips);
|
||||
timeline_ctx->quads->draw();
|
||||
|
||||
draw_strips_foreground(timeline_ctx, strips_batch, strips);
|
||||
|
||||
Reference in New Issue
Block a user