Shaders: model v_permlane16_b32 in whole-wave sections #98

Open
github-bot wants to merge 1 commit from github-bot/gh-98 into main AGit
Owner

@⁠tedin7 on GitHub · 2026-11-24 00:28 UTC · original
tedin7:vic-permlane16 → main · +58 −7 · 1 files · 1 commits · open

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.

**@⁠tedin7** on GitHub · 2026-11-24 00:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/98) `tedin7:vic-permlane16` → `main` · +58 −7 · 1 files · 1 commits · open 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.
A wave reduction that reads a row total with v_permlane16_b32 left the value unknown, so the wave operation was not recognised. It now picks within the lane own row, like v_permlanex16_b32 picks from the other row, and both only with every lane active (fi and bound_ctrl decide what an inactive lane reads).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:50:12 +00:00
github-bot referenced this pull request from a commit 2026-11-26 04:08:58 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 00:36 UTC · original

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).

**@⁠DaviTostes** on GitHub · 2026-11-24 00:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7118247032) 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).
Author
Owner

@⁠lordon1a on GitHub · 2026-11-24 00:51 UTC · original

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.

**@⁠lordon1a** on GitHub · 2026-11-24 00:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7118514365) 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.
Author
Owner

@⁠zed6000 on GitHub · 2026-11-24 17:44 UTC · original

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** on GitHub · 2026-11-24 17:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7139643507) 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.
Author
Owner

@⁠zed6000 on GitHub · 2026-11-24 23:05 UTC · original

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** on GitHub · 2026-11-24 23:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7147005730) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:24 UTC · original · edited 2026-11-25 01:16 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 00:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7148475628) · edited 2026-11-25 01:16 UTC <!-- 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)_
Author
Owner

@⁠zed6000 on GitHub · 2026-11-25 00:24 UTC · original

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** on GitHub · 2026-11-25 00:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7148483455) 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.
Author
Owner

@⁠zed6000 on GitHub · 2026-11-25 00:30 UTC · original

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.

**@⁠zed6000** on GitHub · 2026-11-25 00:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/98#issuecomment-7148578319) 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.
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/wave.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/98/head:github-bot/gh-98'
git switch 'github-bot/gh-98'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-98'
git switch 'github-bot/gh-98'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-98'
git switch 'github-bot/gh-98'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-98'
git switch 'main'
git merge --squash 'github-bot/gh-98'
git switch 'main'
git merge --ff-only 'github-bot/gh-98'
git switch 'main'
git merge 'github-bot/gh-98'
git push origin 'main'
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!98
No description provided.