From 5d308329b4fc52e72c62a49adc2ad72295d227be Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Thu, 18 Feb 2021 15:54:08 +0100 Subject: [PATCH] Recreate swapchain on VK_SUBOPTIMAL_KHR vkQueuePresentKHR can return VK_SUBOPTIMAL_KHR if the window size changed. This should recreate the swapchain, like for VK_ERROR_OUT_OF_DATE_KHR. --- src/Vulkan/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Vulkan/Application.cpp b/src/Vulkan/Application.cpp index e65cbb3e..d331b06f 100644 --- a/src/Vulkan/Application.cpp +++ b/src/Vulkan/Application.cpp @@ -172,7 +172,7 @@ void Application::DrawFrame() uint32_t imageIndex; auto result = vkAcquireNextImageKHR(device_->Handle(), swapChain_->Handle(), noTimeout, imageAvailableSemaphore, nullptr, &imageIndex); - if (result == VK_ERROR_OUT_OF_DATE_KHR || isWireFrame_ != graphicsPipeline_->IsWireFrame()) + if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || isWireFrame_ != graphicsPipeline_->IsWireFrame()) { RecreateSwapChain(); return; @@ -222,7 +222,7 @@ void Application::DrawFrame() result = vkQueuePresentKHR(device_->PresentQueue(), &presentInfo); - if (result == VK_ERROR_OUT_OF_DATE_KHR) + if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR) { RecreateSwapChain(); return;