From 94f42bb201a95dded207d9d3ad3618c018cd0e02 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 11 Jul 2025 08:00:10 -0400 Subject: [PATCH] tc: fix usage wrapping in busy test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit un-wrapping requires adding INT8_MAX (not INT8_MAX-1) because e.g., the cases of batch_generation=126 and batch_generation=0 are not the same also fix a stale comment Fixes: b89e0fa226f ("tc: rework resource usage tracking to be lighter") Acked-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_threaded_context.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 269912ae022..44fe0ff18ac 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -377,12 +377,12 @@ tc_resource_batch_usage_test_busy(const struct threaded_context *tc, const struc int diff; if (tbuf->last_batch_usage < tc->last_completed) - /* account for wrapping */ - diff = (tbuf->last_batch_usage + (INT8_MAX - 1)) - tc->last_completed; + /* account for wrapping: un-wrap the resource's usage */ + diff = (tbuf->last_batch_usage + INT8_MAX) - tc->last_completed; else diff = tbuf->last_batch_usage - tc->last_completed; - /* if diff is positive, then batch usage has completed: resource is not busy */ + /* if diff is positive, then batch usage has not completed: resource is busy */ return diff > 0; }