1
0
forked from mirrors/0ad

Adds an option to destroy Vulkan old swapchain before

Now it's possible to destroy the old swapchain before creating a new
one. It might make the swapchain creation a bit slower but with a
lower memory peak.
This commit is contained in:
Vladislav Belov
2025-11-10 00:06:52 +01:00
parent 8a64182ca2
commit c4bc6c9627
2 changed files with 8 additions and 0 deletions
@@ -1039,6 +1039,13 @@ void CDevice::RecreateSwapChain()
{
vkDeviceWaitIdle(m_Device);
// It seems some drivers might not reuse the same swapchain memory. So
// to avoid higher memory peaks destroy the old swapchain before.
const bool destroyOldSwapchainBefore{
g_ConfigDB.Get("renderer.backend.vulkan.destroyoldswapchainbefore", false)};
if (destroyOldSwapchainBefore)
m_SwapChain.reset();
m_BackbufferReadbackTexture.reset();
// Since we know there is no GPU work in progress we can free resources