tc: fix usage wrapping in busy test
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

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: b89e0fa226 ("tc: rework resource usage tracking to be lighter")

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36069>
This commit is contained in:
Mike Blumenkrantz 2025-07-11 08:00:10 -04:00 committed by Marge Bot
parent e386680ab0
commit 94f42bb201

View file

@ -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;
}