diff options
Diffstat (limited to 'src')
29 files changed, 182 insertions, 127 deletions
@@ -319,15 +319,28 @@ static void * rototiller_thread(void *_rt) struct timeval now; for (;;) { - til_fb_page_t *page; - unsigned ticks; + til_fb_page_t *page; + til_fb_fragment_t *fragment; + unsigned ticks; page = til_fb_page_get(rt->fb); + fragment = &page->fragment; gettimeofday(&now, NULL); ticks = get_ticks(&rt->start_tv, &now, rt->ticks_offset); - til_module_render(rt->module_context, ticks, &page->fragment); + /* XXX FIXME this needs refactoring, maybe til_fb_fragment_ops_t needs + * to implement the page_put, then til_fb_page_get() just returns a + * fragment with a put method. + * + * I've hacked it for now, but it's broken once cloning becomes a thing + * because we assume that page contains fragment @ put time. When a + * clone could have replaced the fragment, and it's the replacement page + * that must be submitted. what makes a page? being submittable, so + * maybe just make submit another op on the fragment and get rid of the + * til_fb_page_t type altogether... hacked to build for now. + */ + til_module_render(rt->module_context, ticks, &fragment); til_fb_page_put(rt->fb, page); } diff --git a/src/modules/blinds/blinds.c b/src/modules/blinds/blinds.c index aa71ddd..d3cddf2 100644 --- a/src/modules/blinds/blinds.c +++ b/src/modules/blinds/blinds.c @@ -83,9 +83,10 @@ static inline void draw_blind_vertical(til_fb_fragment_t *fragment, unsigned col /* draw blinds over the fragment */ -static void blinds_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void blinds_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { blinds_context_t *ctxt = (blinds_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; static float rr; diff --git a/src/modules/checkers/checkers.c b/src/modules/checkers/checkers.c index 20ecd63..32b5aa3 100644 --- a/src/modules/checkers/checkers.c +++ b/src/modules/checkers/checkers.c @@ -200,9 +200,10 @@ static int checkers_fragmenter(til_module_context_t *context, const til_fb_fragm } -static void checkers_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void checkers_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { checkers_context_t *ctxt = (checkers_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; /* XXX: note cpu_affinity is required when fill_module is used, to ensure module_contexts * have a stable relationship to fragnum. Otherwise the output would be unstable because the @@ -227,9 +228,11 @@ static inline unsigned hash(unsigned x) } -static void checkers_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void checkers_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { checkers_context_t *ctxt = (checkers_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; + uint32_t color = ctxt->setup.color, flags = 0; checkers_fill_t fill = ctxt->setup.fill; int state; @@ -293,7 +296,7 @@ static void checkers_render_fragment(til_module_context_t *context, unsigned tic til_fb_fragment_fill(fragment, flags, color); else { /* TODO: we need a way to send down color and flags, and use the module render as a brush of sorts */ - til_module_render(ctxt->fill_module_contexts[cpu], ticks, fragment); + til_module_render(ctxt->fill_module_contexts[cpu], ticks, fragment_ptr); } } } diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c index ff32ac4..922a9b9 100644 --- a/src/modules/compose/compose.c +++ b/src/modules/compose/compose.c @@ -49,7 +49,7 @@ typedef struct compose_setup_t { static til_module_context_t * compose_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, 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); +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); static compose_setup_t compose_default_setup = { @@ -125,9 +125,10 @@ 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) +static void compose_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { compose_context_t *ctxt = (compose_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr, *texture = &ctxt->texture_fb; if (ctxt->texture.module) { if (!ctxt->texture_fb.buf || @@ -146,21 +147,23 @@ static void compose_render_fragment(til_module_context_t *context, unsigned tick } ctxt->texture_fb.cleared = 0; - til_module_render(ctxt->texture.module_ctxt, ticks, &ctxt->texture_fb); - - til_module_render(ctxt->layers[0].module_ctxt, ticks, fragment); + /* XXX: if when snapshotting becomes a thing, ctxt->texture_fb is snapshottable, this will likely break as-is */ + til_module_render(ctxt->texture.module_ctxt, ticks, &texture); + til_module_render(ctxt->layers[0].module_ctxt, ticks, &fragment); for (size_t i = 1; i < ctxt->n_layers; i++) { - til_fb_fragment_t textured = *fragment; - - textured.texture = &ctxt->texture_fb; + til_fb_fragment_t *old_texture = fragment->texture; - til_module_render(ctxt->layers[i].module_ctxt, ticks, &textured); + fragment->texture = texture; + til_module_render(ctxt->layers[i].module_ctxt, ticks, &fragment); + fragment->texture = old_texture; } } else { for (size_t i = 0; i < ctxt->n_layers; i++) - til_module_render(ctxt->layers[i].module_ctxt, ticks, fragment); + til_module_render(ctxt->layers[i].module_ctxt, ticks, &fragment); } + + *fragment_ptr = fragment; } diff --git a/src/modules/drizzle/drizzle.c b/src/modules/drizzle/drizzle.c index ec97d16..fff59bd 100644 --- a/src/modules/drizzle/drizzle.c +++ b/src/modules/drizzle/drizzle.c @@ -106,7 +106,7 @@ static void drizzle_destroy_context(til_module_context_t *context) } -static void drizzle_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void drizzle_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { drizzle_context_t *ctxt = (drizzle_context_t *)context; @@ -130,9 +130,11 @@ static void drizzle_prepare_frame(til_module_context_t *context, unsigned ticks, } -static void drizzle_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void drizzle_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { drizzle_context_t *ctxt = (drizzle_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; + float xf = 1.f / (float)fragment->frame_width; float yf = 1.f / (float)fragment->frame_height; v2f_t coord; diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c index cb249c3..5272e4d 100644 --- a/src/modules/flui2d/flui2d.c +++ b/src/modules/flui2d/flui2d.c @@ -273,10 +273,12 @@ static til_module_context_t * flui2d_create_context(unsigned seed, unsigned tick /* Prepare a frame for concurrent drawing of fragment using multiple fragments */ -static void flui2d_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void flui2d_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { flui2d_context_t *ctxt = (flui2d_context_t *)context; - float r = (ticks % (unsigned)(2 * M_PI * 1000)) * .001f; + til_fb_fragment_t *fragment = *fragment_ptr; + + float r = (ticks % (unsigned)(2 * M_PI * 1000)) * .001f; *res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_tile64 }; @@ -332,9 +334,10 @@ static void flui2d_prepare_frame(til_module_context_t *context, unsigned ticks, /* Draw a the flui2d densities */ -static void flui2d_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void flui2d_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { flui2d_context_t *ctxt = (flui2d_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; for (int y = fragment->y; y < fragment->y + fragment->height; y++) { int y0, y1; diff --git a/src/modules/julia/julia.c b/src/modules/julia/julia.c index aa05dd8..2668061 100644 --- a/src/modules/julia/julia.c +++ b/src/modules/julia/julia.c @@ -106,7 +106,7 @@ static inline unsigned julia_iter(float real, float imag, float creal, float cim /* Prepare a frame for concurrent drawing of fragment using multiple fragments */ -static void julia_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void julia_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { julia_context_t *ctxt = (julia_context_t *)context; @@ -133,9 +133,11 @@ static void julia_prepare_frame(til_module_context_t *context, unsigned ticks, t /* Draw a morphing Julia set */ -static void julia_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void julia_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { - julia_context_t *ctxt = (julia_context_t *)context; + julia_context_t *ctxt = (julia_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; + unsigned x, y; unsigned width = fragment->width, height = fragment->height; uint32_t *buf = fragment->buf; diff --git a/src/modules/meta2d/meta2d.c b/src/modules/meta2d/meta2d.c index b7b6708..8af3981 100644 --- a/src/modules/meta2d/meta2d.c +++ b/src/modules/meta2d/meta2d.c @@ -101,7 +101,7 @@ static void meta2d_destroy_context(til_module_context_t *context) } -static void meta2d_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void meta2d_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { meta2d_context_t *ctxt = (meta2d_context_t *)context; @@ -178,12 +178,14 @@ static void meta2d_prepare_frame(til_module_context_t *context, unsigned ticks, } -static void meta2d_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void meta2d_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { meta2d_context_t *ctxt = (meta2d_context_t *)context; - float xf = 2.f / (float)fragment->frame_width; - float yf = 2.f / (float)fragment->frame_height; - v2f_t coord; + til_fb_fragment_t *fragment = *fragment_ptr; + + float xf = 2.f / (float)fragment->frame_width; + float yf = 2.f / (float)fragment->frame_height; + v2f_t coord; for (int y = fragment->y; y < fragment->y + fragment->height; y++) { coord.y = yf * (float)y - 1.f; diff --git a/src/modules/moire/moire.c b/src/modules/moire/moire.c index ceeefe0..d528f8c 100644 --- a/src/modules/moire/moire.c +++ b/src/modules/moire/moire.c @@ -71,7 +71,7 @@ static til_module_context_t * moire_create_context(unsigned seed, unsigned ticks } -static void moire_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void moire_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { moire_context_t *ctxt = (moire_context_t *)context; @@ -84,12 +84,14 @@ static void moire_prepare_frame(til_module_context_t *context, unsigned ticks, t } -static void moire_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void moire_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { - moire_context_t *ctxt = (moire_context_t *)context; - float xf = 2.f / (float)fragment->frame_width; - float yf = 2.f / (float)fragment->frame_height; - float cx, cy; + moire_context_t *ctxt = (moire_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; + + float xf = 2.f / (float)fragment->frame_width; + float yf = 2.f / (float)fragment->frame_height; + float cx, cy; /* TODO: optimize */ cy = yf * (float)fragment->y - 1.f; diff --git a/src/modules/montage/montage.c b/src/modules/montage/montage.c index 7991e3f..eaf8be7 100644 --- a/src/modules/montage/montage.c +++ b/src/modules/montage/montage.c @@ -18,8 +18,8 @@ typedef struct montage_context_t { static til_module_context_t * montage_create_context(unsigned seed, unsigned ticks, unsigned n_cpus, 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, 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); +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); til_module_t montage_module = { @@ -184,15 +184,16 @@ static int montage_fragmenter(til_module_context_t *context, const til_fb_fragme } -static void montage_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +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) { *res_frame_plan = (til_frame_plan_t){ .fragmenter = montage_fragmenter }; } -static void montage_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void montage_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { montage_context_t *ctxt = (montage_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; if (fragment->number >= ctxt->n_modules) { til_fb_fragment_clear(fragment); @@ -200,5 +201,5 @@ static void montage_render_fragment(til_module_context_t *context, unsigned tick return; } - til_module_render(ctxt->contexts[fragment->number], ticks, fragment); + til_module_render(ctxt->contexts[fragment->number], ticks, fragment_ptr); } diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c index d200ad6..6a6bfb3 100644 --- a/src/modules/pixbounce/pixbounce.c +++ b/src/modules/pixbounce/pixbounce.c @@ -260,9 +260,10 @@ static til_module_context_t * pixbounce_create_context(unsigned seed, unsigned t return &ctxt->til_module_context; } -static void pixbounce_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void pixbounce_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { - pixbounce_context_t *ctxt = (pixbounce_context_t *)context; + pixbounce_context_t *ctxt = (pixbounce_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; int width = fragment->width, height = fragment->height; diff --git a/src/modules/plasma/plasma.c b/src/modules/plasma/plasma.c index 8cc4fda..b58e34f 100644 --- a/src/modules/plasma/plasma.c +++ b/src/modules/plasma/plasma.c @@ -75,7 +75,7 @@ static til_module_context_t * plasma_create_context(unsigned seed, unsigned tick /* Prepare a frame for concurrent drawing of fragment using multiple fragments */ -static void plasma_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void plasma_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { plasma_context_t *ctxt = (plasma_context_t *)context; @@ -85,17 +85,19 @@ static void plasma_prepare_frame(til_module_context_t *context, unsigned ticks, /* Draw a plasma effect */ -static void plasma_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void plasma_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { plasma_context_t *ctxt = (plasma_context_t *)context; - int xstep = PLASMA_WIDTH / fragment->frame_width; - int ystep = PLASMA_HEIGHT / fragment->frame_height; - unsigned width = fragment->width * xstep, height = fragment->height * ystep; - int fw2 = FIXED_NEW(width / 2), fh2 = FIXED_NEW(height / 2); - int x, y, cx, cy, dx2, dy2; - uint32_t *buf = fragment->buf; - color_t c = { .r = 0, .g = 0, .b = 0 }, cscale; - unsigned rr2, rr6, rr8, rr16, rr20, rr12; + til_fb_fragment_t *fragment = *fragment_ptr; + + int xstep = PLASMA_WIDTH / fragment->frame_width; + int ystep = PLASMA_HEIGHT / fragment->frame_height; + unsigned width = fragment->width * xstep, height = fragment->height * ystep; + int fw2 = FIXED_NEW(width / 2), fh2 = FIXED_NEW(height / 2); + int x, y, cx, cy, dx2, dy2; + uint32_t *buf = fragment->buf; + color_t c = { .r = 0, .g = 0, .b = 0 }, cscale; + unsigned rr2, rr6, rr8, rr16, rr20, rr12; rr2 = ctxt->rr * 2; rr6 = ctxt->rr * 6; diff --git a/src/modules/plato/plato.c b/src/modules/plato/plato.c index 43d9bdd..f56bef8 100644 --- a/src/modules/plato/plato.c +++ b/src/modules/plato/plato.c @@ -622,9 +622,10 @@ static til_module_context_t * plato_create_context(unsigned seed, unsigned ticks } -static void plato_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void plato_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { - plato_context_t *ctxt = (plato_context_t *)context; + plato_context_t *ctxt = (plato_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; ctxt->r += (float)(ticks - context->ticks) * .001f; context->ticks = ticks; diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c index ead6636..9814dcc 100644 --- a/src/modules/ray/ray.c +++ b/src/modules/ray/ray.c @@ -145,9 +145,10 @@ static til_module_context_t * ray_create_context(unsigned seed, unsigned ticks, /* prepare a frame for concurrent rendering */ -static void ray_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void ray_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { - ray_context_t *ctxt = (ray_context_t *)context; + ray_context_t *ctxt = (ray_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; *res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_tile64 }; #if 1 @@ -177,15 +178,16 @@ static void ray_prepare_frame(til_module_context_t *context, unsigned ticks, til /* ray trace a simple scene into the fragment */ -static void ray_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void ray_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { - ray_context_t *ctxt = (ray_context_t *)context; + ray_context_t *ctxt = (ray_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; ray_render_trace_fragment(ctxt->render, fragment); } -static void ray_finish_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment) +static void ray_finish_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr) { ray_context_t *ctxt = (ray_context_t *)context; diff --git a/src/modules/roto/roto.c b/src/modules/roto/roto.c index a8ee45d..e2abea3 100644 --- a/src/modules/roto/roto.c +++ b/src/modules/roto/roto.c @@ -174,7 +174,7 @@ static void init_roto(uint8_t texture[256][256], int32_t *costab, int32_t *sinta /* prepare a frame for concurrent rendering */ -static void roto_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void roto_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { roto_context_t *ctxt = (roto_context_t *)context; static int initialized; @@ -207,9 +207,11 @@ static void roto_prepare_frame(til_module_context_t *context, unsigned ticks, ti /* Draw a rotating checkered 256x256 texture into fragment. */ -static void roto_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void roto_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { - roto_context_t *ctxt = (roto_context_t *)context; + roto_context_t *ctxt = (roto_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; + int x, y, frame_width = fragment->frame_width, frame_height = fragment->frame_height; int y_cos_r, y_sin_r, x_cos_r, x_sin_r, x_cos_r_init, x_sin_r_init, cos_r, sin_r; uint32_t *buf = fragment->buf; diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c index 3a8e7fc..13c8da9 100644 --- a/src/modules/rtv/rtv.c +++ b/src/modules/rtv/rtv.c @@ -63,8 +63,8 @@ typedef struct 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 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); -static void rtv_finish_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment); +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); static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup); static rtv_setup_t rtv_default_setup = { @@ -268,7 +268,7 @@ 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) +static void rtv_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { rtv_context_t *ctxt = (rtv_context_t *)context; time_t now = time(NULL); @@ -279,13 +279,14 @@ static void rtv_render_fragment(til_module_context_t *context, unsigned ticks, u if (now >= ctxt->next_hide_caption) ctxt->caption = NULL; - til_module_render(ctxt->channel->module_ctxt, ticks, fragment); + til_module_render(ctxt->channel->module_ctxt, ticks, fragment_ptr); } -static void rtv_finish_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment) +static void rtv_finish_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr) { - rtv_context_t *ctxt = (rtv_context_t *)context; + rtv_context_t *ctxt = (rtv_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; if (!ctxt->caption) return; diff --git a/src/modules/shapes/shapes.c b/src/modules/shapes/shapes.c index 47bb8df..bce0a37 100644 --- a/src/modules/shapes/shapes.c +++ b/src/modules/shapes/shapes.c @@ -115,9 +115,11 @@ static til_module_context_t * shapes_create_context(unsigned seed, unsigned tick } -static void shapes_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void shapes_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { shapes_context_t *ctxt = (shapes_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; + unsigned size = MIN(fragment->frame_width, fragment->frame_height) * ctxt->setup.scale; unsigned xoff = (fragment->frame_width - size) >> 1; unsigned yoff = (fragment->frame_height - size) >> 1; diff --git a/src/modules/snow/snow.c b/src/modules/snow/snow.c index a367113..1a171ee 100644 --- a/src/modules/snow/snow.c +++ b/src/modules/snow/snow.c @@ -37,15 +37,17 @@ static til_module_context_t * snow_create_context(unsigned seed, unsigned ticks, } -static void snow_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void snow_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { *res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_slice_per_cpu }; } -static void snow_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void snow_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { - snow_context_t *ctxt = (snow_context_t *)context; + snow_context_t *ctxt = (snow_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; + unsigned *seed = &ctxt->seeds[cpu].seed; for (unsigned y = fragment->y; y < fragment->y + fragment->height; y++) { diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c index f0f2cb6..339e3e9 100644 --- a/src/modules/sparkler/sparkler.c +++ b/src/modules/sparkler/sparkler.c @@ -75,9 +75,10 @@ static void sparkler_destroy_context(til_module_context_t *context) } -static void sparkler_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void sparkler_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { sparkler_context_t *ctxt = (sparkler_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; *res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_slice_per_cpu }; @@ -91,9 +92,10 @@ static void sparkler_prepare_frame(til_module_context_t *context, unsigned ticks /* Render a 3D particle system */ -static void sparkler_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void sparkler_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { sparkler_context_t *ctxt = (sparkler_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; if (!ctxt->setup.show_bsp_matches) til_fb_fragment_clear(fragment); diff --git a/src/modules/spiro/spiro.c b/src/modules/spiro/spiro.c index 30e5f06..76b3a80 100644 --- a/src/modules/spiro/spiro.c +++ b/src/modules/spiro/spiro.c @@ -53,13 +53,13 @@ static til_module_context_t * spiro_create_context(unsigned seed, unsigned ticks return &ctxt->til_module_context; } -static void spiro_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void spiro_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { - spiro_context_t *ctxt = (spiro_context_t *)context; + spiro_context_t *ctxt = (spiro_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; - int width = fragment->frame_width, height = fragment->frame_height; - - int display_R, display_origin_x, display_origin_y; + int width = fragment->frame_width, height = fragment->frame_height; + int display_R, display_origin_x, display_origin_y; /* Based on the fragment's dimensions, calculate the origin and radius of the fixed outer circle, C0. */ diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c index 3a3f90f..8e6a5d0 100644 --- a/src/modules/stars/stars.c +++ b/src/modules/stars/stars.c @@ -109,9 +109,11 @@ static void stars_destroy_context(til_module_context_t *context) } -static void stars_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void stars_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { - stars_context_t *ctxt = (stars_context_t *)context; + stars_context_t *ctxt = (stars_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; + struct points* iterator; struct points* tmp_ptr; struct points* last_ptr=NULL; diff --git a/src/modules/submit/submit.c b/src/modules/submit/submit.c index daac37b..5f46461 100644 --- a/src/modules/submit/submit.c +++ b/src/modules/submit/submit.c @@ -294,7 +294,7 @@ static void submit_destroy_context(til_module_context_t *context) } -static void submit_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void submit_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { submit_context_t *ctxt = (submit_context_t *)context; @@ -317,9 +317,10 @@ static void submit_prepare_frame(til_module_context_t *context, unsigned ticks, } -static void submit_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void submit_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { submit_context_t *ctxt = (submit_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; if (!ctxt->bilerp) draw_grid(ctxt, fragment); diff --git a/src/modules/swab/swab.c b/src/modules/swab/swab.c index 9047f68..6d1c3d9 100644 --- a/src/modules/swab/swab.c +++ b/src/modules/swab/swab.c @@ -93,7 +93,7 @@ static void swab_destroy_context(til_module_context_t *context) } -static void swab_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void swab_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { swab_context_t *ctxt = (swab_context_t *)context; @@ -103,15 +103,17 @@ static void swab_prepare_frame(til_module_context_t *context, unsigned ticks, ti } -static void swab_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void swab_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { - swab_context_t *ctxt = (swab_context_t *)context; - float cos_r = cos(ctxt->r); - float sin_r = sin(ctxt->r); - float z1 = cos_r; - float z2 = sin_r; - float xscale = 1.f / (float)fragment->frame_width; - float yscale = 1.f / (float)fragment->frame_height; + swab_context_t *ctxt = (swab_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; + + float cos_r = cos(ctxt->r); + float sin_r = sin(ctxt->r); + float z1 = cos_r; + float z2 = sin_r; + float xscale = 1.f / (float)fragment->frame_width; + float yscale = 1.f / (float)fragment->frame_height; for (int y = fragment->y; y < fragment->y + fragment->height; y++) { float yscaled = (float)y * yscale; diff --git a/src/modules/swarm/swarm.c b/src/modules/swarm/swarm.c index 0c58bf9..c896735 100644 --- a/src/modules/swarm/swarm.c +++ b/src/modules/swarm/swarm.c @@ -401,9 +401,10 @@ static void swarm_draw_as_lines(swarm_context_t *ctxt, til_fb_fragment_t *fragme } -static void swarm_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void swarm_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { - swarm_context_t *ctxt = (swarm_context_t *)context; + swarm_context_t *ctxt = (swarm_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; swarm_update(ctxt, ticks); diff --git a/src/modules/voronoi/voronoi.c b/src/modules/voronoi/voronoi.c index 8e9a0f3..2d1c8e5 100644 --- a/src/modules/voronoi/voronoi.c +++ b/src/modules/voronoi/voronoi.c @@ -281,9 +281,10 @@ static void voronoi_sample_colors(voronoi_context_t *ctxt, til_fb_fragment_t *fr } -static void voronoi_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void voronoi_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { voronoi_context_t *ctxt = (voronoi_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; *res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_tile64 }; @@ -314,9 +315,10 @@ static void voronoi_prepare_frame(til_module_context_t *context, unsigned ticks, } -static void voronoi_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void voronoi_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { voronoi_context_t *ctxt = (voronoi_context_t *)context; + til_fb_fragment_t *fragment = *fragment_ptr; for (int y = 0; y < fragment->height; y++) { for (int x = 0; x < fragment->width; x++) { @@ -100,15 +100,15 @@ void til_shutdown(void) } -static void _blank_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment, til_frame_plan_t *res_frame_plan) +static void _blank_prepare_frame(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *res_frame_plan) { *res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_slice_per_cpu }; } -static void _blank_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment) +static void _blank_render_fragment(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr) { - til_fb_fragment_clear(fragment); + til_fb_fragment_clear(*fragment_ptr); } @@ -162,21 +162,21 @@ void til_get_modules(const til_module_t ***res_modules, size_t *res_n_modules) } -static void module_render_fragment(til_module_context_t *context, til_threads_t *threads, unsigned ticks, til_fb_fragment_t *fragment) +static void module_render_fragment(til_module_context_t *context, til_threads_t *threads, unsigned ticks, til_fb_fragment_t **fragment_ptr) { const til_module_t *module; assert(context); assert(context->module); assert(threads); - assert(fragment); + assert(fragment_ptr && *fragment_ptr); module = context->module; if (module->prepare_frame) { til_frame_plan_t frame_plan = {}; - module->prepare_frame(context, ticks, fragment, &frame_plan); + module->prepare_frame(context, ticks, fragment_ptr, &frame_plan); /* XXX: any module which provides prepare_frame() must return a frame_plan.fragmenter, * and provide render_fragment() @@ -185,31 +185,31 @@ static void module_render_fragment(til_module_context_t *context, til_threads_t assert(module->render_fragment); if (context->n_cpus > 1) { - til_threads_frame_submit(threads, fragment, &frame_plan, module->render_fragment, context, ticks); + til_threads_frame_submit(threads, fragment_ptr, &frame_plan, module->render_fragment, context, ticks); til_threads_wait_idle(threads); } else { unsigned fragnum = 0; - til_fb_fragment_t frag; + til_fb_fragment_t frag, *frag_ptr = &frag; - while (frame_plan.fragmenter(context, fragment, fragnum++, &frag)) - module->render_fragment(context, ticks, 0, &frag); + while (frame_plan.fragmenter(context, *fragment_ptr, fragnum++, &frag)) + module->render_fragment(context, ticks, 0, &frag_ptr); } } else if (module->render_fragment) - module->render_fragment(context, ticks, 0, fragment); + module->render_fragment(context, ticks, 0, fragment_ptr); if (module->finish_frame) - module->finish_frame(context, ticks, fragment); + module->finish_frame(context, ticks, fragment_ptr); - fragment->cleared = 1; + (*fragment_ptr)->cleared = 1; } /* This is a public interface to the threaded module rendering intended for use by * modules that wish to get the output of other modules for their own use. */ -void til_module_render(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment) +void til_module_render(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr) { - module_render_fragment(context, til_threads, ticks, fragment); + module_render_fragment(context, til_threads, ticks, fragment_ptr); } @@ -24,9 +24,9 @@ typedef struct til_knob_t til_knob_t; typedef struct til_module_t { til_module_context_t * (*create_context)(unsigned seed, unsigned ticks, unsigned n_cpus, 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, til_frame_plan_t *res_frame_plan); - void (*render_fragment)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment); - void (*finish_frame)(til_module_context_t *context, unsigned ticks, til_fb_fragment_t *fragment); + 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); + void (*finish_frame)(til_module_context_t *context, unsigned ticks, til_fb_fragment_t **fragment_ptr); int (*setup)(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup); size_t (*knobs)(til_module_context_t *context, til_knob_t **res_knobs); char *name; @@ -40,7 +40,7 @@ void til_quiesce(void); 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); +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); 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); diff --git a/src/til_threads.c b/src/til_threads.c index af4de53..e2c8a97 100644 --- a/src/til_threads.c +++ b/src/til_threads.c @@ -22,9 +22,9 @@ typedef struct til_threads_t { pthread_mutex_t frame_mutex; pthread_cond_t frame_cond; - void (*render_fragment_func)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment); + void (*render_fragment_func)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr); void *context; - til_fb_fragment_t *fragment; + til_fb_fragment_t **fragment_ptr; til_frame_plan_t frame_plan; unsigned ticks; @@ -63,27 +63,27 @@ static void * thread_func(void *_thread) * which may require a consistent mapping of CPU to fragnum across frames. */ for (;;) { - til_fb_fragment_t fragment; + til_fb_fragment_t frag, *frag_ptr = &frag; while (!__sync_bool_compare_and_swap(&threads->next_fragment, frag_num, frag_num + 1)); - if (!threads->frame_plan.fragmenter(threads->context, threads->fragment, frag_num, &fragment)) + if (!threads->frame_plan.fragmenter(threads->context, *(threads->fragment_ptr), frag_num, &frag)) break; - threads->render_fragment_func(threads->context, threads->ticks, thread->id, &fragment); + threads->render_fragment_func(threads->context, threads->ticks, thread->id, &frag_ptr); frag_num += threads->n_threads; } } else { /* render *any* available fragment */ for (;;) { unsigned frag_num; - til_fb_fragment_t fragment; + til_fb_fragment_t frag, *frag_ptr = &frag; frag_num = __sync_fetch_and_add(&threads->next_fragment, 1); - if (!threads->frame_plan.fragmenter(threads->context, threads->fragment, frag_num, &fragment)) + if (!threads->frame_plan.fragmenter(threads->context, *(threads->fragment_ptr), frag_num, &frag)) break; - threads->render_fragment_func(threads->context, threads->ticks, thread->id, &fragment); + threads->render_fragment_func(threads->context, threads->ticks, thread->id, &frag_ptr); } } @@ -112,13 +112,13 @@ void til_threads_wait_idle(til_threads_t *threads) /* submit a frame's fragments to the threads */ -void til_threads_frame_submit(til_threads_t *threads, til_fb_fragment_t *fragment, til_frame_plan_t *frame_plan, void (*render_fragment_func)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment), til_module_context_t *context, unsigned ticks) +void til_threads_frame_submit(til_threads_t *threads, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *frame_plan, void (*render_fragment_func)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr), til_module_context_t *context, unsigned ticks) { til_threads_wait_idle(threads); /* XXX: likely non-blocking; already happens pre page flip */ pthread_mutex_lock(&threads->frame_mutex); pthread_cleanup_push((void (*)(void *))pthread_mutex_unlock, &threads->frame_mutex); - threads->fragment = fragment; + threads->fragment_ptr = fragment_ptr; threads->frame_plan = *frame_plan; threads->render_fragment_func = render_fragment_func; threads->context = context; diff --git a/src/til_threads.h b/src/til_threads.h index 329ead9..4e6836d 100644 --- a/src/til_threads.h +++ b/src/til_threads.h @@ -7,7 +7,7 @@ typedef struct til_threads_t til_threads_t; til_threads_t * til_threads_create(); void til_threads_destroy(til_threads_t *threads); -void til_threads_frame_submit(til_threads_t *threads, til_fb_fragment_t *fragment, til_frame_plan_t *frame_plan, void (*render_fragment_func)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment), til_module_context_t *context, unsigned ticks); +void til_threads_frame_submit(til_threads_t *threads, til_fb_fragment_t **fragment_ptr, til_frame_plan_t *frame_plan, void (*render_fragment_func)(til_module_context_t *context, unsigned ticks, unsigned cpu, til_fb_fragment_t **fragment_ptr), til_module_context_t *context, unsigned ticks); void til_threads_wait_idle(til_threads_t *threads); unsigned til_threads_num_threads(til_threads_t *threads); |