From 0b471f3579e49c28032536de3c276a9d6eddd15d Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 16 Aug 2023 22:18:02 -0700 Subject: modules/*: update all taps in context_create() Mechanical change of ensuring what little taps are implemented always get updated @ til_module_t.context_create() time as well as on every frame. This ensures the pipes are registered on stream immediately upon context creation, rather than appearing only once the context gets rendered the first time. --- src/modules/flui2d/flui2d.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/modules/flui2d') diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c index bfa36fb..40307a2 100644 --- a/src/modules/flui2d/flui2d.c +++ b/src/modules/flui2d/flui2d.c @@ -249,6 +249,19 @@ static void gamma_init(float gamma) } +static void flui2d_update_taps(flui2d_context_t *ctxt, til_stream_t *stream, unsigned ticks) +{ + if (!til_stream_tap_context(stream, &ctxt->til_module_context, NULL, &ctxt->taps.viscosity)) + *ctxt->viscosity = ctxt->setup->viscosity; + + if (!til_stream_tap_context(stream, &ctxt->til_module_context, NULL, &ctxt->taps.diffusion)) + *ctxt->diffusion = ctxt->setup->diffusion; + + if (!til_stream_tap_context(stream, &ctxt->til_module_context, NULL, &ctxt->taps.decay)) + *ctxt->decay = ctxt->setup->decay; +} + + static til_module_context_t * flui2d_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { static int initialized; @@ -269,6 +282,8 @@ static til_module_context_t * flui2d_create_context(const til_module_t *module, ctxt->taps.diffusion = til_tap_init_float(ctxt, &ctxt->diffusion, 1, &ctxt->vars.diffusion, "diffusion"); ctxt->taps.decay = til_tap_init_float(ctxt, &ctxt->decay, 1, &ctxt->vars.decay, "decay"); + flui2d_update_taps(ctxt, stream, ticks); + return &ctxt->til_module_context; } @@ -283,14 +298,7 @@ static void flui2d_prepare_frame(til_module_context_t *context, til_stream_t *st *res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_tile64 }; - if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.viscosity)) - *ctxt->viscosity = ctxt->setup->viscosity; - - if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.diffusion)) - *ctxt->diffusion = ctxt->setup->diffusion; - - if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.decay)) - *ctxt->decay = ctxt->setup->decay; + flui2d_update_taps(ctxt, stream, ticks); /* this duplication of visc/diff/decay is silly, it's just a product of this * module being written as a flui2d_t class in-situ but distinct from the module. -- cgit v1.2.3