Skip to content

Recompiler: keep the split wave64 halves' scalar state wave-uniform - #900

Open
mastrr9 wants to merge 1 commit into
xcl-dev:mainfrom
mastrr9:perf/recomp-nvidia-wave-uniform-split64
Open

mastrr9 wants to merge 1 commit into
xcl-dev:mainfrom
mastrr9:perf/recomp-nvidia-wave-uniform-split64

Conversation

@mastrr9

@mastrr9 mastrr9 commented Nov 24, 2026 •

Copy link
Copy Markdown

Speeds up split wave64 console shaders on 32-lane GPUs (NVIDIA):

  • Previously, the half index, console wave index, and partner-half size were derived from per-lane xcl_tid, forcing the GPU compiler to treat exchanged EXEC/VCC values, derived SGPRs, and branches on them as per-lane and divergent.
  • Now computes them from WaveReadLaneFirst(xcl_tid) & ~31u so scalar state stays wave-uniform across each 32-lane hardware wave.
  • Only split-wave64 HLSL changes (all native wave64 and wave32 outputs remain byte-identical). Off-tree analysis across 7 programs in 5 modes: per-lane scalar registers 242/440 -> 0/440, divergent branches 108/129 -> 59/129.

Tested

  • Hardware/OS: NVIDIA RTX 5080 (driver 617.42 / 32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC debug, DXC Windows SDK 10.0.26100.0, d3d12SDKLayers.dll installed
  • Commit tested: 6b75595ae9113814289e0ab2e6a2915672b75431 (HEAD 2817c7c6ee17ba22453da5cd1a7f75cc0f3d0150 has an identical tree; only commit author metadata was updated after GitHub account rename)
  • cargo build --workspace: clean (no new warnings; only pre-existing fetch_update deprecation warning)
  • cargo test --workspace -- --test-threads=4: 717 passed, 0 failed, 41 ignored
  • SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64

Regression run
Smoke run by @Toons29 in comment below: #900 (comment)
Contributed by a community tester; the PR author did not run it. Both blocks are pasted as posted.

main:

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB

PR:

xcl-smoke v1
commit: 2817c7c6ee17ba22453da5cd1a7f75cc0f3d0150
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1615 (PresentX 1615)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14812 MB

Tester's setup and limits: AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

Tester's AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; the tester checked the blocks before posting.

Not tested

  • No retail title was available to the author; whether the community regression run above reaches the code this PR changes is not known.
  • AMD RDNA wave64 hardware not tested.

AI use

  • Authored with Claude Code (Claude Opus 5.5); reviewed, audited, and verified on native Windows/RTX 5080 hardware with Antigravity (Gemini 4 Neon + Claude Sonnet 5.5).
  • Claude Code (Claude Sonnet 5.5) added the community regression run to this description and updated the lines that it made out of date or that the PR check requires.

In the split wave64 form (wave64 compute / mesh / ES+GS programs on GPUs
with 32-lane waves only, e.g. NVIDIA) the half, the console wave and the
other half's size were computed per lane from xcl_tid, which comes from
WavePrefixCountBits. The values are the same in every lane of a hardware
wave, but the GPU compiler cannot prove it, so everything derived from
them was per-lane in its eyes: every exchanged mask (EXEC, VCC), every
SGPR computed from one, and every branch on them (s_cbranch_execz /
vccz / scc, loop exits). The native forms have none of that: there EXEC
comes straight from WaveActiveBallot.

The three values now come from the hardware wave's first console
thread, WaveReadLaneFirst(xcl_tid) & ~31 (its console threads are
32-aligned), and the compute TG_SIZE wave index and the mesh s3 wave
index use the console wave xcl_cw (= gi / 64 there). Same values; only
the split HLSL changes, the native and wave32 HLSL is byte-identical
(checked on 70 translations).

Measured with a flow-insensitive divergence model of the generated
main() (7 programs: ALU, memory, branchy, the bench_split_wave64 loop,
the two gpu_split_wave64 test programs; kernel, CS 64 / 256 / 8x8x4 and
MS 128 modes), assuming a groupshared load from a wave-uniform address
is uniform: scalar registers the compiler must keep per lane 242/440 ->
0/440 (native: 2/440), divergent branches 108/129 -> 59/129 (native
66/131, the rest are per-lane store guards). If the driver treats every
groupshared load as per-lane, 242 -> 226 only (a WaveReadLaneFirst on
the exchanged word would close that; it is exchange code, left alone).
CPU translation time unchanged (median 104.7 -> 102.2 us per program,
noise). Not run on a GPU.

Assisted-by: Claude Code (Claude Opus 5.5)
@dcastell1

Copy link
Copy Markdown

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on clean main@beaa245 (713 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
715 passed; 0 failed; 41 ignored   (exit 0)

Two more passing tests than main: the split wave64 scalar-state uniformity change is exercised here (this device is wave32-only, so the split path is what runs); nothing else changes verdict.

Tree restored afterwards (md5 and a full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

@ClosetPie107

Copy link
Copy Markdown

The AMD RDNA wave64 run from Not tested, with split wave64 forced. On RDNA4 under RADV this doesn't fix the cross-half failures, and two split tests fail more often with it. Native wave64 output is unaffected, as the description says.

Tested

  • AMD Radeon RX 9070 16 GB (RADV GFX1201, Mesa 26.3.1), Ryzen 5 9600X, CachyOS, kernel 7.3.5. Proton Experimental's Wine (experimental-11.0-20261112), vkd3d-proton v3.1 + Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257's patch (-Db_ndebug=true, dxil-spirv 53aac418), DXVK v3.1.1-209, DXC 1.9.2609.5. Rust 1.96.0, x86_64-pc-windows-gnu, release.
  • This PR's head 2817c7c against its base main 1ec4c98. The lib test binary runs under Wine with VKD3D_CONFIG=ignore_shared_fence XCL_NETWORK=0 XCL_ADAPTER=9070, and XCL_SPLIT_WAVE64=1 (this GPU runs wave64 natively, so split has to be forced).
run 1ec4c98 (passed / failed) 2817c7c (passed / failed)
gpu::recomp, split, --test-threads=1, 3 runs 178 / 10 every run 178 / 12, 178 / 12, 179 / 11
whole lib, split, --test-threads=4, 2 runs (1) 660 / 12, 660 / 12 663 / 11, 659 / 15
gpu::recomp, native wave64, --test-threads=1, 3 runs – 187 / 3 every run (the f64 rsq and FMA-control failures this stack always has, #530 / #676)

(1) --skip write_buffer_immediate_on_open_existing_heap_visible_to_cpu --skip a_freed_block_is_decommitted_before_its_address_is_reused, the two tests that take the device down on this stack (#175, #913).

Still failing with the PR (same messages as on main, see the RDNA4 row in #42): gpu_split_wave64_cross_half_operations, …_local_and_exchanged_masks_in_diverging_waves, …_masks_read_whole_after_partial_writes, …_waves_diverge, gpu_valu_16_and_64_bit, gpu_format_stores_atomics_global_lds, gpu_grouped_loads_bounds_and_inactive_lanes. Examples: "the halves ended with different SGPRs", ds_bpermute left: 0.

Worse with the PR:

test, split, alone (--exact), 5 runs 1ec4c98 2817c7c
gpu_divergence_through_exec fails 2 / 5 fails 5 / 5: the halves ended with different SGPRs (lower / upper): s20: 0x11111111 / 0x0, s21: 0x0 / 0x11111111
gpu_split_wave64_partial_groups fails 5 / 5 fails 5 / 5: 40 threads, thread 0 (console wave 0, lane 0): s_bcnt1 of vcc left: 32

In the serial gpu::recomp runs, gpu_split_wave64_partial_groups passed 3 of 3 on main and failed 3 of 3 with the PR. gpu_divergence_through_exec passed 3 of 3 on main and failed 2 of 3 with the PR. So both were already order- or timing-sensitive on RADV in split mode, and the change makes them fail more consistently. I haven't checked whether the cause is the WaveReadLaneFirst(xcl_tid) base or something RADV / ACO does with it on GFX12.

The base is unchanged after main moved: 077ce40 gives the same 178 / 10 split result, with the same 10 tests (2 of 2).

Not tested: RDNA2 / RDNA3, native Windows AMD, a retail title, the head rebased onto 077ce40.

AI use: T3 Code (Claude Opus 5.5) built both trees, ran the tests and wrote this comment from the logs. The runs are real, on the hardware above, and I checked the report before posting.

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head 2817c7c onto main 09940bb, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 707 passed, 11 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). wave-uniform split-half state green; mirror-upload flake hit.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

@DarkPanda69

Copy link
Copy Markdown

Test report for head 2817c7c6e.

Setup

  • Each PR's diff applied on main 077ce40 (all applied cleanly), debug build, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.
  • cargo test -p xcl --lib -- gpu::recomp --test-threads=4, once with XCL_ADAPTER=radeon and once with XCL_ADAPTER=3060.
    • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010: waves 32..64, so wave64 programs run in native 64-lane waves.
    • NVIDIA RTX 3060 (Ampere), driver 32.0.16.1088: 32 only, so wave64 programs run in the split form.
  • Not run per PR: the whole workspace suite (the recompiler tests only) and a retail smoke run.

Tested: pass on both GPUs, including AMD RDNA hardware with native wave64.

  • RX 9070 XT (native wave64): 190 passed, 0 failed, 18 ignored, 0 SKIPPED. gpu_split_wave64_partial_groups ok.
  • RTX 3060 (split wave64): 190 passed, 0 failed, 18 ignored, 2 SKIPPED (no wave64). gpu_split_wave64_partial_groups ok.

Not tested: the retail smoke run this draft still needs (I have no retail run to give).
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@mastrr9

mastrr9 commented Nov 24, 2026

Copy link
Copy Markdown
Author

Thanks @dcastell1, @hkgamingdk231-prog, @SlopTart, and @ClosetPie107 for all the hardware runs across RTX 5090, RTX 3060, RX 9070 XT (native wave64), RX 7900 XT, and RX 9070 (forced split on RADV)! Good note on the forced-split RADV GFX1201 behavior — glad native wave64 on RDNA4 and split wave64 on NVIDIA RTX 3060 / 5080 / 5090 all stay green.

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of 2817c7c6 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 2817c7c6ee17ba22453da5cd1a7f75cc0f3d0150
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1615 (PresentX 1615)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14812 MB

Against the limits in CONTRIBUTING.md: 100 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

@JJAutoCompare

Copy link
Copy Markdown

Arc A770 verification for XCL PR #900

Tested

  • PR #900 was open at 2817c7c6ee17ba22453da5cd1a7f75cc0f3d0150 before and after testing. The existing worktree was clean and detached at this SHA. I read AGENTS.md and CONTRIBUTING.md from upstream main cbc296ab65a2661a61e3e2da109134bcd5319f60 and verified they match the PR head. The live PR discussion and reviews, issues GPU test results: NVIDIA RTX 3080 (wave32) and AMD RDNA2 iGPU (no mesh shaders) #42 and [OFFICIAL] Looking for PRs with shaders optimization #1269, and the T3 thread list showed no equivalent same-head Arc run. The PR already has NVIDIA and AMD reports, including a forced-split RADV result.
  • STOR-WINLAB ran Windows 11 Enterprise Evaluation 25H2 build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, and Rust/Cargo 1.100.0 (x86_64-pc-windows-msvc). Both fixtures logged DXC 1.9.2609.5 (01b62ad4) and DXIL 1.9.2609.5.
  • cargo test --locked -p xcl --lib --no-run ran outside the GPU lock, with two Cargo jobs, CARGO_INCREMENTAL=0, and dev/test debuginfo disabled. The target was L:/XclTooling/pr1512-tiling-edges-fddfa267/target. TEMP and TMP used this run's temp directory. XCL_ADAPTER=A770 and XCL_DXC_DIR pointed to the Arc adapter and %LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64. The first build emitted the test executable in 30.30 s with one deprecation warning, but the launcher did not retain its exit code. The identical prebuild repeated against the same target exited 0.
  • Using the executable emitted by that prebuild, the exact invocations were:
$exe = 'L:/XclTooling/pr1512-tiling-edges-fddfa267/target/debug/build/xcl/77aca8ccb20e299f/out/xcl-77aca8ccb20e299f.exe'
& $exe gpu::recomp::tests::split_wave64_wave_uniform_half --exact --nocapture --test-threads=1
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
    & $exe gpu::recomp::tests::gpu_split_wave64_partial_groups --exact --nocapture --test-threads=1
}
  • CPU (outside the lock, 0.16 s). The fixture compares the wave-uniform half, guest wave index, and partner size formulas to the per-lane versions for group sizes 1 through 1,024 over four rotation choices. It checks the HLSL emitted for kernel, 96- and 256-thread compute, and mesh modes, including compute TG_SIZE and mesh wave indexing, and compiles all four split variants with DXC as cs_6_6.
  • GPU (inside the lock in a new powershell.exe -NoProfile -ExecutionPolicy RemoteSigned process, 0.87 s). The adapter-selected split-wave64 compute fixture translated to HLSL and compiled with DXC as cs_6_6. It checks whole-wave and half-local ballot emission and dispatches three groups for each size 40, 64, 96, 100, 160, 256. These include guest waves with a missing or partial upper half as well as complete waves. Readback matched all 2,864 expected dwords across the six sizes for VCC popcount, entry EXEC popcount, TG_SIZE, and the half-local V_CNDMASK_B32 result. The three groups for a given size share output addresses, so the readback checks each output location once.
  • Each exact filter reported 1 passed, 0 failed, 0 ignored, 0 explicit skips, 696 filtered out. Separate stdout, stderr, and exit logs accompany this report. Both children and the GPU wrapper exited 0. The wrapper logged lock release at 2026-11-25T05:10:35.1077021+01:00. The target slot is available for reuse.

Not tested

Other fixtures (including #2097's dispatch chain), workspace suite, retail-title smoke, other adapters or drivers, native-wave64 GPU execution, and performance.

AI use

T3 Code / Codex (gpt-6.2-sol) verified the revision, ran the checked-in fixtures, and wrote this report from the logs.

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.

7 participants