vulkan: Avoid a validation error

If vkAcquireNextImageKHR returns VK_SUBOPTIMAL_KHR, the semaphore
is in use, but vkDeviceWaitIdle will not wait for it, since it is
not associated with a queue. Make sure that is the case, so we don't
run into a validation error when we try vkAcquireNextImageKHR with
the same semaphore, after recreating the swap chain.

See https://github.com/KhronosGroup/Vulkan-Docs/issues/1059 for
some related discussion.

Fixes: #7079
This commit is contained in:
Matthias Clasen 2024-10-13 14:19:53 -04:00
parent f66b32dca7
commit caf2a7724f

View File

@ -698,6 +698,22 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
{
GError *error = NULL;
if (acquire_result == VK_SUBOPTIMAL_KHR)
{
const VkPipelineStageFlags mask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
vkQueueSubmit (gdk_vulkan_context_get_queue (context),
1,
&(VkSubmitInfo) {
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
.waitSemaphoreCount = 1,
.pWaitSemaphores = &priv->draw_semaphore,
.pWaitDstStageMask = &mask,
},
VK_NULL_HANDLE);
vkQueueWaitIdle (gdk_vulkan_context_get_queue (context));
}
if (gdk_vulkan_context_check_swapchain (context, &error))
continue;