diff --git a/OptiScaler.ini b/OptiScaler.ini index 12e415bc..e5c19b83 100644 --- a/OptiScaler.ini +++ b/OptiScaler.ini @@ -190,7 +190,7 @@ ForceBorderless=auto ; Skip ResizeBuffers call to swapchain ; If old and new descriptions are the same ; Prevents crashes after ResizeBuffers calls -; true or false - Default (auto) is false +; true or false - Default (auto) is true SkipResizeBuffers=auto ; Normally after ResizeBuffers call swapchain buffers diff --git a/OptiScaler/Config.h b/OptiScaler/Config.h index 4a65d969..cc27555e 100644 --- a/OptiScaler/Config.h +++ b/OptiScaler/Config.h @@ -465,7 +465,7 @@ class Config CustomOptional FGXeFGHighResMV { false }; CustomOptional FGXeFGDebugView { false }; CustomOptional FGXeFGForceBorderless { false }; - CustomOptional FGXeFGSkipResizeBuffers { false }; + CustomOptional FGXeFGSkipResizeBuffers { true }; CustomOptional FGXeFGModifyBufferState { false }; CustomOptional FGXeFGModifySCIndex { false }; diff --git a/OptiScaler/hooks/FG_Hooks.cpp b/OptiScaler/hooks/FG_Hooks.cpp index c8194e67..5036d756 100644 --- a/OptiScaler/hooks/FG_Hooks.cpp +++ b/OptiScaler/hooks/FG_Hooks.cpp @@ -392,15 +392,19 @@ HRESULT FGHooks::hkResizeBuffers(IDXGISwapChain* This, UINT BufferCount, UINT Wi IDXGISwapChain* sc = nullptr; - if (State::Instance().currentWrappedSwapchain != nullptr) - sc = State::Instance().currentWrappedSwapchain; - else if (State::Instance().currentSwapchain != nullptr) - sc = State::Instance().currentSwapchain; - else if (State::Instance().currentRealSwapchain != nullptr) - sc = State::Instance().currentRealSwapchain; + // if (State::Instance().currentWrappedSwapchain != nullptr) + // sc = State::Instance().currentWrappedSwapchain; + // else if (State::Instance().currentSwapchain != nullptr) + // sc = State::Instance().currentSwapchain; + // else if (State::Instance().currentRealSwapchain != nullptr) + // sc = State::Instance().currentRealSwapchain; if (sc != nullptr) - return sc->ResizeBuffers(BufferCount, Width, Height, NewFormat, SwapChainFlags); + { + auto result = sc->ResizeBuffers(BufferCount, Width, Height, NewFormat, SwapChainFlags); + LOG_DEBUG("XeFG internal ResizeBuffers result: {:X}", (UINT) result); + return result; + } return o_FGSCResizeBuffers(This, BufferCount, Width, Height, NewFormat, SwapChainFlags); } @@ -581,16 +585,21 @@ HRESULT FGHooks::hkResizeBuffers1(IDXGISwapChain* This, UINT BufferCount, UINT W IDXGISwapChain3* sc = nullptr; - if (State::Instance().currentWrappedSwapchain != nullptr) - sc = (IDXGISwapChain3*) State::Instance().currentWrappedSwapchain; - else if (State::Instance().currentSwapchain != nullptr) - sc = (IDXGISwapChain3*) State::Instance().currentSwapchain; - else if (State::Instance().currentRealSwapchain != nullptr) - sc = (IDXGISwapChain3*) State::Instance().currentRealSwapchain; + // if (State::Instance().currentWrappedSwapchain != nullptr) + // sc = (IDXGISwapChain3*) State::Instance().currentWrappedSwapchain; + // else if (State::Instance().currentSwapchain != nullptr) + // sc = (IDXGISwapChain3*) State::Instance().currentSwapchain; + // else if (State::Instance().currentRealSwapchain != nullptr) + // sc = (IDXGISwapChain3*) State::Instance().currentRealSwapchain; if (sc != nullptr) - return sc->ResizeBuffers1(BufferCount, Width, Height, Format, SwapChainFlags, pCreationNodeMask, - ppPresentQueue); + { + auto result = sc->ResizeBuffers1(BufferCount, Width, Height, Format, SwapChainFlags, pCreationNodeMask, + ppPresentQueue); + + LOG_DEBUG("XeFG internal ResizeBuffers1 result: {:X}", (UINT) result); + return result; + } return o_FGSCResizeBuffers1(This, BufferCount, Width, Height, Format, SwapChainFlags, pCreationNodeMask, ppPresentQueue); @@ -747,8 +756,29 @@ HRESULT FGHooks::hkFGPresent(void* This, UINT SyncInterval, UINT Flags) if (_skipPresent) { LOG_DEBUG("XeFG call skipping"); - auto result = o_FGSCPresent(This, SyncInterval, Flags); - LOG_DEBUG("o_FGSCPresent result: {:X}", (UINT) result); + + IDXGISwapChain* sc = nullptr; + + // if (State::Instance().currentWrappedSwapchain != nullptr) + // sc = State::Instance().currentWrappedSwapchain; + // else if (State::Instance().currentSwapchain != nullptr) + // sc = State::Instance().currentSwapchain; + // else if (State::Instance().currentRealSwapchain != nullptr) + // sc = State::Instance().currentRealSwapchain; + + HRESULT result; + + if (sc != nullptr) + { + result = sc->Present(SyncInterval, Flags); + LOG_DEBUG("sc->Present result: {:X}", (UINT) result); + } + else + { + result = o_FGSCPresent(This, SyncInterval, Flags); + LOG_DEBUG("o_FGSCPresent result: {:X}", (UINT) result); + } + return result; } @@ -768,8 +798,29 @@ HRESULT FGHooks::hkFGPresent1(void* This, UINT SyncInterval, UINT Flags, if (_skipPresent1) { LOG_DEBUG("XeFG call skipping"); - auto result = o_FGSCPresent1(This, SyncInterval, Flags, pPresentParameters); - LOG_DEBUG("o_FGSCPresent result: {:X}", (UINT) result); + + IDXGISwapChain3* sc = nullptr; + + // if (State::Instance().currentWrappedSwapchain != nullptr) + // sc = (IDXGISwapChain3*) State::Instance().currentWrappedSwapchain; + // else if (State::Instance().currentSwapchain != nullptr) + // sc = (IDXGISwapChain3*) State::Instance().currentSwapchain; + // else if (State::Instance().currentRealSwapchain != nullptr) + // sc = (IDXGISwapChain3*) State::Instance().currentRealSwapchain; + + HRESULT result; + + if (sc != nullptr) + { + result = sc->Present1(SyncInterval, Flags, pPresentParameters); + LOG_DEBUG("sc->Present result: {:X}", (UINT) result); + } + else + { + result = o_FGSCPresent1(This, SyncInterval, Flags, pPresentParameters); + LOG_DEBUG("o_FGSCPresent result: {:X}", (UINT) result); + } + return result; }