From cb15487cbebd60250f66b62b015c8303755b4f6d Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 18 Jun 2019 14:58:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0QueuePresent=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/RenderDevice/Vulkan/VKDevice.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/RenderDevice/Vulkan/VKDevice.cpp b/src/RenderDevice/Vulkan/VKDevice.cpp index 9f510f6c..a17d4844 100644 --- a/src/RenderDevice/Vulkan/VKDevice.cpp +++ b/src/RenderDevice/Vulkan/VKDevice.cpp @@ -286,10 +286,20 @@ bool Device::QueuePresent() { present_info.pImageIndices=¤t_frame; - if(vkQueuePresentKHR(attr->graphics_queue,&present_info)!=VK_SUCCESS) - return(false); - - if(vkQueueWaitIdle(attr->graphics_queue)!=VK_SUCCESS) + VkResult result=vkQueuePresentKHR(attr->graphics_queue,&present_info); + + if (!((result == VK_SUCCESS) || (result == VK_SUBOPTIMAL_KHR))) + { + if (result == VK_ERROR_OUT_OF_DATE_KHR) { + // Swap chain is no longer compatible with the surface and needs to be recreated + + return false; + } + } + + result=vkQueueWaitIdle(attr->graphics_queue); + + if(result!=VK_SUCCESS) return(false); return(true);