diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2022-07-21 22:35:17 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2022-07-21 22:35:17 -0700 |
commit | 3350c54719272d8c49b1b579c7711d13a8f290d5 (patch) | |
tree | 31cc4625fce0231751fc8b4acd253ef8390b90bc | |
parent | 75bdc9a1563056582866f5bb370abee4c1a27538 (diff) |
til: simplify and clarify module_render_fragment()
This consolidates the prepare_frame+render_fragment
potentially-threaded branch but more importantly introduces some
asserts codifying the whole prepare_frame() must return a
fragmenter /and/ be accompanied by a render_fragment().
Any single-threaded modules are expected to just populate
render_fragment() and leave prepare_frame() unused.
-rw-r--r-- | src/til.c | 25 |
1 files changed, 14 insertions, 11 deletions
@@ -173,24 +173,27 @@ static void module_render_fragment(til_module_context_t *context, til_threads_t module = context->module; - if (context->n_cpus > 1 && module->prepare_frame) { + if (module->prepare_frame) { til_frame_plan_t frame_plan = {}; module->prepare_frame(context, ticks, fragment, &frame_plan); - if (module->render_fragment) { + /* XXX: any module which provides prepare_frame() must return a frame_plan.fragmenter, + * and provide render_fragment() + */ + assert(frame_plan.fragmenter); + assert(module->render_fragment); + + if (context->n_cpus > 1) { til_threads_frame_submit(threads, fragment, &frame_plan, module->render_fragment, context, ticks); til_threads_wait_idle(threads); - } - } else if (module->prepare_frame) { - til_frame_plan_t frame_plan = {}; - unsigned fragnum = 0; - til_fb_fragment_t frag; - - module->prepare_frame(context, ticks, fragment, &frame_plan); + } else { + unsigned fragnum = 0; + til_fb_fragment_t frag; - while (frame_plan.fragmenter(context, fragment, fragnum++, &frag)) - module->render_fragment(context, ticks, 0, &frag); + while (frame_plan.fragmenter(context, fragment, fragnum++, &frag)) + module->render_fragment(context, ticks, 0, &frag); + } } else if (module->render_fragment) module->render_fragment(context, ticks, 0, fragment); |