From 9f82732e1ece48772d0b1a532a69ff739c9dde16 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Mon, 10 Jul 2023 14:36:29 -0700 Subject: til: introduce "noop" builtin When profiling compositions it's convenient to suppress some modules in the settings to see how their omission affects the FPS. There's already a "blank" builtin which clears the fragment, but there's no way to turn the cost to ~zero. This "noop" builtin does just that, absolutely nothing - it won't even trigger the implicit "til_fb_fragment_t.cleared = 1" update so whatever rendering follows will still find an uncleared fragment if that's what came into the noop. --- src/til.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/til.c b/src/til.c index f8e8d4a..d374759 100644 --- a/src/til.c +++ b/src/til.c @@ -163,6 +163,14 @@ static til_module_t _blank_module = { }; +/* "noop" built-in module */ +static til_module_t _noop_module = { + .name = "noop", + .description = "built-in nothing-doer", + .author = "built-in", +}; + + /* "ref" built-in module */ #include "libs/txt/txt.h" /* for rendering some diagnostics */ @@ -294,6 +302,7 @@ const til_module_t * til_lookup_module(const char *name) { static const til_module_t *builtins[] = { &_blank_module, + &_noop_module, &_ref_module, }; static struct { @@ -380,6 +389,7 @@ char * til_get_module_names(unsigned flags_excluded, const char **exclusions) static void module_render_fragment(til_module_context_t *context, til_stream_t *stream, til_threads_t *threads, unsigned ticks, til_fb_fragment_t **fragment_ptr) { const til_module_t *module; + int touched = 0; assert(context); assert(context->module); @@ -412,13 +422,18 @@ static void module_render_fragment(til_module_context_t *context, til_stream_t * while (frame_plan.fragmenter(context, *fragment_ptr, fragnum++, &frag)) module->render_fragment(context, stream, ticks, 0, &frag_ptr); } - } else if (module->render_fragment) + touched++; + } else if (module->render_fragment) { module->render_fragment(context, stream, ticks, 0, fragment_ptr); + touched++; + } - if (module->finish_frame) + if (module->finish_frame) { module->finish_frame(context, stream, ticks, fragment_ptr); + touched++; + } - (*fragment_ptr)->cleared = 1; + (*fragment_ptr)->cleared = !!touched; } -- cgit v1.2.3