diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2017-09-08 19:09:57 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2017-09-14 17:52:34 -0700 |
commit | 7e999e37a5cf65e466091f4d8eeb36a6cea20f52 (patch) | |
tree | fa1778c1daf753f46dcc1ca16d492dfa888f6fd3 /src/modules/roto | |
parent | 77f6d721564ceba589af14554685821aedfc8462 (diff) |
*: use fragment generator
Rather than laying out all fragments in a frame up-front in
ray_module_t.prepare_frame(), return a fragment generator
(rototiller_fragmenter_t) which produces the numbered fragment
as needed.
This removes complexity from the serially-executed
prepare_frame() and allows the individual fragments to be
computed in parallel by the different threads. It also
eliminates the need for a fragments array in the
rototiller_frame_t, indeed rototiller_frame_t is eliminated
altogether.
Diffstat (limited to 'src/modules/roto')
-rw-r--r-- | src/modules/roto/roto.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/modules/roto/roto.c b/src/modules/roto/roto.c index 2074414..f076188 100644 --- a/src/modules/roto/roto.c +++ b/src/modules/roto/roto.c @@ -25,6 +25,7 @@ typedef struct color_t { typedef struct roto_context_t { unsigned r, rr; + unsigned n_cpus; } roto_context_t; static int32_t costab[FIXED_TRIG_LUT_SIZE], sintab[FIXED_TRIG_LUT_SIZE]; @@ -168,8 +169,16 @@ static void init_roto(uint8_t texture[256][256], int32_t *costab, int32_t *sinta } +static int roto_fragmenter(void *context, const fb_fragment_t *fragment, unsigned num, fb_fragment_t *res_fragment) +{ + roto_context_t *ctxt = context; + + return fb_fragment_divide_single(fragment, ctxt->n_cpus, num, res_fragment); +} + + /* prepare a frame for concurrent rendering */ -static void roto_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fragment, rototiller_frame_t *res_frame) +static void roto_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fragment, rototiller_fragmenter_t *res_fragmenter) { roto_context_t *ctxt = context; static int initialized; @@ -180,8 +189,8 @@ static void roto_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fr init_roto(texture, costab, sintab); } - res_frame->n_fragments = n_cpus; - fb_fragment_divide(fragment, n_cpus, res_frame->fragments); + *res_fragmenter = roto_fragmenter; + ctxt->n_cpus = n_cpus; // This governs the rotation and color cycle. ctxt->r += FIXED_TO_INT(FIXED_MULT(FIXED_SIN(ctxt->rr), FIXED_NEW(16))); |