From 88f1aac5b287ec6ccc2860bd5b4d62b90ff4b221 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: (cherry picked from commit 4ca8be82d5727337bb742ad205f0e156b597c3a6) --- .pick_status.json | 2 +- src/gallium/drivers/r600/r600_pipe.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 1b2e7093725..9e9cd307609 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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" }, diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index a7ba6f74644..b40f85994fa 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); }