vulkan/wsi/win32: add wsi_win32_find_idle_image helper

Prepare to handle timeout for sw wsi (no DXGI).

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40557>
This commit is contained in:
Yiwei Zhang 2026-03-21 17:10:37 -07:00 committed by Marge Bot
parent 889cf429ee
commit 8ff24c7db3

View file

@ -636,6 +636,19 @@ wsi_win32_release_images(struct wsi_swapchain *drv_chain,
return VK_SUCCESS;
}
static bool
wsi_win32_find_idle_image(struct wsi_win32_swapchain *chain,
uint32_t *out_image_index)
{
for (uint32_t i = 0; i < chain->base.image_count; i++) {
if (chain->images[i].state == WSI_IMAGE_IDLE) {
*out_image_index = i;
chain->images[i].state = WSI_IMAGE_DRAWING;
return true;
}
}
return false;
}
static VkResult
wsi_win32_acquire_next_image(struct wsi_swapchain *drv_chain,
@ -649,13 +662,8 @@ wsi_win32_acquire_next_image(struct wsi_swapchain *drv_chain,
if (chain->status != VK_SUCCESS)
return chain->status;
for (uint32_t i = 0; i < chain->base.image_count; i++) {
if (chain->images[i].state == WSI_IMAGE_IDLE) {
*image_index = i;
chain->images[i].state = WSI_IMAGE_DRAWING;
return VK_SUCCESS;
}
}
if (wsi_win32_find_idle_image(chain, image_index))
return VK_SUCCESS;
assert(chain->dxgi);
uint32_t index = chain->dxgi->GetCurrentBackBufferIndex();