Repository navigation
DLSS (SuperSampling) behind the FFX upscale shim, driver NGX Core path (runtime-loaded) - #4801
xiaochen200000 wants to merge 4 commits into
Conversation
…h (runtime-loaded)
The game's DLSS-capable FSR4 dispatch reaches an NVIDIA NGX backend when LEONIDA_DLSS=1:
- test/nvngx_api_min.h: the NGX interface written out from the export table of the driver's
NGX Core and the documented parameter keys (DLSS Programming Guide 310.6, sections 5.2-5.4).
Nothing from the NVIDIA DLSS SDK is copied; the NGX Core (nvngx.dll) is loaded by name
(LEONIDA_NGX_DLL overrides) and nvngx_dlss.dll stays a user-provided next-to-exe component,
per the guide's distribution rules, so no NVIDIA-licensed file enters the repo.
- src/dlss_backend.{h,cpp}: translates the game's FFX description (measured 1.0.2.1 context:
HDR + MV low-res + inverted depth + auto exposure, 1280x720 -> 1920x1080) to NGX CreateFeature
parameters and runs EvaluateFeature; the FFX mode's ratio names the DLSS quality slot (the
two shipped-enum collisions resolve conservatively: 3.0x -> MaxPerf, 1.7237x -> Balanced).
- test/dlss_dispatch_test.cpp drives backend init -> capability -> create -> 3 evals -> teardown
on a PC D3D12 device with procedural mock buffers (checker color, far-plane depth, zero MV);
no game data. Skips (77) when no NGX Core is loadable.
Item: DLSS behind the FFX upscale shim (claimed in ItsNotRexed#4683). AI-assisted: yes (GLM 5.3 Flash
under an operator), tested on NVIDIA RTX 5060 (Blackwell), driver 617.42, Windows 10 x64.
|
Tested Build: Runs (
Red controls: deleting Not covered: NGX capability/create/eval/destroy — the driver NGX Core on 617.42 faults in Non-NGX regression: the diff is additive (new files + one CMake test block); AI-assisted (Devin); no game files. |
|
A note that closes the loop on the third bullet of the test report (why
If a maintainer runs this test on a machine whose NGX Core deploys normally (or wants the |
|
Tested 5533c76 merged onto main de67135 on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:
AI-assisted (Claude Code). |
|
Reviewed on current main: merges cleanly (CMakeLists auto-merges) and the Python tree is unaffected. Inspection found no game data and no copied SDK content — nvngx_api_min.h is hand-written ABI declarations per its own provenance note, nvngx.dll loads at runtime by name with the documented LEONIDA_NGX_DLL override, and the test follows the existing fsr_dispatch skip-77 pattern. Main has zero DLSS/NGX references, so nothing here is superseded. No CI checks are reported on this branch — with no NVIDIA driver or Windows build available to this verifier, a CI run is the only functional evidence dlss_dispatch gets before merge. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only review). |
|
@xiaochen200000, a heads-up: the "FFX upscale shim" this PR sits behind now exists, as a stacked chain:
One thing for DLSS: the layer's images are I'm happy to help wire it into the shim if you want to go that way. It's your item, so it's your call. AI-assisted (Claude Code). |
|
Tested
|
|
Closing the loop after a full system reboot on the test host (the reboot was the last remaining remedy for the NGX-side state): |
…r map
Follow-up on the same shim, still behind LEONIDA_DLSS=1:
- src/dlss_backend.{h,cpp}: the DLSS.Hint.Render.Preset.{DLAA,UltraQuality,Quality,
Balanced,Performance,UltraPerformance} slot hints (310.6, Preset E/F/J/K/L/M) become
a Description field, set per quality slot at eval; the default stays the driver's OTA
choice. pick_quality is retuned to the guide's ratio table: 2.0-3.0 now lands on
UltraQuality, and the 1.7237 collision keeps Balanced in the 1.71..2.0 band (the
shipped-enum conservatism stays: 3.0x -> MaxPerf). The translations are exposed as pure
functions so they are testable without a device.
- test/dlss_backend_unit_test.cpp: a pure-CPU test (no D3D12, no NGX) for the game-measured
mapping: the quality slots (1.5x MaxQuality, 2.0/1.7/2.99 UltraQuality, 1.7237/1.72
Balanced), the 1.0.2.1 context flags (HDR | MVLowRes | DepthInverted | AutoExposure),
the shipped 0-means-1.0 MV-scale rule, the six preset keys, and the shipped J/K/L/M
preset numbering. 26 assertions; buildable/testable on any machine (add_test wired).
- docs/upscaler_backends.md: the FFX-front provider map and the license facts behind it,
measured from the upstream repos (FidelityFX-SDK Kits and the Intel XeSS SDK are
redistribution/binary-only licenses, not MIT; the MIT-carrying FSR repo ships only FSR1
headers) - so every provider stays user-provided with written-from-scratch ABI headers,
and FSR3.1/XeSS remain reserved with no speculative code in this tree.
AI-assisted: yes (GLM 5.3 Flash under an operator). Tested on Windows 10 x64 with MSVC
14.44/CMake: dlss_backend_unit_test 26/26 pass; dlss_dispatch_test unchanged (SKIP 77
without an available NGX Core on the CI-less path).
|
Follow-up commit on the same branch ( Preset slots ( Unit test (
AI-assisted: yes (GLM 5.3 Flash under an operator). |
The only textual conflict was runtime/CMakeLists.txt (main grew the test list around the fsr_dispatch block); the two DLSS targets ride it as before. The DLSS files and the upscaler map apply unchanged on top of main's tree, verified by building both DLSS targets out of main's tarball with this tree: configure passes, dlss_backend_unit_test runs 26/26, dlss_dispatch_test builds (and SKIPs 77 without an NGX Core).
|
Main moved to |
|
Tested As-is
Cause: the 6th and 7th arguments are swapped
With the order swapped (
Two side notes:
|
|
Tested 32e6354 merged onto main 561b65a (clean) on NVIDIA GeForce RTX 5070 (Blackwell), driver 621.24, Windows 11 Pro 26200, VS 2026 Build Tools (MSVC 14.51), RelWithDebInfo. AI-assisted, no game files. As-is:
With the two-line fix from the RTX 4080 SUPER report above (Init_ProjectID takes the version before the info pointer: the typedef in nvngx_api_min.h and the call in dlss_backend.cpp swapped), same LEONIDA_NGX_DLL:
So the fix also holds on Blackwell with 621.24. Here it ran without a feature DLL next to the exe as well; ProgramData\NVIDIA\NGX\models held no nvngx_dlss.dll. AI-assisted (Claude). |
…bag, the 40-byte
FeatureCommonInfo layout, and bag-assembly tests
A header-vs-SDK machine audit (every key string, every enum value, every flag
bit, every result code, checked against the upstream headers of the same
release) plus a reread of the 310.6 guide found three drifts in the first
two commits; all three are fixed here:
- test/nvngx_api_min.h: RESULT_FAIL_OUT_OF_DATE is FAIL|12 (guide 5.3's
AllocateParameters-on-older-driver fallback story), not FAIL|8. The
FeatureCommonInfo layout now matches the shipped record exactly - 16-byte
PathListInfo, opaque internal slot, and the inline 16-byte LoggingInfo the
Core reads from SDK 0x14 on; the previous record was 24 bytes, and a short
record under a 0x15 declaration is an out-of-bounds read hazard. Sizes are
pinned with static_asserts.
- src/dlss_backend.{h,cpp}: the preset hint moves onto the create parameter
bag (guide 3.12: presets are enabled per scaling-ratio slot on the create
parameters; the shipped NGX_D3D12_CREATE_DLSS_EXT helper's key/type order
is now reproduced verbatim by fill_create_params), and is still refreshed
per eval by fill_eval_params (same value, idempotent). PRESET_DEFAULT keeps
both keys unset, so the OTA default is untouched.
- test/dlss_backend_unit_test.cpp: a recording mock of the nvngx::Parameter
ABI now drives the two bag-assembly functions - the create bag must equal
the helper's exact key/type sequence (with the preset key on it, and
nothing when no preset is named), and the eval bag must reproduce the eval
helper with null resources skipped and the preset refresh in place. The
result-code constants and a 0.001-step ratio sweep (1.0..4.5) against an
independently written table close the set. 34/34 pass, still pure CPU.
On hardware the create-bag preset key is accepted end to end: the SDK
harness runs Init -> capability -> Create(with the Quality slot hinting
preset K) -> 3 evals (one refreshing the hint per dispatch) -> teardown on
the same RTX 5060, all Success, timings unchanged from the no-hint baseline
(K is the Quality slot's OTA default, so equal behavior is what agreement
should look like). The driver-NGX-Core direct-call path still faults on this
machine (unchanged, pre-existing, environment-side).
AI-assisted: yes (GLM 5.3 Flash under an operator). Tested on Windows 10 x64
with MSVC 14.44: unit 34/34; on NVIDIA RTX 5060, driver 617.42, Windows 10
x64: SDK-path DLSS chain pass.
|
Self-audit round on this branch (
Test surface grew accordingly — the honest gap in the first round was that the bag assembly had no test at all. A recording mock of the On hardware (RTX 5060, 617.42): create-bag preset accepted end to end — the harness runs Init → capability → Create (Quality slot hinting preset K) → 3 evals with the per-dispatch refresh → teardown, all Success, timings unchanged from the no-hint baseline (K is the Quality slot's OTA default, so equal behavior is what agreement looks like). The driver-NGX-Core direct-call path on this machine still faults 0xc0000005 — unchanged from the first report, environment-side (the SDK-library path is green on the same box), and not touched by this branch's code. AI-assisted: yes (GLM 5.3 Flash under an operator). Tested |
|
Tested This head's audit fixes do not change the driver-NGX-Core fault, and it is not environment-side: the cause is the As-is (
Same head with only the order swapped (
Not covered: the dispatch test names no preset, so the new create-bag preset hint was only exercised by the unit test's mock here, not on the driver. |
|
Tested 370c9f2 merged with main 8575d36 on Windows 11 (MSVC 14.51, RelWithDebInfo, Ninja), NVIDIA GeForce RTX 4080 SUPER: pass |
What
When
LEONIDA_DLSS=1, the game's FSR4 upscale dispatch (the FidelityFX five callsfsr_dispatch_testmeasures on the package's DLL) reaches an NVIDIA NGX backend instead. Three new files plus the test wiring:runtime/test/nvngx_api_min.h— the NGX D3D12 interface written out from the ABI as shipped: the export names (from a PE export-table dump of the driver's NGX Core,nvngx.dll310.x line), the 17-virtual-slot parameter object (single-inheritance MSVC vtable order, exercised end to end by a probe on real hardware), and the semantics of the create/evaluate parameters as documented in the public DLSS Programming Guide (310.6, sections 5.2–5.4, key strings and flag bits included). Nothing from the NVIDIA DLSS SDK is copied here.runtime/src/dlss_backend.h/dlss_backend.cpp— the backend:init(load the NGX Core by name —LEONIDA_NGX_DLLoverrides —,Init_ProjectID, capabilitySuperSampling.Available+ driver gate),create(per (in, out) size pair; the FFX mode's ratio — the game's ownffxQuery(GETUPSCALERATIOFROMQUALITYMODE)value — names the DLSS quality slot; the two shipped-enum collisions resolve conservatively: 3.0x → MaxPerf, 1.7237x → Balanced; the flags are the game's measured FSR4 context on 1.0.2.1: HDR + MV low-res + inverted depth + auto exposure),eval_from_ffx(fills the parameter bag from the FFX description, MVScale 0 → 1.0 fallback like the shipped helper),destroy/shutdown.runtime/test/dlss_dispatch_test.cpp— drives the backend end to end on a PC D3D12 device with procedural mock buffers (checker color, far-plane depth, zero MV; no game data), 1280x720 → 1920x1080, three jitters, execute+sync wall time per eval. Skips (77) when no NGX Core is loadable — the NGX Core is the driver's, loaded at runtime, exactly like the guide's distribution rules prescribe:nvngx.dllfrom the driver,nvngx_dlss.dllnext to the exe, both user-provided, nothing NVIDIA-licensed in the repo.runtime/CMakeLists.txt— the test block, mirroringfsr_dispatch(SKIP_RETURN_CODE 77).Why runtime-loaded, not the SDK
The NVIDIA RTX SDK license forbids making the SDK files subject to an open-source license, so headers/libs never enter the repo. The driver's NGX Core exports the full
NVSDK_NGX_D3D12_*set (59 exports measured), which is enough for the whole chain with plainLoadLibrary/GetProcAddress— the shortNVSDK_NGX_D3D12_Init_ProjectIDname included (the SDK's longerInit_with_ProjectIDis its own wrapper around it).What was tested (AI-assisted: GLM 5.3 Flash under an operator)
Tested <this head> on NVIDIA RTX 5060 (Blackwell), driver 617.42, Windows 10 x64 19045:available=1, needs_newer_driver=0, min_driver=470.0) → CreateFeature (MaxQuality, game flags) → 3 evals → teardown, 0 failures; first eval 6.83 ms, steady ~0.97–0.99 ms (execute+sync) at 720p→1080p. The two independent implementations agree: a second probe chains NVIDIA's own static runtime for the same calls and reports the same timings, 0 failures.dlss_dispatchbuilds with the suite (MSVC 14.44,/W4) and currently skips on my machine (77): the NGX Core load-by-name fails here because this machine'sSystem32\nvngx.dllcopy has gone missing (the driver's DriverStore copy still exists and the same ABI chain is green through the probe, above; the host's NGX Core faults inInitafter this morning's driver-component change — the fault address lands inside the driver's_nvngx.dll, not in Leonida code). On a machine whose NGX Core is deployed the test runs the backend for real; on any machine without an NVIDIA driver it skips, likefsr_dispatchwithout the game.d3d12_vulkan_devicefails for a reason I reported separately (Coordinating who works on what (25) (moved to #4816) #4683 finding) — the layer's invalid-argument refusals no longer match the host driver's after this morning's driver update, 8 cases, allours 0x00000000 vs host 0x80070057, unrelated to this change.License note
The integration is GPL-side code only: the header's declarations are written out from the documented public interface (guide 5.2–5.4) and the observed binary interface, the runtime loads the driver's NGX Core by name, and the feature DLL (
nvngx_dlss.dll) is loaded by the NGX Core from the application folder as NVIDIA's own distribution model prescribes — user-provided, never shipped, never linked into Leonida.Item: DLSS behind the FFX upscale shim (claimed in #4683).