From b48fcb0dc3df3b7d22a48945e3ec55ae2bca3c58 Mon Sep 17 00:00:00 2001 From: FakeMichau <49685661+FakeMichau@users.noreply.github.com> Date: Tue, 20 Oct 2026 01:59:57 +0200 Subject: [PATCH] Ensure that ALLOW_TEARING is applied on swapchain resize with DLSSG Slopped. FIxes a crash in BeamNG with DLSSG Dx12 output on resize --- OptiScaler/hooks/FG_Hooks.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/OptiScaler/hooks/FG_Hooks.cpp b/OptiScaler/hooks/FG_Hooks.cpp index 843bead5..736533fa 100644 --- a/OptiScaler/hooks/FG_Hooks.cpp +++ b/OptiScaler/hooks/FG_Hooks.cpp @@ -661,6 +661,13 @@ HRESULT FGHooks::hkResizeBuffers(IDXGISwapChain* This, UINT BufferCount, UINT Wi } } + // DLSSG creates its swapchain with ALLOW_TEARING and DXGI rejects resizes that add or remove it + if (State::Instance().activeFgOutput == FGOutput::DLSSG && !(SwapChainFlags & DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING)) + { + LOG_DEBUG("Keeping DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING for DLSSG"); + SwapChainFlags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; + } + LOG_DEBUG("BufferCount: {}, Width: {}, Height: {}, NewFormat:{}, SwapChainFlags: {:X}", BufferCount, Width, Height, (UINT) NewFormat, SwapChainFlags); @@ -902,6 +909,13 @@ HRESULT FGHooks::hkResizeBuffers1(IDXGISwapChain3* This, UINT BufferCount, UINT } } + // DLSSG creates its swapchain with ALLOW_TEARING and DXGI rejects resizes that add or remove it + if (State::Instance().activeFgOutput == FGOutput::DLSSG && !(SwapChainFlags & DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING)) + { + LOG_DEBUG("Keeping DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING for DLSSG"); + SwapChainFlags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; + } + LOG_DEBUG("BufferCount: {}, Width: {}, Height: {}, NewFormat:{}, SwapChainFlags: {:X}, Caller: {}", BufferCount, Width, Height, (UINT) Format, SwapChainFlags, Util::WhoIsTheCaller(_ReturnAddress()));