From 7ed1f1d66b430ba35a197fbd9880cd6a76af8f06 Mon Sep 17 00:00:00 2001 From: Codex 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 #include #include +#include #include @@ -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(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