r600: fix refcnt imbalance related to atomic_buffer_state

Indeed, these references are not freed.

For instance, this issue is triggered on an evergreen card with
"piglit/bin/shader_runner tests/spec/arb_shader_atomic_counter_ops/execution/all_touch_test.shader_test -auto -fbo"
while setting GALLIUM_REFCNT_LOG=refcnt.log.

Fixes: 06993e4ee3 ("r600: add support for hw atomic counters. (v3)")
Signed-off-by: Patrick Lerda <patrick9876@free.fr>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22798>
(cherry picked from commit 4ca8be82d5)
This commit is contained in:
Patrick Lerda 2023-04-22 13:18:58 +02:00 committed by Eric Engestrom
parent 788cfe061b
commit 88f1aac5b2
2 changed files with 11 additions and 1 deletions

View file

@ -13,7 +13,7 @@
"description": "r600: fix refcnt imbalance related to atomic_buffer_state",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "06993e4ee350b9c2ab1e3ee7686878add3900d39"
},

View file

@ -130,6 +130,16 @@ static void r600_destroy_context(struct pipe_context *context)
r600_resource_reference(&rctx->last_trace_buf, NULL);
radeon_clear_saved_cs(&rctx->last_gfx);
switch (rctx->b.gfx_level) {
case EVERGREEN:
case CAYMAN:
for (i = 0; i < EG_MAX_ATOMIC_BUFFERS; ++i)
pipe_resource_reference(&rctx->atomic_buffer_state.buffer[i].buffer, NULL);
break;
default:
break;
}
FREE(rctx);
}