shader: lower v_permlanex16_b32 #404

Closed
github-bot wants to merge 1 commit from gh-pr/404/head into gh-pr/404/base
Owner

@⁠NolanCotter on GitHub · 2026-11-24 02:57 UTC · original
NolanCotter:permlanex16-b32 → main · +93 −0 · 1 files · 1 commits · closed without merging

Summary

  • Lowers v_permlanex16_b32 in valu_op: each lane reads src0 of a lane in the other row of 16 of its 32-lane half, the pick taken from nibble i of the {src2, src1} selector — the same math wave.rs already uses to model the op, built through the cross_lane/read_lane machinery v_writelane_b32 uses.
  • v_permlane16_b32 (same row, PR #98's wave.rs model) stays refused; a follow-up can share this arm's index math.
  • The console_lanes detector now covers the v_permlane family so a compute program using the op gets console lane relabeling.
  • opsel != 0 is rejected rather than silently ignored.
  • Adds a smoke test that lowers a hand-encoded compute program (v_permlanex16_b32 feeding an LDS store); it failed on main with the write missing and passes now.

Test plan

  • cargo test -p victory-shader — 57 passed (was 56 + 1 failing before the fix)
  • cargo clippy -p victory-shader — clean
  • cargo fmt --check — clean

AI-assisted change (Devin). Verified against the lane math already in emit/wave.rs; no game shaders were used.

Generated with Devin

**@⁠NolanCotter** on GitHub · 2026-11-24 02:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/404) `NolanCotter:permlanex16-b32` → `main` · +93 −0 · 1 files · 1 commits · closed without merging ## Summary - Lowers `v_permlanex16_b32` in `valu_op`: each lane reads `src0` of a lane in the *other* row of 16 of its 32-lane half, the pick taken from nibble `i` of the `{src2, src1}` selector — the same math `wave.rs` already uses to model the op, built through the `cross_lane`/`read_lane` machinery `v_writelane_b32` uses. - `v_permlane16_b32` (same row, PR #98's wave.rs model) stays refused; a follow-up can share this arm's index math. - The `console_lanes` detector now covers the `v_permlane` family so a compute program using the op gets console lane relabeling. - `opsel != 0` is rejected rather than silently ignored. - Adds a smoke test that lowers a hand-encoded compute program (`v_permlanex16_b32` feeding an LDS store); it failed on main with the write missing and passes now. #### Test plan - [x] `cargo test -p victory-shader` — 57 passed (was 56 + 1 failing before the fix) - [x] `cargo clippy -p victory-shader` — clean - [x] `cargo fmt --check` — clean AI-assisted change (Devin). Verified against the lane math already in `emit/wave.rs`; no game shaders were used. Generated with [Devin](https://devin.ai)
Each lane reads src0 of a lane in the other row of 16 of its 32-lane
half, the pick taken from nibble i of the {src2, src1} selector. The
lowering mirrors the whole-wave model wave.rs already uses for the op,
through the same cross_lane/read_lane machinery as v_writelane_b32, and
the console_lanes detector now covers the v_permlane family so host
lanes are relabeled where the op appears.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:02:39 +00:00
github-bot closed this pull request 2026-11-26 04:02:39 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 04:32 UTC · original

Thanks @⁠NolanCotter for adding v_permlanex16_b32 lowering. I tested head d505b0e4c5e3d29a7d027e639d70651386f71b2a with:

cargo test --locked -p victory-shader --lib permlanex16_reads_a_lane_of_the_other_row -- --test-threads=1

Result: 1 passed, 0 failed (69 filtered out). The synthetic wave test verifies the instruction reads the selected lane from the other 16-lane row. It checks the lowering model, not behavior in an executing title.

**@⁠jeremygold02** on GitHub · 2026-11-24 04:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/404#issuecomment-7122115466) Thanks @⁠NolanCotter for adding `v_permlanex16_b32` lowering. I tested head `d505b0e4c5e3d29a7d027e639d70651386f71b2a` with: ``` cargo test --locked -p victory-shader --lib permlanex16_reads_a_lane_of_the_other_row -- --test-threads=1 ``` Result: 1 passed, 0 failed (69 filtered out). The synthetic wave test verifies the instruction reads the selected lane from the other 16-lane row. It checks the lowering model, not behavior in an executing title.
Author
Owner

@⁠Lyrnc on GitHub · 2026-11-24 06:02 UTC · original

RDNA2 hardware check of the lane rule: matches.

AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. A HIP kernel (assembled by the AMD driver's amd_comgr) runs v_permlanex16_b32 vD, v4, s20, s21 with lane i holding i + 1. There are 16 selectors (identity, reverse, all-0, all-F, a pair swap, 11 random), in wave32 and wave64 kernels, without op_sel, all lanes active. RDNA2 desktop silicon, not the console's. No game data.

Lane i reads lane (i & ~31) | ((i & 16) ^ 16) | nibble_(i & 15)({src2, src1}), that is, the other row of its own 32-lane half: 16/16 selectors in wave32 and 16/16 in wave64. The same run checked v_permlane16_b32 (own row) for #576, also 32/32.

AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run.

**@⁠Lyrnc** on GitHub · 2026-11-24 06:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/404#issuecomment-7123515499) RDNA2 hardware check of the lane rule: **matches.** AMD Radeon iGPU of a Ryzen 7 9800X3D, **gfx1036 (RDNA2)**, AMD driver 32.0.21042.62, Windows 11 Pro 26200. A HIP kernel (assembled by the AMD driver's amd_comgr) runs `v_permlanex16_b32 vD, v4, s20, s21` with lane `i` holding `i + 1`. There are 16 selectors (identity, reverse, all-0, all-F, a pair swap, 11 random), in wave32 and wave64 kernels, without `op_sel`, all lanes active. RDNA2 desktop silicon, not the console's. No game data. Lane `i` reads lane `(i & ~31) | ((i & 16) ^ 16) | nibble_(i & 15)({src2, src1})`, that is, the other row of its own 32-lane half: 16/16 selectors in wave32 and 16/16 in wave64. The same run checked `v_permlane16_b32` (own row) for #576, also 32/32. AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run.
Author
Owner

@⁠slint6614-dev on GitHub · 2026-11-24 10:42 UTC · original

Measured on the full retail shader pack (26,503 containers) with victory translate --validate --pipelines (pipelines on an AMD RX 9070, Windows 11, dxil.dll from SDK 10.0.26100). Counts are emitted / validated / pipelines. Merged locally with current main c7a5f49 (main: CS 1440 / 1417).

CS 1441 / 1418 (+1 validated); VS/PS and MS unchanged.

**@⁠slint6614-dev** on GitHub · 2026-11-24 10:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/404#issuecomment-7129140065) Measured on the full retail shader pack (26,503 containers) with `victory translate --validate --pipelines` (pipelines on an AMD RX 9070, Windows 11, dxil.dll from SDK 10.0.26100). Counts are emitted / validated / pipelines. Merged locally with current main c7a5f49 (main: CS 1440 / 1417). CS 1441 / **1418** (+1 validated); VS/PS and MS unchanged.
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 10:52 UTC · original

We ran the DXIL emitted by d505b0e on an RTX 4090 under Wine/vkd3d-proton 3.2. For an all-active Wave32 guest, lane i held 29 + i and the two selector words were 0x5312e4b0 and 0x98fc6ad7. All 32 output words matched the cross-row rule measured on RDNA2 above. For example, lanes 0 and 16 returned 45 and 29, and lanes 1 and 17 returned 56 and 40. Microsoft DXV accepted the emitted shader.

A separate 64-thread Wave64 guest fixture also validated, but the emitted shader requested WaveSize=64. This adapter advertises only 32, so pipeline creation was refused and no Wave64 result was recorded. These controls used synthetic inputs; the single newly validated title program in the RX 9070 report has no pixel or buffer readback here.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 10:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/404#issuecomment-7129367699) We ran the DXIL emitted by `d505b0e` on an RTX 4090 under Wine/vkd3d-proton 3.2. For an all-active Wave32 guest, lane `i` held `29 + i` and the two selector words were `0x5312e4b0` and `0x98fc6ad7`. All 32 output words matched the cross-row rule measured on RDNA2 above. For example, lanes 0 and 16 returned 45 and 29, and lanes 1 and 17 returned 56 and 40. Microsoft DXV accepted the emitted shader. A separate 64-thread Wave64 guest fixture also validated, but the emitted shader requested `WaveSize=64`. This adapter advertises only 32, so pipeline creation was refused and no Wave64 result was recorded. These controls used synthetic inputs; the single newly validated title program in the RX 9070 report has no pixel or buffer readback here.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:02 UTC · original

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #1014. v_permlanex16_b32 through waveReadLaneAt; #1014 lowers it and v_permlane16_b32 with the same lane math in one change, without the three-PR stack.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/404#issuecomment-7148073423) Automated triage for the maintainers. Closing because another open pull request covers the same change. See #1014. v_permlanex16_b32 through waveReadLaneAt; #1014 lowers it and v_permlane16_b32 with the same lane math in one change, without the three-PR stack. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!404
No description provided.