diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-09-04 15:06:44 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-09-04 20:53:41 -0700 |
commit | bab16b070f95687ec11d43e55f3dd6e69f96a576 (patch) | |
tree | 324246c6582cd74a7240b72f2f3b11a6618b9d40 /src | |
parent | 9170d08854796f8595c9f6cebe85827a71e86e19 (diff) |
til: support multi-pass rendering
Modules can now use the til_module_t.finish_frame() return value
to trigger re-rendering by returning 1, returning 0 finishes the
frame.
A smattering of til_module_t.finish_frame() implementations were
largely mechanically updated to match this change by returning 0,
since nothing actually uses multi-pass rendering yet.
The impetus for this is experimenting with the flow module doing
two passes of threaded rendering per frame. A first pass to
sample the flow field and update the elements, per-cpu, but
drawing nothing. Then a second pass to render the elements in a
tiled manner.
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/checkers/checkers.c | 4 | ||||
-rw-r--r-- | src/modules/drizzle/drizzle.c | 4 | ||||
-rw-r--r-- | src/modules/mixer/mixer.c | 4 | ||||
-rw-r--r-- | src/modules/ray/ray.c | 4 | ||||
-rw-r--r-- | src/modules/rtv/rtv.c | 31 | ||||
-rw-r--r-- | src/modules/shapes/shapes.c | 4 | ||||
-rw-r--r-- | src/modules/strobe/strobe.c | 11 | ||||
-rw-r--r-- | src/modules/voronoi/voronoi.c | 4 | ||||
-rw-r--r-- | src/til.c | 4 | ||||
-rw-r--r-- | src/til.h | 2 |
10 files changed, 44 insertions, 28 deletions
diff --git a/src/modules/checkers/checkers.c b/src/modules/checkers/checkers.c index 360d553..43f4e1f 100644 --- a/src/modules/checkers/checkers.c +++ b/src/modules/checkers/checkers.c @@ -440,7 +440,7 @@ static void checkers_render_fragment(til_module_context_t *context, til_stream_t } -static void checkers_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr) +static int checkers_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr) { checkers_context_t *ctxt = (checkers_context_t *)context; @@ -487,6 +487,8 @@ static void checkers_finish_frame(til_module_context_t *context, til_stream_t *s #endif } } + + return 0; } diff --git a/src/modules/drizzle/drizzle.c b/src/modules/drizzle/drizzle.c index 0614632..b261448 100644 --- a/src/modules/drizzle/drizzle.c +++ b/src/modules/drizzle/drizzle.c @@ -347,12 +347,14 @@ static void drizzle_render_fragment(til_module_context_t *context, til_stream_t } -static void drizzle_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned int ticks, til_fb_fragment_t **fragment_ptr) +static int drizzle_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned int ticks, til_fb_fragment_t **fragment_ptr) { drizzle_context_t *ctxt = (drizzle_context_t *)context; if (ctxt->snapshot) ctxt->snapshot = til_fb_fragment_reclaim(ctxt->snapshot); + + return 0; } diff --git a/src/modules/mixer/mixer.c b/src/modules/mixer/mixer.c index 5ec54ed..d8c1326 100644 --- a/src/modules/mixer/mixer.c +++ b/src/modules/mixer/mixer.c @@ -271,7 +271,7 @@ static void mixer_render_fragment(til_module_context_t *context, til_stream_t *s } -static void mixer_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned int ticks, til_fb_fragment_t **fragment_ptr) +static int mixer_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned int ticks, til_fb_fragment_t **fragment_ptr) { mixer_context_t *ctxt = (mixer_context_t *)context; @@ -281,6 +281,8 @@ static void mixer_finish_frame(til_module_context_t *context, til_stream_t *stre ctxt->snapshots[i] = til_fb_fragment_reclaim(ctxt->snapshots[i]); } + + return 0; } diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c index ea44491..4c4bdd0 100644 --- a/src/modules/ray/ray.c +++ b/src/modules/ray/ray.c @@ -187,11 +187,13 @@ static void ray_render_fragment(til_module_context_t *context, til_stream_t *str } -static void ray_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr) +static int ray_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr) { ray_context_t *ctxt = (ray_context_t *)context; ray_render_free(ctxt->render); + + return 0; } diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c index 95418aa..0c2ab73 100644 --- a/src/modules/rtv/rtv.c +++ b/src/modules/rtv/rtv.c @@ -70,7 +70,7 @@ static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks); static til_module_context_t * rtv_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup); static void rtv_destroy_context(til_module_context_t *context); static void rtv_render_fragment(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr); -static void rtv_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr); +static int rtv_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr); static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup); static til_module_t rtv_none_module = {}; @@ -330,26 +330,27 @@ static void rtv_render_fragment(til_module_context_t *context, til_stream_t *str } -static void rtv_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr) +static int rtv_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr) { rtv_context_t *ctxt = (rtv_context_t *)context; til_fb_fragment_t *fragment = *fragment_ptr; - if (!ctxt->caption) - return; - - txt_render_fragment(ctxt->caption, fragment, 0x00000000, - 1, fragment->frame_height + 1, - (txt_align_t){ + if (ctxt->caption) { + txt_render_fragment(ctxt->caption, fragment, 0x00000000, + 1, fragment->frame_height + 1, + (txt_align_t){ + .horiz = TXT_HALIGN_LEFT, + .vert = TXT_VALIGN_BOTTOM + }); + txt_render_fragment(ctxt->caption, fragment, 0xffffffff, + 0, fragment->frame_height, + (txt_align_t){ .horiz = TXT_HALIGN_LEFT, .vert = TXT_VALIGN_BOTTOM - }); - txt_render_fragment(ctxt->caption, fragment, 0xffffffff, - 0, fragment->frame_height, - (txt_align_t){ - .horiz = TXT_HALIGN_LEFT, - .vert = TXT_VALIGN_BOTTOM - }); + }); + } + + return 0; } diff --git a/src/modules/shapes/shapes.c b/src/modules/shapes/shapes.c index 977d9a7..099c050 100644 --- a/src/modules/shapes/shapes.c +++ b/src/modules/shapes/shapes.c @@ -548,7 +548,7 @@ static void shapes_render_fragment(til_module_context_t *context, til_stream_t * } -static void shapes_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned int ticks, til_fb_fragment_t **fragment_ptr) +static int shapes_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned int ticks, til_fb_fragment_t **fragment_ptr) { shapes_context_t *ctxt = (shapes_context_t *)context; til_fb_fragment_t *fragment = *fragment_ptr; @@ -571,6 +571,8 @@ static void shapes_finish_frame(til_module_context_t *context, til_stream_t *str if (fragment->width == fragment->frame_width && fragment->height == fragment->frame_height) ctxt->radcache->initialized = 1; + + return 0; } diff --git a/src/modules/strobe/strobe.c b/src/modules/strobe/strobe.c index 9e7024c..3d354e8 100644 --- a/src/modules/strobe/strobe.c +++ b/src/modules/strobe/strobe.c @@ -129,15 +129,16 @@ static void strobe_render_fragment(til_module_context_t *context, til_stream_t * } -static void strobe_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned int ticks, til_fb_fragment_t **fragment_ptr) +static int strobe_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned int ticks, til_fb_fragment_t **fragment_ptr) { strobe_context_t *ctxt = (strobe_context_t *)context; - if (!ctxt->flash) - return; + if (ctxt->flash) { + ctxt->flash = 0; + ctxt->last_flash_ticks = ticks; + } - ctxt->flash = 0; - ctxt->last_flash_ticks = ticks; + return 0; } diff --git a/src/modules/voronoi/voronoi.c b/src/modules/voronoi/voronoi.c index 5b38705..ff5f290 100644 --- a/src/modules/voronoi/voronoi.c +++ b/src/modules/voronoi/voronoi.c @@ -357,11 +357,13 @@ static void voronoi_render_fragment(til_module_context_t *context, til_stream_t } -static void voronoi_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr) +static int voronoi_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr) { voronoi_context_t *ctxt = (voronoi_context_t *)context; ctxt->distances.recalc_needed = 0; + + return 0; } @@ -238,6 +238,7 @@ static void module_render_fragment(til_module_context_t *context, til_stream_t * module = context->module; +render_again: if (module->prepare_frame) { til_frame_plan_t frame_plan = {}; @@ -269,7 +270,8 @@ static void module_render_fragment(til_module_context_t *context, til_stream_t * } if (module->finish_frame) { - module->finish_frame(context, stream, ticks, fragment_ptr); + if (module->finish_frame(context, stream, ticks, fragment_ptr) > 0) + goto render_again; touched++; } @@ -30,7 +30,7 @@ struct til_module_t { void (*destroy_context)(til_module_context_t *context); /* destroy gets stream in context, but the render-related functions should always use the passed-in stream so it can potentially change */ void (*prepare_frame)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan); void (*render_fragment)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr); - void (*finish_frame)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr); + int (*finish_frame)(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr); int (*setup)(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup); char *name; char *description; |