Engine: native presets K and M in the D3D12 shim, wider game coverage

A standalone Vulkan inference engine (engine/) for DLSS presets K and M that
runs from weights extracted from the user's own nvngx_dlss.dll, with d4r's
own input, network and reconstruction shaders or the native HIP network
layers, recorded into the game's command list by the shim. Opt-in
([Engine] Enabled / D4R_ENGINE=1); anything uncovered falls back to the
CUDA/ZLUDA path with the reason logged.

Byte-identical to NGX's CUDA backend under the phase-capable reference
(1706x960 -> 2560x1440, native HIP network, eleven frames, RX 9070 XT):
- K render- and display-resolution motion vectors, HDR and LDR
- K game-supplied exposure and automatic exposure with any pre-exposure
  and exposure scale (one residual: effective exposure exactly 2 or 4)
- K and M with the DLSS indicator's inverted-axis parameters
- M with any exposure settings (NGX ignores them for M)
K packages need the current compile_k.py (marker D4RO0003).

Also: HIP shared buffers are pooled across feature recreation (ROCm leaks
destroyed imports), hipnet.bin must match the preset, M-only games do not
load the K model, install_d4r_runtime.sh stages k, k-ldr, m, m-ldr with
hip/, the activation table has a generator (gen_activation_m.py), and
package_release.sh can bundle the engine's shaders (never its weights).

Signed-off-by: woutermans <[email protected]>
This commit is contained in:
woutermans committed 2026-10-10 20:54:01 +02:00
1 parent 16cfc1f063
commit e0d1549a21
82 files changed
+13335 -96

No files matched your search

+23
View File
@@ -97,6 +97,29 @@ ElideNgxSync = true
EvalSync = false
MarkerPollUs = 200
[Engine]
; Experimental. Runs DLSS 4 and 4.5 (models K and M) on d4r's own Vulkan inference engine instead of NVIDIA's
; kernels through ZLUDA: the whole evaluation is recorded into the game's own command list, the game shows the
; result of the frame it just rendered, and FrameAge and the [Interop] hand-off settings do not apply.
; Needs VkD3DDir, a driver with VK_KHR_cooperative_matrix (Mesa RADV on RDNA3/RDNA4) and the model folders
; (RuntimeDir/engine/k, k-ldr, m, m-ldr; scripts/install_d4r_runtime.sh). A game or setting the engine does not
; cover uses the normal path, with the reason in d4r_nvngx.log: other models than K and M, display-resolution
; motion vectors with M, or a K model built before the current engine/compile_k.py for display-resolution
; motion, non-inverted depth or exposure supplied by the game. Details and measurements: engine/README.md.
; (D4R_ENGINE)
Enabled = false
; The model K folder for games with the HDR flag: the folder engine/compile_k.py writes (weights extracted
; from your nvngx_dlss.dll plus d4r's shaders). auto = RuntimeDir/engine/k, where scripts/install_d4r_runtime.sh
; puts D4R_ENGINE_MODEL. The other folders: D4R_ENGINE_MODEL_LDR_DIR, D4R_ENGINE_MODEL_M_DIR and
; D4R_ENGINE_MODEL_M_LDR_DIR. (D4R_ENGINE_MODEL_DIR)
ModelDir = auto
; Where the network between the engine's Vulkan stages runs (K and M). hip = d4r's native HIP layer kernels
; (M: about 1.7x faster than the shader, 3.8 instead of 5.5 ms per frame at 1080p -> 4K on an RX 9070 XT);
; the game's command list is split around the network like a split frame, so it needs VkD3DDir, the CUDA
; bridge and a model built with --hip. vulkan = the engine's cooperative-matrix shader, everything in one
; command list. auto and hip = hip when available, else vulkan (the log says why). (D4R_ENGINE_NETWORK)
Network = auto
[Paths]
; auto = defaults of scripts/d4r_proton_env.sh
RuntimeDir = auto