Vulkan: recreate window swap chains flagged for recreation (#3751)

When acquiring a window frame buffer swap chain returns
VK_SUBOPTIMAL_KHR or VK_ERROR_OUT_OF_DATE_KHR it is flagged with
m_needToRecreateSwapchain and acquire then refuses forever: only the
main back buffer is recreated (by updateResolution), so the window
permanently stops updating (easily triggered by moving the window to a
display with a different scale). Recreate flagged window swap chains
when acquiring them.
This commit is contained in:
Francis De Brabandere
2026-06-17 03:56:24 +00:00
committed by GitHub
parent ba2177ac1d
commit edbec2f2cc
+13
View File
@@ -8691,6 +8691,19 @@ VK_DESTROY
BX_ASSERT(NULL != m_nwh, "FrameBufferVK::acquire is only valid for swap-chain framebuffers.");
BGFX_PROFILER_SCOPE("FrameBufferVK::acquire", kColorFrame);
// Window frame buffers are not recreated by updateResolution like the main back
// buffer is, so recreate here when the swap chain was flagged, e.g. with
// VK_SUBOPTIMAL_KHR after the window moved to another display.
if (this != &s_renderVK->m_backBuffer
&& VK_NULL_HANDLE != m_swapChain.m_swapChain
&& (m_swapChain.m_needToRecreateSwapchain || m_swapChain.m_needToRecreateSurface) )
{
update(_commandBuffer, m_swapChain.m_resolution);
// update may kick the queue and rotate the command buffer, refresh the local handle
_commandBuffer = s_renderVK->m_commandBuffer;
}
const bool acquired = m_swapChain.acquire(_commandBuffer);
m_needPresent = m_swapChain.m_needPresent;
m_currentFramebuffer = m_swapChain.m_backBufferFrameBuffer[m_swapChain.m_backBufferColorIdx];