From 5a0776f1fdc6b7780cd21d568150e804347a6f8a Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Tue, 14 Jun 2022 02:28:36 -0700 Subject: til: til_fb_fragment_t **fragment_ptr all the things Preparatory commit for enabling cloneable/swappable fragments There's an outstanding issue with the til_fb_page_t submission, see comments. Doesn't matter for now since cloning doesn't happen yet, but will need to be addressed before they do. --- src/til_threads.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/til_threads.c') 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; -- cgit v1.2.1