Shaders: model v_permlane16_b32 in whole-wave sections #98

Open
tedin7 wants to merge 1 commit from upstream-pr/98 into main
tedin7 commented 2026-11-24 00:28:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tedin7 on 2026-11-24T00:28:00Z.


What

  • Whole-wave sections (emit/wave.rs): model v_permlane16_b32 next to v_permlanex16_b32. Lane i of a row picks nibble i of {src2, src1} from its own row of 16 (permlanex16: from the other row of its 32).
  • Both only when every lane is active; with fi/bound_ctrl an inactive lane's read differs, so a partial EXEC stays unknown instead of being guessed.

Why

  • v_permlane16_b32 fell into the catch-all, so its result was Sym::Unknown and a reduction/prefix using it (a row total read from lane 15 of the own row) was no longer recognised as a wave operation.

Tested
Linux x86_64 only, synthetic code words (assembled with llvm-mc gfx1030), no game files:

  • New test permlane16_reads_the_lanes_own_row: a wave32 sum (DPP row reduction, permlane16 -1,-1, permlanex16 -1,-1, add) must come out as the active-lane AddU. Before the fix it fails (None), after it passes.
  • cargo test -j4 --manifest-path Cargo.toml -p victory-shader : 52 passed
  • cargo clippy -j4 -p victory-shader --tests : no warnings in wave.rs
  • rustfmt --check --edition 2024 crates/victory-shader/src/emit/wave.rs : clean

Not run: Windows runtime, any GPU, the HLSL diff tests.

Not touched: console_lanes in lower.rs does not list v_permlane* (it lists ds_swizzle, permute, v_mbcnt, v_readlane, DPP). Left alone to keep this to one change.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6571777301 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/98). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T00:28:00Z. --- What - Whole-wave sections (emit/wave.rs): model v_permlane16_b32 next to v_permlanex16_b32. Lane i of a row picks nibble i of {src2, src1} from its own row of 16 (permlanex16: from the other row of its 32). - Both only when every lane is active; with fi/bound_ctrl an inactive lane's read differs, so a partial EXEC stays unknown instead of being guessed. Why - v_permlane16_b32 fell into the catch-all, so its result was Sym::Unknown and a reduction/prefix using it (a row total read from lane 15 of the own row) was no longer recognised as a wave operation. Tested Linux x86_64 only, synthetic code words (assembled with llvm-mc gfx1030), no game files: - New test permlane16_reads_the_lanes_own_row: a wave32 sum (DPP row reduction, permlane16 -1,-1, permlanex16 -1,-1, add) must come out as the active-lane AddU. Before the fix it fails (None), after it passes. - cargo test -j4 --manifest-path Cargo.toml -p victory-shader : 52 passed - cargo clippy -j4 -p victory-shader --tests : no warnings in wave.rs - rustfmt --check --edition 2024 crates/victory-shader/src/emit/wave.rs : clean Not run: Windows runtime, any GPU, the HLSL diff tests. Not touched: console_lanes in lower.rs does not list v_permlane* (it lists ds_swizzle, permute, v_mbcnt, v_readlane, DPP). Left alone to keep this to one change.
DaviTostes commented 2026-11-24 06:54:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T00:36:35Z.


Tested f468457 stacked on #39 on Arch Linux x86_64, rustc 1.98.1: pass.

  • cargo test --workspace: 155 passed, 0 failed, 3 ignored; merge with #39 clean.
  • The PR adds one #[test] for the whole-wave v_permlane16_b32 section modelling, included in that run.
  • No game data used.

AI-assisted (DeepSeek V4.1 Flash coding agent).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7118247032 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7118247032). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T00:36:35Z. --- Tested `f468457` stacked on **#39** on **Arch Linux x86_64, rustc 1.98.1**: **pass**. - `cargo test --workspace`: **155 passed, 0 failed, 3 ignored**; merge with #39 clean. - The PR adds one `#[test]` for the whole-wave `v_permlane16_b32` section modelling, included in that run. - No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
lordon1a commented 2026-11-24 06:54:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by lordon1a on 2026-11-24T00:51:51Z.


Verified f468457a1 on Windows 11 (x86_64-pc-windows-gnullvm, rustc 1.100.0, applied cleanly to main@4c0bb89): pass.

  • cargo xtask policy: 151 files ok
  • cargo test -p victory-shader -- --skip v_med3_f32_matches_rdna2_with_nan: 69 passed, 0 failed.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7118514365 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7118514365). Originally posted by [lordon1a](https://github.com/lordon1a) on 2026-11-24T00:51:51Z. --- Verified `f468457a1` on Windows 11 (`x86_64-pc-windows-gnullvm`, `rustc 1.100.0`, applied cleanly to `main@4c0bb89`): **pass**. - `cargo xtask policy`: 151 files ok - `cargo test -p victory-shader -- --skip v_med3_f32_matches_rdna2_with_nan`: **69 passed, 0 failed**. AI-assisted.
mercuryVM commented 2026-11-24 09:37:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T09:37:28Z.

Review: APPROVED


Tested f468457 on Windows 11, RTX 5070, MSVC: the workspace passes (170 outside victory-shader; victory-shader --lib single-threaded: 58; older base). victory translate <title exe> --validate --pipelines gives the same counts before and after: 12 of 12 programs emitted, 12 validated, 12 pipelines.

  • v_permlane16_b32 picks within the lane's own row (l & !15) and v_permlanex16_b32 from the other row of its half. Both pick with nibble l & 15 of {src2, src1}, which is the RDNA2 definition.
  • Restricting both to exec == all is the right fix and also tightens the existing permlanex16 arm. With inactive lanes, what a lane reads depends on FI and BOUND_CTRL, so leaving it Unknown instead of guessing is correct.
  • The new test is a real console expansion of a wave32 sum (DPP row reduction, then permlane16 and permlanex16). It turns from None into Active(AddU).

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6036817059 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/98#pullrequestreview-6036817059). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T09:37:28Z. **Review:** APPROVED --- Tested f468457 on Windows 11, RTX 5070, MSVC: the workspace passes (170 outside `victory-shader`; `victory-shader --lib` single-threaded: 58; older base). `victory translate <title exe> --validate --pipelines` gives the same counts before and after: 12 of 12 programs emitted, 12 validated, 12 pipelines. - `v_permlane16_b32` picks within the lane's own row (`l & !15`) and `v_permlanex16_b32` from the other row of its half. Both pick with nibble `l & 15` of `{src2, src1}`, which is the RDNA2 definition. - Restricting both to `exec == all` is the right fix and also tightens the existing `permlanex16` arm. With inactive lanes, what a lane reads depends on FI and BOUND_CTRL, so leaving it `Unknown` instead of guessing is correct. - The new test is a real console expansion of a wave32 sum (DPP row reduction, then permlane16 and permlanex16). It turns from `None` into `Active(AddU)`. No issues found. AI-assisted (Claude Code).
zed6000 commented 2026-11-24 18:05:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by zed6000 on 2026-11-24T17:44:46Z.


Measured on real data. I merged this PR onto main ffe310e and ran victory translate --validate --list over shaders.rpf from a retail 1.0.2.1 dump, then compared the result with main program by program. This is part of the offline benchmark in #1247.

29 compute programs that translate and validate on main stop translating with this PR. All 29 now fail with:

emit: a whole-wave section step the simulation does not follow

That reason covers 5 programs on main and 51 with this PR. The PR gains no programs on this data.

The unit tests pass, as the earlier comments say. The failure shows up only on the title's own code: the new modelling makes the whole-wave simulation refuse sections that it accepted before. Shader names and code are not included, per the asset policy. I can check a revised version against the same data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7139643507 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7139643507). Originally posted by [zed6000](https://github.com/zed6000) on 2026-11-24T17:44:46Z. --- Measured on real data. I merged this PR onto main ffe310e and ran `victory translate --validate --list` over `shaders.rpf` from a retail 1.0.2.1 dump, then compared the result with main program by program. This is part of the offline benchmark in #1247. **29 compute programs that translate and validate on main stop translating with this PR.** All 29 now fail with: ``` emit: a whole-wave section step the simulation does not follow ``` That reason covers 5 programs on main and 51 with this PR. The PR gains no programs on this data. The unit tests pass, as the earlier comments say. The failure shows up only on the title's own code: the new modelling makes the whole-wave simulation refuse sections that it accepted before. Shader names and code are not included, per the asset policy. I can check a revised version against the same data.
zed6000 commented 2026-11-24 23:06:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by zed6000 on 2026-11-24T23:05:40Z.


Follow-up on main's new head 70564ae, with the same method (victory translate --validate --list on shaders.rpf 1.0.2.1, dxil.dll 1.8.2502, compared program by program). Merged onto 70564ae, this PR stops 44 compute programs that validate there from translating. That is up from 29 on ffe310e. All 44 now fail with:

emit: a whole-wave section step the simulation does not follow

It gains no programs. As noted on #1247, the losses disappear in integ/next only where this change was hand-merged with #439's emit/wave.rs. On top of #223, #233 and #320 alone, the losses remain. Offline counts only; no program names or data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147005730 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7147005730). Originally posted by [zed6000](https://github.com/zed6000) on 2026-11-24T23:05:40Z. --- Follow-up on main's new head `70564ae`, with the same method (`victory translate --validate --list` on `shaders.rpf` 1.0.2.1, dxil.dll 1.8.2502, compared program by program). Merged onto `70564ae`, this PR stops **44** compute programs that validate there from translating. That is up from 29 on `ffe310e`. All 44 now fail with: ``` emit: a whole-wave section step the simulation does not follow ``` It gains no programs. As noted on #1247, the losses disappear in `integ/next` only where this change was hand-merged with #439's `emit/wave.rs`. On top of #223, #233 and #320 alone, the losses remain. Offline counts only; no program names or data.
zed6000 commented 2026-11-25 01:07:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by zed6000 on 2026-11-25T00:24:49Z.


For the maintainers, alongside the triage above: the head it reviewed (f468457) is the head I measured offline, and it loses programs on the title's shaders. Merged onto 70564ae and compared program by program (victory translate --validate --list, shaders.rpf 1.0.2.1, dxil.dll 1.8.2502), 44 compute programs that validate on 70564ae stop translating. On ffe310e it was 29. They all fail with "a whole-wave section step the simulation does not follow", and the PR gains no programs.

The triage's behaviour note is the likely cause: v_permlanex16_b32 now gives an unknown result when EXEC is not full. Sections the simulation followed before therefore become unknown and are refused. The unit test only covers the full-EXEC case, so it passes. Keeping the previous v_permlanex16_b32 behaviour for partial EXEC, and adding v_permlane16_b32 only alongside it, may keep the new opcode without the losses. That's a guess from the note; I haven't tested it. Details are in the comments above and in #1247.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148483455 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7148483455). Originally posted by [zed6000](https://github.com/zed6000) on 2026-11-25T00:24:49Z. --- For the maintainers, alongside the triage above: the head it reviewed (`f468457`) is the head I measured offline, and it **loses programs on the title's shaders**. Merged onto `70564ae` and compared program by program (`victory translate --validate --list`, `shaders.rpf` 1.0.2.1, dxil.dll 1.8.2502), **44 compute programs that validate on `70564ae` stop translating**. On `ffe310e` it was 29. They all fail with "a whole-wave section step the simulation does not follow", and the PR gains no programs. The triage's behaviour note is the likely cause: `v_permlanex16_b32` now gives an unknown result when EXEC is not full. Sections the simulation followed before therefore become unknown and are refused. The unit test only covers the full-EXEC case, so it passes. Keeping the previous `v_permlanex16_b32` behaviour for partial EXEC, and adding `v_permlane16_b32` only alongside it, may keep the new opcode without the losses. That's a guess from the note; I haven't tested it. Details are in the comments above and in #1247.
zed6000 commented 2026-11-25 01:07:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by zed6000 on 2026-11-25T00:30:21Z.


Tested the guess above: it holds. On 70564ae + this PR, I changed one line in emit/wave.rs, so that the full-EXEC condition applies only to the newly modelled v_permlane16_b32 and v_permlanex16_b32 keeps main's behaviour:

-                    (Some(s1), Some(s2)) if exec == all => {
+                    (Some(s1), Some(s2)) if exec == all || n == "v_permlanex16_b32" => {

Result, program by program over shaders.rpf (1.0.2.1, dxil.dll 1.8.2502):

Build Change vs 70564ae
70564ae + this PR as is 0 gained, 44 lost
70564ae + this PR + the line above 0 gained, 0 lost: all 44 validate again

permlane16_reads_the_lanes_own_row still passes, as do the other wave tests, on an RX 7900 XTX.

The PR's reasoning, that fi/bound_ctrl decide what an inactive lane reads, may well be right for both opcodes. If so, the stricter rule for v_permlanex16_b32 is a separate change from adding v_permlane16_b32, and it costs 44 programs on this title. It might be better split out, perhaps decoding the opsel bits instead of refusing outright. Offline counts only; no program names or data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148578319 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7148578319). Originally posted by [zed6000](https://github.com/zed6000) on 2026-11-25T00:30:21Z. --- Tested the guess above: it holds. On `70564ae` + this PR, I changed one line in `emit/wave.rs`, so that the full-EXEC condition applies only to the newly modelled `v_permlane16_b32` and `v_permlanex16_b32` keeps main's behaviour: ```diff - (Some(s1), Some(s2)) if exec == all => { + (Some(s1), Some(s2)) if exec == all || n == "v_permlanex16_b32" => { ``` Result, program by program over `shaders.rpf` (1.0.2.1, dxil.dll 1.8.2502): | Build | Change vs `70564ae` | |---|---| | `70564ae` + this PR as is | 0 gained, **44 lost** | | `70564ae` + this PR + the line above | **0 gained, 0 lost**: all 44 validate again | `permlane16_reads_the_lanes_own_row` still passes, as do the other `wave` tests, on an RX 7900 XTX. The PR's reasoning, that `fi`/`bound_ctrl` decide what an inactive lane reads, may well be right for both opcodes. If so, the stricter rule for `v_permlanex16_b32` is a separate change from adding `v_permlane16_b32`, and it costs 44 programs on this title. It might be better split out, perhaps decoding the opsel bits instead of refusing outright. Offline counts only; no program names or data.
Marvisak commented 2026-11-25 01:07:59 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-shader/src/emit/wave.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148475628 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7148475628). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:24:22Z. --- <!-- victory-triage v1 head=f468457a18590bea0e9c21d630c5597fa4649517 verdict=needs-rebase at=2026-11-25T01:16:20Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-shader/src/emit/wave.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
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/98:upstream-pr/98'
git switch 'upstream-pr/98'

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 'main'
git merge --no-ff 'upstream-pr/98'
git switch 'upstream-pr/98'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/98'
git switch 'upstream-pr/98'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/98'
git switch 'main'
git merge --squash 'upstream-pr/98'
git switch 'main'
git merge --ff-only 'upstream-pr/98'
git switch 'main'
git merge 'upstream-pr/98'
git push origin 'main'
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!98
No description provided.