VulkanHostDisplay: Handle surface loss gracefully

Also skips a full swap chain recreate on resize.
This commit is contained in:
Connor McLaughlin committed 2021-04-08 03:07:10 +10:00
1 parent 0342d0a26e
commit 19ca102b40
2 files changed
+22 -7

No files matched your search

@@ -580,6 +580,18 @@ bool VulkanHostDisplay::Render()
ResizeRenderWindow(0, 0);
res = m_swap_chain->AcquireNextImage();
}
else if (res == VK_ERROR_SURFACE_LOST_KHR)
{
Log_WarningPrint("Surface lost, attempting to recreate");
if (!m_swap_chain->RecreateSurface(m_window_info))
{
Log_ErrorPrint("Failed to recreate surface after loss");
g_vulkan_context->ExecuteCommandBuffer(false);
return false;
}
res = m_swap_chain->AcquireNextImage();
}
// This can happen when multiple resize events happen in quick succession.
// In this case, just wait until the next frame to try again.