lower: lower v_permlanex16_b32 to waveReadLaneAt #1134

Closed
bitzin-dev wants to merge 1 commit from upstream-pr/1134 into main
bitzin-dev commented 2026-11-24 16:06:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by bitzin-dev on 2026-11-24T16:06:14Z.


Implements lowering for RDNA2 VOP3 opcode v_permlanex16_b32 (Vector Permute Lane Extended 16, 32-bit).

Background

In RDNA2, v_permlanex16_b32 gathers across adjacent 16-lane rows (row 0 <-> row 1, row 2 <-> row 3) using a 64-bit selector composed of scalar operands {s2, s1}. For each 16-lane row, lane i (0..15) extracts 4-bit nibble i:

  • Lanes 0..7 index nibbles 0..7 of s1
  • Lanes 8..15 index nibbles 0..7 of s2

The target lane within the alternate row is alt_row | pick, where alt_row = (lane & !31) | ((lane & 16) ^ 16) and pick = (sel_word >> ((lane & 7) * 4)) & 15. The value is then read via waveReadLaneAt.i32.

Validation

  • Validated on full retail shader pack (victory translate --validate "D:\GTA 6\shaders.rpf"):
    • Resolves rejection of deferred_tiled:CS_WaterTransmittanceOpticalDepthProcessing_44443e79_Wrapped Cs (at 0xd00).
    • Emitted compute programs validated by dxil.dll increased from 1,417 to 1,418 (+1).
    • 0 invalid bitcode errors remaining.
  • All 120 unit tests pass (cargo test -p victory-shader).
  • cargo xtask policy passes cleanly.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6586084224 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1134). Originally posted by [bitzin-dev](https://github.com/bitzin-dev) on 2026-11-24T16:06:14Z. --- Implements lowering for RDNA2 VOP3 opcode `v_permlanex16_b32` (Vector Permute Lane Extended 16, 32-bit). ### Background In RDNA2, `v_permlanex16_b32` gathers across adjacent 16-lane rows (row 0 <-> row 1, row 2 <-> row 3) using a 64-bit selector composed of scalar operands `{s2, s1}`. For each 16-lane row, lane `i` (0..15) extracts 4-bit nibble `i`: - Lanes 0..7 index nibbles 0..7 of `s1` - Lanes 8..15 index nibbles 0..7 of `s2` The target lane within the alternate row is `alt_row | pick`, where `alt_row = (lane & !31) | ((lane & 16) ^ 16)` and `pick = (sel_word >> ((lane & 7) * 4)) & 15`. The value is then read via `waveReadLaneAt.i32`. ### Validation - Validated on full retail shader pack (`victory translate --validate "D:\GTA 6\shaders.rpf"`): - Resolves rejection of `deferred_tiled:CS_WaterTransmittanceOpticalDepthProcessing_44443e79_Wrapped Cs` (at `0xd00`). - Emitted compute programs validated by `dxil.dll` increased from 1,417 to 1,418 (+1). - 0 invalid bitcode errors remaining. - All 120 unit tests pass (`cargo test -p victory-shader`). - `cargo xtask policy` passes cleanly.
upstream-sync closed this pull request 2026-11-24 17:03:25 +00:00
catminou4 commented 2026-11-24 17:03:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T16:29:02Z.

Review: COMMENTED


This implements only v_permlanex16_b32; #1014 covers both v_permlane16_b32 and v_permlanex16_b32 with equivalent math, plus the cross-lane guard-list entry this PR lacks, plus a lowering test. Suggest closing in favor of #1014 (or rebasing to just the delta if the author prefers the separate structure). Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, cargo test -p <crate> --locked. Shader execution tests (valu_tests/host) are #[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. victory-shader: 96 passed, 0 failed on this head.

<!-- greyfinch-sync:Marvisak/VIctory:review:6043263824 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1134#pullrequestreview-6043263824). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T16:29:02Z. **Review:** COMMENTED --- This implements only v_permlanex16_b32; #1014 covers both v_permlane16_b32 and v_permlanex16_b32 with equivalent math, plus the cross-lane guard-list entry this PR lacks, plus a lowering test. Suggest closing in favor of #1014 (or rebasing to just the delta if the author prefers the separate structure). Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, `cargo test -p <crate> --locked`. Shader execution tests (valu_tests/host) are `#[cfg(all(test, windows))]`, so macOS covers lowering/decode/unit tests only. victory-shader: 96 passed, 0 failed on this head.
bitzin-dev commented 2026-11-24 17:04:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by bitzin-dev on 2026-11-24T16:31:20Z.


Thanks for pointing that out, @catminou4! Didn't catch that #1014 was opened just about an hour before. It definitely makes sense to close this in favor of #1014 since it handles both v_permlane16_b32 and v_permlanex16_b32 together with the cross-lane guard list check. Closing!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137795899 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1134#issuecomment-7137795899). Originally posted by [bitzin-dev](https://github.com/bitzin-dev) on 2026-11-24T16:31:20Z. --- Thanks for pointing that out, @catminou4! Didn't catch that #1014 was opened just about an hour before. It definitely makes sense to close this in favor of #1014 since it handles both `v_permlane16_b32` and `v_permlanex16_b32` together with the cross-lane guard list check. Closing!

Pull request closed

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!1134
No description provided.