Skip to content

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

Merged
ivall merged 2 commits into
xcl-dev:mainfrom
Foniass:nvidia-uav-barriers-fract
Nov 23, 2026
Merged

ivall merged 2 commits into
xcl-dev:mainfrom
Foniass:nvidia-uav-barriers-fract

Conversation

@Foniass

@Foniass Foniass commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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 and others added 2 commits November 23, 2026 00:23
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]>
@Foniass

Foniass commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

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.

@certified-retart

Copy link
Copy Markdown
Contributor

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 GPU tests: run wave64 kernels as two wave32 halves on 32-lane GPUs #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.)

@ivall
ivall merged commit a929884 into xcl-dev:main Nov 23, 2026
ivall added a commit that referenced this pull request Nov 23, 2026
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

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.

Michael-Glaser added a commit to Michael-Glaser/xcl that referenced this pull request Nov 24, 2026
…cl-dev#104)

On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (xcl-dev#59, xcl-dev#60, xcl-dev#68, xcl-dev#69, xcl-dev#78, xcl-dev#81, xcl-dev#84, xcl-dev#88, xcl-dev#89, xcl-dev#93, xcl-dev#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method.

Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at xcl-dev#59 and the original base-table stub for slots >= scanned). Slot xcl-dev#10 (Reset) stays Reset on both layouts and is not orphaned.

Assisted-by: Antigravity (Gemini 4 Neon)
Michael-Glaser added a commit to Michael-Glaser/xcl that referenced this pull request Nov 24, 2026
…vall#104)

On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (ivall#59, ivall#60, ivall#68, ivall#69, ivall#78, ivall#81, ivall#84, ivall#88, ivall#89, ivall#93, ivall#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method.

Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at ivall#59 and the original base-table stub for slots >= scanned). Slot ivall#10 (Reset) stays Reset on both layouts and is not orphaned.

Assisted-by: Antigravity (Gemini 4 Neon)
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
v_floor, v_ceil, v_trunc, v_rndne and v_fract in f32 and f16 had no
edge-value GPU test (v_fract_f32 only for +-inf / NaN, xcl-dev#68). 16 inputs
each: halves of both signs (rndne to the even neighbour), the sign of
a zero result, infinities, NaN, values past the last fraction bit, and
fract of a small negative value, which the ISA clamps to the largest
value below 1.0 (0x3F7FFFFF / 0x3BFF).

v_fract_f16 passes today only because the default f16 result goes
through the legacy f32tof16, which rounds toward zero: x - floor(x) for
x = -2^-14 is 1 - 2^-14 in f32, and rounding that to nearest gives 1.0.
With to_f16_expr changed to round to nearest (the default-mode fix
xcl-dev#111 asks for), v_fract_f16(-6.1e-5) returns 0x3c00 and this test
fails, so the fract clamp has to move after the f16 rounding then.

Measured: RTX 4060 (wave32), Windows 11 Pro 26300, Rust 1.100, debug.
cargo test --workspace -- --test-threads=4: 678 passed, 0 failed,
41 ignored; SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask,
gpu_wave32_program_in_wave64_hardware. Removing fract_f's clamp in
emit.rs fails the test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WsgnReN2iZK9RUNckZAhrv
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
Add standalone host-driver parity and contract tests for D3D12.X's
memory-layout and copy-footprint query hooks (Part of xcl-dev#480):
GetResourceAllocationInfo (xcl-dev#25), GetResourceAllocationInfo2 (console
xcl-dev#108 vs PC ID3D12Device8 xcl-dev#68), GetCustomHeapProperties (xcl-dev#26), and
GetCopyableFootprints (xcl-dev#38).

No runtime files outside crates/xcl/tests/ are modified. Full suite
(.\scripts\test.ps1) passed 895 passed, 0 failed, 42 ignored (1 GPU
test skipped: heap_window_out_of_memory_falls_back_to_the_switch_form).

Part of xcl-dev#480
Assisted-by: Antigravity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants