From 5db5218044b233ceb3aa00a7bd9543902007373c Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 11 Apr 2023 17:02:54 -0400 Subject: [PATCH] zink: track per-image swapchain layouts this is important for handing off the swapchain between resources on makecurrent since a context that is made not-current will have its swapchain resources destroyed while the swapchain persists Part-of: --- src/gallium/drivers/zink/zink_kopper.h | 1 + src/gallium/drivers/zink/zink_synchronization.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/gallium/drivers/zink/zink_kopper.h b/src/gallium/drivers/zink/zink_kopper.h index caf0e9a2c22..857a9cd5a5d 100644 --- a/src/gallium/drivers/zink/zink_kopper.h +++ b/src/gallium/drivers/zink/zink_kopper.h @@ -41,6 +41,7 @@ struct kopper_swapchain_image { int age; VkImage image; VkSemaphore acquire; + VkImageLayout layout; }; struct kopper_swapchain { diff --git a/src/gallium/drivers/zink/zink_synchronization.cpp b/src/gallium/drivers/zink/zink_synchronization.cpp index a75f197d9ef..392b6e0ca2c 100644 --- a/src/gallium/drivers/zink/zink_synchronization.cpp +++ b/src/gallium/drivers/zink/zink_synchronization.cpp @@ -386,6 +386,12 @@ zink_resource_image_barrier(struct zink_context *ctx, struct zink_resource *res, res->obj->access = flags; res->obj->access_stage = pipeline; res->layout = new_layout; + if (res->obj->dt) { + struct kopper_displaytarget *cdt = res->obj->dt; + if (cdt->swapchain->num_acquires && res->obj->dt_idx != UINT32_MAX) { + cdt->swapchain->images[res->obj->dt_idx].layout = res->layout; + } + } if (new_layout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) zink_resource_copies_reset(res); }