VulkanHostDisplay: Handle surface changes if this happens

This commit is contained in:
Connor McLaughlin 2021-05-13 12:48:26 +10:00
parent 08a815ad7b
commit 00ffffe8c0
1 changed files with 13 additions and 0 deletions

View File

@ -80,6 +80,18 @@ bool VulkanHostDisplay::ChangeRenderWindow(const WindowInfo& new_wi)
return true;
}
// recreate surface in existing swap chain if it already exists
if (m_swap_chain)
{
if (m_swap_chain->RecreateSurface(new_wi))
{
m_window_info = m_swap_chain->GetWindowInfo();
return true;
}
m_swap_chain.reset();
}
WindowInfo wi_copy(new_wi);
VkSurfaceKHR surface = Vulkan::SwapChain::CreateVulkanSurface(g_vulkan_context->GetVulkanInstance(),
g_vulkan_context->GetPhysicalDevice(), &wi_copy);
@ -93,6 +105,7 @@ bool VulkanHostDisplay::ChangeRenderWindow(const WindowInfo& new_wi)
if (!m_swap_chain)
{
Log_ErrorPrintf("Failed to create swap chain");
Vulkan::SwapChain::DestroyVulkanSurface(g_vulkan_context->GetVulkanInstance(), &wi_copy, surface);
return false;
}