From bb63c57eda99924ed2d99cce80abdac8dcb197f9 Mon Sep 17 00:00:00 2001 From: cdozdil Date: Thu, 21 Nov 2024 22:32:29 +0300 Subject: [PATCH] some fixes --- OptiScaler/NVNGX_DLSS_Dx12.cpp | 7 ++++--- OptiScaler/OptiScaler.vcxproj | 2 +- OptiScaler/hooks/HooksDx.cpp | 10 ++++++---- OptiScaler/hooks/wrapped_swapchain.cpp | 13 +++++++++++++ OptiScaler/resource.h | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/OptiScaler/NVNGX_DLSS_Dx12.cpp b/OptiScaler/NVNGX_DLSS_Dx12.cpp index bcc1cbbe..2416dc9a 100644 --- a/OptiScaler/NVNGX_DLSS_Dx12.cpp +++ b/OptiScaler/NVNGX_DLSS_Dx12.cpp @@ -1423,8 +1423,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom auto fIndex = fgCallbackFrameIndex; // check for status - if (!Config::Instance()->FGEnabled.value_or(false) || Config::Instance()->FGChanged || - FrameGen_Dx12::fgContext == nullptr + if (!Config::Instance()->FGEnabled.value_or(false) || + FrameGen_Dx12::fgContext == nullptr || Config::Instance()->SCChanged #ifdef USE_QUEUE_FOR_FG || FrameGen_Dx12::fgCommandList[fIndex] == nullptr || FrameGen_Dx12::fgCommandQueue == nullptr #endif @@ -1437,7 +1437,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom // If fg is active but upscaling paused if (Config::Instance()->CurrentFeature == nullptr || !FrameGen_Dx12::fgIsActive || - fgLastFGFrame == Config::Instance()->CurrentFeature->FrameCount()) + Config::Instance()->FGChanged || fgLastFGFrame == Config::Instance()->CurrentFeature->FrameCount() || + Config::Instance()->CurrentFeature->FrameCount() == 0) { LOG_WARN("(FG) Callback without active FG! fIndex:{}", fIndex); diff --git a/OptiScaler/OptiScaler.vcxproj b/OptiScaler/OptiScaler.vcxproj index 78cf25b9..976ad651 100644 --- a/OptiScaler/OptiScaler.vcxproj +++ b/OptiScaler/OptiScaler.vcxproj @@ -82,7 +82,7 @@ $(SolutionDir)external\vulkan\include;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\FidelityFX-SDK\ffx-api\include\ffx_api;$(SolutionDir)external\simpleini;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\spdlog\include;$(SolutionDir)external\freetype;$(IncludePath) $(ProjectDir)fsr2\lib;$(ProjectDir)fsr2_212\lib;$(ProjectDir)fsr31\lib;$(ProjectDir)vulkan;$(ProjectDir)d3dx;$(ProjectDir)detours;$(SolutionDir)external\xess\lib;$(SolutionDir)external\freetype;$(LibraryPath) dxgi - E:\Games\Deep Rock Galactic\FSD\Binaries\Win64\ + D:\Folders\Games\Cyberpunk 2077\bin\x64\ .\x64\Debug .dll diff --git a/OptiScaler/hooks/HooksDx.cpp b/OptiScaler/hooks/HooksDx.cpp index 81e87cd3..4e08aafa 100644 --- a/OptiScaler/hooks/HooksDx.cpp +++ b/OptiScaler/hooks/HooksDx.cpp @@ -554,8 +554,9 @@ static void GetHudless(ID3D12GraphicsCommandList* This) auto fIndex = fgCallbackFrameIndex; // check for status - if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || Config::Instance()->FGChanged || - FrameGen_Dx12::fgContext == nullptr || FrameGen_Dx12::fgCommandList[fIndex] == nullptr || FrameGen_Dx12::fgCommandQueue == nullptr) + if (!Config::Instance()->FGEnabled.value_or(false) || !Config::Instance()->FGHUDFix.value_or(false) || + FrameGen_Dx12::fgContext == nullptr || FrameGen_Dx12::fgCommandList[fIndex] == nullptr || + FrameGen_Dx12::fgCommandQueue == nullptr || Config::Instance()->SCChanged) { LOG_WARN("Cancel async dispatch"); fgDispatchCalled = false; @@ -564,8 +565,9 @@ static void GetHudless(ID3D12GraphicsCommandList* This) } // If fg is active but upscaling paused - if (!fgDispatchCalled || Config::Instance()->CurrentFeature == nullptr || - fgLastFGFrame == Config::Instance()->CurrentFeature->FrameCount() || !FrameGen_Dx12::fgIsActive) + if (!fgDispatchCalled || Config::Instance()->CurrentFeature == nullptr || Config::Instance()->FGChanged || + fgLastFGFrame == Config::Instance()->CurrentFeature->FrameCount() || !FrameGen_Dx12::fgIsActive || + Config::Instance()->CurrentFeature->FrameCount() == 0) { LOG_WARN("Callback without hudless! frameID: {}", params->frameID); diff --git a/OptiScaler/hooks/wrapped_swapchain.cpp b/OptiScaler/hooks/wrapped_swapchain.cpp index c837fecf..16eea1dd 100644 --- a/OptiScaler/hooks/wrapped_swapchain.cpp +++ b/OptiScaler/hooks/wrapped_swapchain.cpp @@ -2,6 +2,7 @@ #include "../Config.h" #include "../Util.h" +#include "HooksDx.h" // Used RenderDoc's wrapped object as referance // https://github.com/baldurk/renderdoc/blob/v1.x/renderdoc/driver/dxgi/dxgi_wrapped.cpp @@ -117,6 +118,8 @@ HRESULT WrappedIDXGISwapChain4::ResizeBuffers(UINT BufferCount, UINT Width, UINT { LOG_DEBUG(""); + FrameGen_Dx12::ffxMutex.lock(); + HRESULT result; DXGI_SWAP_CHAIN_DESC desc{}; GetDesc(&desc); @@ -220,6 +223,8 @@ HRESULT WrappedIDXGISwapChain4::ResizeBuffers(UINT BufferCount, UINT Width, UINT LOG_DEBUG("result: {0:X}", (UINT)result); + FrameGen_Dx12::ffxMutex.unlock(); + return result; } @@ -231,6 +236,8 @@ HRESULT STDMETHODCALLTYPE WrappedIDXGISwapChain4::GetContainingOutput(IDXGIOutpu HRESULT WrappedIDXGISwapChain4::ResizeBuffers1(UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT Format, UINT SwapChainFlags, const UINT* pCreationNodeMask, IUnknown* const* ppPresentQueue) { + FrameGen_Dx12::ffxMutex.lock(); + LOG_DEBUG(""); HRESULT result; @@ -333,11 +340,15 @@ HRESULT WrappedIDXGISwapChain4::ResizeBuffers1(UINT BufferCount, UINT Width, UIN LOG_DEBUG("result: {0:X}", (UINT)result); + FrameGen_Dx12::ffxMutex.unlock(); + return result; } HRESULT WrappedIDXGISwapChain4::SetFullscreenState(BOOL Fullscreen, IDXGIOutput* pTarget) { + FrameGen_Dx12::ffxMutex.lock(); + auto result = m_pReal->SetFullscreenState(Fullscreen, pTarget); LOG_DEBUG("Fullscreen: {}", Fullscreen); @@ -385,6 +396,8 @@ HRESULT WrappedIDXGISwapChain4::SetFullscreenState(BOOL Fullscreen, IDXGIOutput* LOG_DEBUG("result: {0:X}", (UINT)result); + FrameGen_Dx12::ffxMutex.unlock(); + return result; } diff --git a/OptiScaler/resource.h b/OptiScaler/resource.h index c0d7ed21..637eba82 100644 --- a/OptiScaler/resource.h +++ b/OptiScaler/resource.h @@ -21,7 +21,7 @@ #define VER_MAJOR_VERSION 0 #define VER_MINOR_VERSION 7 #define VER_HOTFIX_VERSION 0 -#define VER_BUILD_NUMBER 66 +#define VER_BUILD_NUMBER 67 #define VER_PRE_RELEASE