From 9b8660a62e3c5c9ad8f70c0d56ccaac7c4a531fc Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 21 May 2022 20:26:32 -0700 Subject: til: supply a seed to til_module_t.create_context() In the recent surge of ADD-style rtv+compose focused development, a bunch of modules were changed to randomize initial states at context_create() so they wouldn't be so repetitive. But the way this was done in a way that made it impossible to suppress the randomized initial state, which sometimes may be desirable in compositions. Imagine for instance something like the checkers module, rendering one module in the odd cells, and another module into the even cells. Imagine if these modules are actually the same, but if checkers used one seed for all the odd cells and another seed for all the even cells. If the modules used actually utilized the seed provided, checkers would be able to differentiate the odd from even by seeding them differently even when the modules are the same. This commit is a step in that direction, but rototiller and all the composite modules (rtv,compose,montage) are simply passing rand() as the seeds. Also none of the modules have yet been modified to actually make use of these seeds. Subsequent commits will update modules to seed their pseudo-randomized initial state from the seed value rather than always calling things like rand() themselves. --- src/modules/compose/compose.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/modules/compose') diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c index a331b3f..b0f0104 100644 --- a/src/modules/compose/compose.c +++ b/src/modules/compose/compose.c @@ -46,7 +46,7 @@ typedef struct compose_setup_t { char *layers[]; } compose_setup_t; -static void * compose_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup); +static void * compose_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup); static void compose_destroy_context(void *context); static void compose_prepare_frame(void *context, unsigned ticks, unsigned n_cpus, til_fb_fragment_t *fragment, til_fragmenter_t *res_fragmenter); static int compose_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup); @@ -66,7 +66,7 @@ til_module_t compose_module = { }; -static void * compose_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * compose_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { compose_context_t *ctxt; size_t n; @@ -82,7 +82,7 @@ static void * compose_create_context(unsigned ticks, unsigned n_cpus, til_setup_ ctxt->n_cpus = n_cpus; - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { const til_module_t *layer_module; til_setup_t *layer_setup = NULL; @@ -90,19 +90,19 @@ static void * compose_create_context(unsigned ticks, unsigned n_cpus, til_setup_ (void) til_module_randomize_setup(layer_module, &layer_setup, NULL); ctxt->layers[i].module = layer_module; - (void) til_module_create_context(layer_module, ticks, layer_setup, &ctxt->layers[i].module_ctxt); + (void) til_module_create_context(layer_module, rand(), ticks, layer_setup, &ctxt->layers[i].module_ctxt); til_setup_free(layer_setup); ctxt->n_layers++; } if (((compose_setup_t *)setup)->texture) { - til_setup_t *texture_setup = NULL; + til_setup_t *texture_setup = NULL; ctxt->texture.module = til_lookup_module(((compose_setup_t *)setup)->texture); (void) til_module_randomize_setup(ctxt->texture.module, &texture_setup, NULL); - (void) til_module_create_context(ctxt->texture.module, ticks, texture_setup, &ctxt->texture.module_ctxt); + (void) til_module_create_context(ctxt->texture.module, rand(), ticks, texture_setup, &ctxt->texture.module_ctxt); til_setup_free(texture_setup); } -- cgit v1.2.3