From d7a4ecfae30067c702abaca58fdd4d3feeefc4b5 Mon Sep 17 00:00:00 2001 From: levzzz <86072227+levzzz5154@users.noreply.github.com> Date: Tue, 1 Sep 2026 20:38:23 +0500 Subject: [PATCH] Fix GPU probe recursion with dxvk-nvapi (issue #1101) queryNvapi() calls NvAPI_Initialize, which (via dxvk-nvapi) internally creates a DXGI factory and enumerates adapters. That enumeration hits OptiScaler's hooked EnumAdapters/EnumAdapters1, which calls getAllGpus() again while is_fetching is already set and returns an empty list. dxvk-nvapi then sees zero adapters, NvAPI_Initialize fails, and dlssCapable is never set - hiding DLSS in games like Death Stranding 2. Wrap queryNvapi in ScopedSkipDxgiLoadChecks so nvapi's internal DXGI enumeration passes through to the real adapters. --- OptiScaler/misc/IdentifyGpu.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OptiScaler/misc/IdentifyGpu.cpp b/OptiScaler/misc/IdentifyGpu.cpp index d2c3f810..da51cd83 100644 --- a/OptiScaler/misc/IdentifyGpu.cpp +++ b/OptiScaler/misc/IdentifyGpu.cpp @@ -194,6 +194,12 @@ std::vector IdentifyGpu::checkGpuInfo() void IdentifyGpu::queryNvapi(GpuInformation& gpuInfo) { + // Prevent recursion: NvAPI_Initialize (dxvk-nvapi) internally creates a DXGI factory + // and enumerates adapters, which re-enters our hooked EnumAdapters/EnumAdapters1 and + // calls getAllGpus() again while is_fetching is already set (returns empty list). + // Skip the DXGI load checks so nvapi sees the real adapters, allowing init to succeed. + ScopedSkipDxgiLoadChecks skipDxgiLoadChecks {}; + auto nvapiModule = NtdllProxy::LoadLibraryExW_Ldr(L"nvapi64.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); // No nvapi, should not be nvidia, possibly external spoofing