gallium/u_threaded: use TC_END_BATCH to terminate the loop

TC_END_BATCH (TC_NUM_CALLS) is always present as the batch terminator,
so use it

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33087>
This commit is contained in:
Marek Olšák 2025-01-16 03:06:27 -05:00
parent 1776a12949
commit c2983d93da

View file

@ -73,6 +73,7 @@ enum tc_call_id {
#include "u_threaded_context_calls.h" #include "u_threaded_context_calls.h"
#undef CALL #undef CALL
TC_NUM_CALLS, TC_NUM_CALLS,
TC_END_BATCH = TC_NUM_CALLS,
}; };
static void static void
@ -467,7 +468,7 @@ tc_add_call_end(struct tc_batch *next)
assert(next->num_total_slots < TC_SLOTS_PER_BATCH); assert(next->num_total_slots < TC_SLOTS_PER_BATCH);
struct tc_call_base *call = struct tc_call_base *call =
(struct tc_call_base*)&next->slots[next->num_total_slots]; (struct tc_call_base*)&next->slots[next->num_total_slots];
call->call_id = TC_NUM_CALLS; call->call_id = TC_END_BATCH;
call->num_slots = 1; call->num_slots = 1;
} }
@ -5036,16 +5037,20 @@ static const tc_execute execute_func[TC_NUM_CALLS] = {
}; };
ALWAYS_INLINE static void ALWAYS_INLINE static void
batch_execute(struct tc_batch *batch, struct pipe_context *pipe, uint64_t *last, bool parsing) batch_execute(struct tc_batch *batch, struct pipe_context *pipe, bool parsing)
{ {
/* if the framebuffer state is persisting from a previous batch, /* if the framebuffer state is persisting from a previous batch,
* begin incrementing renderpass info on the first set_framebuffer_state call * begin incrementing renderpass info on the first set_framebuffer_state call
*/ */
bool first = !batch->first_set_fb; bool first = !batch->first_set_fb;
uint64_t *iter = batch->slots;
for (uint64_t *iter = batch->slots; iter != last;) { while (1) {
struct tc_call_base *call = (struct tc_call_base *)iter; struct tc_call_base *call = (struct tc_call_base *)iter;
if (call->call_id == TC_END_BATCH)
return;
tc_assert(call->sentinel == TC_SENTINEL); tc_assert(call->sentinel == TC_SENTINEL);
#if TC_DEBUG >= 3 #if TC_DEBUG >= 3
@ -5085,7 +5090,6 @@ tc_batch_execute(void *job, UNUSED void *gdata, int thread_index)
{ {
struct tc_batch *batch = job; struct tc_batch *batch = job;
struct pipe_context *pipe = batch->tc->pipe; struct pipe_context *pipe = batch->tc->pipe;
uint64_t *last = &batch->slots[batch->num_total_slots];
tc_batch_check(batch); tc_batch_check(batch);
tc_set_driver_thread(batch->tc); tc_set_driver_thread(batch->tc);
@ -5096,7 +5100,7 @@ tc_batch_execute(void *job, UNUSED void *gdata, int thread_index)
batch->tc->renderpass_info = batch->renderpass_infos.data; batch->tc->renderpass_info = batch->renderpass_infos.data;
if (batch->tc->options.parse_renderpass_info) { if (batch->tc->options.parse_renderpass_info) {
batch_execute(batch, pipe, last, true); batch_execute(batch, pipe, true);
struct tc_batch_rp_info *info = batch->renderpass_infos.data; struct tc_batch_rp_info *info = batch->renderpass_infos.data;
for (unsigned i = 0; i < batch->max_renderpass_info_idx + 1; i++) { for (unsigned i = 0; i < batch->max_renderpass_info_idx + 1; i++) {
@ -5105,7 +5109,7 @@ tc_batch_execute(void *job, UNUSED void *gdata, int thread_index)
info[i].next = NULL; info[i].next = NULL;
} }
} else { } else {
batch_execute(batch, pipe, last, false); batch_execute(batch, pipe, false);
} }
/* Add the fence to the list of fences for the driver to signal at the next /* Add the fence to the list of fences for the driver to signal at the next