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/julia | |
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/julia')
-rw-r--r-- | src/modules/julia/julia.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/modules/julia/julia.c b/src/modules/julia/julia.c index 3215902..f2fb87d 100644 --- a/src/modules/julia/julia.c +++ b/src/modules/julia/julia.c @@ -13,11 +13,12 @@ /* TODO: explore using C99 complex.h and its types? */ typedef struct julia_context_t { - float rr; - float realscale; - float imagscale; - float creal; - float cimag; + float rr; + float realscale; + float imagscale; + float creal; + float cimag; + unsigned n_cpus; } julia_context_t; static uint32_t colors[] = { @@ -100,13 +101,21 @@ static inline unsigned julia_iter(float real, float imag, float creal, float cim } +static int julia_fragmenter(void *context, const fb_fragment_t *fragment, unsigned num, fb_fragment_t *res_fragment) +{ + julia_context_t *ctxt = context; + + return fb_fragment_divide_single(fragment, ctxt->n_cpus, num, res_fragment); +} + + /* Prepare a frame for concurrent drawing of fragment using multiple fragments */ -static void julia_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fragment, rototiller_frame_t *res_frame) +static void julia_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fragment, rototiller_fragmenter_t *res_fragmenter) { julia_context_t *ctxt = context; - res_frame->n_fragments = n_cpus; - fb_fragment_divide(fragment, n_cpus, res_frame->fragments); + *res_fragmenter = julia_fragmenter; + ctxt->n_cpus = n_cpus; ctxt->rr += .01; /* Rather than just sweeping creal,cimag from -2.0-+2.0, I try to keep things confined |