From b437600c820f489049c022d2c4697226cf8d68fc Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 9 Jun 2022 22:40:06 -0700 Subject: til: add ticks to til_module_context_t Also wire this up to the til_module_context_new() helper and all its callers. This is in preparation for modules doing more correct delta-T derived animation. --- src/modules/blinds/blinds.c | 2 +- src/modules/checkers/checkers.c | 2 +- src/modules/compose/compose.c | 2 +- src/modules/drizzle/drizzle.c | 2 +- src/modules/flui2d/flui2d.c | 2 +- src/modules/julia/julia.c | 2 +- src/modules/meta2d/meta2d.c | 2 +- src/modules/moire/moire.c | 2 +- src/modules/montage/montage.c | 2 +- src/modules/pixbounce/pixbounce.c | 2 +- src/modules/plasma/plasma.c | 2 +- src/modules/plato/plato.c | 2 +- src/modules/ray/ray.c | 2 +- src/modules/roto/roto.c | 2 +- src/modules/rtv/rtv.c | 2 +- src/modules/shapes/shapes.c | 2 +- src/modules/snow/snow.c | 2 +- src/modules/sparkler/sparkler.c | 2 +- src/modules/spiro/spiro.c | 2 +- src/modules/stars/stars.c | 2 +- src/modules/submit/submit.c | 2 +- src/modules/swab/swab.c | 2 +- src/modules/swarm/swarm.c | 2 +- src/modules/voronoi/voronoi.c | 2 +- src/til.c | 2 +- src/til_module_context.c | 3 ++- src/til_module_context.h | 3 ++- 27 files changed, 29 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/modules/blinds/blinds.c b/src/modules/blinds/blinds.c index 1d7b580..aa71ddd 100644 --- a/src/modules/blinds/blinds.c +++ b/src/modules/blinds/blinds.c @@ -44,7 +44,7 @@ static til_module_context_t * blinds_create_context(unsigned seed, unsigned tick if (!setup) setup = &blinds_default_setup.til_setup; - ctxt = til_module_context_new(sizeof(blinds_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(blinds_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/checkers/checkers.c b/src/modules/checkers/checkers.c index 079df4d..c9a0444 100644 --- a/src/modules/checkers/checkers.c +++ b/src/modules/checkers/checkers.c @@ -70,7 +70,7 @@ static til_module_context_t * checkers_create_context(unsigned seed, unsigned ti if (!setup) setup = &checkers_default_setup.til_setup; - ctxt = til_module_context_new(sizeof(checkers_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(checkers_context_t), ticks, seed, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c index 7415150..06fa01c 100644 --- a/src/modules/compose/compose.c +++ b/src/modules/compose/compose.c @@ -77,7 +77,7 @@ static til_module_context_t * compose_create_context(unsigned seed, unsigned tic for (n = 0; ((compose_setup_t *)setup)->layers[n]; n++); - ctxt = til_module_context_new(sizeof(compose_context_t) + n * sizeof(compose_layer_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(compose_context_t) + n * sizeof(compose_layer_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/drizzle/drizzle.c b/src/modules/drizzle/drizzle.c index b23fba8..2ed8533 100644 --- a/src/modules/drizzle/drizzle.c +++ b/src/modules/drizzle/drizzle.c @@ -81,7 +81,7 @@ static til_module_context_t * drizzle_create_context(unsigned seed, unsigned tic if (!setup) setup = &drizzle_default_setup.til_setup; - ctxt = til_module_context_new(sizeof(drizzle_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(drizzle_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c index df980ba..78f0265 100644 --- a/src/modules/flui2d/flui2d.c +++ b/src/modules/flui2d/flui2d.c @@ -253,7 +253,7 @@ static til_module_context_t * flui2d_create_context(unsigned seed, unsigned tick if (!setup) setup = &flui2d_default_setup.til_setup; - ctxt = til_module_context_new(sizeof(flui2d_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(flui2d_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/julia/julia.c b/src/modules/julia/julia.c index dd11f25..f878f99 100644 --- a/src/modules/julia/julia.c +++ b/src/modules/julia/julia.c @@ -71,7 +71,7 @@ static til_module_context_t * julia_create_context(unsigned seed, unsigned ticks { julia_context_t *ctxt; - ctxt = til_module_context_new(sizeof(julia_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(julia_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/meta2d/meta2d.c b/src/modules/meta2d/meta2d.c index eb816d0..c6a6c86 100644 --- a/src/modules/meta2d/meta2d.c +++ b/src/modules/meta2d/meta2d.c @@ -71,7 +71,7 @@ static til_module_context_t * meta2d_create_context(unsigned seed, unsigned tick { meta2d_context_t *ctxt; - ctxt = til_module_context_new(sizeof(meta2d_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(meta2d_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/moire/moire.c b/src/modules/moire/moire.c index 1678170..e16a8ab 100644 --- a/src/modules/moire/moire.c +++ b/src/modules/moire/moire.c @@ -54,7 +54,7 @@ static til_module_context_t * moire_create_context(unsigned seed, unsigned ticks if (!setup) setup = &moire_default_setup.til_setup; - ctxt = til_module_context_new(sizeof(moire_context_t) + ((moire_setup_t *)setup)->n_centers * sizeof(moire_center_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(moire_context_t) + ((moire_setup_t *)setup)->n_centers * sizeof(moire_center_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/montage/montage.c b/src/modules/montage/montage.c index 2db9fdd..f1dffd1 100644 --- a/src/modules/montage/montage.c +++ b/src/modules/montage/montage.c @@ -38,7 +38,7 @@ static til_module_context_t * montage_create_context(unsigned seed, unsigned tic size_t n_modules; montage_context_t *ctxt; - ctxt = til_module_context_new(sizeof(montage_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(montage_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c index 8c23fa4..206d8a2 100644 --- a/src/modules/pixbounce/pixbounce.c +++ b/src/modules/pixbounce/pixbounce.c @@ -244,7 +244,7 @@ static til_module_context_t * pixbounce_create_context(unsigned seed, unsigned t { pixbounce_context_t *ctxt; - ctxt = til_module_context_new(sizeof(pixbounce_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(pixbounce_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/plasma/plasma.c b/src/modules/plasma/plasma.c index 56f1176..225b4e3 100644 --- a/src/modules/plasma/plasma.c +++ b/src/modules/plasma/plasma.c @@ -64,7 +64,7 @@ static til_module_context_t * plasma_create_context(unsigned seed, unsigned tick init_plasma(costab, sintab); } - ctxt = til_module_context_new(sizeof(plasma_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(plasma_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/plato/plato.c b/src/modules/plato/plato.c index c22a6c4..ffa7e68 100644 --- a/src/modules/plato/plato.c +++ b/src/modules/plato/plato.c @@ -614,7 +614,7 @@ static til_module_context_t * plato_create_context(unsigned seed, unsigned ticks { plato_context_t *ctxt; - ctxt = til_module_context_new(sizeof(plato_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(plato_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c index 84e4eb2..e781adc 100644 --- a/src/modules/ray/ray.c +++ b/src/modules/ray/ray.c @@ -136,7 +136,7 @@ static til_module_context_t * ray_create_context(unsigned seed, unsigned ticks, { ray_context_t *ctxt; - ctxt = til_module_context_new(sizeof(ray_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(ray_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/roto/roto.c b/src/modules/roto/roto.c index cc69103..389aa5d 100644 --- a/src/modules/roto/roto.c +++ b/src/modules/roto/roto.c @@ -37,7 +37,7 @@ static til_module_context_t * roto_create_context(unsigned seed, unsigned ticks, { roto_context_t *ctxt; - ctxt = til_module_context_new(sizeof(roto_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(roto_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c index fe68903..bf6a578 100644 --- a/src/modules/rtv/rtv.c +++ b/src/modules/rtv/rtv.c @@ -232,7 +232,7 @@ static til_module_context_t * rtv_create_context(unsigned seed, unsigned ticks, n_channels++; } - ctxt = til_module_context_new(sizeof(rtv_context_t) + n_channels * sizeof(rtv_channel_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(rtv_context_t) + n_channels * sizeof(rtv_channel_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/shapes/shapes.c b/src/modules/shapes/shapes.c index 8a1da6e..0a53a34 100644 --- a/src/modules/shapes/shapes.c +++ b/src/modules/shapes/shapes.c @@ -105,7 +105,7 @@ static til_module_context_t * shapes_create_context(unsigned seed, unsigned tick if (!setup) setup = &shapes_default_setup.til_setup; - ctxt = til_module_context_new(sizeof(shapes_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(shapes_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/snow/snow.c b/src/modules/snow/snow.c index 767459e..fcc40b3 100644 --- a/src/modules/snow/snow.c +++ b/src/modules/snow/snow.c @@ -26,7 +26,7 @@ static til_module_context_t * snow_create_context(unsigned seed, unsigned ticks, { snow_context_t *ctxt; - ctxt = til_module_context_new(sizeof(snow_context_t) + n_cpus * sizeof(snow_seed_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(snow_context_t) + n_cpus * sizeof(snow_seed_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c index 8c8348b..95b19b7 100644 --- a/src/modules/sparkler/sparkler.c +++ b/src/modules/sparkler/sparkler.c @@ -42,7 +42,7 @@ static til_module_context_t * sparkler_create_context(unsigned seed, unsigned ti if (!setup) setup = &sparkler_default_setup.til_setup; - ctxt = til_module_context_new(sizeof(sparkler_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(sparkler_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/spiro/spiro.c b/src/modules/spiro/spiro.c index 39868f6..9da4686 100644 --- a/src/modules/spiro/spiro.c +++ b/src/modules/spiro/spiro.c @@ -36,7 +36,7 @@ static til_module_context_t * spiro_create_context(unsigned seed, unsigned ticks spiro_context_t *ctxt; float z; - ctxt = til_module_context_new(sizeof(spiro_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(spiro_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c index 31f4ead..665534a 100644 --- a/src/modules/stars/stars.c +++ b/src/modules/stars/stars.c @@ -60,7 +60,7 @@ static til_module_context_t * stars_create_context(unsigned seed, unsigned ticks if (!setup) setup = &stars_default_setup.til_setup; - ctxt = til_module_context_new(sizeof(stars_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(stars_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/submit/submit.c b/src/modules/submit/submit.c index 1573688..6262dec 100644 --- a/src/modules/submit/submit.c +++ b/src/modules/submit/submit.c @@ -274,7 +274,7 @@ static til_module_context_t * submit_create_context(unsigned seed, unsigned tick if (!setup) setup = &submit_default_setup.til_setup; - ctxt = til_module_context_new(sizeof(submit_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(submit_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/swab/swab.c b/src/modules/swab/swab.c index 8566fa3..69b369a 100644 --- a/src/modules/swab/swab.c +++ b/src/modules/swab/swab.c @@ -70,7 +70,7 @@ static til_module_context_t * swab_create_context(unsigned seed, unsigned ticks, { swab_context_t *ctxt; - ctxt = til_module_context_new(sizeof(swab_context_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(swab_context_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/swarm/swarm.c b/src/modules/swarm/swarm.c index 14d82ed..fd852cd 100644 --- a/src/modules/swarm/swarm.c +++ b/src/modules/swarm/swarm.c @@ -188,7 +188,7 @@ static til_module_context_t * swarm_create_context(unsigned seed, unsigned ticks if (!setup) setup = &swarm_default_setup.til_setup; - ctxt = til_module_context_new(sizeof(swarm_context_t) + sizeof(*(ctxt->boids)) * SWARM_SIZE, seed, n_cpus); + ctxt = til_module_context_new(sizeof(swarm_context_t) + sizeof(*(ctxt->boids)) * SWARM_SIZE, seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/modules/voronoi/voronoi.c b/src/modules/voronoi/voronoi.c index 9365015..6775416 100644 --- a/src/modules/voronoi/voronoi.c +++ b/src/modules/voronoi/voronoi.c @@ -87,7 +87,7 @@ static til_module_context_t * voronoi_create_context(unsigned seed, unsigned tic if (!setup) setup = &voronoi_default_setup.til_setup; - ctxt = til_module_context_new(sizeof(voronoi_context_t) + ((voronoi_setup_t *)setup)->n_cells * sizeof(voronoi_cell_t), seed, n_cpus); + ctxt = til_module_context_new(sizeof(voronoi_context_t) + ((voronoi_setup_t *)setup)->n_cells * sizeof(voronoi_cell_t), seed, ticks, n_cpus); if (!ctxt) return NULL; diff --git a/src/til.c b/src/til.c index b8aecd8..951a398 100644 --- a/src/til.c +++ b/src/til.c @@ -234,7 +234,7 @@ int til_module_create_context(const til_module_t *module, unsigned seed, unsigne n_cpus = til_threads_num_threads(til_threads); if (!module->create_context) - context = til_module_context_new(sizeof(til_module_context_t), seed, n_cpus); + context = til_module_context_new(sizeof(til_module_context_t), seed, ticks, n_cpus); else context = module->create_context(seed, ticks, n_cpus, setup); diff --git a/src/til_module_context.c b/src/til_module_context.c index a029f37..59f3f9d 100644 --- a/src/til_module_context.c +++ b/src/til_module_context.c @@ -23,7 +23,7 @@ * as the callers are generally using it in place of calloc(), and assign it to a * container struct of some other type but having an embedded til_module_context_t. */ -void * til_module_context_new(size_t size, unsigned seed, unsigned n_cpus) +void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsigned n_cpus) { til_module_context_t *module_context; @@ -35,6 +35,7 @@ void * til_module_context_new(size_t size, unsigned seed, unsigned n_cpus) return NULL; module_context->seed = seed; + module_context->ticks = ticks; module_context->n_cpus = n_cpus; return module_context; diff --git a/src/til_module_context.h b/src/til_module_context.h index 3751b84..43d06a7 100644 --- a/src/til_module_context.h +++ b/src/til_module_context.h @@ -7,10 +7,11 @@ typedef struct til_module_t til_module_t; struct til_module_context_t { const til_module_t *module; unsigned seed; + unsigned ticks; unsigned n_cpus; }; -void * til_module_context_new(size_t size, unsigned seed, unsigned n_cpus); +void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsigned n_cpus); void * til_module_context_free(til_module_context_t *module_context); #endif -- cgit v1.2.3