Skip to content

[upstream #900] Recompiler: keep the split wave64 halves' scalar state wave-uniform - #182

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/900
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/900

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

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

Not tested

  • Retail title regression run (scripts/smoke.ps1) not yet run (no retail title available in this clean-room environment); opened as Draft pending a smoke run.
  • 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).

Mirror of xcl-dev#900 (auto-synced, do not edit).

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)
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#900 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/900 branch November 25, 2026 00:07
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.

2 participants