summaryrefslogtreecommitdiff
path: root/src/modules/plasma
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2017-09-08 19:09:57 -0700
committerVito Caputo <vcaputo@pengaru.com>2017-09-14 17:52:34 -0700
commit7e999e37a5cf65e466091f4d8eeb36a6cea20f52 (patch)
treefa1778c1daf753f46dcc1ca16d492dfa888f6fd3 /src/modules/plasma
parent77f6d721564ceba589af14554685821aedfc8462 (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/plasma')
-rw-r--r--src/modules/plasma/plasma.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/modules/plasma/plasma.c b/src/modules/plasma/plasma.c
index 9746882..b9c5cc4 100644
--- a/src/modules/plasma/plasma.c
+++ b/src/modules/plasma/plasma.c
@@ -26,6 +26,7 @@ static int32_t costab[FIXED_TRIG_LUT_SIZE], sintab[FIXED_TRIG_LUT_SIZE];
typedef struct plasma_context_t {
unsigned rr;
+ unsigned n_cpus;
} plasma_context_t;
static inline uint32_t color2pixel(color_t *color)
@@ -58,8 +59,16 @@ static void plasma_destroy_context(void *context)
}
+static int plasma_fragmenter(void *context, const fb_fragment_t *fragment, unsigned num, fb_fragment_t *res_fragment)
+{
+ plasma_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 plasma_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fragment, rototiller_frame_t *res_frame)
+static void plasma_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fragment, rototiller_fragmenter_t *res_fragmenter)
{
plasma_context_t *ctxt = context;
static int initialized;
@@ -70,9 +79,8 @@ static void plasma_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *
init_plasma(costab, sintab);
}
- res_frame->n_fragments = n_cpus;
- fb_fragment_divide(fragment, n_cpus, res_frame->fragments);
-
+ *res_fragmenter = plasma_fragmenter;
+ ctxt->n_cpus = n_cpus;
ctxt->rr += 3;
}
© All Rights Reserved