summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-07-10 14:36:29 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-07-10 15:15:05 -0700
commit9f82732e1ece48772d0b1a532a69ff739c9dde16 (patch)
tree7dd5ef8069c94a7ec91d22453dcbf7174828860a
parent9d64c336f82a14f19a344825df2ff713aa4e9f08 (diff)
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.
-rw-r--r--src/til.c21
1 files changed, 18 insertions, 3 deletions
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;
}
© All Rights Reserved