diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2022-05-21 20:26:32 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2022-05-21 20:26:32 -0700 |
commit | 9b8660a62e3c5c9ad8f70c0d56ccaac7c4a531fc (patch) | |
tree | 039336351d80f7e70e1d136d256a364a93a2da1d /src/modules | |
parent | 192a89a7f9f396fff4eb6b0836f597c376e98932 (diff) |
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.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/blinds/blinds.c | 2 | ||||
-rw-r--r-- | src/modules/checkers/checkers.c | 2 | ||||
-rw-r--r-- | src/modules/compose/compose.c | 12 | ||||
-rw-r--r-- | src/modules/drizzle/drizzle.c | 2 | ||||
-rw-r--r-- | src/modules/flui2d/flui2d.c | 2 | ||||
-rw-r--r-- | src/modules/julia/julia.c | 2 | ||||
-rw-r--r-- | src/modules/meta2d/meta2d.c | 2 | ||||
-rw-r--r-- | src/modules/montage/montage.c | 6 | ||||
-rw-r--r-- | src/modules/pixbounce/pixbounce.c | 2 | ||||
-rw-r--r-- | src/modules/plasma/plasma.c | 2 | ||||
-rw-r--r-- | src/modules/plato/plato.c | 2 | ||||
-rw-r--r-- | src/modules/ray/ray.c | 2 | ||||
-rw-r--r-- | src/modules/roto/roto.c | 2 | ||||
-rw-r--r-- | src/modules/rtv/rtv.c | 8 | ||||
-rw-r--r-- | src/modules/shapes/shapes.c | 2 | ||||
-rw-r--r-- | src/modules/snow/snow.c | 2 | ||||
-rw-r--r-- | src/modules/sparkler/sparkler.c | 2 | ||||
-rw-r--r-- | src/modules/spiro/spiro.c | 2 | ||||
-rw-r--r-- | src/modules/stars/stars.c | 2 | ||||
-rw-r--r-- | src/modules/submit/submit.c | 2 | ||||
-rw-r--r-- | src/modules/swab/swab.c | 2 | ||||
-rw-r--r-- | src/modules/swarm/swarm.c | 2 | ||||
-rw-r--r-- | src/modules/voronoi/voronoi.c | 2 |
23 files changed, 33 insertions, 33 deletions
diff --git a/src/modules/blinds/blinds.c b/src/modules/blinds/blinds.c index c4a94c9..8f32054 100644 --- a/src/modules/blinds/blinds.c +++ b/src/modules/blinds/blinds.c @@ -35,7 +35,7 @@ static blinds_setup_t blinds_default_setup = { }; -static void * blinds_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * blinds_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { blinds_context_t *ctxt; diff --git a/src/modules/checkers/checkers.c b/src/modules/checkers/checkers.c index 27da42b..56037fa 100644 --- a/src/modules/checkers/checkers.c +++ b/src/modules/checkers/checkers.c @@ -61,7 +61,7 @@ static checkers_setup_t checkers_default_setup = { }; -static void * checkers_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * checkers_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { checkers_context_t *ctxt; 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); } diff --git a/src/modules/drizzle/drizzle.c b/src/modules/drizzle/drizzle.c index 5717bc7..21d4fbf 100644 --- a/src/modules/drizzle/drizzle.c +++ b/src/modules/drizzle/drizzle.c @@ -72,7 +72,7 @@ static inline uint32_t color_to_uint32(v3f_t color) { } -static void * drizzle_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * drizzle_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { drizzle_context_t *ctxt; diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c index f8afffb..4f87b54 100644 --- a/src/modules/flui2d/flui2d.c +++ b/src/modules/flui2d/flui2d.c @@ -243,7 +243,7 @@ static void gamma_init(float gamma) } -static void * flui2d_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * flui2d_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { static int initialized; flui2d_context_t *ctxt; diff --git a/src/modules/julia/julia.c b/src/modules/julia/julia.c index 95846e3..c24e40a 100644 --- a/src/modules/julia/julia.c +++ b/src/modules/julia/julia.c @@ -65,7 +65,7 @@ static uint32_t colors[] = { }; -static void * julia_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * julia_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { julia_context_t *ctxt; diff --git a/src/modules/meta2d/meta2d.c b/src/modules/meta2d/meta2d.c index 24af28c..8b87804 100644 --- a/src/modules/meta2d/meta2d.c +++ b/src/modules/meta2d/meta2d.c @@ -65,7 +65,7 @@ static inline uint32_t color_to_uint32(v3f_t color) { } -static void * meta2d_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * meta2d_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { meta2d_context_t *ctxt; diff --git a/src/modules/montage/montage.c b/src/modules/montage/montage.c index 645e9da..a7030ff 100644 --- a/src/modules/montage/montage.c +++ b/src/modules/montage/montage.c @@ -15,7 +15,7 @@ typedef struct montage_context_t { } montage_context_t; static void setup_next_module(montage_context_t *ctxt); -static void * montage_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup); +static void * montage_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup); static void montage_destroy_context(void *context); static void montage_prepare_frame(void *context, unsigned ticks, unsigned n_cpus, til_fb_fragment_t *fragment, til_fragmenter_t *res_fragmenter); static void montage_render_fragment(void *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment); @@ -31,7 +31,7 @@ til_module_t montage_module = { }; -static void * montage_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * montage_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { const til_module_t **modules, *rtv_module, *compose_module; size_t n_modules; @@ -90,7 +90,7 @@ static void * montage_create_context(unsigned ticks, unsigned n_cpus, til_setup_ (void) til_module_randomize_setup(module, &setup, NULL); if (module->create_context) /* FIXME errors */ - ctxt->contexts[i] = module->create_context(ticks, 1, setup); + ctxt->contexts[i] = module->create_context(rand(), ticks, 1, setup); til_setup_free(setup); } diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c index a66fb78..99a8519 100644 --- a/src/modules/pixbounce/pixbounce.c +++ b/src/modules/pixbounce/pixbounce.c @@ -239,7 +239,7 @@ static uint32_t pick_color() return makergb(rand()%256, rand()%256, rand()%256, 1); } -static void * pixbounce_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * pixbounce_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { pixbounce_context_t *ctxt; diff --git a/src/modules/plasma/plasma.c b/src/modules/plasma/plasma.c index ee499a6..aca4e85 100644 --- a/src/modules/plasma/plasma.c +++ b/src/modules/plasma/plasma.c @@ -51,7 +51,7 @@ static void init_plasma(int32_t *costab, int32_t *sintab) } -static void * plasma_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * plasma_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { static int initialized; plasma_context_t *ctxt; diff --git a/src/modules/plato/plato.c b/src/modules/plato/plato.c index 18f02e3..2ca3478 100644 --- a/src/modules/plato/plato.c +++ b/src/modules/plato/plato.c @@ -608,7 +608,7 @@ static void draw_polyhedron(const polyhedron_t *polyhedron, m4f_t *transform, ti } -static void * plato_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * plato_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { plato_context_t *ctxt; diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c index 2b3c836..14ef45f 100644 --- a/src/modules/ray/ray.c +++ b/src/modules/ray/ray.c @@ -130,7 +130,7 @@ typedef struct ray_context_t { } ray_context_t; -static void * ray_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * ray_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { return calloc(1, sizeof(ray_context_t)); } diff --git a/src/modules/roto/roto.c b/src/modules/roto/roto.c index 1dafd53..0969929 100644 --- a/src/modules/roto/roto.c +++ b/src/modules/roto/roto.c @@ -31,7 +31,7 @@ static int32_t costab[FIXED_TRIG_LUT_SIZE], sintab[FIXED_TRIG_LUT_SIZE]; static uint8_t texture[256][256]; static color_t palette[2]; -static void * roto_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * roto_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { roto_context_t *ctxt; diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c index 4dde3bc..6cd9744 100644 --- a/src/modules/rtv/rtv.c +++ b/src/modules/rtv/rtv.c @@ -59,7 +59,7 @@ typedef struct rtv_setup_t { } rtv_setup_t; static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks); -static void * rtv_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup); +static void * rtv_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup); static void rtv_destroy_context(void *context); static void rtv_prepare_frame(void *context, unsigned ticks, unsigned n_cpus, til_fb_fragment_t *fragment, til_fragmenter_t *res_fragmenter); static void rtv_finish_frame(void *context, unsigned ticks, til_fb_fragment_t *fragment); @@ -186,7 +186,7 @@ static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks) } if (!ctxt->channel->module_ctxt) - (void) til_module_create_context(ctxt->channel->module, ticks, ctxt->channel->module_setup, &ctxt->channel->module_ctxt); + (void) til_module_create_context(ctxt->channel->module, rand(), ticks, ctxt->channel->module_setup, &ctxt->channel->module_ctxt); ctxt->channel->last_on_time = now; } @@ -213,7 +213,7 @@ static int rtv_should_skip_module(const rtv_setup_t *setup, const til_module_t * } -static void * rtv_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * rtv_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { rtv_context_t *ctxt; const til_module_t **modules; @@ -242,7 +242,7 @@ static void * rtv_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *s ctxt->snow_channel.module = &rtv_none_module; if (((rtv_setup_t *)setup)->snow_module) { ctxt->snow_channel.module = til_lookup_module(((rtv_setup_t *)setup)->snow_module); - (void) til_module_create_context(ctxt->snow_channel.module, ticks, NULL, &ctxt->snow_channel.module_ctxt); + (void) til_module_create_context(ctxt->snow_channel.module, rand(), ticks, NULL, &ctxt->snow_channel.module_ctxt); } for (size_t i = 0; i < n_modules; i++) { diff --git a/src/modules/shapes/shapes.c b/src/modules/shapes/shapes.c index 6c912ca..6159684 100644 --- a/src/modules/shapes/shapes.c +++ b/src/modules/shapes/shapes.c @@ -89,7 +89,7 @@ static shapes_setup_t shapes_default_setup = { }; -static void * shapes_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * shapes_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { shapes_context_t *ctxt; diff --git a/src/modules/snow/snow.c b/src/modules/snow/snow.c index 8befc92..82ad847 100644 --- a/src/modules/snow/snow.c +++ b/src/modules/snow/snow.c @@ -20,7 +20,7 @@ typedef struct snow_context_t { } snow_context_t; -static void * snow_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * snow_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { snow_context_t *ctxt; diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c index 08d0e9a..10d8638 100644 --- a/src/modules/sparkler/sparkler.c +++ b/src/modules/sparkler/sparkler.c @@ -33,7 +33,7 @@ extern particle_ops_t simple_ops; static sparkler_setup_t sparkler_default_setup; -static void * sparkler_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * sparkler_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { sparkler_context_t *ctxt; diff --git a/src/modules/spiro/spiro.c b/src/modules/spiro/spiro.c index b51b22d..07d9fbf 100644 --- a/src/modules/spiro/spiro.c +++ b/src/modules/spiro/spiro.c @@ -29,7 +29,7 @@ typedef struct spiro_context_t { } spiro_context_t; -static void * spiro_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * spiro_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { spiro_context_t *ctxt; float z; diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c index e975c7c..21ae7f5 100644 --- a/src/modules/stars/stars.c +++ b/src/modules/stars/stars.c @@ -49,7 +49,7 @@ float get_random_unit_coord() { } -static void * stars_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * stars_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { stars_context_t *ctxt; float z; diff --git a/src/modules/submit/submit.c b/src/modules/submit/submit.c index af2d044..fa7a95c 100644 --- a/src/modules/submit/submit.c +++ b/src/modules/submit/submit.c @@ -265,7 +265,7 @@ static void setup_grid(submit_context_t *ctxt) } -static void * submit_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * submit_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { submit_context_t *ctxt; diff --git a/src/modules/swab/swab.c b/src/modules/swab/swab.c index 90f7a36..e81fec9 100644 --- a/src/modules/swab/swab.c +++ b/src/modules/swab/swab.c @@ -64,7 +64,7 @@ static inline uint32_t color_to_uint32(color_t color) { } -static void * swab_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * swab_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { swab_context_t *ctxt; diff --git a/src/modules/swarm/swarm.c b/src/modules/swarm/swarm.c index 2d37e28..a57c9fe 100644 --- a/src/modules/swarm/swarm.c +++ b/src/modules/swarm/swarm.c @@ -179,7 +179,7 @@ static inline uint32_t color_to_uint32(v3f_t color) { } -static void * swarm_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * swarm_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { swarm_context_t *ctxt; diff --git a/src/modules/voronoi/voronoi.c b/src/modules/voronoi/voronoi.c index 2bd6cdc..3e6a5e3 100644 --- a/src/modules/voronoi/voronoi.c +++ b/src/modules/voronoi/voronoi.c @@ -77,7 +77,7 @@ static void voronoi_randomize(voronoi_context_t *ctxt) } -static void * voronoi_create_context(unsigned ticks, unsigned n_cpus, til_setup_t *setup) +static void * voronoi_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) { voronoi_context_t *ctxt; |