Shaders: wave32 lane masks on 64-lane host waves take their half's dword #3556

Open
kilolimaVI wants to merge 5 commits from upstream-pr/3556 into main
kilolimaVI commented 2026-11-27 17:26:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T17:26:26Z.


On hosts that run pixel waves of 64 lanes (AMD: RDNA pixel shaders run wave64; measured on a Radeon 780M, RDNA3), a wave32 pixel or vertex program's 32-bit lane masks were the ballot's low dword in every lane. Lanes 32-63 tested the bits of lanes 0-31, so the console compiler's loop that serves one value per pass (s_ff1 of EXEC, v_readlane at that lane, v_cmpx_eq) never served them: those pixels kept whatever they held before the loop.

NVIDIA (32-lane pixel waves) and WARP never show it, which is likely why it went unnoticed.

Fix (emit/lower.rs)

With MaskData::Host and a wave32 program, a 64-lane host wave is treated as two console waves:

  • mask_dword: each lane takes its own half's dword of the ballot (Lower::host_half, waveGetLaneIndex >= 32).
  • v_readlane at a computed (host) lane adds the half's base (Lower::host_lane).
  • v_mbcnt counts within the half (lane & 31).

On a 32-lane host the upper half never exists, so nothing changes there; wave64 programs and compute (MaskData::Console) are untouched (wave64 DXIL is byte-identical).

Test (emit/lane_mask_tests.rs)

wave32_lane_mask_loops_serve_every_lane_of_a_64_lane_host_wave: a hand-assembled pixel program runs that loop over a per-pixel key, drawn over a 16x16 target (no helper lanes), wave32 and wave64, on the hardware adapter and WARP. Pixels served a wrong key:

before after
wave32, Radeon 780M 88 / 256 0
wave64, Radeon 780M 0 0
wave32 / wave64, WARP 0 / 0 0 / 0

0/5 failures over 5 runs. cargo test -p victory-shader on the 780M: 303 passed, 0 failed. cargo clippy -p victory-shader --all-targets [--all-features] -- -D warnings clean. cargo fmt --check reports no new sites (main already has 33 in lower.rs and 2 in mod.rs).

Related: helper lanes at triangle edges are a separate issue (#2373); this test draws a full-coverage triangle so it measures only the mask width.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:issue:5530640184 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3556). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-27T17:26:26Z. --- On hosts that run pixel waves of 64 lanes (AMD: RDNA pixel shaders run wave64; measured on a Radeon 780M, RDNA3), a wave32 pixel or vertex program's 32-bit lane masks were the ballot's low dword in every lane. Lanes 32-63 tested the bits of lanes 0-31, so the console compiler's loop that serves one value per pass (`s_ff1` of EXEC, `v_readlane` at that lane, `v_cmpx_eq`) never served them: those pixels kept whatever they held before the loop. NVIDIA (32-lane pixel waves) and WARP never show it, which is likely why it went unnoticed. ## Fix (`emit/lower.rs`) With `MaskData::Host` and a wave32 program, a 64-lane host wave is treated as two console waves: - `mask_dword`: each lane takes its own half's dword of the ballot (`Lower::host_half`, `waveGetLaneIndex >= 32`). - `v_readlane` at a computed (host) lane adds the half's base (`Lower::host_lane`). - `v_mbcnt` counts within the half (`lane & 31`). On a 32-lane host the upper half never exists, so nothing changes there; wave64 programs and compute (`MaskData::Console`) are untouched (wave64 DXIL is byte-identical). ## Test (`emit/lane_mask_tests.rs`) `wave32_lane_mask_loops_serve_every_lane_of_a_64_lane_host_wave`: a hand-assembled pixel program runs that loop over a per-pixel key, drawn over a 16x16 target (no helper lanes), wave32 and wave64, on the hardware adapter and WARP. Pixels served a wrong key: | | before | after | |---|---|---| | wave32, Radeon 780M | 88 / 256 | 0 | | wave64, Radeon 780M | 0 | 0 | | wave32 / wave64, WARP | 0 / 0 | 0 / 0 | 0/5 failures over 5 runs. `cargo test -p victory-shader` on the 780M: 303 passed, 0 failed. `cargo clippy -p victory-shader --all-targets [--all-features] -- -D warnings` clean. `cargo fmt --check` reports no new sites (main already has 33 in `lower.rs` and 2 in `mod.rs`). Related: helper lanes at triangle edges are a separate issue (#2373); this test draws a full-coverage triangle so it measures only the mask width. AI-assisted (Claude).
andrewpozdnakov7-jpg commented 2026-11-27 17:44:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T17:44:45Z.


I checked the merge order for the Wave32 mask fix alongside #3421. The exact heads of #3556 (48f1646) and #3421 (c2698c3) merge cleanly, but the resulting lower.rs is 524,618 bytes, 330 bytes over the 512 KiB asset-policy limit.

Adding the barycentric lowering split from #3335 (e495d2d) also merges cleanly. On the combined commit, lower.rs is 508,704 bytes and the asset policy passes for all 194 files. Both merge commits preserve the original parent commits.

  • The 9 wave lowering tests and 9 barycentric tests pass.
  • App-local D3D12 and WARP ran the pixel comparison. Both guest wave widths returned the expected keys for all 256 pixels. The WARP DPP row-mask and quad-swizzle plus first-lane readbacks passed as well.
  • Clippy passes for all shader targets with both default and all features.

These are local software-rendering results. The Radeon 780M measurement above is the hardware evidence for #3556. Its Windows workflow is still awaiting approval.

The next step is for the maintainers to choose a merge order that puts the split in place before both wave changes are in main. If you reuse the integration work, please retain Git authorship, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding it into another commit.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7224741076 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3556#issuecomment-7224741076). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T17:44:45Z. --- I checked the merge order for the Wave32 mask fix alongside #3421. The exact heads of #3556 (`48f1646`) and #3421 (`c2698c3`) merge cleanly, but the resulting `lower.rs` is 524,618 bytes, 330 bytes over the 512 KiB asset-policy limit. Adding the barycentric lowering split from #3335 (`e495d2d`) also merges cleanly. On [the combined commit](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/cf42f0390bf94b17f98bc3a0051f5006f6d46ccd), `lower.rs` is 508,704 bytes and the asset policy passes for all 194 files. Both merge commits preserve the original parent commits. - The 9 wave lowering tests and 9 barycentric tests pass. - App-local D3D12 and WARP ran the pixel comparison. Both guest wave widths returned the expected keys for all 256 pixels. The WARP DPP row-mask and quad-swizzle plus first-lane readbacks passed as well. - Clippy passes for all shader targets with both default and all features. These are local software-rendering results. The Radeon 780M measurement above is the hardware evidence for #3556. Its Windows workflow is still awaiting approval. The next step is for the maintainers to choose a merge order that puts the split in place before both wave changes are in `main`. If you reuse the integration work, please retain Git authorship, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding it into another commit.
ColorMeBoom commented 2026-11-27 17:49:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-27T17:49:08Z.


RDNA1 run, and an overlap with #125 / #145. RX 5700 XT (RDNA1), driver 32.0.21045.29003, Windows 11 26200, no game files. All trees are merged onto main 63bcca4.

wave32_lane_mask_loops_serve_every_lane_of_a_64_lane_host_wave (your test):

tree wave32, RX 5700 XT wave64, RX 5700 XT WARP (both)
main + this test only 88 / 256 pixels wrong, first (3, 4): 0 instead of 30 0 0
this PR (48f1646) 0 0 0
#145 rebased on main (ColorMeBoom:pr145-rebase, dec8a5b) + this test 0 0 0

So RDNA1 shows the same 88/256 as your 780M, and this PR fixes it. Full victory-shader --lib --features host on this PR: 303 passed, 0 failed.

Overlap: this is the bug #125 tracks: a wave32 pixel/vertex program's lane masks only use the low ballot dword on a 64-lane host wave, which I confirmed on this card earlier today. #145 (TheHoracio's) fixes it a different way: a 64-bit host ballot for mask ops (emit/lower/host_masks.rs). Its head conflicts with main. The rebase above merges cleanly, and its own pixel_lane_masks_count_every_lane_of_the_host_wave fails on main here ("the host wave is wider than 32 lanes and its high half is lost") and passes with it. The two PRs conflict in lower.rs, and as the table shows, both pass your test on this card. So they look like two fixes for one bug, and it's worth settling which one lands.

Not run: #145's test on this PR. Windows Application Control on this machine blocked that test binary on every rebuild.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7224819009 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3556#issuecomment-7224819009). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-27T17:49:08Z. --- **RDNA1 run, and an overlap with #125 / #145.** RX 5700 XT (RDNA1), driver 32.0.21045.29003, Windows 11 26200, no game files. All trees are merged onto `main` `63bcca4`. `wave32_lane_mask_loops_serve_every_lane_of_a_64_lane_host_wave` (your test): | tree | wave32, RX 5700 XT | wave64, RX 5700 XT | WARP (both) | | --- | --- | --- | --- | | `main` + this test only | **88 / 256** pixels wrong, first (3, 4): 0 instead of 30 | 0 | 0 | | this PR (`48f1646`) | **0** | 0 | 0 | | #145 rebased on `main` ([`ColorMeBoom:pr145-rebase`](https://github.com/ColorMeBoom/VIctory/tree/pr145-rebase), `dec8a5b`) + this test | **0** | 0 | 0 | So RDNA1 shows the same 88/256 as your 780M, and this PR fixes it. Full `victory-shader --lib --features host` on this PR: 303 passed, 0 failed. **Overlap:** this is the bug #125 tracks: a wave32 pixel/vertex program's lane masks only use the low ballot dword on a 64-lane host wave, which [I confirmed on this card](https://github.com/Marvisak/VIctory/issues/125) earlier today. #145 (TheHoracio's) fixes it a different way: a 64-bit host ballot for mask ops (`emit/lower/host_masks.rs`). Its head conflicts with `main`. The rebase above merges cleanly, and its own `pixel_lane_masks_count_every_lane_of_the_host_wave` fails on `main` here ("the host wave is wider than 32 lanes and its high half is lost") and passes with it. The two PRs conflict in `lower.rs`, and as the table shows, both pass your test on this card. So they look like two fixes for one bug, and it's worth settling which one lands. Not run: #145's test on this PR. Windows Application Control on this machine blocked that test binary on every rebuild. AI use: Claude Code (Claude Opus 5.5).
kilolimaVI commented 2026-11-27 17:54:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T17:54:15Z.


Thanks for checking the merge order. Rather than depend on #3335 landing first, I moved the two helpers (host_half, host_lane) into lower/lanes.rs, as lower/bvh.rs already is. This PR now adds about 0.8 KB to lower.rs instead of 2.2 KB, so with #3421 beside it the file is about 523.3 KB, under the 512 KiB limit in either merge order. No change in behaviour: the hardware test still gives 0 of 256 on the 780M, and clippy is clean.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7224909487 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3556#issuecomment-7224909487). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-27T17:54:15Z. --- Thanks for checking the merge order. Rather than depend on #3335 landing first, I moved the two helpers (`host_half`, `host_lane`) into `lower/lanes.rs`, as `lower/bvh.rs` already is. This PR now adds about 0.8 KB to `lower.rs` instead of 2.2 KB, so with #3421 beside it the file is about 523.3 KB, under the 512 KiB limit in either merge order. No change in behaviour: the hardware test still gives 0 of 256 on the 780M, and clippy is clean. AI-assisted (Claude).
kilolimaVI commented 2026-11-27 17:54:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T17:54:31Z.


Thanks for the RDNA1 run and for spotting #125 / #145. That overlap is my miss: my check of open PRs didn't go back that far, and #145 was first.

The two fixes differ in shape. #145 widens a wave32 program's masks to the host's 64-bit ballot (lane numbers, counts and compares over the whole host wave). This PR treats a 64-lane host wave as two console waves: each lane reads its own half's dword, and lane numbers from masks count within the half (mask_dword, v_readlane at a computed lane, v_mbcnt; about 60 lines plus the test), so every 32-bit mask operation keeps its console meaning without tracking a second dword through the program. Either way your table shows the 88/256 gone on RDNA1 and RDNA3.

I'm happy for the maintainers to take whichever they prefer. If it's #145, I'll close this one, and the hardware test (emit/lane_mask_tests.rs) can go there with it.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7224914237 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3556#issuecomment-7224914237). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-27T17:54:31Z. --- Thanks for the RDNA1 run and for spotting #125 / #145. That overlap is my miss: my check of open PRs didn't go back that far, and #145 was first. The two fixes differ in shape. #145 widens a wave32 program's masks to the host's 64-bit ballot (lane numbers, counts and compares over the whole host wave). This PR treats a 64-lane host wave as two console waves: each lane reads its own half's dword, and lane numbers from masks count within the half (`mask_dword`, `v_readlane` at a computed lane, `v_mbcnt`; about 60 lines plus the test), so every 32-bit mask operation keeps its console meaning without tracking a second dword through the program. Either way your table shows the 88/256 gone on RDNA1 and RDNA3. I'm happy for the maintainers to take whichever they prefer. If it's #145, I'll close this one, and the hardware test (`emit/lane_mask_tests.rs`) can go there with it. AI-assisted (Claude).
andrewpozdnakov7-jpg commented 2026-11-27 18:03:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T18:03:51Z.


I retested the split on the exact new #3556 head dcc8ca4 with #3421 c2698c3. Git reports one conflict where both branches add a module declaration. Keeping mod lanes; and #[cfg(test)] mod wave_tests; resolves it. The rest merged automatically.

The combined commit keeps both exact parents. lower.rs is 523,263 bytes, 1,025 bytes below the 512 KiB limit. The asset policy passes for 194 files. This combination passes with the split in #3556 itself.

App-local WARP gave the expected keys for all 256 pixels at each guest wave width, and the DPP row-mask and quad-swizzle/first-lane readbacks passed. All nine wave lowering tests and both strict shader Clippy configurations passed. The author reported the same pixel result on the Radeon 780M after the split. The earlier RX 5700 XT result is for 48f1646. The new Windows workflow awaits approval.

The merge-order question is resolved for these two changes. The maintainers can now choose between the approaches in #3556 and #145. If reusing my merge resolution, please retain Git authorship, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding it into another commit.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7225082215 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3556#issuecomment-7225082215). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T18:03:51Z. --- I retested the split on the exact new #3556 head `dcc8ca4` with #3421 `c2698c3`. Git reports one conflict where both branches add a module declaration. Keeping `mod lanes;` and `#[cfg(test)] mod wave_tests;` resolves it. The rest merged automatically. The [combined commit](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/17eda9bdb34b74ac74134d4927bd16fa5f41bad0) keeps both exact parents. `lower.rs` is 523,263 bytes, 1,025 bytes below the 512 KiB limit. The asset policy passes for 194 files. This combination passes with the split in #3556 itself. App-local WARP gave the expected keys for all 256 pixels at each guest wave width, and the DPP row-mask and quad-swizzle/first-lane readbacks passed. All nine wave lowering tests and both strict shader Clippy configurations passed. The author reported the same pixel result on the Radeon 780M after the split. The earlier RX 5700 XT result is for `48f1646`. The new Windows workflow awaits approval. The merge-order question is resolved for these two changes. The maintainers can now choose between the approaches in #3556 and #145. If reusing my merge resolution, please retain Git authorship, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding it into another commit.
ColorMeBoom commented 2026-11-27 18:44:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-27T18:44:39Z.


RX 5700 XT at the new head dcc8ca4 (merged onto main 63bcca4), and the cross-check that was blocked last time.

  • wave32_lane_mask_loops_serve_every_lane_of_a_64_lane_host_wave: 0 of 256 pixels wrong, wave32 and wave64, hardware and WARP. Full victory-shader --lib --features host: 303 passed, 0 failed.
  • #145's test on this PR (pixel_lane_masks_count_every_lane_of_the_host_wave, taken from the #145 rebase): passes. What it prints shows how the two fixes differ, on the same card:
tree probe line test
main up to 32 active lanes, lane indices up to 32 fails: "the host wave is wider than 32 lanes and its high half is lost"
#145 rebase up to 64 active lanes, lane indices up to 63 passes
this PR up to 32 active lanes, lane indices up to 31 passes

So the two agree on the bug, but disagree on what a wave32 program sees on a 64-lane host wave:

  • With #145 it sees one 64-lane wave: s_bcnt1 of EXEC up to 64, v_mbcnt up to 63.
  • With this PR it sees two 32-lane waves, as on the console: counts and lane numbers stay within 0–32 / 0–31.

A wave32 program on the console never sees a lane number above 31, so where its code depends on that (a lane number used as an index or a shift, a count compared with 32), this PR's form keeps the console's values. That could help the maintainers choose between the two.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7225820691 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3556#issuecomment-7225820691). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-27T18:44:39Z. --- **RX 5700 XT at the new head `dcc8ca4`** (merged onto `main` `63bcca4`), and the cross-check that was blocked last time. - `wave32_lane_mask_loops_serve_every_lane_of_a_64_lane_host_wave`: **0 of 256** pixels wrong, wave32 and wave64, hardware and WARP. Full `victory-shader --lib --features host`: **303 passed, 0 failed**. - **#145's test on this PR** (`pixel_lane_masks_count_every_lane_of_the_host_wave`, taken from the [#145 rebase](https://github.com/ColorMeBoom/VIctory/tree/pr145-rebase)): **passes**. What it prints shows how the two fixes differ, on the same card: | tree | probe line | test | | --- | --- | --- | | `main` | `up to 32 active lanes, lane indices up to 32` | fails: "the host wave is wider than 32 lanes and its high half is lost" | | #145 rebase | `up to 64 active lanes, lane indices up to 63` | passes | | this PR | `up to 32 active lanes, lane indices up to 31` | passes | So the two agree on the bug, but disagree on what a wave32 program sees on a 64-lane host wave: - With #145 it sees one 64-lane wave: `s_bcnt1` of EXEC up to 64, `v_mbcnt` up to 63. - With this PR it sees two 32-lane waves, as on the console: counts and lane numbers stay within 0–32 / 0–31. A wave32 program on the console never sees a lane number above 31, so where its code depends on that (a lane number used as an index or a shift, a count compared with 32), this PR's form keeps the console's values. That could help the maintainers choose between the two. AI use: Claude Code (Claude Opus 5.5).
kilolimaVI commented 2026-11-28 16:09:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-28T16:09:42Z.


Added one commit (2445a0c): the same split for v_readfirstlane_b32.

A wave32 pixel program on a 64-lane host wave has two console waves in it. Lane masks were already taken per half; v_readfirstlane still went to waveReadLaneFirst over the whole host wave, so lanes 32-63 read the first value of lanes 0-31, another console wave's. A value the console keeps uniform per wave (a flat attribute, a scalarised index) then comes from the wrong primitive in the upper half.

With masks split, it now reads the first active lane of its own half (FirstbitLo of the half's ballot dword, +32 in the upper half, waveReadLaneAt). Elsewhere it is still waveReadLaneFirst. The helper is in lower/lanes.rs; lower.rs stays at 521,136 bytes.

New test wave32_first_lane_reads_stay_in_the_console_wave_on_a_64_lane_host_wave: every pixel reads the first lane's unique key; the pixels reading one value must be at most a console wave and include the pixel whose key it is. Radeon 780M (RDNA3) + WARP:

code wave32, 780M WARP
main 63bcca4 4 values, groups of 64 72 values, groups of 4
this PR before (dcc8ca4) 4 values, groups of 64 72 values, groups of 4
this PR now (2445a0c) 8 values, groups of 32 72 values, groups of 4

WARP runs 4-lane waves, so only a 64-lane hardware wave shows it. The lane-mask loop test is unchanged (88/256 wrong on main, 0 here). 5 of 5 runs, full suite 553 passed, clippy clean.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7242020309 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3556#issuecomment-7242020309). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-28T16:09:42Z. --- Added one commit (`2445a0c`): the same split for `v_readfirstlane_b32`. A wave32 pixel program on a 64-lane host wave has two console waves in it. Lane masks were already taken per half; `v_readfirstlane` still went to `waveReadLaneFirst` over the whole host wave, so lanes 32-63 read the first value of lanes 0-31, another console wave's. A value the console keeps uniform per wave (a flat attribute, a scalarised index) then comes from the wrong primitive in the upper half. With masks split, it now reads the first active lane of its own half (FirstbitLo of the half's ballot dword, +32 in the upper half, `waveReadLaneAt`). Elsewhere it is still `waveReadLaneFirst`. The helper is in `lower/lanes.rs`; `lower.rs` stays at 521,136 bytes. New test `wave32_first_lane_reads_stay_in_the_console_wave_on_a_64_lane_host_wave`: every pixel reads the first lane's unique key; the pixels reading one value must be at most a console wave and include the pixel whose key it is. Radeon 780M (RDNA3) + WARP: | code | wave32, 780M | WARP | |---|---|---| | main `63bcca4` | 4 values, groups of 64 | 72 values, groups of 4 | | this PR before (`dcc8ca4`) | 4 values, groups of 64 | 72 values, groups of 4 | | this PR now (`2445a0c`) | **8 values, groups of 32** | 72 values, groups of 4 | WARP runs 4-lane waves, so only a 64-lane hardware wave shows it. The lane-mask loop test is unchanged (88/256 wrong on main, 0 here). 5 of 5 runs, full suite 553 passed, clippy clean. AI-assisted (Claude).
kilolimaVI commented 2026-11-28 19:59:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-28T19:59:02Z.


Added a third commit (4f4e98d): whole-wave reductions split by halves too.

A whole-wave section (the compiler's expansion of a wave sum, min/max, bit operation or prefix sum) lowers to waveActiveOp / waveActiveBit / wavePrefixOp over the host's active lanes. For a wave32 program on a 64-lane host wave that reduced both console waves together.

With masks split, the operation now runs twice, each half's lanes giving the identity in the other run, and each lane takes its own half's result (a prefix the same way). Elsewhere it is one operation as before. The DXIL emission moved to lower/lanes.rs (wave_reduce), so lower.rs shrinks to 519,957 bytes.

New test wave32_wave_sums_stay_in_the_console_wave_on_a_64_lane_host_wave: each pixel adds 2^20 + its key through the compiler's DPP / v_permlanex16 / v_readlane sequence, so the result carries the lane count and the key sum. Radeon 780M (RDNA3) + WARP:

code wave32, 780M WARP
this PR before (2445a0c) 4 sums, lane count 64, all 4 inconsistent 72 sums, lane count 4
this PR now (4f4e98d) 8 sums, lane count 32, 0 inconsistent 72 sums, lane count 4

The other two lane-mask tests are unchanged and pass. 5 of 5 runs, full suite 554 passed, clippy clean.

So the PR now covers the three ways a wave32 program read the other console wave in a 64-lane host wave: lane-mask loops, v_readfirstlane, and wave reductions.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7244947924 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3556#issuecomment-7244947924). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-28T19:59:02Z. --- Added a third commit (`4f4e98d`): whole-wave reductions split by halves too. A whole-wave section (the compiler's expansion of a wave sum, min/max, bit operation or prefix sum) lowers to `waveActiveOp` / `waveActiveBit` / `wavePrefixOp` over the host's active lanes. For a wave32 program on a 64-lane host wave that reduced both console waves together. With masks split, the operation now runs twice, each half's lanes giving the identity in the other run, and each lane takes its own half's result (a prefix the same way). Elsewhere it is one operation as before. The DXIL emission moved to `lower/lanes.rs` (`wave_reduce`), so `lower.rs` shrinks to 519,957 bytes. New test `wave32_wave_sums_stay_in_the_console_wave_on_a_64_lane_host_wave`: each pixel adds 2^20 + its key through the compiler's DPP / `v_permlanex16` / `v_readlane` sequence, so the result carries the lane count and the key sum. Radeon 780M (RDNA3) + WARP: | code | wave32, 780M | WARP | |---|---|---| | this PR before (`2445a0c`) | 4 sums, lane count 64, all 4 inconsistent | 72 sums, lane count 4 | | this PR now (`4f4e98d`) | **8 sums, lane count 32, 0 inconsistent** | 72 sums, lane count 4 | The other two lane-mask tests are unchanged and pass. 5 of 5 runs, full suite 554 passed, clippy clean. So the PR now covers the three ways a wave32 program read the other console wave in a 64-lane host wave: lane-mask loops, `v_readfirstlane`, and wave reductions. AI-assisted (Claude).
kilolimaVI commented 2026-11-28 20:18:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-28T20:18:49Z.


Merge note for whoever lands these: all five of my open PRs together (#3556 4f4e98d, #3571, #3583, #3613 4fb5462, #3749 152ebaa) on main 63bcca4, Radeon 780M (RDNA3) + WARP:

  • the lane-mask, helper-lane, quad-read, LOD and gather tests together: 12/12, 3 of 3 runs; the shader-cache test passes;
  • full suite (victory-shader + victory-gpu --features diagnostics): 562 passed, 0 failed; clippy clean;
  • lower.rs is 520,854 bytes combined (limit 524,288).

The only conflicts are module-order lines: the test modules in emit/mod.rs (#3583, #3613, #3749), and in emit/lower.rs this PR's mod lanes; against #3613's mod gather; right after mod bvh; (keep both, gather first).

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7245194153 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3556#issuecomment-7245194153). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-28T20:18:49Z. --- Merge note for whoever lands these: all five of my open PRs together (#3556 `4f4e98d`, #3571, #3583, #3613 `4fb5462`, #3749 `152ebaa`) on main `63bcca4`, Radeon 780M (RDNA3) + WARP: - the lane-mask, helper-lane, quad-read, LOD and gather tests together: 12/12, 3 of 3 runs; the shader-cache test passes; - full suite (`victory-shader` + `victory-gpu --features diagnostics`): 562 passed, 0 failed; clippy clean; - `lower.rs` is 520,854 bytes combined (limit 524,288). The only conflicts are module-order lines: the test modules in `emit/mod.rs` (#3583, #3613, #3749), and in `emit/lower.rs` this PR's `mod lanes;` against #3613's `mod gather;` right after `mod bvh;` (keep both, `gather` first). AI-assisted (Claude).
kilolimaVI commented 2026-11-28 20:35:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-28T20:35:38Z.


Added a fourth commit (82813e4): 16-bit wave sums now translate in pixel and vertex programs.

A whole-wave section summing f16 halves (Shape::Half: the sum in the low half, console lane hi's high half on top) was refused outside compute ("a 16-bit wave reduction outside compute"), because the high half names a console lane. With host lanes that lane is known: lane hi of a wave64 program, or of a wave32 program within its own half of a 64-lane host wave. Mesh programs still refuse it. Where the host wave is narrower than the console's (WARP's 4 lanes) there is no lane hi, and the high half is the identity's, as in compute.

The f16 sum goes through the same per-half split as the other reductions (wave_reduce_halves), and console_lane gives a console lane's ballot dword and host lane. lower.rs shrinks to 519,102 bytes.

New test wave32_half_wave_sums_stay_in_the_console_wave_on_a_64_lane_host_wave, Radeon 780M (RDNA3) + WARP:

code result
this PR before (4f4e98d) refused at translation
this PR now (82813e4) 780M: 8 f16 sums, at most 32 lanes, 0 inconsistent; WARP: 0 inconsistent; 5 of 5 runs

Full suite 555 passed, clippy clean.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7245399951 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3556#issuecomment-7245399951). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-28T20:35:38Z. --- Added a fourth commit (`82813e4`): 16-bit wave sums now translate in pixel and vertex programs. A whole-wave section summing f16 halves (`Shape::Half`: the sum in the low half, console lane `hi`'s high half on top) was refused outside compute ("a 16-bit wave reduction outside compute"), because the high half names a console lane. With host lanes that lane is known: lane `hi` of a wave64 program, or of a wave32 program within its own half of a 64-lane host wave. Mesh programs still refuse it. Where the host wave is narrower than the console's (WARP's 4 lanes) there is no lane `hi`, and the high half is the identity's, as in compute. The f16 sum goes through the same per-half split as the other reductions (`wave_reduce_halves`), and `console_lane` gives a console lane's ballot dword and host lane. `lower.rs` shrinks to 519,102 bytes. New test `wave32_half_wave_sums_stay_in_the_console_wave_on_a_64_lane_host_wave`, Radeon 780M (RDNA3) + WARP: | code | result | |---|---| | this PR before (`4f4e98d`) | refused at translation | | this PR now (`82813e4`) | 780M: 8 f16 sums, at most 32 lanes, 0 inconsistent; WARP: 0 inconsistent; 5 of 5 runs | Full suite 555 passed, clippy clean. AI-assisted (Claude).
ColorMeBoom commented 2026-11-28 20:37:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-28T20:37:00Z.


@kilolimaVI RDNA1 row for 4f4e98d: RX 5700 XT (Navi 10, runs both wave sizes, driver 32.0.21045.29003), Windows 11 26200.

code wave32_wave_sums_stay_in_the_console_wave_on_a_64_lane_host_wave, hardware WARP
before (2445a0c + this test) fails: 4 sums, lane count 64, 4 inconsistent 72 sums, lane count 4, 0 inconsistent
after (4f4e98d), 3 of 3 runs passes: 8 sums, lane count 32, 0 inconsistent the same

The other two tests at 4f4e98d, 3 of 3 runs on hardware:

  • lane-mask loops: 0 of 256 pixels served a wrong key;
  • v_readfirstlane: 8 values read, largest group 32 pixels, 0 groups over 32, 0 not their own pixel's.

Full victory-shader --lib --features host: 305 passed, 0 failed, 3 ignored.

The same counts as the 780M, so the reduction fix covers RDNA1 as well as RDNA3.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7245416189 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3556#issuecomment-7245416189). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-28T20:37:00Z. --- @kilolimaVI RDNA1 row for `4f4e98d`: RX 5700 XT (Navi 10, runs both wave sizes, driver 32.0.21045.29003), Windows 11 26200. | code | `wave32_wave_sums_stay_in_the_console_wave_on_a_64_lane_host_wave`, hardware | WARP | |---|---|---| | before (`2445a0c` + this test) | fails: 4 sums, lane count 64, **4 inconsistent** | 72 sums, lane count 4, 0 inconsistent | | after (`4f4e98d`), 3 of 3 runs | passes: **8 sums, lane count 32, 0 inconsistent** | the same | The other two tests at `4f4e98d`, 3 of 3 runs on hardware: - **lane-mask loops:** 0 of 256 pixels served a wrong key; - **`v_readfirstlane`:** 8 values read, largest group 32 pixels, 0 groups over 32, 0 not their own pixel's. Full `victory-shader --lib --features host`: 305 passed, 0 failed, 3 ignored. The same counts as the 780M, so the reduction fix covers RDNA1 as well as RDNA3. AI use: Claude Code (Claude Opus 5.5).
Anzymanz commented 2026-12-01 07:26:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Anzymanz on 2026-12-01T07:26:06Z.


A Linux data point for why this matters on AMD beyond the 780M: RADV runs pixel and vertex/geometry shaders at wave64 by default on every RDNA generation. In Mesa 26.3.1, src/amd/vulkan/radv_physical_device.c sets ps_wave_size and ge_wave_size to 64 and only drops them to 32 with RADV_PERFTEST=ps_wave32 / ge_wave32 (compute and ray tracing are different). vkd3d-proton (libs/vkd3d/state.c) leaves the size to the driver unless the shader declares a WaveSize, which DXIL only has for compute, so a wave32 pixel program from the translator lands on a 64-lane wave under Proton too. That's the same situation as your Windows test, on RDNA4 (RX 9070 XT) here.

Scale, from a count over the title's translated programs on our side: 1,127 wave32 pixel programs, 1,010 of them using v_readlane or v_readfirstlane.

From the source, RADV_PERFTEST=ps_wave32,ge_wave32 should also avoid the bug on Linux without this PR, at whatever cost wave32 pixel shading has there. We haven't tested that in game yet. We'll add our before/after picture result here once our run is in.

Written with Claude Code.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7304051741 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3556#issuecomment-7304051741). Originally posted by [Anzymanz](https://github.com/Anzymanz) on 2026-12-01T07:26:06Z. --- A Linux data point for why this matters on AMD beyond the 780M: RADV runs pixel and vertex/geometry shaders at wave64 by default on every RDNA generation. In Mesa 26.3.1, `src/amd/vulkan/radv_physical_device.c` sets `ps_wave_size` and `ge_wave_size` to 64 and only drops them to 32 with `RADV_PERFTEST=ps_wave32` / `ge_wave32` (compute and ray tracing are different). vkd3d-proton (`libs/vkd3d/state.c`) leaves the size to the driver unless the shader declares a `WaveSize`, which DXIL only has for compute, so a wave32 pixel program from the translator lands on a 64-lane wave under Proton too. That's the same situation as your Windows test, on RDNA4 (RX 9070 XT) here. Scale, from a count over the title's translated programs on our side: 1,127 wave32 pixel programs, 1,010 of them using `v_readlane` or `v_readfirstlane`. From the source, `RADV_PERFTEST=ps_wave32,ge_wave32` should also avoid the bug on Linux without this PR, at whatever cost wave32 pixel shading has there. We haven't tested that in game yet. We'll add our before/after picture result here once our run is in. Written with Claude Code.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3556:upstream-pr/3556'
git switch 'upstream-pr/3556'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3556'
git switch 'upstream-pr/3556'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3556'
git switch 'upstream-pr/3556'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3556'
git switch 'main'
git merge --squash 'upstream-pr/3556'
git switch 'main'
git merge --ff-only 'upstream-pr/3556'
git switch 'main'
git merge 'upstream-pr/3556'
git push origin 'main'
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
Marvisak/VIctory!3556
No description provided.