From d90a4da1bfdec5ff29593e5788c5cccd8e390c5d Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 12 Oct 2026 21:55:29 +1000 Subject: [PATCH] VulkanDevice: Wait for image acquire when submitting mid-present --- src/util/vulkan_device.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/util/vulkan_device.cpp b/src/util/vulkan_device.cpp index 9b9feba41..7bdb3856b 100644 --- a/src/util/vulkan_device.cpp +++ b/src/util/vulkan_device.cpp @@ -1294,15 +1294,20 @@ void VulkanDevice::EndAndSubmitCommandBuffer(bool wait_for_completion, VulkanSwa u32 wait_bits; std::array signal_semaphores; std::array signal_values = {}; - if (present_swap_chain) + + // Submitting mid-present still has to wait for the image. The acquire semaphore is signaled again in this case, + // so that the final submission can wait on it too. + VulkanSwapChain* const wait_swap_chain = present_swap_chain ? present_swap_chain : m_current_swap_chain; + if (wait_swap_chain) { wait_bits = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - submit_info.pWaitSemaphores = present_swap_chain->GetImageAcquireSemaphorePtr(); + submit_info.pWaitSemaphores = wait_swap_chain->GetImageAcquireSemaphorePtr(); submit_info.waitSemaphoreCount = 1; submit_info.pWaitDstStageMask = &wait_bits; - signal_semaphores[submit_info.signalSemaphoreCount++] = present_swap_chain->GetPresentSemaphore(); + signal_semaphores[submit_info.signalSemaphoreCount++] = + present_swap_chain ? present_swap_chain->GetPresentSemaphore() : wait_swap_chain->GetImageAcquireSemaphore(); } std::array wait_values = {};