From d30dedf5fb15e6d8ee4d1be067ddeb49e9d7ef43 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Fri, 11 Jul 2025 16:15:04 -0400 Subject: [PATCH] zink/kopper: Don't recycle unused acquire semaphores Fixes: e9f18f64b9ec ("zink: also cache swapchain semaphores") Reviewed-by: Mike Blumenkrantz Part-of: (cherry picked from commit 8d9675520fcae086ef3daa863043793534c036ea) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_kopper.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 009ec6eb32f..d82c468f992 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1594,7 +1594,7 @@ "description": "zink/kopper: Don't recycle unused acquire semaphores", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "e9f18f64b9ec56ed0e89a5baa41b4536585a8a90", "notes": null diff --git a/src/gallium/drivers/zink/zink_kopper.c b/src/gallium/drivers/zink/zink_kopper.c index 6069ae156d2..53a73ec6d7c 100644 --- a/src/gallium/drivers/zink/zink_kopper.c +++ b/src/gallium/drivers/zink/zink_kopper.c @@ -150,9 +150,14 @@ destroy_swapchain(struct zink_screen *screen, struct kopper_swapchain *cswap) return; util_queue_fence_destroy(&cswap->present_fence); for (unsigned i = 0; i < cswap->num_images; i++) { - simple_mtx_lock(&screen->semaphores_lock); - util_dynarray_append(&screen->semaphores, VkSemaphore, cswap->images[i].acquire); - simple_mtx_unlock(&screen->semaphores_lock); + /* Destroy the acquire semaphore directly, if any. If acquire != NULL + * then we've called vkAcquireNextImage() with the given semaphore but + * not submitted anything which waits on it. This means the semaphore + * has a pending signal operation and is not safe to recycle. + */ + if (cswap->images[i].acquire != VK_NULL_HANDLE) + VKSCR(DestroySemaphore)(screen->dev, cswap->images[i].acquire, NULL); + pipe_resource_reference(&cswap->images[i].readback, NULL); } free(cswap->images);