Shaders: v_writelane_b32 takes its lane from S1[4:0] (wave32) or S1[5:0] (wave64) #650

Open
11run11 wants to merge 1 commit from upstream-pr/650 into a-publier
11run11 commented 2026-11-27 16:28:07 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by 11run11 on 2026-11-27T16:28:07Z.


v_writelane_b32 selects its lane with S1[4:0] in a 32-lane wave and S1[5:0] in a 64-lane one. The lowering compared the console lane with the whole of S1, so a select past the wave (for example 33 in a 32-lane wave) matched no lane and the write was lost. The console writes lane 1.

The change

  • emit/lower.rs: the v_writelane_b32 lane select is masked to the console wave (wave() - 1) before the comparison.
  • TRANSLATOR_VERSION 2 → 3. #634 makes the same bump, so whichever lands second needs the next number.
  • New test lane_selects_past_the_wave_wrap (emit/valu_tests.rs, hardware, because WARP refuses wave-size-32 cross-lane code). A read of lane 33 gives lane 1's value; this already wrapped on the host, and the test now pins it. A write to lane 33 lands in lane 1. That half failed before (left: 0, right: 7 on an RX 9070 XT).

Tested

Windows 11, RX 9070 XT, Rust 1.98.1. cargo test -p victory-shader: 303 passed, 0 failed. size_tests::the_record_count_of_a_structured_buffer_read_by_index crashes the process on this machine with or without the change, so I skipped it (see #634). cargo clippy -p victory-shader --all-targets --all-features -- -D warnings is clean.

The bug was first reported as AvatarManz #404. This implementation is written independently from the ISA definition.

CI

Belobug's own ci.yml, unmodified, passes on this branch in my fork (Clippy with -D warnings, default and diagnostics tests): https://github.com/11run11/VIctory-Belobug-11run/actions/runs/46032477888 (commit 91666aa).

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:issue:5529913553 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/650). Originally posted by [11run11](https://github.com/11run11) on 2026-11-27T16:28:07Z. --- `v_writelane_b32` selects its lane with S1[4:0] in a 32-lane wave and S1[5:0] in a 64-lane one. The lowering compared the console lane with the whole of S1, so a select past the wave (for example 33 in a 32-lane wave) matched no lane and the write was lost. The console writes lane 1. ## The change - `emit/lower.rs`: the `v_writelane_b32` lane select is masked to the console wave (`wave() - 1`) before the comparison. - `TRANSLATOR_VERSION` 2 → 3. #634 makes the same bump, so whichever lands second needs the next number. - New test `lane_selects_past_the_wave_wrap` (`emit/valu_tests.rs`, hardware, because WARP refuses wave-size-32 cross-lane code). A read of lane 33 gives lane 1's value; this already wrapped on the host, and the test now pins it. A write to lane 33 lands in lane 1. That half failed before (`left: 0, right: 7` on an RX 9070 XT). ## Tested Windows 11, RX 9070 XT, Rust 1.98.1. `cargo test -p victory-shader`: 303 passed, 0 failed. `size_tests::the_record_count_of_a_structured_buffer_read_by_index` crashes the process on this machine with or without the change, so I skipped it (see #634). `cargo clippy -p victory-shader --all-targets --all-features -- -D warnings` is clean. The bug was first reported as AvatarManz #404. This implementation is written independently from the ISA definition. ## CI Belobug's own `ci.yml`, unmodified, passes on this branch in my fork (Clippy with `-D warnings`, default and diagnostics tests): https://github.com/11run11/VIctory-Belobug-11run/actions/runs/46032477888 (commit 91666aa).
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/650:upstream-pr/650'
git switch 'upstream-pr/650'

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 'a-publier'
git merge --no-ff 'upstream-pr/650'
git switch 'upstream-pr/650'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/650'
git switch 'upstream-pr/650'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'upstream-pr/650'
git switch 'a-publier'
git merge --squash 'upstream-pr/650'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/650'
git switch 'a-publier'
git merge 'upstream-pr/650'
git push origin 'a-publier'
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
Belobug/VIctory-Belobug-AMD!650
No description provided.