summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c1
-rw-r--r--src/modules/blinds/blinds.c4
-rw-r--r--src/modules/checkers/checkers.c6
-rw-r--r--src/modules/compose/compose.c10
-rw-r--r--src/modules/drizzle/drizzle.c4
-rw-r--r--src/modules/flui2d/flui2d.c4
-rw-r--r--src/modules/julia/julia.c4
-rw-r--r--src/modules/meta2d/meta2d.c4
-rw-r--r--src/modules/moire/moire.c4
-rw-r--r--src/modules/montage/montage.c8
-rw-r--r--src/modules/pixbounce/pixbounce.c4
-rw-r--r--src/modules/plasma/plasma.c4
-rw-r--r--src/modules/plato/plato.c4
-rw-r--r--src/modules/ray/ray.c4
-rw-r--r--src/modules/roto/roto.c4
-rw-r--r--src/modules/rtv/rtv.c10
-rw-r--r--src/modules/shapes/shapes.c4
-rw-r--r--src/modules/snow/snow.c4
-rw-r--r--src/modules/sparkler/sparkler.c4
-rw-r--r--src/modules/spiro/spiro.c4
-rw-r--r--src/modules/stars/stars.c4
-rw-r--r--src/modules/strobe/strobe.c4
-rw-r--r--src/modules/submit/submit.c4
-rw-r--r--src/modules/swab/swab.c4
-rw-r--r--src/modules/swarm/swarm.c4
-rw-r--r--src/modules/voronoi/voronoi.c4
-rw-r--r--src/til.c25
-rw-r--r--src/til.h4
-rw-r--r--src/til_module_context.c12
-rw-r--r--src/til_module_context.h3
30 files changed, 96 insertions, 67 deletions
diff --git a/src/main.c b/src/main.c
index d1399c3..970ca86 100644
--- a/src/main.c
+++ b/src/main.c
@@ -386,6 +386,7 @@ int main(int argc, const char *argv[])
&rototiller.start_tv,
rototiller.ticks_offset),
0,
+ "",
setup.module_setup,
&rototiller.module_context)) < 0,
"unable to create module context: %s", strerror(-r));
diff --git a/src/modules/blinds/blinds.c b/src/modules/blinds/blinds.c
index d93a3c9..890b569 100644
--- a/src/modules/blinds/blinds.c
+++ b/src/modules/blinds/blinds.c
@@ -37,14 +37,14 @@ static blinds_setup_t blinds_default_setup = {
};
-static til_module_context_t * blinds_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * blinds_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
blinds_context_t *ctxt;
if (!setup)
setup = &blinds_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(blinds_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(blinds_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/checkers/checkers.c b/src/modules/checkers/checkers.c
index 9dcc05c..b7a4f11 100644
--- a/src/modules/checkers/checkers.c
+++ b/src/modules/checkers/checkers.c
@@ -79,7 +79,7 @@ static checkers_setup_t checkers_default_setup = {
};
-static til_module_context_t * checkers_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * checkers_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
size_t size = sizeof(checkers_context_t);
checkers_context_t *ctxt;
@@ -90,7 +90,7 @@ static til_module_context_t * checkers_create_context(unsigned seed, unsigned ti
if (((checkers_setup_t *)setup)->fill_module)
size += sizeof(til_module_context_t *) * n_cpus;
- ctxt = til_module_context_new(size, ticks, seed, n_cpus);
+ ctxt = til_module_context_new(size, ticks, seed, n_cpus, path);
if (!ctxt)
return NULL;
@@ -104,7 +104,7 @@ static til_module_context_t * checkers_create_context(unsigned seed, unsigned ti
/* since checkers is already threaded, create an n_cpus=1 context per-cpu */
for (unsigned i = 0; i < n_cpus; i++) /* TODO: errors */
- (void) til_module_create_context(module, seed, ticks, 1, module_setup, &ctxt->fill_module_contexts[i]);
+ (void) til_module_create_context(module, seed, ticks, 1, path /* FIXME TODO path-per-context breaks down on these per-cpu-context abuses */, module_setup, &ctxt->fill_module_contexts[i]);
/* XXX: it would be interesting to support various patterns/layouts by varying the seed, but this will require
* more complex context allocation strategies while also maintaining the per-cpu allocation.
diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c
index 613c864..a73f2b7 100644
--- a/src/modules/compose/compose.c
+++ b/src/modules/compose/compose.c
@@ -47,7 +47,7 @@ typedef struct compose_setup_t {
char *layers[];
} compose_setup_t;
-static til_module_context_t * compose_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup);
+static til_module_context_t * compose_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup);
static void compose_destroy_context(til_module_context_t *context);
static void compose_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
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);
@@ -67,7 +67,7 @@ til_module_t compose_module = {
};
-static til_module_context_t * compose_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * compose_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
compose_context_t *ctxt;
size_t n;
@@ -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, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(compose_context_t) + n * sizeof(compose_layer_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -89,7 +89,7 @@ static til_module_context_t * compose_create_context(unsigned seed, unsigned tic
(void) til_module_randomize_setup(layer_module, rand_r(&seed), &layer_setup, NULL);
ctxt->layers[i].module = layer_module;
- (void) til_module_create_context(layer_module, rand_r(&seed), ticks, 0, layer_setup, &ctxt->layers[i].module_ctxt);
+ (void) til_module_create_context(layer_module, rand_r(&seed), ticks, 0, path, layer_setup, &ctxt->layers[i].module_ctxt);
til_setup_free(layer_setup);
ctxt->n_layers++;
@@ -101,7 +101,7 @@ static til_module_context_t * compose_create_context(unsigned seed, unsigned tic
ctxt->texture.module = til_lookup_module(((compose_setup_t *)setup)->texture);
(void) til_module_randomize_setup(ctxt->texture.module, rand_r(&seed), &texture_setup, NULL);
- (void) til_module_create_context(ctxt->texture.module, rand_r(&seed), ticks, 0, texture_setup, &ctxt->texture.module_ctxt);
+ (void) til_module_create_context(ctxt->texture.module, rand_r(&seed), ticks, 0, path, 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 f8aabcd..e5b79eb 100644
--- a/src/modules/drizzle/drizzle.c
+++ b/src/modules/drizzle/drizzle.c
@@ -85,14 +85,14 @@ static inline uint32_t color_to_uint32(v3f_t color) {
}
-static til_module_context_t * drizzle_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * drizzle_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
drizzle_context_t *ctxt;
if (!setup)
setup = &drizzle_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(drizzle_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(drizzle_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c
index 5272e4d..4b75520 100644
--- a/src/modules/flui2d/flui2d.c
+++ b/src/modules/flui2d/flui2d.c
@@ -245,7 +245,7 @@ static void gamma_init(float gamma)
}
-static til_module_context_t * flui2d_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * flui2d_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
static int initialized;
flui2d_context_t *ctxt;
@@ -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, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(flui2d_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/julia/julia.c b/src/modules/julia/julia.c
index 2668061..0dcefe5 100644
--- a/src/modules/julia/julia.c
+++ b/src/modules/julia/julia.c
@@ -67,11 +67,11 @@ static uint32_t colors[] = {
};
-static til_module_context_t * julia_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * julia_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
julia_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(julia_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(julia_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/meta2d/meta2d.c b/src/modules/meta2d/meta2d.c
index 8af3981..978f32f 100644
--- a/src/modules/meta2d/meta2d.c
+++ b/src/modules/meta2d/meta2d.c
@@ -67,11 +67,11 @@ static inline uint32_t color_to_uint32(v3f_t color) {
}
-static til_module_context_t * meta2d_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * meta2d_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
meta2d_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(meta2d_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(meta2d_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/moire/moire.c b/src/modules/moire/moire.c
index d528f8c..9bf782c 100644
--- a/src/modules/moire/moire.c
+++ b/src/modules/moire/moire.c
@@ -47,14 +47,14 @@ static moire_setup_t moire_default_setup = {
};
-static til_module_context_t * moire_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * moire_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
moire_context_t *ctxt;
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, ticks, 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, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/montage/montage.c b/src/modules/montage/montage.c
index 1191a60..6697bc5 100644
--- a/src/modules/montage/montage.c
+++ b/src/modules/montage/montage.c
@@ -16,7 +16,7 @@ typedef struct montage_context_t {
size_t n_modules;
} montage_context_t;
-static til_module_context_t * montage_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup);
+static til_module_context_t * montage_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup);
static void montage_destroy_context(til_module_context_t *context);
static void montage_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan);
static void montage_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
@@ -32,13 +32,13 @@ til_module_t montage_module = {
};
-static til_module_context_t * montage_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * montage_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
const til_module_t **modules, *rtv_module, *compose_module;
size_t n_modules;
montage_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(montage_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(montage_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -92,7 +92,7 @@ static til_module_context_t * montage_create_context(unsigned seed, unsigned tic
(void) til_module_randomize_setup(module, rand_r(&seed), &setup, NULL);
/* FIXME errors */
- (void) til_module_create_context(module, rand_r(&seed), ticks, 1, setup, &ctxt->contexts[i]);
+ (void) til_module_create_context(module, rand_r(&seed), ticks, 1, path, setup, &ctxt->contexts[i]);
til_setup_free(setup);
}
diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c
index 6a6bfb3..f10bd5b 100644
--- a/src/modules/pixbounce/pixbounce.c
+++ b/src/modules/pixbounce/pixbounce.c
@@ -240,11 +240,11 @@ static uint32_t pick_color(unsigned *seedp)
return makergb(rand_r(seedp)%256, rand_r(seedp)%256, rand_r(seedp)%256, 1);
}
-static til_module_context_t * pixbounce_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * pixbounce_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
pixbounce_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(pixbounce_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(pixbounce_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/plasma/plasma.c b/src/modules/plasma/plasma.c
index b58e34f..f49b396 100644
--- a/src/modules/plasma/plasma.c
+++ b/src/modules/plasma/plasma.c
@@ -53,7 +53,7 @@ static void init_plasma(int32_t *costab, int32_t *sintab)
}
-static til_module_context_t * plasma_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * plasma_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
static int initialized;
plasma_context_t *ctxt;
@@ -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, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(plasma_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/plato/plato.c b/src/modules/plato/plato.c
index c3302f6..1e9f6bd 100644
--- a/src/modules/plato/plato.c
+++ b/src/modules/plato/plato.c
@@ -629,11 +629,11 @@ static void draw_polyhedron(const polyhedron_t *polyhedron, m4f_t *transform, ti
}
-static til_module_context_t * plato_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * plato_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
plato_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(plato_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(plato_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c
index 9814dcc..e3887b6 100644
--- a/src/modules/ray/ray.c
+++ b/src/modules/ray/ray.c
@@ -132,11 +132,11 @@ typedef struct ray_context_t {
} ray_context_t;
-static til_module_context_t * ray_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * ray_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
ray_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(ray_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(ray_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/roto/roto.c b/src/modules/roto/roto.c
index 1427947..c5106ab 100644
--- a/src/modules/roto/roto.c
+++ b/src/modules/roto/roto.c
@@ -62,7 +62,7 @@ static void init_roto(uint8_t texture[256][256], int32_t *costab, int32_t *sinta
}
-static til_module_context_t * roto_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * roto_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
static int initialized;
roto_context_t *ctxt;
@@ -73,7 +73,7 @@ static til_module_context_t * roto_create_context(unsigned seed, unsigned ticks,
init_roto(texture, costab, sintab);
}
- ctxt = til_module_context_new(sizeof(roto_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(roto_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c
index 13c8da9..a8cac2a 100644
--- a/src/modules/rtv/rtv.c
+++ b/src/modules/rtv/rtv.c
@@ -61,7 +61,7 @@ typedef struct rtv_setup_t {
} rtv_setup_t;
static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks);
-static til_module_context_t * rtv_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup);
+static til_module_context_t * rtv_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup);
static void rtv_destroy_context(til_module_context_t *context);
static void rtv_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
static void rtv_finish_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr);
@@ -188,7 +188,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, rand_r(&ctxt->til_module_context.seed), ticks, 0, ctxt->channel->module_setup, &ctxt->channel->module_ctxt);
+ (void) til_module_create_context(ctxt->channel->module, rand_r(&ctxt->til_module_context.seed), ticks, 0, ctxt->til_module_context.path, ctxt->channel->module_setup, &ctxt->channel->module_ctxt);
ctxt->channel->last_on_time = now;
}
@@ -215,7 +215,7 @@ static int rtv_should_skip_module(const rtv_setup_t *setup, const til_module_t *
}
-static til_module_context_t * rtv_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * rtv_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
rtv_context_t *ctxt;
const til_module_t **modules;
@@ -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, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(rtv_context_t) + n_channels * sizeof(rtv_channel_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
@@ -244,7 +244,7 @@ static til_module_context_t * rtv_create_context(unsigned seed, unsigned ticks,
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, rand_r(&seed), ticks, 0, NULL, &ctxt->snow_channel.module_ctxt);
+ (void) til_module_create_context(ctxt->snow_channel.module, rand_r(&seed), ticks, 0, path, 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 bce0a37..65a13fa 100644
--- a/src/modules/shapes/shapes.c
+++ b/src/modules/shapes/shapes.c
@@ -98,14 +98,14 @@ static shapes_setup_t shapes_default_setup = {
};
-static til_module_context_t * shapes_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * shapes_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
shapes_context_t *ctxt;
if (!setup)
setup = &shapes_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(shapes_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(shapes_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/snow/snow.c b/src/modules/snow/snow.c
index 1a171ee..9a86689 100644
--- a/src/modules/snow/snow.c
+++ b/src/modules/snow/snow.c
@@ -22,11 +22,11 @@ typedef struct snow_context_t {
} snow_context_t;
-static til_module_context_t * snow_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * snow_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
snow_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(snow_context_t) + n_cpus * sizeof(snow_seed_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(snow_context_t) + n_cpus * sizeof(snow_seed_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c
index 339e3e9..1a2c8bb 100644
--- a/src/modules/sparkler/sparkler.c
+++ b/src/modules/sparkler/sparkler.c
@@ -35,14 +35,14 @@ extern particle_ops_t simple_ops;
static sparkler_setup_t sparkler_default_setup;
-static til_module_context_t * sparkler_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * sparkler_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
sparkler_context_t *ctxt;
if (!setup)
setup = &sparkler_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(sparkler_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(sparkler_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/spiro/spiro.c b/src/modules/spiro/spiro.c
index 76b3a80..236dd4a 100644
--- a/src/modules/spiro/spiro.c
+++ b/src/modules/spiro/spiro.c
@@ -31,12 +31,12 @@ typedef struct spiro_context_t {
} spiro_context_t;
-static til_module_context_t * spiro_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * spiro_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
spiro_context_t *ctxt;
float z;
- ctxt = til_module_context_new(sizeof(spiro_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(spiro_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c
index 12de4ed..e8a2f18 100644
--- a/src/modules/stars/stars.c
+++ b/src/modules/stars/stars.c
@@ -69,7 +69,7 @@ float get_random_unit_coord(unsigned *seed) {
}
-static til_module_context_t * stars_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * stars_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
stars_context_t *ctxt;
float z;
@@ -78,7 +78,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, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(stars_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/strobe/strobe.c b/src/modules/strobe/strobe.c
index bff1e64..bc0c365 100644
--- a/src/modules/strobe/strobe.c
+++ b/src/modules/strobe/strobe.c
@@ -40,14 +40,14 @@ static strobe_setup_t strobe_default_setup = {
};
-static til_module_context_t * strobe_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * strobe_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
strobe_context_t *ctxt;
if (!setup)
setup = &strobe_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(strobe_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(strobe_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/submit/submit.c b/src/modules/submit/submit.c
index 5f46461..f46a205 100644
--- a/src/modules/submit/submit.c
+++ b/src/modules/submit/submit.c
@@ -267,14 +267,14 @@ static void setup_grid(submit_context_t *ctxt)
}
-static til_module_context_t * submit_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * submit_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
submit_context_t *ctxt;
if (!setup)
setup = &submit_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(submit_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(submit_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/swab/swab.c b/src/modules/swab/swab.c
index 6d1c3d9..b7ccf9d 100644
--- a/src/modules/swab/swab.c
+++ b/src/modules/swab/swab.c
@@ -66,11 +66,11 @@ static inline uint32_t color_to_uint32(color_t color) {
}
-static til_module_context_t * swab_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * swab_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
swab_context_t *ctxt;
- ctxt = til_module_context_new(sizeof(swab_context_t), seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(swab_context_t), seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/swarm/swarm.c b/src/modules/swarm/swarm.c
index c896735..48b70aa 100644
--- a/src/modules/swarm/swarm.c
+++ b/src/modules/swarm/swarm.c
@@ -181,14 +181,14 @@ static inline uint32_t color_to_uint32(v3f_t color) {
}
-static til_module_context_t * swarm_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * swarm_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
swarm_context_t *ctxt;
if (!setup)
setup = &swarm_default_setup.til_setup;
- ctxt = til_module_context_new(sizeof(swarm_context_t) + sizeof(*(ctxt->boids)) * SWARM_SIZE, seed, ticks, n_cpus);
+ ctxt = til_module_context_new(sizeof(swarm_context_t) + sizeof(*(ctxt->boids)) * SWARM_SIZE, seed, ticks, n_cpus, path);
if (!ctxt)
return NULL;
diff --git a/src/modules/voronoi/voronoi.c b/src/modules/voronoi/voronoi.c
index 2d1c8e5..bf82ca3 100644
--- a/src/modules/voronoi/voronoi.c
+++ b/src/modules/voronoi/voronoi.c
@@ -80,14 +80,14 @@ static void voronoi_randomize(voronoi_context_t *ctxt)
}
-static til_module_context_t * voronoi_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup)
+static til_module_context_t * voronoi_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup)
{
voronoi_context_t *ctxt;
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, ticks, 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, path);
if (!ctxt)
return NULL;
diff --git a/src/til.c b/src/til.c
index f7e3225..9435e28 100644
--- a/src/til.c
+++ b/src/til.c
@@ -223,23 +223,40 @@ void til_module_render(til_module_context_t *context, unsigned ticks, til_fb_fra
* the purpose of explicitly constraining rendering parallelization to less than n_threads,
* if n_cpus is specified > n_threads it won't increase n_threads...
*/
-int til_module_create_context(const til_module_t *module, unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup, til_module_context_t **res_context)
+int til_module_create_context(const til_module_t *module, unsigned seed, unsigned ticks, unsigned n_cpus, const char *parent_path, til_setup_t *setup, til_module_context_t **res_context)
{
til_module_context_t *context;
+ char *path;
assert(module);
+ assert(parent_path);
assert(res_context);
+ {
+ size_t path_len;
+
+ /* TODO: when til_setup_t learns to name settings blocks, this would be where to override module->name with the setup-specified name */
+ path_len = strlen(parent_path) + 1 + strlen(module->name) + 1;
+ path = calloc(1, path_len);
+ if (!path)
+ return -ENOMEM;
+
+ snprintf(path, path_len, "%s/%s", parent_path, module->name);
+ }
+
if (!n_cpus)
n_cpus = til_threads_num_threads(til_threads);
if (!module->create_context)
- context = til_module_context_new(sizeof(til_module_context_t), seed, ticks, n_cpus);
+ context = til_module_context_new(sizeof(til_module_context_t), seed, ticks, n_cpus, path);
else
- context = module->create_context(seed, ticks, n_cpus, setup);
+ context = module->create_context(seed, ticks, n_cpus, path, setup);
+
+ if (!context) {
+ free(path);
- if (!context)
return -ENOMEM;
+ }
context->module = module;
diff --git a/src/til.h b/src/til.h
index 5d19ea7..852cb96 100644
--- a/src/til.h
+++ b/src/til.h
@@ -22,7 +22,7 @@ typedef struct til_knob_t til_knob_t;
#define TIL_MODULE_OVERLAYABLE 1u
typedef struct til_module_t {
- til_module_context_t * (*create_context)(unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup);
+ til_module_context_t * (*create_context)(unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup);
void (*destroy_context)(til_module_context_t *context);
void (*prepare_frame)(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan);
void (*render_fragment)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr);
@@ -41,7 +41,7 @@ void til_shutdown(void);
const til_module_t * til_lookup_module(const char *name);
void til_get_modules(const til_module_t ***res_modules, size_t *res_n_modules);
void til_module_render(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr);
-int til_module_create_context(const til_module_t *module, unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup, til_module_context_t **res_context);
+int til_module_create_context(const til_module_t *module, unsigned seed, unsigned ticks, unsigned n_cpus, const char *parent_path, til_setup_t *setup, til_module_context_t **res_context);
til_module_context_t * til_module_destroy_context(til_module_context_t *context);
int til_module_setup(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup);
int til_module_randomize_setup(const til_module_t *module, unsigned seed, til_setup_t **res_setup, char **res_arg);
diff --git a/src/til_module_context.c b/src/til_module_context.c
index 59f3f9d..5dffa73 100644
--- a/src/til_module_context.c
+++ b/src/til_module_context.c
@@ -22,13 +22,16 @@
* Note this returns void * despite creating a til_module_context_t, this is for convenience
* 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.
+ *
+ * path must not be NULL, and the context takes ownership of the path; it's freed @ context_free().
*/
-void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsigned n_cpus)
+void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsigned n_cpus, char *path)
{
til_module_context_t *module_context;
assert(size >= sizeof(til_module_context_t));
assert(n_cpus > 0);
+ assert(path); /* modules must be able to key things like taps off their context's path */
module_context = calloc(1, size);
if (!module_context)
@@ -37,6 +40,7 @@ void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsign
module_context->seed = seed;
module_context->ticks = ticks;
module_context->n_cpus = n_cpus;
+ module_context->path = path;
return module_context;
}
@@ -49,13 +53,19 @@ void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsign
*/
void * til_module_context_free(til_module_context_t *module_context)
{
+ char *path;
+
if (!module_context)
return NULL;
+ path = module_context->path; /* free last just in case the module destructor makes use of it */
+
if (module_context->module->destroy_context)
module_context->module->destroy_context(module_context);
else
free(module_context);
+ free(path);
+
return NULL;
}
diff --git a/src/til_module_context.h b/src/til_module_context.h
index 43d06a7..d017a99 100644
--- a/src/til_module_context.h
+++ b/src/til_module_context.h
@@ -9,9 +9,10 @@ struct til_module_context_t {
unsigned seed;
unsigned ticks;
unsigned n_cpus;
+ char *path; /* for locating this instance of the module, NOT a file path */
};
-void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsigned n_cpus);
+void * til_module_context_new(size_t size, unsigned seed, unsigned ticks, unsigned n_cpus, char *path);
void * til_module_context_free(til_module_context_t *module_context);
#endif
© All Rights Reserved