From f7725299c3c7f7ea3f140e21d48210437b792362 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 8 Oct 2025 12:13:42 +0200 Subject: [PATCH] tc: add debug code for tc_set_vertex_elements_for_call_pending MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To make sure the issue fixed by the previous commit isn't reintrodued. Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_threaded_context.c | 13 +++++++++++++ src/gallium/auxiliary/util/u_threaded_context.h | 10 +++++++++- src/mesa/state_tracker/st_atom_array.cpp | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 70646a917bf..d3c977a5fc2 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -559,6 +559,10 @@ tc_batch_flush(struct threaded_context *tc, bool full_copy) struct tc_batch *next = &tc->batch_slots[tc->next]; unsigned next_id = (tc->next + 1) % TC_MAX_BATCHES; +#if !defined(NDEBUG) + assert(!next->tc_set_vertex_elements_for_call_pending); +#endif + tc_assert(next->num_total_slots != 0); tc_add_call_end(next); @@ -2296,6 +2300,12 @@ tc_add_set_vertex_elements_and_buffers_call(struct pipe_context *_pipe, tc_vertex_elements_and_buffers, count, extra_slots); p->count = count; + +#if !defined(NDEBUG) + struct tc_batch *next = &tc->batch_slots[tc->next]; + next->tc_set_vertex_elements_for_call_pending = true; +#endif + return p->slot; } @@ -5345,6 +5355,9 @@ tc_batch_execute(void *job, UNUSED void *gdata, int thread_index) tc_batch_check(batch); tc_set_driver_thread(batch->tc); +#if !defined(NDEBUG) + assert(!batch->tc_set_vertex_elements_for_call_pending); +#endif assert(!batch->token); /* setup renderpass info */ diff --git a/src/gallium/auxiliary/util/u_threaded_context.h b/src/gallium/auxiliary/util/u_threaded_context.h index 5a02f16aa0b..f0c592d99ad 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.h +++ b/src/gallium/auxiliary/util/u_threaded_context.h @@ -531,6 +531,7 @@ struct tc_batch { uint64_t slots[TC_SLOTS_PER_BATCH]; struct util_dynarray renderpass_infos; #if !defined(NDEBUG) + bool tc_set_vertex_elements_for_call_pending; bool closed; #endif }; @@ -865,9 +866,16 @@ tc_track_vertex_buffer(struct pipe_context *_pipe, unsigned index, * buffers. */ static inline void -tc_set_vertex_elements_for_call(struct pipe_vertex_buffer *buffers, +tc_set_vertex_elements_for_call(struct pipe_context *_pipe, + struct pipe_vertex_buffer *buffers, void *state) { +#if !defined(NDEBUG) + struct threaded_context *tc = threaded_context(_pipe); + struct tc_batch *next = &tc->batch_slots[tc->next]; + assert(next->tc_set_vertex_elements_for_call_pending); + next->tc_set_vertex_elements_for_call_pending = false; +#endif void **ptr = (void**)buffers; ptr[-1] = state; } diff --git a/src/mesa/state_tracker/st_atom_array.cpp b/src/mesa/state_tracker/st_atom_array.cpp index 45bf2674f49..5b18954c5db 100644 --- a/src/mesa/state_tracker/st_atom_array.cpp +++ b/src/mesa/state_tracker/st_atom_array.cpp @@ -477,7 +477,7 @@ st_update_array_templ(struct st_context *st, /* Set vertex buffers and elements. */ if (FILL_TC_SET_VB) { void *state = cso_get_vertex_elements_for_bind(cso, &velements); - tc_set_vertex_elements_for_call(vbuffer, state); + tc_set_vertex_elements_for_call(st->pipe, vbuffer, state); } else { cso_set_vertex_buffers_and_elements(cso, &velements, num_vbuffers, uses_user_vertex_buffers, vbuffer);