mesa: don't wraparound st_context::work_counter

st->release_counter is initialized to 0, so if we happen to call
st_add_releasebuf with a non-NULL releasebuf when st->work_counter
is 0 due to wraparound in st_context_add_work, we might end up never
calling st_prune_releasebufs.

Since st_context_add_work and st_add_releasebuf both use work_counter
as a "some work was done" and don't care about the actual value, we
can remove the wraparound which will fix the buffer not being released
issue.

Fixes: b3133e250e ("gallium: add pipe_context::resource_release to eliminate buffer refcounting")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14955
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14499
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
(cherry picked from commit 10d32feae8)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40359>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2026-03-02 11:30:43 +01:00 committed by Eric Engestrom
parent d6ea90b495
commit b299e0323a
2 changed files with 1 additions and 2 deletions

View file

@ -3544,7 +3544,7 @@
"description": "mesa: don't wraparound st_context::work_counter",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "b3133e250e1c40496d98c4ba52386b7ae423d194",
"notes": null

View file

@ -545,7 +545,6 @@ st_context_add_work(struct st_context *st)
* performance.
*/
if (unlikely(++st->work_counter % 512 == 0)) {
st->work_counter = 0;
if (!st->thread_scheduler_disabled)
st_context_apply_scheduler_policy(st);
}