From 4ca8be82d5727337bb742ad205f0e156b597c3a6 Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Sat, 22 Apr 2023 13:18:58 +0200 Subject: [PATCH] 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: 06993e4ee350 ("r600: add support for hw atomic counters. (v3)") Signed-off-by: Patrick Lerda Reviewed-by: Gert Wollny Part-of: --- src/gallium/drivers/r600/r600_pipe.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 14311e66dc5..08f35d6013c 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -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); }