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.

(cherry picked from commit c4bc6c9627)
Signed-off-by: phosit <phosit@autistici.org>
This commit is contained in:
Vladislav Belov 2025-11-10 00:06:52 +01:00 committed by phosit
parent b08f2d1d33
commit 1e1db43854
No known key found for this signature in database
GPG key ID: C9430B600671C268
2 changed files with 8 additions and 0 deletions

View file

@ -138,6 +138,7 @@ renderer.backend.gl.enableframebufferinvalidating = false
renderer.backend.vulkan.disabledescriptorindexing = false
renderer.backend.vulkan.deviceindexoverride = -1
renderer.backend.vulkan.destroyoldswapchainbefore = false
renderer.backend.vulkan.debugbarrierafterframebufferpass = false
renderer.backend.vulkan.debugwaitidlebeforeacquire = false

View file

@ -1040,6 +1040,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