From 5d8ccf598605c40ee9ec8e7372cc6675b3245e5a Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 5 Aug 2025 16:07:17 -0400 Subject: [PATCH] tc: break out buffer list busy check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no functional changes Reviewed-by: Marek Olšák Part-of: --- .../auxiliary/util/u_threaded_context.c | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index e23b337bdf8..91d502dcd96 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -1027,16 +1027,12 @@ tc_is_buffer_bound_for_write(struct threaded_context *tc, uint32_t id) } static bool -tc_is_buffer_busy(struct threaded_context *tc, struct threaded_resource *tbuf, - unsigned map_usage) +tc_is_buffer_on_busy_list(const struct threaded_context *tc, const struct threaded_resource *tbuf) { - if (!tc->options.is_resource_busy) - return true; - uint32_t id_hash = tbuf->buffer_id_unique & TC_BUFFER_ID_MASK; for (unsigned i = 0; i < TC_MAX_BUFFER_LISTS; i++) { - struct tc_buffer_list *buf_list = &tc->buffer_lists[i]; + struct tc_buffer_list *buf_list = (void*)&tc->buffer_lists[i]; /* If the buffer is referenced by a batch that hasn't been flushed (by tc or the driver), * then the buffer is considered busy. */ @@ -1044,6 +1040,18 @@ tc_is_buffer_busy(struct threaded_context *tc, struct threaded_resource *tbuf, BITSET_TEST(buf_list->buffer_list, id_hash)) return true; } + return false; +} + +static bool +tc_is_buffer_busy(struct threaded_context *tc, struct threaded_resource *tbuf, + unsigned map_usage) +{ + if (!tc->options.is_resource_busy) + return true; + + if (tc_is_buffer_on_busy_list(tc, tbuf)) + return true; /* The buffer isn't referenced by any unflushed batch: we can safely ask to the driver whether * this buffer is busy or not. */