summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-03-30 16:20:44 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-03-30 16:20:44 -0700
commit78c275b094b63e01a5f7bc71af80fe787911bbf4 (patch)
treed695440a22c2ff4308c4b196ac6d4ea042b3cdc6 /src/modules
parentad31d39a7edad0fc4c59a4fb254cbb214a4ed1b1 (diff)
*: wire up context-specific setup instances
This is a preparatory commit for cleaning up the existing sloppy global-ish application of settings during the iterative _setup() call sequences. Due to how this has evolved from a very rudimentary thing enjoying many assumptions about there ever only being a single module instance being configured by the settings, there's a lot of weirdness and inconsistency surrounding module setup WRT changes being applied instantaneously to /all/ existing and future context's renderings of a given module vs. requiring a new context be created to realize changes. This commit doesn't actually change any of that, but puts the plumbing in place for the setup methods to allocate and initialize a private struct encapsulating the parsed and validated setup once the settings are complete. This opaque setup pointer will then be provided to the associated create_context() method as the setup pointer. Then the created context can configure itself using the provided setup when non-NULL, or simply use defaults when NULL. A future commit will update the setup methods to allocate and populate their respective setup structs, adding the structs as needed, as well as updating their create_context() methods to utilize those setups. One consequence of these changes when fully realized will be that every setting change will require a new context be created from the changed settings for the change to be realized. For settings appropriately manipulated at runtime the concept of knobs was introduced but never finished. That will have to be finished in the future to enable more immediate/interactive changing of settings-like values appropriate for interactive manipulation
Diffstat (limited to 'src/modules')
-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.c2
-rw-r--r--src/modules/meta2d/meta2d.c2
-rw-r--r--src/modules/montage/montage.c6
-rw-r--r--src/modules/pixbounce/pixbounce.c2
-rw-r--r--src/modules/plasma/plasma.c2
-rw-r--r--src/modules/plato/plato.c2
-rw-r--r--src/modules/ray/ray.c2
-rw-r--r--src/modules/roto/roto.c2
-rw-r--r--src/modules/rtv/rtv.c19
-rw-r--r--src/modules/snow/snow.c2
-rw-r--r--src/modules/sparkler/sparkler.c4
-rw-r--r--src/modules/spiro/spiro.c2
-rw-r--r--src/modules/stars/stars.c4
-rw-r--r--src/modules/submit/submit.c4
-rw-r--r--src/modules/swab/swab.c2
-rw-r--r--src/modules/swarm/swarm.c4
19 files changed, 40 insertions, 39 deletions
diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c
index b3e2dbc..adf638c 100644
--- a/src/modules/compose/compose.c
+++ b/src/modules/compose/compose.c
@@ -36,10 +36,10 @@ typedef struct compose_context_t {
compose_layer_t layers[];
} compose_context_t;
-static void * compose_create_context(unsigned ticks, unsigned num_cpus);
+static void * compose_create_context(unsigned ticks, unsigned num_cpus, void *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);
+static int compose_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup);
static char *compose_default_layers[] = { "drizzle", "stars", "spiro", "plato", NULL };
static char **compose_layers;
@@ -55,7 +55,7 @@ til_module_t compose_module = {
};
-static void * compose_create_context(unsigned ticks, unsigned num_cpus)
+static void * compose_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
char **layers = compose_default_layers;
compose_context_t *ctxt;
@@ -78,7 +78,7 @@ static void * compose_create_context(unsigned ticks, unsigned num_cpus)
module = til_lookup_module(layers[i]);
ctxt->layers[i].module = module;
- (void) til_module_create_context(module, ticks, &ctxt->layers[i].module_ctxt);
+ (void) til_module_create_context(module, ticks, NULL, &ctxt->layers[i].module_ctxt);
ctxt->n_layers++;
}
@@ -108,7 +108,7 @@ static void compose_prepare_frame(void *context, unsigned ticks, unsigned n_cpus
}
-static int compose_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int compose_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *layers;
int r;
diff --git a/src/modules/drizzle/drizzle.c b/src/modules/drizzle/drizzle.c
index 294d671..0a53492 100644
--- a/src/modules/drizzle/drizzle.c
+++ b/src/modules/drizzle/drizzle.c
@@ -64,7 +64,7 @@ static inline uint32_t color_to_uint32(v3f_t color) {
}
-static void * drizzle_create_context(unsigned ticks, unsigned num_cpus)
+static void * drizzle_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
drizzle_context_t *ctxt;
@@ -153,7 +153,7 @@ static void drizzle_render_fragment(void *context, unsigned ticks, unsigned cpu,
}
-static int drizzle_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int drizzle_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *viscosity;
const char *values[] = {
diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c
index 7a30c7e..cf6024b 100644
--- a/src/modules/flui2d/flui2d.c
+++ b/src/modules/flui2d/flui2d.c
@@ -185,7 +185,7 @@ typedef struct flui2d_context_t {
} flui2d_context_t;
-static void * flui2d_create_context(unsigned ticks, unsigned num_cpus)
+static void * flui2d_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
flui2d_context_t *ctxt;
@@ -283,7 +283,7 @@ static void flui2d_render_fragment(void *context, unsigned ticks, unsigned cpu,
/* Settings hooks for configurable variables */
-static int flui2d_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int flui2d_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *viscosity;
const char *diffusion;
diff --git a/src/modules/julia/julia.c b/src/modules/julia/julia.c
index f00c44c..dfe6726 100644
--- a/src/modules/julia/julia.c
+++ b/src/modules/julia/julia.c
@@ -66,7 +66,7 @@ static uint32_t colors[] = {
};
-static void * julia_create_context(unsigned ticks, unsigned num_cpus)
+static void * julia_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
return calloc(1, sizeof(julia_context_t));
}
diff --git a/src/modules/meta2d/meta2d.c b/src/modules/meta2d/meta2d.c
index c1b2a8a..ddf20f1 100644
--- a/src/modules/meta2d/meta2d.c
+++ b/src/modules/meta2d/meta2d.c
@@ -66,7 +66,7 @@ static inline uint32_t color_to_uint32(v3f_t color) {
}
-static void * meta2d_create_context(unsigned ticks, unsigned num_cpus)
+static void * meta2d_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
meta2d_context_t *ctxt;
diff --git a/src/modules/montage/montage.c b/src/modules/montage/montage.c
index 5782782..5a9b688 100644
--- a/src/modules/montage/montage.c
+++ b/src/modules/montage/montage.c
@@ -16,7 +16,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 num_cpus);
+static void * montage_create_context(unsigned ticks, unsigned num_cpus, void *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);
@@ -32,7 +32,7 @@ til_module_t montage_module = {
};
-static void * montage_create_context(unsigned ticks, unsigned num_cpus)
+static void * montage_create_context(unsigned ticks, unsigned num_cpus, void *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 num_cpus)
const til_module_t *module = ctxt->modules[i];
if (module->create_context) /* FIXME errors */
- ctxt->contexts[i] = module->create_context(ticks, 1);
+ ctxt->contexts[i] = module->create_context(ticks, 1, NULL);
}
return ctxt;
diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c
index 3efa797..d016ff7 100644
--- a/src/modules/pixbounce/pixbounce.c
+++ b/src/modules/pixbounce/pixbounce.c
@@ -109,7 +109,7 @@ static int pick_pix(int num_pics, int last_pic)
return pix_num;
}
-static void * pixbounce_create_context(unsigned ticks, unsigned num_cpus)
+static void * pixbounce_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
pixbounce_context_t *ctxt;
diff --git a/src/modules/plasma/plasma.c b/src/modules/plasma/plasma.c
index 7598fe3..c6380ef 100644
--- a/src/modules/plasma/plasma.c
+++ b/src/modules/plasma/plasma.c
@@ -52,7 +52,7 @@ static void init_plasma(int32_t *costab, int32_t *sintab)
}
-static void * plasma_create_context(unsigned ticks, unsigned num_cpus)
+static void * plasma_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
static int initialized;
diff --git a/src/modules/plato/plato.c b/src/modules/plato/plato.c
index 05d80cb..c8aba18 100644
--- a/src/modules/plato/plato.c
+++ b/src/modules/plato/plato.c
@@ -609,7 +609,7 @@ static void draw_polyhedron(const polyhedron_t *polyhedron, m4f_t *transform, ti
}
-static void * plato_create_context(unsigned ticks, unsigned num_cpus)
+static void * plato_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
plato_context_t *ctxt;
diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c
index 06b0180..79e14ce 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 num_cpus)
+static void * ray_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
return calloc(1, sizeof(ray_context_t));
}
diff --git a/src/modules/roto/roto.c b/src/modules/roto/roto.c
index 7aff770..ac66987 100644
--- a/src/modules/roto/roto.c
+++ b/src/modules/roto/roto.c
@@ -32,7 +32,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 num_cpus)
+static void * roto_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
return calloc(1, sizeof(roto_context_t));
}
diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c
index 1804613..b49ac37 100644
--- a/src/modules/rtv/rtv.c
+++ b/src/modules/rtv/rtv.c
@@ -24,6 +24,7 @@
typedef struct rtv_channel_t {
const til_module_t *module;
void *module_ctxt;
+ void *module_setup;
time_t last_on_time, cumulative_time;
char *settings;
txt_t *caption;
@@ -44,11 +45,11 @@ typedef struct rtv_context_t {
} rtv_context_t;
static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks);
-static void * rtv_create_context(unsigned ticks, unsigned num_cpus);
+static void * rtv_create_context(unsigned ticks, unsigned num_cpus, void *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);
-static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc);
+static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup);
static unsigned rtv_duration = RTV_DURATION_SECS;
static unsigned rtv_context_duration = RTV_CONTEXT_DURATION_SECS;
@@ -92,7 +93,7 @@ static void randomize_channels(rtv_context_t *ctxt)
}
-static char * randomize_module_setup(const til_module_t *module)
+static char * randomize_module_setup(const til_module_t *module, void **res_setup)
{
til_settings_t *settings;
til_setting_t *setting;
@@ -106,7 +107,7 @@ static char * randomize_module_setup(const til_module_t *module)
if (!settings)
return NULL;
- while (module->setup(settings, &setting, &desc) > 0) {
+ while (module->setup(settings, &setting, &desc, res_setup) > 0) {
if (desc->random) {
char *value;
@@ -181,7 +182,7 @@ static void setup_next_channel(rtv_context_t *ctxt, unsigned ticks)
char *settings;
txt_t *caption;
- settings = randomize_module_setup(ctxt->channel->module);
+ settings = randomize_module_setup(ctxt->channel->module, &ctxt->channel->module_setup);
caption = txt_newf("Title: %s%s%s\nDescription: %s%s%s",
ctxt->channel->module->name,
ctxt->channel->module->author ? "\nAuthor: " : "",
@@ -199,7 +200,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_ctxt);
+ (void) til_module_create_context(ctxt->channel->module, ticks, ctxt->channel->module_setup, &ctxt->channel->module_ctxt);
ctxt->channel->last_on_time = now;
}
@@ -223,7 +224,7 @@ static int rtv_should_skip_module(const rtv_context_t *ctxt, const til_module_t
}
-static void * rtv_create_context(unsigned ticks, unsigned num_cpus)
+static void * rtv_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
rtv_context_t *ctxt;
const til_module_t **modules;
@@ -241,7 +242,7 @@ static void * rtv_create_context(unsigned ticks, unsigned num_cpus)
ctxt->snow_channel.module = &none_module;
if (rtv_snow_module) {
ctxt->snow_channel.module = til_lookup_module(rtv_snow_module);
- (void) til_module_create_context(ctxt->snow_channel.module, ticks, &ctxt->snow_channel.module_ctxt);
+ (void) til_module_create_context(ctxt->snow_channel.module, ticks, NULL, &ctxt->snow_channel.module_ctxt);
}
for (size_t i = 0; i < n_modules; i++) {
@@ -307,7 +308,7 @@ static void rtv_finish_frame(void *context, unsigned ticks, til_fb_fragment_t *f
}
-static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *channels;
const char *duration;
diff --git a/src/modules/snow/snow.c b/src/modules/snow/snow.c
index cffc10c..f61f2e9 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)
+static void * snow_create_context(unsigned ticks, unsigned n_cpus, void *setup)
{
snow_context_t *ctxt;
diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c
index 7cebfcd..51184b1 100644
--- a/src/modules/sparkler/sparkler.c
+++ b/src/modules/sparkler/sparkler.c
@@ -25,7 +25,7 @@ extern particle_ops_t simple_ops;
static particles_conf_t sparkler_conf;
-static void * sparkler_create_context(unsigned ticks, unsigned num_cpus)
+static void * sparkler_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
static int initialized;
sparkler_context_t *ctxt;
@@ -96,7 +96,7 @@ static void sparkler_render_fragment(void *context, unsigned ticks, unsigned cpu
/* Settings hooks for configurable variables */
-static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *show_bsp_leafs;
const char *show_bsp_matches;
diff --git a/src/modules/spiro/spiro.c b/src/modules/spiro/spiro.c
index 7f31ddb..20fd7f0 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 num_cpus)
+static void * spiro_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
spiro_context_t *ctxt;
float z;
diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c
index 859fb1f..055a495 100644
--- a/src/modules/stars/stars.c
+++ b/src/modules/stars/stars.c
@@ -41,7 +41,7 @@ float get_random_unit_coord() {
}
-static void * stars_create_context(unsigned ticks, unsigned num_cpus)
+static void * stars_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
stars_context_t *ctxt;
float z;
@@ -201,7 +201,7 @@ static void stars_render_fragment(void *context, unsigned ticks, unsigned cpu, t
ctxt->offset_y = tmp_y;
}
-int stars_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+int stars_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *rot_adj;
const char *rot_adj_values[] = {
diff --git a/src/modules/submit/submit.c b/src/modules/submit/submit.c
index db5cf29..a2dea77 100644
--- a/src/modules/submit/submit.c
+++ b/src/modules/submit/submit.c
@@ -261,7 +261,7 @@ static void setup_grid(submit_context_t *ctxt)
}
-static void * submit_create_context(unsigned ticks, unsigned num_cpus)
+static void * submit_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
submit_context_t *ctxt;
@@ -322,7 +322,7 @@ static void submit_render_fragment(void *context, unsigned ticks, unsigned cpu,
}
-static int submit_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int submit_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *values[] = {
"off",
diff --git a/src/modules/swab/swab.c b/src/modules/swab/swab.c
index fee20cf..b64ca2b 100644
--- a/src/modules/swab/swab.c
+++ b/src/modules/swab/swab.c
@@ -65,7 +65,7 @@ static inline uint32_t color_to_uint32(color_t color) {
}
-static void * swab_create_context(unsigned ticks, unsigned num_cpus)
+static void * swab_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
swab_context_t *ctxt;
diff --git a/src/modules/swarm/swarm.c b/src/modules/swarm/swarm.c
index 8ff4812..ffaaa1d 100644
--- a/src/modules/swarm/swarm.c
+++ b/src/modules/swarm/swarm.c
@@ -170,7 +170,7 @@ static inline uint32_t color_to_uint32(v3f_t color) {
}
-static void * swarm_create_context(unsigned ticks, unsigned num_cpus)
+static void * swarm_create_context(unsigned ticks, unsigned num_cpus, void *setup)
{
swarm_context_t *ctxt;
@@ -408,7 +408,7 @@ static void swarm_render_fragment(void *context, unsigned ticks, unsigned cpu, t
}
-static int swarm_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc)
+static int swarm_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, void **res_setup)
{
const char *styles[] = {
"points",
© All Rights Reserved