From 67b6d47c0960e3eff38a8f6574a114e29d31ea4a Mon Sep 17 00:00:00 2001 From: BearOso Date: Mon, 4 Sep 2023 14:00:03 -0500 Subject: [PATCH] Vulkan: Catch out-of-date on present that vulkan.hpp throws. --- vulkan/vulkan_swapchain.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vulkan/vulkan_swapchain.cpp b/vulkan/vulkan_swapchain.cpp index 6cfedb2d..3bf4b04d 100644 --- a/vulkan/vulkan_swapchain.cpp +++ b/vulkan/vulkan_swapchain.cpp @@ -320,11 +320,19 @@ bool Swapchain::swap() .setSwapchains(swapchain_object.get()) .setImageIndices(current_swapchain_image); - auto result = queue.presentKHR(present_info); + vk::Result result; + try + { + result = queue.presentKHR(present_info); + } + catch (std::exception &e) + { + printf("%s\n", e.what()); + } current_frame = (current_frame + 1) % num_swapchain_images; - if (result != vk::Result::eSuccess) + if (result != vk::Result::eSuccess && result != vk::Result::eSuboptimalKHR) return false; return true; }