From 4a60cc4c1ee4f8402c8264486f3d6666c43a9361 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 24 Jan 2021 17:31:08 +1000 Subject: [PATCH] VulkanHostDisplay: Ensure previous frame is presented before acquiring image --- src/common/vulkan/context.cpp | 3 +++ src/frontend-common/vulkan_host_display.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/common/vulkan/context.cpp b/src/common/vulkan/context.cpp index 1002f314f..6d9466460 100644 --- a/src/common/vulkan/context.cpp +++ b/src/common/vulkan/context.cpp @@ -941,6 +941,9 @@ void Context::DoPresent(VkSemaphore wait_semaphore, VkSwapchainKHR present_swap_ void Context::WaitForPresentComplete() { + if (m_present_done.load()) + return; + std::unique_lock lock(m_present_mutex); WaitForPresentComplete(lock); } diff --git a/src/frontend-common/vulkan_host_display.cpp b/src/frontend-common/vulkan_host_display.cpp index 1cafab374..61ef4084c 100644 --- a/src/frontend-common/vulkan_host_display.cpp +++ b/src/frontend-common/vulkan_host_display.cpp @@ -602,6 +602,9 @@ bool VulkanHostDisplay::Render() return false; } + // Previous frame needs to be presented before we can acquire the swap chain. + g_vulkan_context->WaitForPresentComplete(); + VkResult res = m_swap_chain->AcquireNextImage(); if (res != VK_SUCCESS) {