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

Merged
Foniass merged 3 commits from upstream-pr/133 into main 2026-11-23 14:39:51 +00:00
Foniass commented 2026-11-23 14:24:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-23T14:24:30Z.


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

<!-- greyfinch-sync:ivall/xcl:issue:6561443454 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/133). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-23T14:24:30Z. --- 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)
upstream-sync closed this pull request 2026-11-24 06:57:18 +00:00
ivall commented 2026-11-24 07:00:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T14:40:00Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7104348155 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/133#issuecomment-7104348155). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T14:40:00Z. --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!131
No description provided.