From 9c9f69856fbd4ff93b44bf138af5c4514f361ef2 Mon Sep 17 00:00:00 2001 From: Benau Date: Thu, 5 May 2022 09:30:29 +0800 Subject: [PATCH] Enable maximum parallelization by making vkWaitForFences closer --- lib/graphics_engine/src/ge_vulkan_driver.cpp | 23 +++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/graphics_engine/src/ge_vulkan_driver.cpp b/lib/graphics_engine/src/ge_vulkan_driver.cpp index 63fc4c446..93892e903 100644 --- a/lib/graphics_engine/src/ge_vulkan_driver.cpp +++ b/lib/graphics_engine/src/ge_vulkan_driver.cpp @@ -1422,6 +1422,18 @@ bool GEVulkanDriver::beginScene(bool backBuffer, bool zBuffer, SColor color, return false; m_clear_color = color; + return true; +} // beginScene + +// ---------------------------------------------------------------------------- +bool GEVulkanDriver::endScene() +{ + if (g_paused_rendering.load()) + { + GEVulkan2dRenderer::clear(); + return false; + } + VkFence fence = m_vk->in_flight_fences[m_current_frame]; vkWaitForFences(m_vk->device, 1, &fence, VK_TRUE, std::numeric_limits::max()); @@ -1432,14 +1444,9 @@ bool GEVulkanDriver::beginScene(bool backBuffer, bool zBuffer, SColor color, std::numeric_limits::max(), semaphore, VK_NULL_HANDLE, &m_image_index); - return (result != VK_ERROR_OUT_OF_DATE_KHR); -} // beginScene - -// ---------------------------------------------------------------------------- -bool GEVulkanDriver::endScene() -{ - if (g_paused_rendering.load()) + if (result != VK_SUCCESS) { + video::CNullDriver::endScene(); GEVulkan2dRenderer::clear(); return false; } @@ -1462,7 +1469,7 @@ bool GEVulkanDriver::endScene() VkQueue queue = VK_NULL_HANDLE; std::unique_lock ul = getGraphicsQueue(&queue); - VkResult result = vkQueueSubmit(queue, 1, &submit_info, + result = vkQueueSubmit(queue, 1, &submit_info, m_vk->in_flight_fences[m_current_frame]); ul.unlock();