Enable maximum parallelization by making vkWaitForFences closer

This commit is contained in:
Benau 2022-05-05 09:30:29 +08:00
parent d2da2e22e1
commit 9c9f69856f

View File

@ -1422,6 +1422,18 @@ bool GEVulkanDriver::beginScene(bool backBuffer, bool zBuffer, SColor color,
return false; return false;
m_clear_color = color; 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]; VkFence fence = m_vk->in_flight_fences[m_current_frame];
vkWaitForFences(m_vk->device, 1, &fence, VK_TRUE, vkWaitForFences(m_vk->device, 1, &fence, VK_TRUE,
std::numeric_limits<uint64_t>::max()); std::numeric_limits<uint64_t>::max());
@ -1432,14 +1444,9 @@ bool GEVulkanDriver::beginScene(bool backBuffer, bool zBuffer, SColor color,
std::numeric_limits<uint64_t>::max(), semaphore, VK_NULL_HANDLE, std::numeric_limits<uint64_t>::max(), semaphore, VK_NULL_HANDLE,
&m_image_index); &m_image_index);
return (result != VK_ERROR_OUT_OF_DATE_KHR); if (result != VK_SUCCESS)
} // beginScene
// ----------------------------------------------------------------------------
bool GEVulkanDriver::endScene()
{
if (g_paused_rendering.load())
{ {
video::CNullDriver::endScene();
GEVulkan2dRenderer::clear(); GEVulkan2dRenderer::clear();
return false; return false;
} }
@ -1462,7 +1469,7 @@ bool GEVulkanDriver::endScene()
VkQueue queue = VK_NULL_HANDLE; VkQueue queue = VK_NULL_HANDLE;
std::unique_lock<std::mutex> ul = getGraphicsQueue(&queue); std::unique_lock<std::mutex> ul = getGraphicsQueue(&queue);
VkResult result = vkQueueSubmit(queue, 1, &submit_info, result = vkQueueSubmit(queue, 1, &submit_info,
m_vk->in_flight_fences[m_current_frame]); m_vk->in_flight_fences[m_current_frame]);
ul.unlock(); ul.unlock();