Shaders: DPP16 row masks name the console's rows in host waves of 32 #233

Open
murillojndem wants to merge 1 commit from upstream-pr/233 into main
murillojndem commented 2026-11-29 22:27:18 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by murillojndem on 2026-11-29T22:27:18Z.


A DPP16 row mask names the console's rows of 16 lanes. dpp() took the row from lane_index(), the host lane. A console wave64 compute program on a host whose waves have at most 32 lanes runs in two host waves (halves), each one half of the console wave, so its console rows 2 and 3 are the second host wave's lanes 0 to 31, and they tested mask bits 0 and 1. With row_mask:0x3 the upper half was written, which RDNA2 leaves alone, and with 0xC neither half was. Only masks whose two halves agree (0x0, 0x5, 0xA, 0xF) came out right. Programs with DPP go to halves whenever nothing in them crosses the halves (lower, where wave becomes 32), so this reaches DPP code on 32-lane hosts such as NVIDIA's; hosts with 64-lane waves run such programs whole and are not affected.

Change (emit/lower.rs, dpp()): under halves, the row index is taken from the console lane, console_thread() & 63 (the host wave's first console thread from wave_base, plus the host lane). The bank index stays by the host lane, since banks lie inside a host wave. Native waves are unchanged.

Found by an independent review of #232, which leaves this alone. That PR's tests are wave32 only.

Tests:

  • emit::wave64_tests::dpp_row_masks_name_the_consoles_rows_in_host_waves_of_32: a 64-thread wave64 program, lowered for host waves of 32, runs v_mov_b32_dpp v1, v0 quad_perm:[1,0,3,2] with row masks 0x3, 0xC, 0x5 and 0x9 over v1 = 0xdead0000 | lane, and stores every lane's v1. Each lane must hold its quad partner's lane number where its console row is in the mask, and its own v1 elsewhere. On main, on an RX 7900 XT, it fails at row_mask 0x3 (lanes 32 to 63 written: lane 32 holds 0x21). With this change it passes.
  • victory-shader --lib on the RX 7900 XT and WARP with one test thread: 238 passed, 2 failed, 4 ignored (main: 237, 2, 4). The 2 failures (emit::rect::tests::rectangles_are_drawn_whole and the_rectangle_stage_is_a_geometry_shader) fail on main too.
  • Clippy with -D warnings, with and without --all-features, and cargo xtask policy pass. It merges with #232.

Limits:

  • The test runs where the hardware device takes waves of 32; elsewhere it reports that it did not run. Masks 0x3, 0xC and 0x9 tell main and this apart; 0x5 passes on both.
  • The same review points to two older places that take the host lane for the console's under halves without exchange, not changed here: lane_bit (a lane's bit of a 64-bit mask held as a number, as v_cndmask_b32 reads one; console lanes 32 to 63 read the low dword), and v_readfirstlane_b32, which reads the host wave's own first lane. They need tests of their own.

Generated with Claude Code

<!-- greyfinch-sync:DexNom/VIctory:issue:5555813500 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/233). Originally posted by [murillojndem](https://github.com/murillojndem) on 2026-11-29T22:27:18Z. --- A DPP16 row mask names the console's rows of 16 lanes. `dpp()` took the row from `lane_index()`, the host lane. A console wave64 compute program on a host whose waves have at most 32 lanes runs in two host waves (`halves`), each one half of the console wave, so its console rows 2 and 3 are the second host wave's lanes 0 to 31, and they tested mask bits 0 and 1. With `row_mask:0x3` the upper half was written, which RDNA2 leaves alone, and with `0xC` neither half was. Only masks whose two halves agree (0x0, 0x5, 0xA, 0xF) came out right. Programs with DPP go to `halves` whenever nothing in them crosses the halves (`lower`, where `wave` becomes 32), so this reaches DPP code on 32-lane hosts such as NVIDIA's; hosts with 64-lane waves run such programs whole and are not affected. Change (`emit/lower.rs`, `dpp()`): under `halves`, the row index is taken from the console lane, `console_thread() & 63` (the host wave's first console thread from `wave_base`, plus the host lane). The bank index stays by the host lane, since banks lie inside a host wave. Native waves are unchanged. Found by an independent review of #232, which leaves this alone. That PR's tests are wave32 only. Tests: - `emit::wave64_tests::dpp_row_masks_name_the_consoles_rows_in_host_waves_of_32`: a 64-thread wave64 program, lowered for host waves of 32, runs `v_mov_b32_dpp v1, v0 quad_perm:[1,0,3,2]` with row masks 0x3, 0xC, 0x5 and 0x9 over v1 = 0xdead0000 | lane, and stores every lane's v1. Each lane must hold its quad partner's lane number where its console row is in the mask, and its own v1 elsewhere. On main, on an RX 7900 XT, it fails at row_mask 0x3 (lanes 32 to 63 written: lane 32 holds 0x21). With this change it passes. - `victory-shader --lib` on the RX 7900 XT and WARP with one test thread: 238 passed, 2 failed, 4 ignored (main: 237, 2, 4). The 2 failures (`emit::rect::tests::rectangles_are_drawn_whole` and `the_rectangle_stage_is_a_geometry_shader`) fail on main too. - Clippy with `-D warnings`, with and without `--all-features`, and `cargo xtask policy` pass. It merges with #232. Limits: - The test runs where the hardware device takes waves of 32; elsewhere it reports that it did not run. Masks 0x3, 0xC and 0x9 tell main and this apart; 0x5 passes on both. - The same review points to two older places that take the host lane for the console's under `halves` without `exchange`, not changed here: `lane_bit` (a lane's bit of a 64-bit mask held as a number, as `v_cndmask_b32` reads one; console lanes 32 to 63 read the low dword), and `v_readfirstlane_b32`, which reads the host wave's own first lane. They need tests of their own. Generated with [Claude Code](https://claude.com/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/233:upstream-pr/233'
git switch 'upstream-pr/233'

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