Commit Graph
46 Commits
Author SHA1 Message Date
woutermans 1038825225 Hardware e4m3 decode in dec0's tail on the native-FP8 build
make_ptx.py turns the 32 cvt.rn.f16x2.e4m3x2 of rrlite_dec0_4x4_folded into calls of d4r_dec_e4m3x2 (tex_common.h) when D4R_TEX_FP8=1: v_cvt_pk_f32_fp8 and two conversions to f16 instead of ZLUDA's integer lowering (about 25 instructions each; the kernel goes from 4058 to 3418 instructions). The conversion equals ZLUDA's e4m3_to_f16_bits for every code except the NaN codes 0x7f / 0xff, checked over all 65536 code pairs on an RX 9070 XT, and the head never stages those codes (it clamps to +-448 before encoding). Harness frames are byte-identical in the accuracy and the fast set, over a 16-frame moving sequence in the accuracy set. dec0 at 2227x1253 render: 0.43 -> 0.38 ms (accuracy), 0.36 -> 0.30 ms (fast). -DD4R_TEX_SOFT_E4M3 gives ZLUDA's lowering; builds without D4R_TEX_FP8 keep the PTX instruction.
2026-10-07 01:15:36 +02:00
woutermans 5198fd38b3 Hardware e4m3 in the texture tails: enc0 tail and dec0 head
On the gfx12 native-FP8 path the enc0 tail and the dec0 head encode their results with v_cvt_pk_fp8_f32 on the f32 copies of the f16 values (e4m3x4_f32 in tex_common.h) instead of ZLUDA's integer e4m3x2. The clamps keep the conversion in range: +-2pi for enc0 (the f16 bound hi[0], same in f32) and +-448 for dec0, both as a median of three, where a NaN gives the lower bound. The codes equal e4m3x2 for every non-NaN f16, checked over all 65536 patterns on an RX 9070 XT; a NaN in dec0 now encodes as -448 instead of the NaN code. Harness frames are byte-identical in both sets (LDR and HDR, motion vectors at render and display resolution). dec0: 0.21 -> 0.15 ms at 1280x720 render and 0.74 -> 0.53 ms at 2560x1440; enc0 changes by 1-2% (its time is ZLUDA's compile of the feature code). -DD4R_TEX_SOFT_E4M3 (D4R_TEX_CFLAGS) keeps e4m3x2.
2026-10-06 23:25:14 +02:00
woutermans 3490023668 Token lanes for enc2 and dec2 too
The remaining two layers (96 channels, four heads) use the same swin_tok.h template: byte-identical on the same recorded launches and harness sequences, enc2 0.22 -> 0.14 ms and dec2 0.20 -> 0.14 ms at 1280x720 render, 0.75 -> 0.47 and 0.69 -> 0.47 ms at 2560x1440. Skipping windows that lie entirely outside the image is also exact but below the measurement noise (at most 2.4% of the windows of every other tube launch), so it is not kept; true16 code generation remains not tried.
2026-10-06 23:00:03 +02:00
woutermans a7d565d1cd Token-lane block for the RDNA4 native-FP8 layers: enc1, dec1 and the enc3 tube
swin_tok.h passes the weights as the first WMMA operand and the activations as the second, so each GEMM's encoded result is already the next one's operand and stays in registers (swin_block.h transposes every result through LDS). One wave owns one 4x4 window for the whole block: norms, attention and the MLP need no LDS and no barriers; only the patch expand and the patch merge go through an e4m3 image in LDS. Outputs are bit-identical to swin_block.h (swapped WMMA operand roles, verified on an RX 9070 XT and on recorded launches). mix2 rounds in place (accumulator is addend and destination, no copy per pair). -DSWIN_NO_TOKEN_LANES builds these layers from swin_block.h again; enc2 and dec2 are unchanged. RX 9070 XT accuracy set, 2560x1440 render: whole evaluation 8.56 -> 7.18 ms.
2026-10-06 22:10:41 +02:00
Woutermans 7c60d53cd0 Merge pull request #25 from woutermans/rdna4-fp8-byte-activations
Speed up preset M on RDNA4 native FP8 (byte activations, cheaper accuracy set)
2026-10-06 19:27:30 +02:00
Woutermans 8537c3132f Merge pull request #23 from dhaern/fix/launcher-config-and-packaging
fix(launcher): harden config parsing and release packaging
2026-10-06 19:20:35 +02:00
Woutermans 17012ea588 Merge pull request #21 from dhaern/fix/native-kernel-hardening
fix(native-kernels): harden kernel loading in the bridge and ZLUDA patch
2026-10-06 19:20:31 +02:00
Woutermans 9f96c3e57e Merge pull request #20 from dhaern/fix/ngx-feature-cleanup
fix(shim): release NGX state when feature creation or recreation fails
2026-10-06 19:20:27 +02:00
Woutermans 1db8df252f Merge pull request #22 from dhaern/fix/shim-log-path-and-ranges
fix(shim): fix log path overflow, negative numeric settings and RGB9E5 range
2026-10-06 19:20:23 +02:00
Woutermans 3381127259 Merge pull request #24 from Tk-Glitch/R8G8B8A8_UNORM_motion
Add R8G8B8A8_UNORM motion vector format
2026-10-06 19:20:20 +02:00
woutermans cf741c2e3d docs: RDNA4 fast and accuracy sets, FP8 and 16-bit, before and after 2026-10-06 15:18:11 +02:00
woutermans 11c84193e6 docs: compare the RDNA4 FP8 set with the 16-bit path
The 2x figure is against the previous native-FP8 layers. With NativeFp8 off
the RX 9070 XT was already at 3.37 ms for 1280x720 -> 3840x2160; the FP8 set
is 2.88 ms there.
2026-10-06 15:03:00 +02:00
woutermans ffa686e079 Narrow the RDNA4 accuracy set's cost for preset M
The FP8 Swin layers encode with a clamp to +-448 (NaN-propagating packed
minimum/maximum) followed by v_cvt_pk_fp8_f32, in both the fast and the
accuracy build: equal to half_to_e4m3 for every non-NaN input, NaN encodes
as 0xff. The accuracy build rounds each k32 step with v_fma_mix (K32_MIX).
On gfx12 the accuracy builds of M's post and downsample kernels are wave64
with denormal handling kept.

RX 9070 XT, 1280x720 -> 3840x2160, D3D12 harness: the accuracy set goes
from 3.54 ms to 3.05 ms per evaluation (3.01 -> 2.59 ms under load). Its
Swin layers still equal swin_model.py on sampled blocks and its image is
byte-identical to the previous accuracy set over 8 temporal frames.
2026-10-06 15:03:00 +02:00
woutermans ba77946a4a Speed up preset M on RDNA4: e4m3 byte activations in the FP8 Swin layers
On the gfx12 native-FP8 path the Swin layers kept GEMM activations as f16
in LDS and encoded them to e4m3 again at every operand load. They are now
encoded once where they are produced, with v_cvt_pk_fp8_f32, and stored as
bytes (SWIN_A8); the patch merge reads the stored output codes. The M
downsample kernels are built as wave64 on gfx12.

RX 9070 XT, 1280x720 -> 3840x2160, D3D12 harness, DLSS 310.7: whole
evaluation 5.9 ms -> 2.8 ms of GPU time with the GPU otherwise idle, 2.4 ms
at 80-98% GPU utilisation. Harness output is byte-identical to the previous
kernels; the accuracy build matches swin_model.py on sampled blocks.

Builds without D4R_FP8_WMMA (RDNA3, and RDNA4 with NativeFp8 off) compile to
the same instructions as before.
2026-10-06 15:02:51 +02:00
Tk-Glitch 58c1edf767 Add R8G8B8A8_UNORM motion vector format
Spider-Man Remastered uses R8G8B8A8_UNORM (DXGI fmt=28) for (some?) motion vectors.

Signed-off-by: Tk-Glitch <[email protected]>
2026-10-06 12:46:23 +02:00
dhaern 6876288761 Harden launcher config parsing and release packaging
Validate Env identifiers and accept UTF-8 BOMs and last-value INI keys.
Resolve the OptiScaler GPL license before builds and support both system
license locations. Match the bridge's KFD selection by SIMD count.
2026-10-06 00:39:47 +00:00
dhaern c7f645d153 Fix shim log path, numeric settings and RGB9E5 range
- Build the default log path from the DLL's folder, now recorded even
  without d4r.ini, instead of copying the name into a MAX_PATH buffer
  that a folder path of 246+ characters overflowed; no log is opened
  when that folder is unknown
- Fall back to the default when a numeric setting does not start with a
  decimal digit, so MarkerPollUs = -1 no longer polls every ~71 minutes;
  hex values such as 0x40 still parse
- Decode RGB9E5 exponent 0 as c * 2^-24 instead of zero, and encode with
  the format's real maximum 65408 (511 * 2^7) and exponents from 0
- Choose the RGB9E5 exponent by the rounded channel (< 511.5), so a
  value such as 511.25 keeps the lower exponent instead of decoding as 512
2026-10-06 00:39:46 +00:00
dhaern 51afff95de Reject truncated native code objects in ZLUDA
An interrupted extraction or a full disk can leave an empty or truncated
.hsaco, and hipModuleLoadData can crash on it. native_override now skips
files under 64 bytes and ELF files whose section header table ends past
the end of the file; ZLUDA then compiles the PTX as usual.
2026-10-06 00:03:49 +00:00
dhaern 369eff35a1 Harden native kernel serving and output redirects
- Fatbin parser: stop when an entry header runs past the declared files
  size instead of wrapping the unsigned remainder and reading outside the
  image.
- Output kernel table: keep the latest 64 lookups and resolve launches
  newest first under its own lock, so a full table no longer drops new
  lookups and a handle reused by a later output-kernel lookup resolves
  with that lookup.
- Resolve a relative D4R_ZLUDA_NATIVE_DIR before linking its kernels into
  the per-process directory; the relative links dangled.
- cuSurfObjectCreate: destroy the surface and return the error when its
  output redirect cannot be written.
- Serve native kernels from D4R_ZLUDA_CACHE_HOME, XDG_CACHE_HOME or
  ~/.cache, never /tmp, where the stale-PID cleanup could follow links
  planted by another user.
2026-10-06 00:03:49 +00:00
dhaern 4981cf0630 Clean up NGX state when feature setup fails
Reuse feature teardown on setup errors and publish output metadata only after all slots are ready. Keep render-size recovery retryable after failed restoration, and retry partially failed library loads.
2026-10-05 23:35:38 +00:00
ayo c4954dc3c4 Recreate NGX feature on render size mismatch
Fixes the black screen when the game renders at a different size than
its DLSS feature (some games after a relaunch).
2026-10-05 16:06:13 -04:00
ayo 67c657bb90 Merge pull request #19 from Tk-Glitch/R9G9B9E5
Add support for DXGI_FORMAT_R9G9B9E5_SHAREDEXP
2026-10-05 20:41:57 +01:00
ayo 22026ede12 Port K kernel tuning and M gfx1101 flags
Preset K, byte-identical to the previous output in all captured buffers
and the harness image, measured on an RX 7700 XT:

- LDS row padding so WMMA operand loads hit distinct banks

- WGP mode for enc1/enc2/dec1/dec2, ds_bpermute half-wave exchange for
  enc0/dec0/dec3, more waves per window in enc4/dec4/dec5

- cheaper operand plumbing in common/wmma_layout.h (packed f16
  conversions, no dynamic vector indexing), raw buffer weight loads,
  accumulator-init vectors prepared once

- enc1 as a single-buffer recompute layer, dec1 Q/K/V chains split

- dec5 as four dependent phase kernels
2026-10-05 14:48:37 -04:00
Etienne JUVIGNY 30af9bde35 Add support for DXGI_FORMAT_R9G9B9E5_SHAREDEXP
Fixes RE9 and probably other games with HDR outputs

Signed-off-by: Etienne JUVIGNY <[email protected]>
2026-10-05 13:47:12 +02:00
ayo 8ce8618181 slight readme changes + discord server 2026-10-05 00:41:33 -04:00
ayo 6684888c0b Fix DLSS quality-change corruption and frame completion ordering
- Reprepare enc3 weights each launch to avoid stale caches after feature recreation
- Require per-slot input markers before evaluating recorded frames
- Advance split-frame timelines only through completed frames
- Add cancellation and readiness tests plus recreation consistency checks
- Update architecture and native kernel documentation

ref #8
2026-10-02 19:14:07 -04:00
ayo 1620c36e15 dlss settings clarified 2026-10-02 16:37:52 -04:00
ayo cb08e1c313 Fix OptiScaler NGX routing and align marker polling defaults
- Explicitly route OptiScaler to d4r\nvngx.dll in release packages.

- Extract INI generation into a helper that preserves line endings
  and rejects missing or duplicate settings.

- Check NGX routing separately from file presence and return failure
  when the installation is incomplete or misconfigured.

- Add an optional OptiScaler patch for external DLSS backends while
  preserving AMD identity for FSR4, with matching launch guidance.

- Align portable and launcher marker polling defaults at 200 us.

- Log when d4r's model override replaces game or OptiScaler presets.

- Add configuration, package, routing and coexistence regression tests.

- Update installation documentation, add FSR/DLSS comparison videos
  and ignore local .tools artifacts.

Refs: #7, #14
2026-10-02 16:32:49 -04:00
ayo f66cccaf28 Add experimental preset L and fix DLSS resource lifetimes and waits
- Build L texture variants and complete older release kernel bundles.
- Add selective Swin encoder fallback to reduce L/M motion trails.
- Add opt-in GPU motion-vector dilation for thin geometry and sky gaps.
- Replace GPU input waits with cancellable readiness polling and use
  sleeping event queries for completion.
- Retain recorded resources through command allocator completion, defer
  shutdown until cleanup, and preserve unfinished output synchronization.
- Extend lifecycle harness checks and add event, model and motion tests.
- Update configuration defaults, build scripts and release documentation.
2026-10-02 00:30:46 -04:00
ayo b645ef9096 Add DLSS accuracy mode and GLIBC 2.41 release builds
- Add default-off PreferAccuracy for all native kernel families,
  including RDNA4 FP8 variants.

- Restore intermediate FP8 quantization, per-MMA FP16 rounding,
  denormal handling and NGX synchronization in accuracy mode.

- Select separately marked accuracy kernels and use a separate JIT
  cache; reject mixed sets and never silently substitute fast kernels.

- Add a pinned GLIBC 2.41 build environment for ZLUDA/LLVM, the DLLs
  and both kernel sets, with ABI checks and toolchain provenance.

- Support parallel target builds and pre-extracted PTX; correct
  ROCm header paths and Clang-CL input handling.

- Bump to 0.1.3 and update release notes, documentation and tests.

Validation: 11 tests passed; all 912 kernels built; E/K/M GPU harness
runs completed with accuracy off/on. Packaged libraries loaded under
GLIBC 2.41 and require no GLIBC version newer than 2.38.

RTX image-quality parity remains unverified.

Fixes #6
Refs #6
2026-10-01 01:35:39 -04:00
ayo b2b3781aca Fix DLSS artifacts and improve synchronization diagnostics
- Fix Cyberpunk 2077 preset-K black artifacts by preserving FP16/FP64
  denormal requirements while limiting denormal suppression to FP32.

- Fix stale direct-output redirects after array destruction, preventing
  reused handles from inheriting an earlier feature's output buffer.

- Log rejected resource formats and dimensions, including failures after
  startup, with rate limiting for repeated errors.

- Add opt-in blocking output synchronization with a dedicated bridge
  export and fallback to context synchronization.

- Report output-wait CPU and wall time, and defer GPU timing queries
  until asynchronous evaluation has completed. The CPU-overhead
  mitigation for #7 still needs reporter confirmation.

- Reject release libraries requiring GLIBC newer than the configured
  baseline, defaulting to 2.41, and document compatible builds.

Validation: shim and bridge builds pass; targeted redirect-lifetime and
format-logging checks pass.

Fixes #5
Fixes #8
Refs #7
2026-09-30 23:17:25 -04:00
ayo 4334a0c3c4 Add RDNA4 (gfx12) support and a 0.1.2 optimization round
RDNA4 (experimental; untested on RDNA4 hardware)
- kernels/common/wmma_layout.h picks the WMMA operand/accumulator layout
  per target; K (pwin_*) and M (swin_*) index through it, so the same
  sources build for gfx11 and gfx12. D4R_WMMA_LAYOUT=12 on gfx11 is a test
  shim that runs the gfx12 indexing on gfx11 WMMA.

- M can use native e4m3 FP8 WMMA on gfx12 (D4R_NATIVE_FP8=1). Texture
  tails (enc0_tail, dec0_head) get gfx12 f16 and FP8 paths that match
  ZLUDA's gfx12 lowering.

- ZLUDA patch 0007: gfx12 WMMA helpers, optional native FP8 MMA
  (D4R_ZLUDA_WMMA_FP8_NATIVE), a layout override for testing, and an
  architecture argument for d4r_emit. Texture kernels are now compiled
  offline per target through d4r_emit (D4R_ZLUDA_EMIT) instead of on the
  local GPU.

- New d4r.ini option [Kernels] NativeFp8 (default on), wired through the
  shim and d4r_config.py. On gfx12 the bridge serves kernels/<arch>-fp8
  when it is on.

- The bridge picks the KFD GPU with the most SIMDs (so an iGPU is not
  chosen over a discrete GPU); D4R_GPU_ARCH overrides it.

- kernels/build.sh and package_release.sh build gfx1100-gfx1103 and
  gfx1200/gfx1201 (plus -fp8 variants), and D4R_BUNDLE_TEX takes
  per-target folders.

Performance (RDNA3; harness byte-identical unless noted)
- ZLUDA patch 0006: m16n8k8 f16 MMAs on WMMA (E; not bit-exact, 52-55 dB
  per layer, D4R_ZLUDA_WMMA_K8=0 disables it), per-key weight-image slots
  for native prep kernels (d4r_prep_key_at, d4r_prep_key_slots), and
  wave64 builds of MMA-free kernels (D4R_ZLUDA_WAVE64).

- M: packed FP8 encoding, conflict-free patch-merge reads, scalar weight
  loads in enc1, and weight prep once per weight set for the six enc3
  tube blocks.

- K: CU mode for the six non-wide pwin layers.

- Texture kernels: every DLSS flag variant is built natively (24 K output,
  8 M post, 4 M downsample, 4 M enc0), not only Townfall's; post and K
  output run as wave64.

- M direct output: rrlite_downsample_kernel writes the shim's output
  buffer; the shim's default direct-output presets are now 11,13.

Tools
- dump_runner takes the prep grid from d4r_prep_blocks and refuses
  texture/surface dumps.

- New pwin_check.py, swin_check.py, model_enc3.py and tail_check.hip.

Docs: README GPU table and RDNA4 notes, building (patches 0002-0007,
d4r_emit), native-kernels (RDNA4 section), performance (new numbers),
packaging README. Version 0.1.2.
v0.1.2
2026-09-29 20:36:10 -04:00
ayo f310d52b69 package folder changes 2026-09-28 01:34:53 -04:00
ayo da263ecf75 Fix VRAM leak on quality changes and RGBA16 motion vectors; more games
- Shim: reuse VRAM interop buffers across features instead of freeing them;
  ROCm 7.2.x's hipExternalMemoryGetMappedBuffer retains its view twice, so
  freed buffers never released their memory (~130 MB per quality change)
- Bridge: close the exported fd after hipImportExternalMemory
- Shim: accept R16G16B16A16_TYPELESS motion vectors and convert 4-channel
  motion vectors to RG16F on the GPU, keeping VRAM interop (Dying Light:
  The Beast rendered black)
- Harness: D4R_HARNESS_RECREATE=N quality-change cycles,
  D4R_HARNESS_MV_RGBA16=1 motion vector format
- Supported games: TLOU, Control, Cyberpunk 2077, Rift Apart, HZD Remastered,
  Subnautica 2, Alan Wake 2, Silent Hill 2, Dying Light: The Beast; general notes
- README: GPU support section (native kernels only for gfx1101); ignore videos/
v0.1.1
2026-09-28 01:26:51 -04:00
ayo 1952452830 Bundle the ROCm 7.2.4 runtime in the release zip 2026-09-27 18:59:07 -04:00
ayo bc31abdd50 Fix reflection lag from RGBA exposure 2026-09-27 18:31:42 -04:00
ayo 00cb497ede supported games 2026-09-27 17:49:42 -04:00
ayo db51da64ec supported games 2026-09-27 17:49:42 -04:00
ayo 508312ebf9 moved
Added a demo video link for DLSS Ultra Performance and removed duplicate mention.
v0.1.0
2026-09-27 17:23:31 -04:00
ayo 818dd8bf42 Fix 8-bit DLSS VRAM interop 2026-09-27 17:22:04 -04:00
ayo bcc1fa6560 just link for demo 2026-09-27 17:01:03 -04:00
ayo 17c2c83723 Show DLSS demo preview in GitHub README 2026-09-27 16:55:46 -04:00
ayo 629bc35e9d ZLUDA: read null texture objects as zero (fixes Ghost of Tsushima GPU fault) 2026-09-27 16:53:22 -04:00
ayo b36b6d21c4 readme 2026-09-27 16:20:39 -04:00
ayo 0edf1b138f release notes 2026-09-27 16:13:32 -04:00
ayo 118173ecd7 d4r: official NVIDIA DLSS on AMD GPUs under Linux and Proton 2026-09-27 15:26:56 -04:00