From 4df29ca3cc45198fcdabe86488ef2f78d8389bbd Mon Sep 17 00:00:00 2001 From: cdozdil Date: Thu, 16 Jan 2025 02:03:30 +0300 Subject: [PATCH 1/4] disable ffxFsr2GetInterfaceDX12 for FSR2 --- OptiScaler/FSR2_Dx12.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/OptiScaler/FSR2_Dx12.cpp b/OptiScaler/FSR2_Dx12.cpp index 2f252649..088ae3f3 100644 --- a/OptiScaler/FSR2_Dx12.cpp +++ b/OptiScaler/FSR2_Dx12.cpp @@ -904,9 +904,9 @@ void HookFSR2ExeInputs() o_ffxFsr2GetRenderResolutionFromQualityMode_Dx12 = (PFN_ffxFsr2GetRenderResolutionFromQualityMode)DetourFindFunction(exeName.c_str(), "?ffxFsr2GetRenderResolutionFromQualityMode@@YAHPEAH0HHW4FfxFsr2QualityMode@@@Z"); //ffxFsr2GetInterfaceDX12 - o_ffxFsr2GetInterfaceDX12 = (PFN_ffxFsr2GetInterfaceDX12)DetourFindFunction(exeName.c_str(), "ffxFsr2GetInterfaceDX12"); - if (o_ffxFsr2GetInterfaceDX12 == nullptr) - o_ffxFsr2GetInterfaceDX12 = (PFN_ffxFsr2GetInterfaceDX12)DetourFindFunction(exeName.c_str(), "?ffxFsr2GetInterfaceDX12@@YAHPEAUFfxFsr2Interface@@PEAUID3D12Device@@PEAX_K@Z"); + //o_ffxFsr2GetInterfaceDX12 = (PFN_ffxFsr2GetInterfaceDX12)DetourFindFunction(exeName.c_str(), "ffxFsr2GetInterfaceDX12"); + //if (o_ffxFsr2GetInterfaceDX12 == nullptr) + // o_ffxFsr2GetInterfaceDX12 = (PFN_ffxFsr2GetInterfaceDX12)DetourFindFunction(exeName.c_str(), "?ffxFsr2GetInterfaceDX12@@YAHPEAUFfxFsr2Interface@@PEAUID3D12Device@@PEAX_K@Z"); // Pattern matching { @@ -1001,8 +1001,8 @@ void HookFSR2ExeInputs() if (o_ffxFsr2GetRenderResolutionFromQualityMode_Dx12 != nullptr) DetourAttach(&(PVOID&)o_ffxFsr2GetRenderResolutionFromQualityMode_Dx12, ffxFsr2GetRenderResolutionFromQualityMode_Dx12); - if (o_ffxFsr2GetInterfaceDX12 != nullptr) - DetourAttach(&(PVOID&)o_ffxFsr2GetInterfaceDX12, hk_ffxFsr2GetInterfaceDX12); + //if (o_ffxFsr2GetInterfaceDX12 != nullptr) + // DetourAttach(&(PVOID&)o_ffxFsr2GetInterfaceDX12, hk_ffxFsr2GetInterfaceDX12); Config::Instance()->fsrHooks = true; @@ -1019,7 +1019,7 @@ void HookFSR2ExeInputs() LOG_DEBUG("ffxFsr2ContextDestroy_Pattern_Dx12: {:X}", (size_t)o_ffxFsr2ContextDestroy_Pattern_Dx12); LOG_DEBUG("ffxFsr2GetUpscaleRatioFromQualityMode_Dx12: {:X}", (size_t)o_ffxFsr2GetUpscaleRatioFromQualityMode_Dx12); LOG_DEBUG("ffxFsr2GetRenderResolutionFromQualityMode_Dx12: {:X}", (size_t)o_ffxFsr2GetRenderResolutionFromQualityMode_Dx12); - LOG_DEBUG("ffxFsr2GetInterfaceDX12: {:X}", (size_t)o_ffxFsr2GetInterfaceDX12); + //LOG_DEBUG("ffxFsr2GetInterfaceDX12: {:X}", (size_t)o_ffxFsr2GetInterfaceDX12); } void HookFSR2Inputs(HMODULE module) @@ -1074,6 +1074,8 @@ void HookFSR2Inputs(HMODULE module) void HookFSR2Dx12Inputs(HMODULE module) { + return; + LOG_INFO("Trying to hook FSR2 methods"); if (o_ffxFsr2GetInterfaceDX12 != nullptr) @@ -1091,8 +1093,8 @@ void HookFSR2Dx12Inputs(HMODULE module) DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); - if (o_ffxFsr2GetInterfaceDX12 != nullptr) - DetourAttach(&(PVOID&)o_ffxFsr2GetInterfaceDX12, hk_ffxFsr2GetInterfaceDX12); + //if (o_ffxFsr2GetInterfaceDX12 != nullptr) + // DetourAttach(&(PVOID&)o_ffxFsr2GetInterfaceDX12, hk_ffxFsr2GetInterfaceDX12); DetourTransactionCommit(); } From 1a775c2a7a970e0f1364f5af897cf7344e371dff Mon Sep 17 00:00:00 2001 From: cdozdil Date: Thu, 16 Jan 2025 02:03:53 +0300 Subject: [PATCH 2/4] add nullpointer check for d3d11 device --- OptiScaler/hooks/HooksDx.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OptiScaler/hooks/HooksDx.cpp b/OptiScaler/hooks/HooksDx.cpp index 58f14bf0..595c017c 100644 --- a/OptiScaler/hooks/HooksDx.cpp +++ b/OptiScaler/hooks/HooksDx.cpp @@ -3347,7 +3347,7 @@ static HRESULT hkD3D11On12CreateDevice(IUnknown* pDevice, UINT Flags, D3D_FEATUR HookToDevice(d3d11on12Device); } - if (*ppDevice != nullptr) + if (result == S_OK && *ppDevice != nullptr) Config::Instance()->d3d11Devices.push_back(*ppDevice); LOG_FUNC_RESULT(result); @@ -3397,7 +3397,7 @@ static HRESULT hkD3D11CreateDevice(IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE Drive LOG_FUNC_RESULT(result); - if (*ppDevice != nullptr) + if (result == S_OK && ppDevice != nullptr && *ppDevice != nullptr) Config::Instance()->d3d11Devices.push_back(*ppDevice); return result; @@ -3450,7 +3450,7 @@ static HRESULT hkD3D11CreateDeviceAndSwapChain(IDXGIAdapter* pAdapter, D3D_DRIVE HookToDevice(d3d11Device); } - if (*ppDevice != nullptr) + if (result == S_OK && ppDevice != nullptr && *ppDevice != nullptr) Config::Instance()->d3d11Devices.push_back(*ppDevice); LOG_FUNC_RESULT(result); @@ -3489,7 +3489,7 @@ static HRESULT hkD3D12CreateDevice(IDXGIAdapter* pAdapter, D3D_FEATURE_LEVEL Min auto result = o_D3D12CreateDevice(pAdapter, MinimumFeatureLevel, riid, ppDevice); //Config::Instance()->skipSpoofing = false; - if (result == S_OK && *ppDevice != nullptr) + if (result == S_OK && ppDevice != nullptr && *ppDevice != nullptr) { LOG_DEBUG("Device captured: {0:X}", (size_t)*ppDevice); g_pd3dDeviceParam = (ID3D12Device*)*ppDevice; From 7c7b81085049696938e087742088093a289681e8 Mon Sep 17 00:00:00 2001 From: cdozdil Date: Thu, 16 Jan 2025 02:04:09 +0300 Subject: [PATCH 3/4] bump to pre2 --- OptiScaler/resource.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OptiScaler/resource.h b/OptiScaler/resource.h index 0ad5a3bf..ea224ecc 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 7 -#define VER_BUILD_NUMBER 1 +#define VER_BUILD_NUMBER 2 #define VER_PRE_RELEASE From 841a77892a8c1cc4944557adc6e32daec13eb866 Mon Sep 17 00:00:00 2001 From: cdozdil Date: Thu, 16 Jan 2025 02:29:04 +0300 Subject: [PATCH 4/4] add scanner to project --- OptiScaler/FfxApi_Dx12.cpp | 2 -- OptiScaler/OptiScaler.vcxproj | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OptiScaler/FfxApi_Dx12.cpp b/OptiScaler/FfxApi_Dx12.cpp index de7c6609..642828b6 100644 --- a/OptiScaler/FfxApi_Dx12.cpp +++ b/OptiScaler/FfxApi_Dx12.cpp @@ -225,8 +225,6 @@ ffxReturnCode_t ffxDestroyContext_Dx12(ffxContext* context, const ffxAllocationC LOG_DEBUG("context: {:X}", (size_t)*context); - auto contextId = (size_t)*context; - if (!_initParams.contains(*context)) { LOG_INFO("Not upscaler context: {:X}", (size_t)*context); diff --git a/OptiScaler/OptiScaler.vcxproj b/OptiScaler/OptiScaler.vcxproj index db1ec516..d99c2057 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:\Games\Steam\steamapps\common\Warhammer 40,000 DARKTIDE\binaries\ .\x64\Debug .dll @@ -284,6 +284,7 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" + @@ -359,6 +360,7 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" +