summaryrefslogtreecommitdiff
path: root/src/til_threads.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/til_threads.c')
-rw-r--r--src/til_threads.c20
1 files changed, 10 insertions, 10 deletions
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;
© All Rights Reserved