victory-shader: lower v_permlane16_b32 and v_permlanex16_b32 #1014

Closed
bartikele wants to merge 1 commit from upstream-pr/1014 into main
bartikele commented 2026-11-24 15:03:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by bartikele on 2026-11-24T15:03:18Z.


Adds DXIL lowering for \ _permlane16_b32\ and \ _permlanex16_b32\ in \ ictory-shader:

  • Marks both instructions for \console_lanes\ so host lane order matches the console.
  • Checks \cross_lane(false)\ and lowers via \dx.op.waveGetLaneIndex\ + \dx.op.waveReadLaneAt.i32.
  • Includes unit test \permlane16_lowers.

Verified with \cargo clippy -p victory-shader --all-targets --locked -- -D warnings, \cargo test -p victory-shader --locked, \cargo xtask policy, and \ ictory translate --validate.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6584792431 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1014). Originally posted by [bartikele](https://github.com/bartikele) on 2026-11-24T15:03:18Z. --- Adds DXIL lowering for \ _permlane16_b32\ and \ _permlanex16_b32\ in \ ictory-shader\: - Marks both instructions for \console_lanes\ so host lane order matches the console. - Checks \cross_lane(false)\ and lowers via \dx.op.waveGetLaneIndex\ + \dx.op.waveReadLaneAt.i32\. - Includes unit test \permlane16_lowers\. Verified with \cargo clippy -p victory-shader --all-targets --locked -- -D warnings\, \cargo test -p victory-shader --locked\, \cargo xtask policy\, and \ ictory translate --validate\.
Zipettte commented 2026-11-24 16:05:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T15:40:25Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 9d1c299: cargo test -p victory-shader passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136420825 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1014#issuecomment-7136420825). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T15:40:25Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 9d1c299: `cargo test -p victory-shader` passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
shortselow-byte commented 2026-11-24 16:05:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by shortselow-byte on 2026-11-24T15:51:35Z.


This PR has no CI run yet, so I ran the CI's checks at head 9d1c299 (on main ffe310e): Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2).

  • cargo test --workspace --locked -- --test-threads=1: 343 passed, 0 failed (GPU tests on the AMD device and WARP).
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and with --all-features: clean.
  • cargo xtask policy: ok.

Review of the lowering against the ISA's description: the 4-bit select per lane (lanes 0-7 from s1, 8-15 from s2), the own row for v_permlane16_b32 and the other row of the 32-lane pair for v_permlanex16_b32 all look right to me.

Two things I could not confirm:

  • op_sel is not read. On these two opcodes it carries FI (op_sel[0]) and BOUND_CTRL (op_sel[1]), which decide what a lane gets when its source lane is inactive. With every lane active it makes no difference; with inactive source lanes, waveReadLaneAt returns whatever the host gives.
  • permlane16_lowers only checks that the instruction lowers, not the lanes it reads. valu_tests runs one thread, so a result check would need a multi-lane harness like waterfall_tests.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7136733278 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1014#issuecomment-7136733278). Originally posted by [shortselow-byte](https://github.com/shortselow-byte) on 2026-11-24T15:51:35Z. --- This PR has no CI run yet, so I ran the CI's checks at head `9d1c299` (on `main` `ffe310e`): Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2). - `cargo test --workspace --locked -- --test-threads=1`: 343 passed, 0 failed (GPU tests on the AMD device and WARP). - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and with `--all-features`: clean. - `cargo xtask policy`: ok. Review of the lowering against the ISA's description: the 4-bit select per lane (lanes 0-7 from `s1`, 8-15 from `s2`), the own row for `v_permlane16_b32` and the other row of the 32-lane pair for `v_permlanex16_b32` all look right to me. Two things I could not confirm: - `op_sel` is not read. On these two opcodes it carries `FI` (`op_sel[0]`) and `BOUND_CTRL` (`op_sel[1]`), which decide what a lane gets when its source lane is inactive. With every lane active it makes no difference; with inactive source lanes, `waveReadLaneAt` returns whatever the host gives. - `permlane16_lowers` only checks that the instruction lowers, not the lanes it reads. `valu_tests` runs one thread, so a result check would need a multi-lane harness like `waterfall_tests`.
catminou4 commented 2026-11-24 17:02:58 +00:00 (Migrated from github.com)

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

Review: APPROVED


v_permlane16_b32 + v_permlanex16_b32 lowering: 16-lane row semantics check out (base = row aligned to 16, or 32 with bit-4 flipped for the x16 form; nibble selector from S1/S2 by lane bit 3; shift = (lane&7)*4; pick & 15). Also adds both ops to the cross-lane mask guard, which #1134 lacks. Includes a lowering smoke test. 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: 97 passed, 0 failed. Note: supersedes #1134, which implements only the x16 form without the guard entry or test.

<!-- greyfinch-sync:Marvisak/VIctory:review:6043262210 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1014#pullrequestreview-6043262210). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T16:28:56Z. **Review:** APPROVED --- v_permlane16_b32 + v_permlanex16_b32 lowering: 16-lane row semantics check out (base = row aligned to 16, or 32 with bit-4 flipped for the x16 form; nibble selector from S1/S2 by lane bit 3; shift = (lane&7)*4; pick & 15). Also adds both ops to the cross-lane mask guard, which #1134 lacks. Includes a lowering smoke test. 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: 97 passed, 0 failed. Note: supersedes #1134, which implements only the x16 form without the guard entry or test.
Marvisak commented 2026-11-25 01:08:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:32:57Z.


Automated triage for the maintainers.

Proposed close: superseded by #1737. Thanks for the rebase. It now merges cleanly, and CI check passes at c5d3a9a.

#1737 is built on this PR's own commit (9d1c299), so your lowering is kept there with your authorship. It adds the two things this branch is still missing:

  • op_sel handling: FI and BOUND_CTRL, which decide what a lane gets when its source lane is inactive. Here, op_sel is ignored in the new arm in Lower (crates/victory-shader/src/emit/lower.rs).
  • A multi-lane test (emit/permlane_tests.rs) that checks which lanes are read. Here, permlane16_lowers only checks that the instruction lowers.

#1737 also merges cleanly and is marked as a merge candidate. The lane selection in both PRs matches what main already assumes in emit/wave.rs.

This PR will be closed in 48 hours unless you push a change or a maintainer removes the triage: proposed close label.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148623103 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1014#issuecomment-7148623103). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:32:57Z. --- <!-- victory-triage v1 head=c5d3a9a54ce3943fa3d40fc82daf45ce3cee4f47 verdict=proposed-close at=2026-11-25T12:21:00Z --> Automated triage for the maintainers. **Proposed close: superseded by #1737.** Thanks for the rebase. It now merges cleanly, and CI `check` passes at `c5d3a9a`. #1737 is built on this PR's own commit (`9d1c299`), so your lowering is kept there with your authorship. It adds the two things this branch is still missing: - `op_sel` handling: `FI` and `BOUND_CTRL`, which decide what a lane gets when its source lane is inactive. Here, `op_sel` is ignored in the new arm in `Lower` (`crates/victory-shader/src/emit/lower.rs`). - A multi-lane test (`emit/permlane_tests.rs`) that checks which lanes are read. Here, `permlane16_lowers` only checks that the instruction lowers. #1737 also merges cleanly and is marked as a merge candidate. The lane selection in both PRs matches what `main` already assumes in `emit/wave.rs`. This PR will be closed in 48 hours unless you push a change or a maintainer removes the `triage: proposed close` label. --- _Generated by [Claude Code](https://claude.ai/code)_
bartikele commented 2026-11-25 12:03:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by bartikele on 2026-11-25T11:58:17Z.


Rebased onto current main (940d32f, resolving the test-list merge conflict in crates/victory-shader/src/emit/lower.rs) and extended permlane16_lowers to cover both _permlane16_b32 (

<!-- greyfinch-sync:Marvisak/VIctory:comment:7161747756 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1014#issuecomment-7161747756). Originally posted by [bartikele](https://github.com/bartikele) on 2026-11-25T11:58:17Z. --- Rebased onto current main (940d32f, resolving the test-list merge conflict in crates/victory-shader/src/emit/lower.rs) and extended permlane16_lowers to cover both _permlane16_b32 (
upstream-sync closed this pull request 2026-11-25 17:02:26 +00:00
bartikele commented 2026-11-25 17:05:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by bartikele on 2026-11-25T16:28:06Z.


Closing in favor of #1737, which builds on commit 9d1c299 (preserving authorship) and adds the missing EXEC/FI/BOUND_CTRL handling and multi-lane tests. Thanks everyone for the reviews!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168028909 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1014#issuecomment-7168028909). Originally posted by [bartikele](https://github.com/bartikele) on 2026-11-25T16:28:06Z. --- Closing in favor of #1737, which builds on commit 9d1c299 (preserving authorship) and adds the missing EXEC/FI/BOUND_CTRL handling and multi-lane tests. Thanks everyone for the reviews!

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