Windows: drag-in install with a per-game d4r.ini

Players extract one ZIP into the game folder, copy their two NVIDIA
DLLs, and start the game from Steam, Epic or a shortcut. No launcher
script is needed; settings live in d4r\d4r.ini.

- Shim player mode: when the launcher has not set D4R_HIP_ROOT and
  d4r.ini sits beside the shim, derive the backend environment from it.
  Codegen flags stay at the Windows-validated values. NVIDIA DLLs must
  match an exact SHA256 in dll-pins.txt, with "you have X, you need Y"
  errors. Rejects a vkd3d/Wine d3d12.dll and code objects built for
  another GPU. [DLSS] Model accepts K or M and is applied by rewriting
  the render preset hints.

- d4r.ini exposes only options that exist on Windows: Model, AsyncInterop,
  ValidateOutput, Log, CacheDir. Invalid values fall back with a note in
  d4r_nvngx.log.

- d4r_nvngx_loader: one _nvngx.dll for all GPUs. It matches the game's
  adapter by LUID and loads _nvngx_<arch>.dll from the same folder.

- OptiScaler patch 0006: relative NvngxPath/NvngxDlssPath/
  NvngxFeaturePath resolve against OptiScaler's folder.

- package-windows-release.ps1 builds the release from the per-target
  game packages and refuses mixed targets or differing shared runtimes.

- Tests: test-player-config.ps1 (ini and DLL-pin decisions, loader
  selection on the local GPU) and test-windows-release-package.ps1.
This commit is contained in:
ayo committed 2026-10-03 03:10:19 -04:00
1 parent 7ab56d42fc
commit 65ab1460a8
13 files changed
+1004 -1

No files matched your search

+6
View File
@@ -1,5 +1,6 @@
// Native Windows backend. The Linux/Wine implementation remains separate.
#include "ngx_windows_runtime.h"
#include "player_config.h"
#include <dxgi.h>
#include <unordered_map>
#include <functional>
@@ -59,6 +60,7 @@ API unsigned d4r_WindowsBackendVersion() { return 1; }
API unsigned NVSDK_NGX_D3D12_Init_Ext(unsigned long long app, const wchar_t* data, ID3D12Device* device, unsigned sdk, const void* info) {
std::lock_guard<std::mutex> lock(apiMutex);
return call([&] {
d4r::win::player::ensure_environment();
if (!runtime) runtime = std::make_shared<d4r::win::Runtime>(device, app, data, sdk, static_cast<const d4r::ngx::FeatureCommonInfo*>(info));
if (const char* backend = std::getenv("D4R_D3D12_COMMAND_BACKEND"); backend && std::string(backend) == "1")
d4r::win::commands::install(device);
@@ -72,6 +74,7 @@ API unsigned NVSDK_NGX_D3D12_Init_ProjectID(const char* project, int engine, con
std::lock_guard<std::mutex> lock(apiMutex);
return call([&] {
if (!project || !*project) return invalid;
d4r::win::player::ensure_environment();
d4r::ngx::ProjectIdentity identity{project, engine, version ? version : ""};
if (!runtime) runtime = std::make_shared<d4r::win::Runtime>(device, 0, data, sdk, static_cast<const d4r::ngx::FeatureCommonInfo*>(info), &identity);
if (const char* backend = std::getenv("D4R_D3D12_COMMAND_BACKEND"); backend && std::string(backend) == "1") d4r::win::commands::install(device);
@@ -84,6 +87,7 @@ API unsigned NVSDK_NGX_D3D12_GetFeatureRequirements(IDXGIAdapter* adapter, const
return call([&] {
*requirements = {}; requirements->FeatureSupported = 16; // Unsupported feature.
if (info->FeatureID != 1) return 1u;
d4r::win::player::ensure_environment();
DXGI_ADAPTER_DESC desc{}; d4r::win::dx(adapter->GetDesc(&desc), "NGX requirements adapter");
// OptiScaler can override the DXGI vendor ID. The physical HIP
// architecture and full adapter LUID are the authoritative identity.
@@ -116,6 +120,7 @@ API unsigned NVSDK_NGX_D3D12_CreateFeature(ID3D12GraphicsCommandList*, unsigned
std::lock_guard<std::mutex> lock(apiMutex);
return call([&] {
if (!runtime || feature != 1 || !p || !out) return invalid;
d4r::win::player::apply_preset(p);
auto value = std::make_shared<d4r::win::Feature>(runtime, p);
auto handle = std::make_unique<Handle>(); handle->Id = nextId++;
features.emplace(handle.get(), std::move(value)); *out = handle.release(); return 1u;
@@ -141,6 +146,7 @@ API unsigned NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCommandList* list, co
};
auto snapshot = std::make_shared<Snapshot>();
if (!snapshot->parameters) return failure;
d4r::win::player::apply_preset(p);
d4r::ngx::copy_create(p, snapshot->parameters); d4r::ngx::copy_frame(p, snapshot->parameters);
const char* names[] = {"Color", "Depth", "MotionVectors", "Output", "ExposureTexture"};
const char* states[] = {"D4R.Color.State", "D4R.Depth.State", "D4R.Motion.State", "D4R.Output.State", "D4R.Exposure.State"};