From 8d5e2b5105219d2db39b614f88ead74cd2a2684c Mon Sep 17 00:00:00 2001 From: cdozdil Date: Fri, 8 May 2026 22:48:27 +0300 Subject: [PATCH] Be sure real swapchain is released to prevent swapchain re-creating issues --- OptiScaler/wrapped/wrapped_swapchain.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OptiScaler/wrapped/wrapped_swapchain.cpp b/OptiScaler/wrapped/wrapped_swapchain.cpp index 18123e98..083fc7e1 100644 --- a/OptiScaler/wrapped/wrapped_swapchain.cpp +++ b/OptiScaler/wrapped/wrapped_swapchain.cpp @@ -473,6 +473,16 @@ ULONG STDMETHODCALLTYPE WrappedIDXGISwapChain4::Release() auto refCount = _real->Release(); + // Release real swapchain, otherwise it can cause issues when re-creating swapchain with same handle + while (refCount > 0) + { + LOG_DEBUG("Waiting for real swapchain to be released, refCount: {}", refCount); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + refCount = _real->Release(); + } + + LOG_DEBUG("Real swapchain released, refCount: {}", refCount); + delete this; }