Files
d4r/patches/optiscaler/0002-early-d3d12-command-backend.patch

46 lines
1.8 KiB
Diff

From 7ed1f1d66b430ba35a197fbd9880cd6a76af8f06 Mon Sep 17 00:00:00 2001
From: Codex <codex@localhost>
Date: Thu, 1 Oct 2026 16:45:01 +0300
Subject: [PATCH] Install the external d4r command backend before NGX
initialization
---
OptiScaler/hooks/D3D12_Hooks.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/OptiScaler/hooks/D3D12_Hooks.cpp b/OptiScaler/hooks/D3D12_Hooks.cpp
index 29c0bec..3b757be 100644
--- a/OptiScaler/hooks/D3D12_Hooks.cpp
+++ b/OptiScaler/hooks/D3D12_Hooks.cpp
@@ -14,6 +14,7 @@
#include <proxies/IGDExt_Proxy.h>
#include <proxies/Streamline_Proxy.h>
#include <proxies/KernelBase_Proxy.h>
+#include <proxies/NVNGX_Proxy.h>
#include <detours/detours.h>
@@ -2230,6 +2231,19 @@ static void HookToDevice(ID3D12Device* InDevice)
if (Util::CheckForRealObject(__FUNCTION__, InDevice, (IUnknown**) &realDevice))
pVTable = *(PVOID**) realDevice;
+ if (State::Instance().dlssExternalBackend)
+ {
+ // Capture command signatures/resources created before the game's NGX
+ // Init. Install before adding OptiScaler's own method trampolines.
+ using InstallCommandBackend = unsigned (*)(ID3D12Device*);
+ auto install = reinterpret_cast<InstallCommandBackend>(KernelBaseProxy::GetProcAddress_()(
+ NVNGXProxy::NVNGXModule(), "d4r_D3D12_InstallCommandBackend"));
+ auto result = install ? install(realDevice ? realDevice : InDevice) : 0;
+ LOG_INFO("External d4r command backend installed at device discovery: result={:X}", result);
+ if (result != 1)
+ LOG_ERROR("External d4r early command tracking failed; DLSS initialization must be checked");
+ }
+
// hudless
o_D3D12DeviceRelease = (PFN_Release) pVTable[2];
o_CreateSampler = (PFN_CreateSampler) pVTable[22];
--
2.55.0.windows.5