From d2cb0e2017214420207a0d057e4fc4bead80700f Mon Sep 17 00:00:00 2001 From: Tobias Frisch <tfrisch@uni-koblenz.de> Date: Tue, 29 Jun 2021 14:25:06 +0200 Subject: [PATCH] [#82] Fixed crash because of suboptimal images Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de> --- src/vkcv/Core.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/vkcv/Core.cpp b/src/vkcv/Core.cpp index ed7718d0..ad89d0fa 100644 --- a/src/vkcv/Core.cpp +++ b/src/vkcv/Core.cpp @@ -123,7 +123,6 @@ namespace vkcv Result Core::acquireSwapchainImage() { uint32_t imageIndex; - vk::Result result; try { @@ -140,9 +139,14 @@ namespace vkcv result = vk::Result::eErrorDeviceLost; } - if (result != vk::Result::eSuccess) { + if ((result != vk::Result::eSuccess) && + (result != vk::Result::eSuboptimalKHR)) { vkcv_log(LogLevel::ERROR, "%s", vk::to_string(result).c_str()); return Result::ERROR; + } else + if (result == vk::Result::eSuboptimalKHR) { + vkcv_log(LogLevel::WARNING, "Acquired image is suboptimal"); + m_swapchain.signalSwapchainRecreation(); } m_currentSwapchainImageIndex = imageIndex; @@ -373,8 +377,13 @@ namespace vkcv result = vk::Result::eErrorDeviceLost; } - if (result != vk::Result::eSuccess) { - vkcv_log(LogLevel::ERROR, "Swapchain present failed (%s)", vk::to_string(result).c_str()); + if ((result != vk::Result::eSuccess) && + (result != vk::Result::eSuboptimalKHR)) { + vkcv_log(LogLevel::ERROR, "Swapchain presentation failed (%s)", vk::to_string(result).c_str()); + } else + if (result == vk::Result::eSuboptimalKHR) { + vkcv_log(LogLevel::WARNING, "Swapchain presentation is suboptimal"); + m_swapchain.signalSwapchainRecreation(); } } -- GitLab