Shaders: follow plain v_mov_b32 copies when pairing interpolations #1293

Closed
github-bot wants to merge 2 commits from gh-pr/1293/head into gh-pr/1293/base
Owner

@⁠mgunes1311-lab on GitHub · 2026-11-24 17:11 UTC · original
mgunes1311-lab:shader-interp-vgpr-copies → main · +337 −24 · 1 files · 2 commits · closed without merging

Follow plain VGPR-to-VGPR v_mov_b32 copies and agreeing phis when pairing pixel shader interpolations in crates/victory-shader/src/io.rs. Copy-based pairing is accepted only when the copies and both interpolation halves use the program entry EXEC mask.

Changes

  • Trace unmodified VGPR copies for barycentric i/j and the first-half accumulator; reject modifiers, SDWA, DPP, mismatched inputs, and empty copy/phi cycles.
  • Check both EXEC dwords for wave64. This conservative rule rejects changed/restored or loop-dependent masks unless they retain the entry SSA values, preventing inactive lanes' old destinations from being treated as copied values. Existing pairing without copies is unchanged.
  • Fix the invalid Reg::V(*reg) dereference in the f16 first-half match.
  • Cover plain copies, agreeing/mismatched phis, modified copies, f16/f32, wave32/wave64, and independently masked i, j, accumulator, p1, and p2 instructions.

Verification

  • cargo test -p victory-shader --target x86_64-pc-windows-msvc --locked io::: 7 passed.
  • cargo test -p victory-shader --target x86_64-pc-windows-msvc --all-features --locked: 123 passed, 0 failed, 1 benchmark ignored.
  • The new execution-mask regression fails with only the dereference fix applied and passes with the EXEC guard.
  • Workspace Clippy with all targets, both default and all features, and -D warnings: passed.
  • cargo run -p xtask --target x86_64-pc-windows-msvc --locked -- policy: 154 files passed.

The full workspace test run encountered victory-loader::crash::tests::unwinds_like_the_system_walk (stack frames differ by one). The same failure was reproduced with unchanged main-version loader and shader I/O code, so a green full-workspace run is not claimed. No in-game validation or performance improvement is claimed.

**@⁠mgunes1311-lab** on GitHub · 2026-11-24 17:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/1293) `mgunes1311-lab:shader-interp-vgpr-copies` → `main` · +337 −24 · 1 files · 2 commits · closed without merging Follow plain VGPR-to-VGPR `v_mov_b32` copies and agreeing phis when pairing pixel shader interpolations in `crates/victory-shader/src/io.rs`. Copy-based pairing is accepted only when the copies and both interpolation halves use the program entry EXEC mask. ### Changes - Trace unmodified VGPR copies for barycentric `i`/`j` and the first-half accumulator; reject modifiers, SDWA, DPP, mismatched inputs, and empty copy/phi cycles. - Check both EXEC dwords for wave64. This conservative rule rejects changed/restored or loop-dependent masks unless they retain the entry SSA values, preventing inactive lanes' old destinations from being treated as copied values. Existing pairing without copies is unchanged. - Fix the invalid `Reg::V(*reg)` dereference in the f16 first-half match. - Cover plain copies, agreeing/mismatched phis, modified copies, f16/f32, wave32/wave64, and independently masked i, j, accumulator, p1, and p2 instructions. ### Verification - `cargo test -p victory-shader --target x86_64-pc-windows-msvc --locked io::`: 7 passed. - `cargo test -p victory-shader --target x86_64-pc-windows-msvc --all-features --locked`: 123 passed, 0 failed, 1 benchmark ignored. - The new execution-mask regression fails with only the dereference fix applied and passes with the EXEC guard. - Workspace Clippy with all targets, both default and all features, and `-D warnings`: passed. - `cargo run -p xtask --target x86_64-pc-windows-msvc --locked -- policy`: 154 files passed. The full workspace test run encountered `victory-loader::crash::tests::unwinds_like_the_system_walk` (stack frames differ by one). The same failure was reproduced with unchanged main-version loader and shader I/O code, so a green full-workspace run is not claimed. No in-game validation or performance improvement is claimed.
Fix the invalid u8 dereference in the f16 pairing path. Restrict copy tracing and both interpolation halves to the entry EXEC mask, checking both halves for wave64. Unknown masks remain unsupported rather than treating partially written VGPRs as full copies.

Add f16/f32, wave32/wave64 regressions for i, j, accumulator, p1 and p2 mask changes. The regression fails without the EXEC guard. All-feature shader suite: 123 passed, 1 benchmark ignored. Workspace all-target/all-feature Clippy and asset policy passed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:26:39 +00:00
github-bot closed this pull request 2026-11-26 04:26:39 +00:00
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 17:30 UTC · original

Independent check of \971c075\ on Windows 11 / Rust 1.98.1 MSVC:

  • Build blocker (\error[E0614]): \crates/victory-shader/src/io.rs:563\ fails to compile because \Some(&Operand::Vector { reg, .. })\ already binds
    eg: u8\ by value, so \Reg::V(*reg)\ cannot be dereferenced:
    \\
    error[E0614]: type \u8\ cannot be dereferenced
    \\
    Changing \Reg::V(*reg)\ back to \Reg::V(reg)\ should unblock compilation so tests and clippy can run.

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 17:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1293#issuecomment-7139288670) Independent check of \971c075\ on **Windows 11 / Rust 1.98.1 MSVC**: - **Build blocker (\error[E0614]\)**: \crates/victory-shader/src/io.rs:563\ fails to compile because \Some(&Operand::Vector { reg, .. })\ already binds \ eg: u8\ by value, so \Reg::V(*reg)\ cannot be dereferenced: \\\ error[E0614]: type \u8\ cannot be dereferenced \\\ Changing \Reg::V(*reg)\ back to \Reg::V(reg)\ should unblock compilation so tests and clippy can run. *AI-assisted; synthetic tests only, no game files.*
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 19:28 UTC · original

Reviewed at head 6a9cc8f (two commits over ffe310e, worktree on the PR head, isolated target dir, Windows 11 / Rust 1.98.1). Findings, ranked:

1. The copy-following is conservative in exactly the right places. vgpr_copy only follows v_mov_b32 with every modifier field clear (neg/abs/neg_hi/opsel/opsel_hi/clamp/omod/SDWA/DPP all checked) and a single VGPR source — anything else stops the trace. Phi tracing requires all incoming args to resolve to the same barycentric (kind, index), and the cycle guard moved into sites/barycentric_from (seen) so loops terminate without silently dropping args.

2. The EXEC guard is the important part and it is correct. entry_exec requires the instruction to read the entry EXEC value (both EXEC halves on wave64) from p.inputs — so a loop's EXEC phi with the same SSA name but a different per-iteration mask fails the check, and a partial copy cannot let inactive lanes rejoin with the destination's old value. pair rejects a copied interpolation unless both halves (and every traced first-half site) use the entry mask. This addresses the unsound case where copy-following would pair halves computed under different masks.

3. Verified here. New tests in io.rs cover copy-following (interpolation_follows_vgpr_copies: v_mov_b32 v4,v0 / v5,v1 / acc copy v3,v2 pair into one Interpolated with first: [(0,2)]) and the EXEC-mask rejection. cargo test -p victory-shader --lib io:: 7 passed / 0 failed; full lib 123 passed / 0 failed / 1 ignored (22 s, GPU tests included).

4. Checks: cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings clean; cargo build --release -p victory builds; rustfmt --edition 2024 --check crates/victory-shader/src/io.rs fully clean (0 hunks).

5. Effect, not a defect: this widens pairing to shaders that move barycentrics/acc through plain copies before interpolating — previously those refused with "an interpolation with computed barycentrics". The refusal remains for anything that isn't a provably plain copy under the entry mask, so no unsound pairing is introduced.

Nothing found that would block this.

**@⁠adamdotpy** on GitHub · 2026-11-24 19:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1293#issuecomment-7142155268) Reviewed at head `6a9cc8f` (two commits over `ffe310e`, worktree on the PR head, isolated target dir, Windows 11 / Rust 1.98.1). Findings, ranked: **1. The copy-following is conservative in exactly the right places.** `vgpr_copy` only follows `v_mov_b32` with every modifier field clear (neg/abs/neg_hi/opsel/opsel_hi/clamp/omod/SDWA/DPP all checked) and a single VGPR source — anything else stops the trace. Phi tracing requires *all* incoming args to resolve to the same barycentric `(kind, index)`, and the cycle guard moved into `sites`/`barycentric_from` (`seen`) so loops terminate without silently dropping args. **2. The EXEC guard is the important part and it is correct.** `entry_exec` requires the instruction to read the *entry* EXEC value (both EXEC halves on wave64) from `p.inputs` — so a loop's EXEC phi with the same SSA name but a different per-iteration mask fails the check, and a partial copy cannot let inactive lanes rejoin with the destination's old value. `pair` rejects a copied interpolation unless both halves (and every traced first-half site) use the entry mask. This addresses the unsound case where copy-following would pair halves computed under different masks. **3. Verified here.** New tests in `io.rs` cover copy-following (`interpolation_follows_vgpr_copies`: `v_mov_b32 v4,v0` / `v5,v1` / acc copy `v3,v2` pair into one `Interpolated` with `first: [(0,2)]`) and the EXEC-mask rejection. `cargo test -p victory-shader --lib io::` 7 passed / 0 failed; full lib 123 passed / 0 failed / 1 ignored (22 s, GPU tests included). **4. Checks:** `cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings` clean; `cargo build --release -p victory` builds; `rustfmt --edition 2024 --check crates/victory-shader/src/io.rs` fully clean (0 hunks). **5. Effect, not a defect:** this widens pairing to shaders that move barycentrics/acc through plain copies before interpolating — previously those refused with "an interpolation with computed barycentrics". The refusal remains for anything that isn't a provably plain copy under the entry mask, so no unsound pairing is introduced. Nothing found that would block this.
Author
Owner

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

Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

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:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/1293#issuecomment-7148695925) Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. 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!1293
No description provided.