Wave64 VS / PS on 32-lane GPUs: the lanes 32..63 they read (NVIDIA) #133

Manually merged
github merged 3 commits from gh-pr/133/head into gh-pr/133/base 2026-11-26 04:11:46 +00:00
Owner

@⁠Foniass on GitHub · 2026-11-23 14:24 UTC · original
Foniass:nvidia/wave64-graphics-lanes → main · +1667 −44 · 8 files · 3 commits · merged 2026-11-23 14:39 UTC

The last open NVIDIA gap from HANDOFF / #42: wave64 VS / PS on GPUs with 32-lane waves only.

Problem

On NVIDIA the driver runs a console wave64 VS / PS in waves of 32: a console wave whose lanes 32..63 aren't populated. On the console those lanes exist (inactive) and hold whatever v_writelane or whole-wave code put there. Here they don't exist, and WaveReadLaneAt of a lane ≥ 32 reads lane & 31. wave_hazards flagged 749 programs of the retail pack.

What those programs do (748 PS, 1 VS)

pattern reads programs what the console reads there before, on NVIDIA
whole-wave reduction (identity into lanes outside the mask, DPP8 xor 1/2/4, row_mirror, v_permlanex16, v_readlane 32; min_u32 / max_u32 / or_b32) 1 082 436 the identity right only by accident: lane 32 read lane 0, and min / max / or are idempotent
waterfall read v_readlane v, s_ff1(mask & exec) 355 353 a lane < 32 right
SGPR spill slots in lanes 32..47 of one VGPR 200 11 the spilled SGPR wrong: the v_writelane was lost, the read returned slot lane & 31
ds_bpermute 0 0 — —

Change

  • Analysis: gpu/recomp/upper_lanes.rs, a forward pass. It follows EXEC's upper word (0 / all ones / anything) through the SGPRs, and what each VGPR's lanes 32..63 hold:
    • unwritten;
    • a constant (it evaluates whole-wave moves, selects, integer min / max / logic / add and their DPP and permlane forms);
    • a spill slot;
    • unknown.
  • Translation (split_wave64, when WaveGetLaneCount() < 64):
    • A lane ≥ 32 that holds a constant reads the constant.
    • A spill slot is read from a scalar shadow that its v_writelanes also write.
    • Spill slots < 32 come from their shadows at any wave size, because a lane a partial wave didn't launch loses its slot. 287 PS spill to lanes < 32.
    • Only programs with such a read get the new form: 613 in the pack, and DXC compiles all of them.
  • Unchanged HLSL: without split_wave64 (AMD and other 64-lane GPUs) the HLSL of all 26 698 programs is unchanged. The 32-lane form of the other modes is unchanged too; retail_wave64_graphics_lane_forms compares the digests.
  • Graphics pipelines (hle/d3d12x/real.rs): the pipeline hook compiled VS / PS with console_to_dxil (split_wave64 false), so on NVIDIA the split form never reached a title. VS / PS, and the PS of two-pass (MS / GS) pipelines, now pass wave32_only(device) like compute and the geometry stages.
  • wave_hazards: now reports only the reads the pass can't follow; there are none in the pack. xcl shaders --recomp prints the resolved reads by kind.

Tests (RTX 5070 Ti, 32-lane waves)

  • GPU tests: these three fail with the old translation on this card, and pass now:
    • gpu_wave64_ps_whole_wave_reductions: the pack's reduction as min and as a sum, plus the waterfall read, per hardware wave against a console wave of the same lanes.
    • gpu_wave64_ps_spill_slots: full target and a 6-pixel triangle.
    • gpu_wave64_vs_spill_slots_and_identity: 3 vertices.
  • Unit tests: upper_lanes has 9, including v_swaprel, SDWA v_cmpx and absorbing constants found in review; they fail without the fix.
  • Workspace: cargo test --workspace --release with XCL_SAMPLE_RPF: 560 passed, 0 failed, 2 no wave64 skips as on main.
  • Retail census: the ignored retail_wave64_graphics_lane_census / _forms run on the retail pack.
  • Minecraft (NVIDIA): menu and a world render the same as main, 60 fps.

Not exact yet (documented in docs/wave64-on-wave32.md)

  • Partial waves, on every GPU: in a partial wave (a triangle edge) the reduction reads lanes the PC GPU never launched; the console runs whole-wave code in its inactive lanes too. On the 5070 Ti those read 0, so a min reduction over a 3-quad wave returns 0. max, or and sum come out right. 325 of the 436 reduction programs contain a min. This predates the change and also happens on AMD.
  • Possible fix: recognise the whole reduction and use WaveActiveMin / Max / BitOr. That would change the HLSL AMD gets, so it isn't part of this PR; your call.

Once, during a full test run with another heavy session on the machine, the lib test binary died with an access violation in the hle::d3d12x descriptor-heap tests. It didn't come back in 35 further runs (25 of that module alone, 10 of the whole lib).

🤖 Generated with Claude Code

**@⁠Foniass** on GitHub · 2026-11-23 14:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/133) `Foniass:nvidia/wave64-graphics-lanes` → `main` · +1667 −44 · 8 files · 3 commits · merged 2026-11-23 14:39 UTC The last open NVIDIA gap from HANDOFF / #42: wave64 **VS / PS** on GPUs with 32-lane waves only. ### Problem On NVIDIA the driver runs a console wave64 VS / PS in waves of 32: a console wave whose lanes 32..63 aren't populated. On the console those lanes exist (inactive) and hold whatever `v_writelane` or whole-wave code put there. Here they don't exist, and `WaveReadLaneAt` of a lane ≥ 32 reads lane & 31. `wave_hazards` flagged 749 programs of the retail pack. ### What those programs do (748 PS, 1 VS) | pattern | reads | programs | what the console reads there | before, on NVIDIA | |---|---|---|---|---| | whole-wave reduction (identity into lanes outside the mask, DPP8 xor 1/2/4, row_mirror, `v_permlanex16`, `v_readlane 32`; min_u32 / max_u32 / or_b32) | 1 082 | 436 | the identity | right only by accident: lane 32 read lane 0, and min / max / or are idempotent | | waterfall read `v_readlane v, s_ff1(mask & exec)` | 355 | 353 | a lane < 32 | right | | SGPR spill slots in lanes 32..47 of one VGPR | 200 | 11 | the spilled SGPR | **wrong**: the `v_writelane` was lost, the read returned slot lane & 31 | | `ds_bpermute` | 0 | 0 | — | — | ### Change - **Analysis:** `gpu/recomp/upper_lanes.rs`, a forward pass. It follows EXEC's upper word (0 / all ones / anything) through the SGPRs, and what each VGPR's lanes 32..63 hold: - unwritten; - a constant (it evaluates whole-wave moves, selects, integer min / max / logic / add and their DPP and permlane forms); - a spill slot; - unknown. - **Translation (`split_wave64`, when `WaveGetLaneCount() < 64`):** - A lane ≥ 32 that holds a constant reads the constant. - A spill slot is read from a scalar shadow that its `v_writelane`s also write. - Spill slots < 32 come from their shadows at any wave size, because a lane a partial wave didn't launch loses its slot. 287 PS spill to lanes < 32. - Only programs with such a read get the new form: 613 in the pack, and DXC compiles all of them. - **Unchanged HLSL:** without `split_wave64` (AMD and other 64-lane GPUs) the HLSL of all 26 698 programs is unchanged. The 32-lane form of the other modes is unchanged too; `retail_wave64_graphics_lane_forms` compares the digests. - **Graphics pipelines** (`hle/d3d12x/real.rs`): the pipeline hook compiled VS / PS with `console_to_dxil` (`split_wave64` false), so on NVIDIA the split form never reached a title. VS / PS, and the PS of two-pass (MS / GS) pipelines, now pass `wave32_only(device)` like compute and the geometry stages. - **`wave_hazards`:** now reports only the reads the pass can't follow; there are none in the pack. `xcl shaders --recomp` prints the resolved reads by kind. ### Tests (RTX 5070 Ti, 32-lane waves) - **GPU tests:** these three fail with the old translation on this card, and pass now: - `gpu_wave64_ps_whole_wave_reductions`: the pack's reduction as min and as a sum, plus the waterfall read, per hardware wave against a console wave of the same lanes. - `gpu_wave64_ps_spill_slots`: full target and a 6-pixel triangle. - `gpu_wave64_vs_spill_slots_and_identity`: 3 vertices. - **Unit tests:** `upper_lanes` has 9, including `v_swaprel`, SDWA `v_cmpx` and absorbing constants found in review; they fail without the fix. - **Workspace:** `cargo test --workspace --release` with `XCL_SAMPLE_RPF`: 560 passed, 0 failed, 2 `no wave64` skips as on `main`. - **Retail census:** the ignored `retail_wave64_graphics_lane_census` / `_forms` run on the retail pack. - **Minecraft (NVIDIA):** menu and a world render the same as `main`, 60 fps. ### Not exact yet (documented in docs/wave64-on-wave32.md) - **Partial waves, on every GPU:** in a partial wave (a triangle edge) the reduction reads lanes the PC GPU never launched; the console runs whole-wave code in its inactive lanes too. On the 5070 Ti those read 0, so a min reduction over a 3-quad wave returns 0. max, or and sum come out right. 325 of the 436 reduction programs contain a min. This predates the change and also happens on AMD. - **Possible fix:** recognise the whole reduction and use `WaveActiveMin` / `Max` / `BitOr`. That would change the HLSL AMD gets, so it isn't part of this PR; your call. Once, during a full test run with another heavy session on the machine, the lib test binary died with an access violation in the `hle::d3d12x` descriptor-heap tests. It didn't come back in 35 further runs (25 of that module alone, 10 of the whole lib). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On a GPU with 32-lane waves only (NVIDIA) the driver runs a console wave64
VS / PS in waves of 32: a console wave whose lanes 32..63 are not populated.
Those lanes exist on the console (inactive) and hold what v_writelane or
whole-wave code put there; here they do not exist, and WaveReadLaneAt of a
lane >= 32 reads lane & 31.

The 749 programs wave_hazards flagged in the retail pack (748 PS, 1 VS):
- 1 082 reads in 436 programs: whole-wave reductions (identity into the
  lanes outside the mask, DPP8 xor 1/2/4, row_mirror, v_permlanex16,
  v_readlane 32 for the upper half; min_u32 / max_u32 / or_b32). Right only
  because lane 32 reads lane 0 and those ops are idempotent.
- 355 reads in 353 programs: waterfall reads, v_readlane v, s_ff1(mask &
  EXEC) - a lane < 32. Right.
- 200 reads in 11 programs: SGPR spill slots in lanes 32..47. Wrong: the
  v_writelane is lost, the read gets another slot.

upper_lanes.rs follows what the console's lanes 32..63 hold through the
program (forward pass: EXEC's upper word through the SGPRs as 0 / all ones /
anything; per VGPR lane unwritten / a constant / a spill slot / unknown,
evaluating whole-wave moves, selects, integer min / max / logic / add and
their DPP forms). With split_wave64 a wave64 VS / PS reads a lane >= 32 that
holds a constant as the constant, and a spill slot from a scalar shadow its
v_writelanes also write, when WaveGetLaneCount() < 64. Spill slots < 32 come
from their shadows at any wave size: a lane a partial wave did not launch
loses its slot (287 PS spill to lanes < 32). Only programs with such a read
get the form (613 of the pack; DXC compiles all). Without split_wave64 the
HLSL of all 26 698 programs is unchanged, and so is the 32-lane form of the
other modes (digests compared with main, retail_wave64_graphics_lane_forms).

wave_hazards now reports only reads the pass cannot follow: none in the pack.

GPU tests on an RTX 5070 Ti: gpu_wave64_ps_whole_wave_reductions (the pack's
reduction as min and as a sum, and the waterfall read, per hardware wave
against a console wave of the same lanes), gpu_wave64_ps_spill_slots (full
target and a 6-pixel triangle), gpu_wave64_vs_spill_slots_and_identity (3
vertices). With the old form all three fail there.

Not exact yet, on every GPU: whole-wave code in a partial wave reads lanes
the PC never launched. On the 5070 Ti they read 0, so a min reduction gives
0 in a partial pixel wave (325 programs have one); max / or are right.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The pipeline hook compiled console VS / PS with console_to_dxil (split_wave64
false), so on a GPU with 32-lane waves the upper_lanes form never reached a
title: only the tests saw it. VS / PS of a graphics pipeline and the PS of a
two-pass (MS / GS) pipeline now pass wave32_only(device), as compute and the
geometry stages already did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Found in review, none of them reached in the retail pack:
- v_swaprel_b32 writes v[src0 + m0] and v[dst + m0]: any VGPR, as v_movrel*.
- An SDWA v_cmpx writes EXEC only; it was taken as writing VCC (with EXEC's
  zero upper word), so a stale all-ones VCC read as a lane mask.
- An operation on a lane nothing wrote is not "unwritten" when a constant
  decides it (0 & x, -1 | x, min / max with their extreme); x ^ x may be
  0 – unknown.

Unit tests for each; they fail without the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:11:44 +00:00
github manually merged commit 55156f0951 into gh-pr/133/base 2026-11-26 04:11:46 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 14:40 UTC · original

Merged - thanks, a very clean one. Checked on Windows 11 with an RX 9070 (RDNA4, 64-lane waves):

  • cargo test --workspace green with the retail samples (529 lib tests), and the lib tests with XCL_SPLIT_WAVE64=1; the three new GPU tests pass on AMD too.
  • retail_wave64_graphics_lane_forms: 613 changed VS / PS, all compile. I also ran the same test (with XCL_FORMS_NO_DXC=1) on main before the merge: native-form digest ac67db269b7452be and other-modes 32-lane digest 09d45ad13eddc30d on both, so AMD's HLSL is indeed unchanged.
  • Retail survey still 26 698 / 26 698.
  • XDefiant and Minecraft run, with and without XCL_SPLIT_WAVE64=1 (the forced 32-lane form on AMD; XDefiant stays black for a while there since that form starts from a cold shader cache).

On the partial-wave min reduction: recognising the whole reduction and emitting WaveActiveMin / Max / BitOr sounds right to me, even if it changes AMD's HLSL - as a separate PR, with a GPU test of a partial wave and the census numbers like here.

**@⁠ivall** on GitHub · 2026-11-23 14:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/133#issuecomment-7104348155) Merged - thanks, a very clean one. Checked on Windows 11 with an RX 9070 (RDNA4, 64-lane waves): - `cargo test --workspace` green with the retail samples (529 lib tests), and the lib tests with `XCL_SPLIT_WAVE64=1`; the three new GPU tests pass on AMD too. - `retail_wave64_graphics_lane_forms`: 613 changed VS / PS, all compile. I also ran the same test (with `XCL_FORMS_NO_DXC=1`) on `main` before the merge: native-form digest `ac67db269b7452be` and other-modes 32-lane digest `09d45ad13eddc30d` on both, so AMD's HLSL is indeed unchanged. - Retail survey still 26 698 / 26 698. - XDefiant and Minecraft run, with and without `XCL_SPLIT_WAVE64=1` (the forced 32-lane form on AMD; XDefiant stays black for a while there since that form starts from a cold shader cache). On the partial-wave min reduction: recognising the whole reduction and emitting `WaveActiveMin` / `Max` / `BitOr` sounds right to me, even if it changes AMD's HLSL - as a separate PR, with a GPU test of a partial wave and the census numbers like here.
This discussion has been locked. Commenting is limited to contributors.
No description provided.