Shaders: follow plain v_mov_b32 copies when pairing interpolations #1293

Closed
mgunes1311-lab wants to merge 2 commits from upstream-pr/1293 into main
mgunes1311-lab commented 2026-11-24 17:11:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mgunes1311-lab on 2026-11-24T17:11:11Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6587302032 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1293). Originally posted by [mgunes1311-lab](https://github.com/mgunes1311-lab) on 2026-11-24T17:11:11Z. --- 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.
geiyiliyabumo commented 2026-11-24 18:05:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T17:30:06Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7139288670 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1293#issuecomment-7139288670). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T17:30:06Z. --- 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.*
adamdotpy commented 2026-11-24 20:03:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by adamdotpy on 2026-11-24T19:28:48Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7142155268 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1293#issuecomment-7142155268). Originally posted by [adamdotpy](https://github.com/adamdotpy) on 2026-11-24T19:28:48Z. --- 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.
upstream-sync closed this pull request 2026-11-25 01:06:10 +00:00
Marvisak commented 2026-11-25 01:08:08 +00:00 (Migrated from github.com)

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


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148695925 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1293#issuecomment-7148695925). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:36:52Z. --- 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

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!1293
No description provided.