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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22431>
This commit is contained in:
Mike Blumenkrantz 2023-04-11 17:02:54 -04:00 committed by Marge Bot
parent ba73a41a2b
commit 5db5218044
2 changed files with 7 additions and 0 deletions

View File

@ -41,6 +41,7 @@ struct kopper_swapchain_image {
int age;
VkImage image;
VkSemaphore acquire;
VkImageLayout layout;
};
struct kopper_swapchain {

View File

@ -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);
}