shader: lower v_permlane16_b32 and v_permlanex16_b32 #30

Merged
claytonblythe merged 2 commits from upstream-pr/30 into main 2026-11-26 10:20:10 +00:00
claytonblythe commented 2026-11-26 10:13:37 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by claytonblythe on 2026-11-26T10:13:37Z.


Summary

During Story Mode world loading (frame 2788 in --console series-s), two compute shaders were refused with GFX10 code: v_permlane16_b32 is not supported.

This change adds support for v_permlane16_b32 (and general VALU lowering for v_permlanex16_b32 outside whole-wave sections):

  • crates/victory-shader/src/emit/wave.rs: handles v_permlane16_b32 alongside v_permlanex16_b32 in whole-wave reduction simulation (same 16-lane row vs cross-row in the same 32-lane half).
  • crates/victory-shader/src/emit/lower.rs:
    • Marks compute shaders using v_permlane* as requiring console_lanes.
    • Lowers v_permlane16_b32 and v_permlanex16_b32 in valu_op using read_in_half (dx.op.waveReadLaneAt), since both stay within the lane's 32-lane half and require no cross-half LDS exchange on wave32 hosts (Apple Silicon Metal).
    • Handles fi:0 inactive-lane fallback (bound_ctrl:1 → 0, bound_ctrl:0 → destination's old value) via waveActiveBallot when guarded.
  • crates/victory-shader/src/emit/wave32_tests.rs: adds permlane16_and_permlanex16_lower_within_host32_half verifying wave32 lowering with 0 exchange barriers.

Verification

  • cargo test -p victory-shader --lib — 216 passed, 0 failed.
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings — 0 warnings.
  • cargo xtask policy — 363 files ok.
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6624371655 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/30). Originally posted by [claytonblythe](https://github.com/claytonblythe) on 2026-11-26T10:13:37Z. --- ## Summary During Story Mode world loading (frame 2788 in `--console series-s`), two compute shaders were refused with `GFX10 code: v_permlane16_b32 is not supported`. This change adds support for `v_permlane16_b32` (and general VALU lowering for `v_permlanex16_b32` outside whole-wave sections): - `crates/victory-shader/src/emit/wave.rs`: handles `v_permlane16_b32` alongside `v_permlanex16_b32` in whole-wave reduction simulation (same 16-lane row vs cross-row in the same 32-lane half). - `crates/victory-shader/src/emit/lower.rs`: - Marks compute shaders using `v_permlane*` as requiring `console_lanes`. - Lowers `v_permlane16_b32` and `v_permlanex16_b32` in `valu_op` using `read_in_half` (`dx.op.waveReadLaneAt`), since both stay within the lane's 32-lane half and require no cross-half LDS exchange on wave32 hosts (Apple Silicon Metal). - Handles `fi:0` inactive-lane fallback (`bound_ctrl:1` → `0`, `bound_ctrl:0` → destination's old value) via `waveActiveBallot` when guarded. - `crates/victory-shader/src/emit/wave32_tests.rs`: adds `permlane16_and_permlanex16_lower_within_host32_half` verifying wave32 lowering with 0 exchange barriers. ## Verification - `cargo test -p victory-shader --lib` — 216 passed, 0 failed. - `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` — 0 warnings. - `cargo xtask policy` — 363 files ok.
LakshanSivakumar commented 2026-11-26 10:17:35 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T10:17:35Z.

Review: APPROVED


Reviewed and tested on top of current main together with #29: all tests including the new wave32 permlane test, clippy (Windows target) and policy pass. The row/nibble selection matches the ISA (lanes 8-15 take src2's nibbles), and FI/bound_ctrl map to op_sel[0]/[1] as expected. Follow-up when convenient: a value-level test (e.g. a WARP compute run on Windows CI) for the inactive-lane fallback would be nice, since the current test only checks the lowering.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6072263012 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/30#pullrequestreview-6072263012). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T10:17:35Z. **Review:** APPROVED --- Reviewed and tested on top of current main together with #29: all tests including the new wave32 permlane test, clippy (Windows target) and policy pass. The row/nibble selection matches the ISA (lanes 8-15 take src2's nibbles), and FI/bound_ctrl map to op_sel[0]/[1] as expected. Follow-up when convenient: a value-level test (e.g. a WARP compute run on Windows CI) for the inactive-lane fallback would be nice, since the current test only checks the lowering.
claytonblythe commented 2026-11-26 10:19:19 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by claytonblythe on 2026-11-26T10:19:19Z.


Live-tested on a 16 GB Apple M4 (--console series-s, --headless, VICTORY_GUESS_GRAPHICS=1) on top of origin/main (a2940ab) + PRs #25/#28:

  • 0 refused shaders across the entire 240 s Story Mode run (both previously refused v_permlane16_b32 compute shaders at frame 2788 now translate and compile on Metal).
  • Reached frame 2880+ (recorded=16593 encoded=16593 no_pipeline=0 no_texture=0).
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7189209190 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/30#issuecomment-7189209190). Originally posted by [claytonblythe](https://github.com/claytonblythe) on 2026-11-26T10:19:19Z. --- Live-tested on a 16 GB Apple M4 (`--console series-s`, `--headless`, `VICTORY_GUESS_GRAPHICS=1`) on top of `origin/main` (`a2940ab`) + PRs #25/#28: - **0** refused shaders across the entire 240 s Story Mode run (both previously refused `v_permlane16_b32` compute shaders at frame 2788 now translate and compile on Metal). - Reached frame 2880+ (`recorded=16593 encoded=16593 no_pipeline=0 no_texture=0`).
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
LakshanSivakumar/Native-Victory-macOS!30
No description provided.