From e550c9e8c6ffcdc902b56393609e76a8b191b279 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 6 Aug 2023 18:20:33 -0700 Subject: modules/roto: only update fill_fb on changed ticks In compositions where roto recurs in the same frame, it's wasteful to keep rendering the fill_fb contents manifold for the same tick. They shouldn't be varying anyways... It'd be different if the fill_module rendered directly to the output fragment in an overlay manner, but the current roto implementation doesn't do that. It's just sampling fill_fb like a tiled texture sampler would. The performance hit here is easily observed by doing something like: --module='checkers,size=4,fill_module=roto\,fill_module\=moire' --video=mem --defaults --go Before this change, FPS=1 on my i7 X230. After, FPS=~400. --- src/modules/roto/roto.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/modules') diff --git a/src/modules/roto/roto.c b/src/modules/roto/roto.c index f69d010..b040b1d 100644 --- a/src/modules/roto/roto.c +++ b/src/modules/roto/roto.c @@ -329,8 +329,8 @@ static void roto_prepare_frame(til_module_context_t *context, til_stream_t *stre *res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_slice_per_cpu_x16 }; - // This governs the rotation and color cycle. if (ticks != context->last_ticks) { + /* This governs the rotation and color cycle. */ ctxt->r += FIXED_TO_INT(FIXED_MULT(FIXED_SIN(ctxt->rr), FIXED_NEW(16))); ctxt->rr += (ticks - context->last_ticks) >> 2; @@ -342,13 +342,13 @@ static void roto_prepare_frame(til_module_context_t *context, til_stream_t *stre ctxt->palette[1].r = (FIXED_MULT(FIXED_SIN(ctxt->rr / 2), FIXED_NEW(127)) + FIXED_NEW(128)); ctxt->palette[1].g = (FIXED_MULT(FIXED_COS(ctxt->rr / 2), FIXED_NEW(127)) + FIXED_NEW(128)); ctxt->palette[1].b = (FIXED_MULT(FIXED_SIN(ctxt->rr), FIXED_NEW(127)) + FIXED_NEW(128)); - } - if (ctxt->fill_module_context) { - til_fb_fragment_t *fb_ptr = &ctxt->fill_fb; + if (ctxt->fill_module_context) { + til_fb_fragment_t *fb_ptr = &ctxt->fill_fb; - ctxt->fill_fb.cleared = 0; - til_module_render(ctxt->fill_module_context, stream, ticks, &fb_ptr); + ctxt->fill_fb.cleared = 0; + til_module_render(ctxt->fill_module_context, stream, ticks, &fb_ptr); + } } } -- cgit v1.2.3