summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-05-23 21:43:43 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-05-23 22:53:47 -0700
commit4268d43b2dac01c354409a0d5dbbbe903d6e28d0 (patch)
tree4ae509c12eed32bd55eec8f130930ccff8467340 /src
parentc1fed8c508dd89c86de7dd647de0d014c441344e (diff)
til: simplify fragment->cleared maintenance
Just assume a fragment has been logically cleared after til_module_render() has done all its potential steps. I'm not certain this doesn't break some existing assumptions WRT fragmented/threaded clears and their propagation out to the outer frame. But I've been operating under the assumption that this was already happening in terms of an implicit setting of til_fb_fragment_t.cleared after a module's render happened. Except I don't see anything in the existing code or history actually doing that, which is odd. For modules that don't invoke til_fb_fragment_clear() explicitly because they are frame-fillers (think submit, swab, ray, julia, plasma, these are all full-frame renders that don't benefit from pre-clearing), they weren't leaving fragment->cleared set, despite having fully initialized the frame's contents. We should be able to just assume after prepare/render/finish has happened for a given module, the target fragment has been cleared. Commit 4e5286 had introduced somewhat complicated .cleared maintenance and propagation for threaded renders, but when we just treat all finished module renders into a given fragment as logically clearing the fragment we can just skip all that.
Diffstat (limited to 'src')
-rw-r--r--src/til.c2
-rw-r--r--src/til_threads.c15
2 files changed, 5 insertions, 12 deletions
diff --git a/src/til.c b/src/til.c
index ce63b59..56944cb 100644
--- a/src/til.c
+++ b/src/til.c
@@ -188,6 +188,8 @@ static void module_render_fragment(const til_module_t *module, void *context, ti
if (module->finish_frame)
module->finish_frame(context, ticks, fragment);
+
+ fragment->cleared = 1;
}
diff --git a/src/til_threads.c b/src/til_threads.c
index bb19b05..9f5c191 100644
--- a/src/til_threads.c
+++ b/src/til_threads.c
@@ -18,8 +18,6 @@ typedef struct til_threads_t {
pthread_mutex_t idle_mutex;
pthread_cond_t idle_cond;
- unsigned idle_n_fragments;
- unsigned idle_n_cleared;
unsigned n_idle;
pthread_mutex_t frame_mutex;
@@ -47,7 +45,7 @@ static void * thread_func(void *_thread)
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
for (;;) {
- unsigned n_fragments = 0, n_cleared = 0;
+ unsigned n_fragments = 0;
/* wait for a new frame */
pthread_mutex_lock(&threads->frame_mutex);
@@ -68,22 +66,15 @@ static void * thread_func(void *_thread)
break;
threads->render_fragment_func(threads->context, threads->ticks, thread->id, &fragment);
- n_cleared += fragment.cleared;
n_fragments++;
}
/* report as idle */
pthread_mutex_lock(&threads->idle_mutex);
pthread_cleanup_push((void (*)(void *))pthread_mutex_unlock, &threads->idle_mutex);
- threads->idle_n_fragments += n_fragments;
- threads->idle_n_cleared += n_cleared;
threads->n_idle++;
- if (threads->n_idle == threads->n_threads) { /* Frame finished! Notify potential waiter. */
- if (threads->idle_n_cleared == threads->idle_n_fragments)
- threads->fragment->cleared = 1;
-
+ if (threads->n_idle == threads->n_threads) /* Frame finished! Notify potential waiter. */
pthread_cond_signal(&threads->idle_cond);
- }
pthread_cleanup_pop(1);
}
@@ -115,7 +106,7 @@ void til_threads_frame_submit(til_threads_t *threads, til_fb_fragment_t *fragmen
threads->context = context;
threads->ticks = ticks;
threads->frame_num++;
- threads->n_idle = threads->idle_n_cleared = threads->idle_n_fragments = threads->next_fragment = 0;
+ threads->n_idle = threads->next_fragment = 0;
pthread_cond_broadcast(&threads->frame_cond);
pthread_cleanup_pop(1);
}
© All Rights Reserved