Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

feat(fg): NVAPI architecture spoof for RTX 30 (off by default) + preparation ordering

Veyra Goal Agentfc8a33b09cd1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ada0c8d1..c264009d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -119,6 +119,7 @@ add_library(veyra_ngx STATIC
src/ngx/DlssFgBackend.cpp
src/ngx/AdaMfgUnlock.cpp
src/ngx/AmpereMfgUnlock.cpp
+ src/ngx/NvapiArchSpoof.cpp
)
veyra_apply_warnings(veyra_ngx)
target_compile_features(veyra_ngx PUBLIC cxx_std_20)
diff --git a/include/veyra/ngx/AmpereMfgUnlock.h b/include/veyra/ngx/AmpereMfgUnlock.h
index 12768fdf..4d771566 100644
--- a/include/veyra/ngx/AmpereMfgUnlock.h
+++ b/include/veyra/ngx/AmpereMfgUnlock.h
@@ -93,9 +93,12 @@ public:
// keep their own paths and are refused here.
static bool adapterIsAmpere(uint32_t vendorId, uint32_t deviceId);
- // Installs the sm_86 fatbin redirection and the architecture compares.
- // Refuses (and rolls back) unless every audited structure matches.
- static State apply(HMODULE module);
+ // Installs the sm_86 fatbin redirection and (unless `retargetArchGates` is
+ // false) the architecture compares. Refuses (and rolls back) unless every
+ // audited structure matches. Callers that make the provider see Blackwell
+ // through the NVAPI spoof must pass false so the provider's own 0x1b0
+ // compare stays byte-identical and therefore passes.
+ static State apply(HMODULE module, bool retargetArchGates = true);
// Restores every patched byte and frees the rebuilt fatbins. Safe to call
// repeatedly and when nothing was applied.
diff --git a/include/veyra/ngx/NvapiArchSpoof.h b/include/veyra/ngx/NvapiArchSpoof.h
new file mode 100644
index 00000000..d21dbdda
--- /dev/null
+++ b/include/veyra/ngx/NvapiArchSpoof.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#include <windows.h>
+
+#include <cstdint>
+#include <string>
+
+namespace veyra::ngx {
+
+// Makes the DLSS-G provider see a different GPU architecture than the physical
+// card reports. The audited 310.7 build has exactly one place that turns the
+// driver's NV_GPU_ARCH_INFO into the value the provider stores and compares
+// (DLSSGInstanceManager::SetGPUArch, "mov eax,[rsp+294h]" at RVA 0x20DCA). That
+// seven-byte load is replaced with "mov eax,<architecture>" so the provider
+// sees the requested id while everything else - including the real
+// implementation/revision fields it later reads - stays intact. Process memory
+// only, fully reverted on release.
+//
+// Used on RTX 30 (sm_86): the provider's frame-generation availability gate
+// reads the architecture and refuses Ampere outright. Reporting Blackwell makes
+// every architecture-based check pass; the kernel rewrite (AmpereMfgUnlock) is
+// still required so the programs can actually run on sm_86. Nothing here runs
+// on Ada or Blackwell - those keep their untouched native paths.
+class NvapiArchSpoof {
+public:
+ static constexpr uint32_t kNvapiGetArchInfoId = 0xD8265D24u; // nvapi_QueryInterface id
+ static constexpr uintptr_t kGetArchInfoWrapperRva = 0x1670u; // audited 310.7 internal wrapper
+ static constexpr uint32_t kArchBlackwell = 0x1B0u; // NV_GPU_ARCHITECTURE_GB200
+ static constexpr uint32_t kArchAda = 0x190u; // NV_GPU_ARCHITECTURE_AD100
+ static constexpr uint32_t kArchAmpere = 0x170u; // NV_GPU_ARCHITECTURE_GA100
+
+ // `module` is the loaded nvngx_dlssg.dll. `reportedArchitecture` is an
+ // NV_GPU_ARCHITECTURE_ID; 0 refuses.
+ static bool install(HMODULE module, uint32_t reportedArchitecture);
+ static void release();
+ static bool installed();
+
+ struct State {
+ bool installed = false;
+ bool targetResolved = false;
+ bool slotWritten = false;
+ uint32_t reportedArchitecture = 0;
+ uint32_t wrapperCalls = 0;
+ uint32_t realArchitectureSeen = 0;
+ std::wstring detail;
+ };
+ static State snapshot();
+};
+
+} // namespace veyra::ngx
diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.h
index e4a33937..20277547 100644
--- a/include/veyra/pipeline/EnhanceGraph.h
+++ b/include/veyra/pipeline/EnhanceGraph.h
@@ -265,6 +265,10 @@ private:
// DLSS-G runtime. Never touched on any other architecture.
void applyAdaMfgUnlock();
void applyAmpereMfgUnlock();
+ // RTX 30 only: must run before the NGX core initializes the provider, which
+ // resolves NvAPI_GPU_GetArchInfo once and caches the architecture decision.
+ void prepareAmpereFgSpoof();
+ bool ampereSpoofed_ = false;
bool createComputePasses();
gfx::D3D12DeviceContext& context_;
diff --git a/src/ngx/AmpereMfgUnlock.cpp b/src/ngx/AmpereMfgUnlock.cpp
index 30b16ea9..bfab0605 100644
--- a/src/ngx/AmpereMfgUnlock.cpp
+++ b/src/ngx/AmpereMfgUnlock.cpp
@@ -774,7 +774,7 @@ bool AmpereMfgUnlock::adapterIsAmpere(uint32_t vendorId, uint32_t deviceId) {
return deviceId >= 0x2200 && deviceId < 0x2680;
}
-AmpereMfgUnlock::State AmpereMfgUnlock::apply(HMODULE module) {
+AmpereMfgUnlock::State AmpereMfgUnlock::apply(HMODULE module, bool retargetArchGates) {
auto& g = global();
std::lock_guard lock(g.mutex);
State state{};
@@ -1022,18 +1022,24 @@ AmpereMfgUnlock::State AmpereMfgUnlock::apply(HMODULE module) {
}
};
- // 1. architecture compares (0x1b0 -> 0x170)
- patchArchGates(image.base, image.nt, g.archGateWrites);
- if (g.archGateWrites.size() < kMinArchGateSites ||
- g.archGateWrites.size() > kMaxArchGateSites) {
- const size_t found = g.archGateWrites.size();
- rollbackAll();
- state.detail = std::format(L"arch-gate site count {} outside the audited range {}-{}",
- found, kMinArchGateSites, kMaxArchGateSites);
- g.state = state;
- return state;
+ // 1. architecture compares (0x1b0 -> 0x170). Skipped when the caller makes
+ // the provider see Blackwell through the NVAPI spoof: then the provider's
+ // own compare must stay byte-identical so that the reported id matches it.
+ if (retargetArchGates) {
+ patchArchGates(image.base, image.nt, g.archGateWrites);
+ if (g.archGateWrites.size() < kMinArchGateSites ||
+ g.archGateWrites.size() > kMaxArchGateSites) {
+ const size_t found = g.archGateWrites.size();
+ rollbackAll();
+ state.detail = std::format(L"arch-gate site count {} outside the audited range {}-{}",
+ found, kMinArchGateSites, kMaxArchGateSites);
+ g.state = state;
+ return state;
+ }
+ state.archGateSites = g.archGateWrites.size();
+ } else {
+ log::info("ampere-mfg", "arch-gate retarget skipped: the provider is being told it runs on Blackwell");
}
- state.archGateSites = g.archGateWrites.size();
state.archGatesPatched = true;
// 2. registration slot pointers
diff --git a/src/ngx/NvapiArchSpoof.cpp b/src/ngx/NvapiArchSpoof.cpp
new file mode 100644
index 00000000..3c5dee31
--- /dev/null
+++ b/src/ngx/NvapiArchSpoof.cpp
@@ -0,0 +1,207 @@
+#include "veyra/ngx/NvapiArchSpoof.h"
+
+#include "veyra/Log.h"
+
+#include <format>
+#include <mutex>
+
+namespace veyra::ngx {
+namespace {
+
+// NV_GPU_ARCH_INFO_V1 from the public nvapi.h: version, architecture,
+// implementation, revision. The provider sets the version field to 0x20010
+// before calling (seen in the audited disassembly at 0x180020DB4).
+struct NvGpuArchInfo {
+ uint32_t version;
+ uint32_t architecture;
+ uint32_t implementation;
+ uint32_t revision;
+};
+using GetArchInfoFn = int(__cdecl*)(void* physicalGpu, NvGpuArchInfo* info);
+using EnumPhysicalGpusFn = int(__cdecl*)(void* handles, uint32_t* count);
+using QueryInterfaceFn = void*(__cdecl*)(uint32_t id);
+constexpr uint32_t kNvapiEnumPhysicalGpusId = 0xADD604D1u;
+constexpr uint32_t kNvapiInitializeId = 0x0150E828u;
+constexpr uint32_t kNvGpuArchInfoVersion = 0x20010u;
+using NvapiInitializeFn = int(__cdecl*)();
+
+// The audited provider resolves NvAPI_GPU_GetArchInfo through a small internal
+// wrapper at RVA 0x1670. Its first 24 bytes are a stable prologue ending at the
+// next instruction boundary; a 14-byte absolute jump fits in the first 14 of
+// them, and a trampoline holding the original 24 bytes plus a jump back runs the
+// real logic. That keeps every real field (implementation/revision included)
+// and only rewrites the architecture the provider adopts.
+constexpr uint8_t kExpectedPrologue[24] = {
+ 0x48, 0x89, 0x74, 0x24, 0x10, 0x57, 0x48, 0x83, 0xEC, 0x20,
+ 0x48, 0x8B, 0xFA, 0x48, 0x8B, 0xF1,
+ 0xF0, 0x83, 0x05, 0x4C, 0x14, 0x73, 0x00, 0x01};
+constexpr size_t kRelocatedBytes = sizeof(kExpectedPrologue);
+constexpr size_t kJumpBytes = 14; // ff 25 00 00 00 00 <addr64>
+constexpr size_t kTrampolineBytes = kRelocatedBytes + kJumpBytes;
+
+struct Global {
+ std::mutex mutex;
+ uint8_t* entry = nullptr;
+ uint8_t* trampoline = nullptr;
+ uint32_t reportedArchitecture = 0;
+ uint32_t realArchitectureSeen = 0;
+ bool targetResolved = false;
+ bool installed = false;
+ std::wstring detail;
+};
+
+Global& global() {
+ static Global value;
+ return value;
+}
+
+bool writeCode(void* target, const uint8_t* bytes, size_t count) {
+ DWORD oldProtect = 0;
+ if (VirtualProtect(target, count, PAGE_EXECUTE_READWRITE, &oldProtect) == 0) {
+ return false;
+ }
+ std::memcpy(target, bytes, count);
+ DWORD ignored = 0;
+ VirtualProtect(target, count, oldProtect, &ignored);
+ FlushInstructionCache(GetCurrentProcess(), target, count);
+ return true;
+}
+
+int __cdecl SpoofedGetArchInfo(void* physicalGpu, NvGpuArchInfo* info) {
+ auto& g = global();
+ if (g.trampoline == nullptr) {
+ return -1;
+ }
+ const int status = reinterpret_cast<GetArchInfoFn>(g.trampoline)(physicalGpu, info);
+ if (status == 0 && info != nullptr && g.reportedArchitecture != 0) {
+ if (g.realArchitectureSeen == 0) {
+ g.realArchitectureSeen = info->architecture;
+ }
+ info->architecture = g.reportedArchitecture;
+ }
+ return status;
+}
+
+} // namespace
+
+bool NvapiArchSpoof::install(HMODULE module, uint32_t reportedArchitecture) {
+ auto& g = global();
+ std::lock_guard lock(g.mutex);
+ if (g.installed) {
+ return true;
+ }
+ if (module == nullptr || reportedArchitecture == 0) {
+ g.detail = L"module or reported architecture missing";
+ return false;
+ }
+
+ // Record what the driver really reports, purely for the log.
+ HMODULE nvapi = LoadLibraryExW(L"nvapi64.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
+ if (nvapi != nullptr) {
+ const auto query = reinterpret_cast<QueryInterfaceFn>(GetProcAddress(nvapi, "nvapi_QueryInterface"));
+ if (query != nullptr) {
+ const auto getArchInfo = reinterpret_cast<GetArchInfoFn>(query(kNvapiGetArchInfoId));
+ const auto enumGpus = reinterpret_cast<EnumPhysicalGpusFn>(query(kNvapiEnumPhysicalGpusId));
+ const auto initialize = reinterpret_cast<NvapiInitializeFn>(query(kNvapiInitializeId));
+ if (initialize != nullptr) {
+ initialize();
+ }
+ if (getArchInfo != nullptr && enumGpus != nullptr) {
+ uint64_t handles[64]{};
+ uint32_t count = 0;
+ if (enumGpus(handles, &count) == 0 && count > 0) {
+ NvGpuArchInfo info{};
+ info.version = kNvGpuArchInfoVersion;
+ if (getArchInfo(reinterpret_cast<void*>(handles[0]), &info) == 0) {
+ g.realArchitectureSeen = info.architecture;
+ }
+ }
+ }
+ }
+ }
+
+ g.entry = reinterpret_cast<uint8_t*>(module) + kGetArchInfoWrapperRva;
+ if (std::memcmp(g.entry, kExpectedPrologue, kRelocatedBytes) != 0) {
+ g.detail = L"provider GetArchInfo wrapper prologue does not match the audited build";
+ g.entry = nullptr;
+ return false;
+ }
+ g.targetResolved = true;
+
+ // Trampoline: the original 24 bytes followed by "jmp [rip+0] <wrapper+24>".
+ g.trampoline = static_cast<uint8_t*>(VirtualAlloc(
+ nullptr, kTrampolineBytes, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE));
+ if (g.trampoline == nullptr) {
+ g.detail = L"trampoline allocation failed";
+ g.entry = nullptr;
+ return false;
+ }
+ std::memcpy(g.trampoline, g.entry, kRelocatedBytes);
+ {
+ uint8_t* jump = g.trampoline + kRelocatedBytes;
+ jump[0] = 0xFF; jump[1] = 0x25;
+ const uint32_t zero = 0;
+ std::memcpy(jump + 2, &zero, 4);
+ const uint64_t back = reinterpret_cast<uint64_t>(g.entry + kRelocatedBytes);
+ std::memcpy(jump + 6, &back, 8);
+ }
+ FlushInstructionCache(GetCurrentProcess(), g.trampoline, kTrampolineBytes);
+
+ // Entry: "jmp [rip+0] <SpoofedGetArchInfo>" (14 bytes, no register touched).
+ uint8_t patch[kJumpBytes]{};
+ patch[0] = 0xFF; patch[1] = 0x25;
+ const uint32_t zero = 0;
+ std::memcpy(patch + 2, &zero, 4);
+ const uint64_t target = reinterpret_cast<uint64_t>(&SpoofedGetArchInfo);
+ std::memcpy(patch + 6, &target, 8);
+ if (!writeCode(g.entry, patch, kJumpBytes)) {
+ g.detail = L"the provider GetArchInfo wrapper page is not writable";
+ VirtualFree(g.trampoline, 0, MEM_RELEASE);
+ g.trampoline = nullptr;
+ g.entry = nullptr;
+ return false;
+ }
+ g.reportedArchitecture = reportedArchitecture;
+ g.installed = true;
+ log::info("nvapi-spoof", std::format(
+ "provider GetArchInfo wrapper hooked (trampoline at {}): will report 0x{:X}",
+ static_cast<const void*>(g.trampoline), reportedArchitecture));
+ return true;
+}
+
+void NvapiArchSpoof::release() {
+ auto& g = global();
+ std::lock_guard lock(g.mutex);
+ if (!g.installed) {
+ return;
+ }
+ const bool restored = writeCode(g.entry, kExpectedPrologue, kRelocatedBytes);
+ if (g.trampoline != nullptr) {
+ VirtualFree(g.trampoline, 0, MEM_RELEASE);
+ g.trampoline = nullptr;
+ }
+ log::info("nvapi-spoof", std::format(
+ "provider architecture load site restored={} (process memory only)", restored ? 1 : 0));
+ g.installed = false;
+ g.entry = nullptr;
+}
+
+bool NvapiArchSpoof::installed() {
+ auto& g = global();
+ std::lock_guard lock(g.mutex);
+ return g.installed;
+}
+
+NvapiArchSpoof::State NvapiArchSpoof::snapshot() {
+ auto& g = global();
+ std::lock_guard lock(g.mutex);
+ State state;
+ state.installed = g.installed;
+ state.targetResolved = g.targetResolved;
+ state.slotWritten = g.entry != nullptr;
+ state.reportedArchitecture = g.reportedArchitecture;
+ state.detail = g.detail;
+ return state;
+}
+
+} // namespace veyra::ngx
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index 388c3db7..6cd7b769 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -23,6 +23,7 @@
#include "veyra/ngx/DlssFgBackend.h"
#include "veyra/ngx/AdaMfgUnlock.h"
#include "veyra/ngx/AmpereMfgUnlock.h"
+#include "veyra/ngx/NvapiArchSpoof.h"
#include "veyra/gfx/FsrSrBackend.h"
#include "veyra/ngx/DlssNrParameters.h"
#include "veyra/ngx/DlssNrRuntimeAdapter.h"
@@ -480,6 +481,60 @@ void EnhanceGraph::applyAdaMfgUnlock()
std::string(state.detail.begin(), state.detail.end())));
}
+// Must run before the NGX core initializes the DLSS-G provider: the provider
+// resolves NvAPI_GPU_GetArchInfo once during its own initialization and caches
+// the resulting architecture decision, so installing the spoof afterwards has
+// no effect (measured 2026-09-17 on the local 5070: the cached entry was
+// already populated and the capability verdict stayed unchanged).
+void EnhanceGraph::prepareAmpereFgSpoof()
+{
+ if (!fgEnabled_ || desc_.frameGenerationBackend != engine::FrameGenerationBackend::Dlss) {
+ return;
+ }
+ wchar_t disabled[2]{};
+ if (GetEnvironmentVariableW(L"VEYRA_DISABLE_AMPERE_MFG_UNLOCK", disabled, 2) > 0) {
+ return;
+ }
+ const auto& adapter = context_.adapter();
+ wchar_t forced[2]{};
+ const bool forceOnAnyAdapter = GetEnvironmentVariableW(L"VEYRA_TEST_FORCE_AMPERE_UNLOCK", forced, 2) > 0;
+ if (!forceOnAnyAdapter && !ngx::AmpereMfgUnlock::adapterIsAmpere(adapter.vendorId, adapter.deviceId)) {
+ return;
+ }
+
+ const auto modulePath = std::filesystem::path(desc_.runtimeAbsPath) / L"nvngx_dlssg.dll";
+ HMODULE module = GetModuleHandleW(L"nvngx_dlssg.dll");
+ if (module == nullptr) {
+ module = LoadLibraryExW(modulePath.c_str(), nullptr,
+ LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
+ }
+ if (module == nullptr) {
+ veyra::log::warn("ampere-mfg", std::format("DLSS-G runtime could not be preloaded for the architecture spoof (path={} win32={})",
+ modulePath.string(), GetLastError()));
+ return;
+ }
+ // Disabled by default: the hook is still under investigation (it changes the
+ // architecture the provider adopts but does not yet produce a stable
+ // frame-generation session on the test host). Set VEYRA_TEST_NVAPI_SPOOF_ARCH
+ // to a NV_GPU_ARCHITECTURE_ID (e.g. 0x1B0 for Blackwell) to try it.
+ uint32_t spoofArchitecture = 0;
+ {
+ wchar_t overrideText[16]{};
+ if (GetEnvironmentVariableW(L"VEYRA_TEST_NVAPI_SPOOF_ARCH", overrideText, 16) > 0) {
+ spoofArchitecture = static_cast<uint32_t>(std::wcstoul(overrideText, nullptr, 0));
+ }
+ }
+ if (spoofArchitecture == 0) {
+ return;
+ }
+ ampereSpoofed_ = ngx::NvapiArchSpoof::install(module, spoofArchitecture);
+ if (!ampereSpoofed_) {
+ const auto state = ngx::NvapiArchSpoof::snapshot();
+ veyra::log::warn("ampere-mfg", std::format("NVAPI architecture spoof unavailable ({}); the arch-gate retarget will be used instead",
+ std::string(state.detail.begin(), state.detail.end())));
+ }
+}
+
void EnhanceGraph::applyAmpereMfgUnlock()
{
const auto& adapter = context_.adapter();
@@ -525,9 +580,16 @@ void EnhanceGraph::applyAmpereMfgUnlock()
scan.detail));
return;
}
- const auto state = ngx::AmpereMfgUnlock::apply(module);
- veyra::log::info("ampere-mfg", std::format("adapter deviceId=0x{:04X} unlock applied={} runs={} slots={} fatbins={} lea={} gates={} ({})",
- adapter.deviceId, state.applied ? 1 : 0, state.slotRuns,
+ // The spoof was installed before the provider was initialized (see
+ // prepareAmpereFgSpoof). When it is active the provider's own 0x1b0 compare
+ // must stay byte-identical so the reported architecture matches it; only
+ // the kernel rewrite runs here. Without the spoof the old retarget is kept.
+ const auto spoofState = ngx::NvapiArchSpoof::snapshot();
+ const bool spoofed = ampereSpoofed_ && spoofState.installed;
+ const auto state = ngx::AmpereMfgUnlock::apply(module, !spoofed);
+ veyra::log::info("ampere-mfg", std::format("adapter deviceId=0x{:04X} unlock applied={} spoofed={} reportedArch=0x{:X} runs={} slots={} fatbins={} lea={} gates={} ({})",
+ adapter.deviceId, state.applied ? 1 : 0,
+ spoofed ? 1 : 0, spoofState.reportedArchitecture, state.slotRuns,
state.slotPointers,
state.programFatbins + state.networkFatbins + state.auxFatbins,
state.leaSites, state.archGateSites,
@@ -603,6 +665,10 @@ bool EnhanceGraph::initNgxFeatures()
return false;
}
+ // RTX 30 needs the NVAPI architecture spoof in place before the provider is
+ // initialized below. No-op on Ada/Blackwell and when FG is off.
+ prepareAmpereFgSpoof();
+
coreHost_ = std::make_unique<ngx::NgxCoreHost>();
Status st = Status::Ok;
if (!coreHost_->initialize(context_.device(), desc_.runtimeAbsPath.c_str(),
@@ -1746,6 +1812,7 @@ void EnhanceGraph::shutdown()
// feature (the unlock is process memory only; the file on disk is untouched).
ngx::AdaMfgUnlock::release();
ngx::AmpereMfgUnlock::release();
+ ngx::NvapiArchSpoof::release();
// Staged explicit release (scope-end destructors then have nothing left).
decPass_ = ComputePass{};