From e965b5d2912d4bcdbe1d8305b524231dc6088c28 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Wed, 24 May 2023 14:33:48 -0700 Subject: [PATCH] wsi/win32: Handle acquiring an image while one is already acquired In the case where the app is attempting to acquire both (since the min/max num images is 2) swapchain images, we need to wait on the fence for the next image in the chain. Reviewed-by: Giancarlo Devich Part-of: --- src/vulkan/wsi/wsi_common_win32.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vulkan/wsi/wsi_common_win32.cpp b/src/vulkan/wsi/wsi_common_win32.cpp index ba418ff2b52..34ef5f531d8 100644 --- a/src/vulkan/wsi/wsi_common_win32.cpp +++ b/src/vulkan/wsi/wsi_common_win32.cpp @@ -648,6 +648,10 @@ wsi_win32_acquire_next_image(struct wsi_swapchain *drv_chain, assert(chain->dxgi); uint32_t index = chain->dxgi->GetCurrentBackBufferIndex(); + if (chain->images[index].state == WSI_IMAGE_DRAWING) { + index = (index + 1) % chain->base.image_count; + assert(chain->images[index].state == WSI_IMAGE_QUEUED); + } if (chain->wsi->wsi->WaitForFences(chain->base.device, 1, &chain->base.fences[index], false, info->timeout) != VK_SUCCESS)