From 8d9675520fcae086ef3daa863043793534c036ea 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: --- src/gallium/drivers/zink/zink_kopper.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/zink/zink_kopper.c b/src/gallium/drivers/zink/zink_kopper.c index 7cfdb9bc2b5..f2fee4f0fc6 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); zink_destroy_resource_surface_cache(screen, &cswap->images[i].surface_cache, false); }