Console UAV barriers for all resources; v_fract_f32 of ±inf / NaN gives NaN (NVIDIA) #68

Manually merged
github merged 2 commits from gh-pr/68/head into gh-pr/68/base 2026-11-26 04:07:47 +00:00
Owner

@⁠Foniass on GitHub · 2026-11-22 23:26 UTC · original
Foniass:nvidia-uav-barriers-fract → main · +52 −2 · 3 files · 2 commits · merged 2026-11-23 09:59 UTC

Two small fixes for NVIDIA found while working on wave64 programs on 32-lane GPUs (#67). They are independent of it.

Console UAV barriers apply to all resources

Translated shaders reach title memory through XCL's memory-window buffers, which are different D3D12 resources over the same memory as the title's buffers and textures. A UAV barrier the title issues for its own resource, or a transition into or out of UNORDERED_ACCESS, therefore did not order the shaders' window accesses. AMD drivers wait and flush on any UAV barrier, but NVIDIA's need not, so a pass could read what the previous one is still writing. That is a possible cause of NVIDIA-only flicker.

resource_barrier_x now sends one UAV barrier with no resource (all UAV accesses) per batch that has a UAV barrier or a transition from or to UNORDERED_ACCESS. That costs about the same as one barrier per resource. Not reproduced without a game; the test title's command lists go through this path and pass.

v_fract_f32 of ±inf / NaN gives NaN, as on RDNA

fract_f clamped x - floor(x) with min(). HLSL min returns its non-NaN operand, so fract(±inf) and fract(NaN) came out as 0.99999994 on an RTX 5070 Ti. RDNA computes x - floor(x) kept below 1.0, so ±inf gives NaN and NaN passes through. A compare-and-select does the same now. The new test gpu_fract_f32_edges fails with the old helper. It needs wave64 like the other recompiler GPU tests, so on NVIDIA it runs only together with #67, where it was verified. Pixel and vertex shaders, which do run on NVIDIA today, use the same helper.

Tests

RTX 5070 Ti: workspace, release: 373 passed, 0 failed, 34 ignored; the 39 SKIPPED …: no wave64 lines are the same as on main. AMD not run: the machine's AMD iGPU is disabled.

🤖 Generated with Claude Code

**@⁠Foniass** on GitHub · 2026-11-22 23:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/68) `Foniass:nvidia-uav-barriers-fract` → `main` · +52 −2 · 3 files · 2 commits · merged 2026-11-23 09:59 UTC Two small fixes for NVIDIA found while working on wave64 programs on 32-lane GPUs (#67). They are independent of it. ### Console UAV barriers apply to all resources Translated shaders reach title memory through XCL's memory-window buffers, which are different D3D12 resources over the same memory as the title's buffers and textures. A UAV barrier the title issues for its own resource, or a transition into or out of `UNORDERED_ACCESS`, therefore did not order the shaders' window accesses. AMD drivers wait and flush on any UAV barrier, but NVIDIA's need not, so a pass could read what the previous one is still writing. That is a possible cause of NVIDIA-only flicker. `resource_barrier_x` now sends one UAV barrier with no resource (all UAV accesses) per batch that has a UAV barrier or a transition from or to `UNORDERED_ACCESS`. That costs about the same as one barrier per resource. Not reproduced without a game; the test title's command lists go through this path and pass. ### `v_fract_f32` of ±inf / NaN gives NaN, as on RDNA `fract_f` clamped `x - floor(x)` with `min()`. HLSL `min` returns its non-NaN operand, so `fract(±inf)` and `fract(NaN)` came out as 0.99999994 on an RTX 5070 Ti. RDNA computes `x - floor(x)` kept below 1.0, so ±inf gives NaN and NaN passes through. A compare-and-select does the same now. The new test `gpu_fract_f32_edges` fails with the old helper. It needs wave64 like the other recompiler GPU tests, so on NVIDIA it runs only together with #67, where it was verified. Pixel and vertex shaders, which do run on NVIDIA today, use the same helper. ### Tests RTX 5070 Ti: workspace, release: 373 passed, 0 failed, 34 ignored; the 39 `SKIPPED …: no wave64` lines are the same as on main. AMD not run: the machine's AMD iGPU is disabled. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fract_f clamped x - floor(x) with min(), and HLSL min returns its non-NaN
operand: fract(±inf) and fract(NaN) came out 0.99999994 (measured on an
RTX 5070 Ti). RDNA (GFX8 and later) computes x - floor(x) and keeps it below
1.0, so ±inf gives NaN and NaN passes through; a compare-and-select does the
same. Test: gpu_fract_f32_edges (fails with the old helper).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Translated shaders reach title memory through XCL's memory window buffers,
other D3D12 resources over the same memory as the title's buffers and
textures. A UAV barrier the title gives for its own resource, or a transition
out of / into UNORDERED_ACCESS, therefore did not order the shaders' window
accesses on the PC: AMD drivers wait and flush for any UAV barrier, NVIDIA's
need not – a possible cause of NVIDIA-only flicker (a pass reading what the
previous one is still writing). Such a batch now carries one UAV barrier with
no resource (all UAV accesses), which costs about the same as one per resource.

Not reproduced without a game; the test title's lists go through this path
and pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:07:45 +00:00
github manually merged commit 319bcd6127 into gh-pr/68/base 2026-11-26 04:07:47 +00:00
Author
Owner

@⁠Foniass on GitHub · 2026-11-23 02:39 UTC · original

Note for merging: this conflicts with #46 only in gpu/recomp/tests.rs, where both add a test at the same spot (gpu_fract_f32_edges here, gpu_f64_compares_with_nan and the rest there). Keeping both sides resolves it.

**@⁠Foniass** on GitHub · 2026-11-23 02:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/68#issuecomment-7090108153) Note for merging: this conflicts with #46 only in `gpu/recomp/tests.rs`, where both add a test at the same spot (`gpu_fract_f32_edges` here, `gpu_f64_compares_with_nan` and the rest there). Keeping both sides resolves it.
Author
Owner

@⁠certified-retart on GitHub · 2026-11-23 03:00 UTC · original

Tested PR #68 (319bcd6) on Windows 10 (with D3D12 Agility SDK 1.620.2 via #75 for SM 6.6+ on Win10) across two GPUs:

  • AMD Radeon Graphics (9800X3D iGPU, RDNA2, wave64): gpu_fract_f32_edges executed live and passed (0.12s).
  • NVIDIA GeForce RTX 5070 (Blackwell, wave32):
    • Merged with #71 (wave32 runner), gpu_fract_f32_edges skips as-written (no wave64) because it guards on gpu_ready() rather than gpu_ready_wave32().
    • With a local 1-line switch to gpu_ready_wave32(), gpu_fract_f32_edges executed live on the RTX 5070 and passed (0.35s), confirming ±inf → NaN, NaN → NaN, and -(2^-25) → 0x3F7F_FFFF on Blackwell hardware.

(Note for after #71 merges: switching gpu_fract_f32_edges to gpu_ready_wave32() will let this NVIDIA-specific regression test run automatically on wave32 NVIDIA GPUs too.)

**@⁠certified-retart** on GitHub · 2026-11-23 03:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/68#issuecomment-7090386719) Tested PR #68 (`319bcd6`) on Windows 10 (with D3D12 Agility SDK 1.620.2 via #75 for SM 6.6+ on Win10) across two GPUs: - **AMD Radeon Graphics (9800X3D iGPU, RDNA2, wave64):** `gpu_fract_f32_edges` executed live and **passed** (0.12s). - **NVIDIA GeForce RTX 5070 (Blackwell, wave32):** - Merged with #71 (wave32 runner), `gpu_fract_f32_edges` skips as-written (`no wave64`) because it guards on `gpu_ready()` rather than `gpu_ready_wave32()`. - With a local 1-line switch to `gpu_ready_wave32()`, `gpu_fract_f32_edges` executed live on the RTX 5070 and **passed** (0.35s), confirming `±inf` → `NaN`, `NaN` → `NaN`, and `-(2^-25)` → `0x3F7F_FFFF` on Blackwell hardware. *(Note for after #71 merges: switching `gpu_fract_f32_edges` to `gpu_ready_wave32()` will let this NVIDIA-specific regression test run automatically on wave32 NVIDIA GPUs too.)*
Author
Owner

@⁠ivall on GitHub · 2026-11-23 09:59 UTC · original

Merged. Checked on an RX 9070 (RDNA4): cargo test --workspace with the retail samples (shader pack, console DLLs, texture archive) – natively, and with XCL_SPLIT_WAVE64=1 (new in ba905cf: forces the split wave64 form on RDNA, which runs both wave sizes, so the NVIDIA path can be checked on AMD). XDefiant (title screen correct, 6 299 translated pipelines, 0 translation errors), Minecraft and Unicorn Overlord run.

**@⁠ivall** on GitHub · 2026-11-23 09:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/68#issuecomment-7097358839) Merged. Checked on an RX 9070 (RDNA4): `cargo test --workspace` with the retail samples (shader pack, console DLLs, texture archive) – natively, and with `XCL_SPLIT_WAVE64=1` (new in ba905cf: forces the split wave64 form on RDNA, which runs both wave sizes, so the NVIDIA path can be checked on AMD). XDefiant (title screen correct, 6 299 translated pipelines, 0 translation errors), Minecraft and Unicorn Overlord run.
This discussion has been locked. Commenting is limited to contributors.
No description provided.