Shaders: honor EXEC guards in Lower::interp #3149

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

@⁠Arkenoz on GitHub · 2026-11-26 10:23 UTC · original
Arkenoz:fix/shader-interp-exec-guard → main · +345 −9 · 2 files · 1 commits · open

Summary

Fixes missing EXEC guard handling when writing interpolation results in Lower::interp (crates/victory-shader/src/emit/lower.rs):

  1. Guarded vdst writes: ir.rs and structure.rs already classify Fields::Vintrp instructions as vector writes governed by EXEC and compute guards[b][i], but Lower::interp previously passed None to write and write_half. While the interpolation evaluation itself runs across lanes, the write to vdst must still preserve inactive lanes under narrowed EXEC (v_cmpx_*, s_and_saveexec_*). Lower::interp now queries self.guard(site.0, site.1)? and applies it to v_interp_mov_f32, v_interp_p2_f32, and v_interp_p2_f16.
  2. Preserving pre-p1 vdst on shared-destination p1 + p2 pairs: When v_interp_p1_* and v_interp_p2_* target the same VGPR, p1 is not emitted to DXIL and records Val::Missing(_), which would otherwise collapse inactive lanes to 0 on p2. Added Lower::interp_old to trace back to p1.read(Reg::V(reg)) when bools.meet proves p1 never executed on lanes outside p2's guard (and reach[b] => reach[b1]).
  3. Half-register writes (v_interp_p2_f16): Factored write_placed_with_old and write_half_with_old so active lanes keep existing half-preservation/modifier behavior while inactive lanes preserve the full previous (or pre-p1) vdst.

Leaves omod/clamp/op_sel[3] and SV_Barycentrics paths untouched to avoid conflicts with open PRs.

Testing

  • Added emit::tests::guarded_interpolation_preserves_inactive_lanes in crates/victory-shader/src/emit/mod.rs, running 5 synthetic pixel shaders via Host::draw (verified failing before the fix and passing after on both NVIDIA RTX 3060 and WARP, with DXIL validation):
    • v_interp_mov_f32
    • v_interp_p1_f32 + v_interp_p2_f32 (shared vdst)
    • v_interp_p1ll_f16 + v_interp_p2_f16 (low half, separate vdst)
    • v_interp_p1ll_f16 + v_interp_p2_f16 (shared vdst)
    • v_interp_p1ll_f16 + v_interp_p2_f16 (op_sel[3] = 1 high half, separate vdst)
  • rustfmt --edition 2024 --check — 0 diffs on all touched/added lines
  • cargo clippy --workspace --all-targets -- -D warnings — passed
  • cargo check --workspace --all-targets — passed
  • cargo xtask policy — passed (asset policy: 191 files ok)
  • cargo test -p victory-shader --locked --lib emit::tests:: — passed (18 passed; 0 failed)

Coordination & AI disclosure

  • Claimed in #1633.
  • AI-assisted (Antigravity / Gemini 4 Neon).
**@⁠Arkenoz** on GitHub · 2026-11-26 10:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/3149) `Arkenoz:fix/shader-interp-exec-guard` → `main` · +345 −9 · 2 files · 1 commits · open ### Summary Fixes missing `EXEC` guard handling when writing interpolation results in `Lower::interp` (`crates/victory-shader/src/emit/lower.rs`): 1. **Guarded `vdst` writes:** `ir.rs` and `structure.rs` already classify `Fields::Vintrp` instructions as vector writes governed by `EXEC` and compute `guards[b][i]`, but `Lower::interp` previously passed `None` to `write` and `write_half`. While the interpolation evaluation itself runs across lanes, the write to `vdst` must still preserve inactive lanes under narrowed `EXEC` (`v_cmpx_*`, `s_and_saveexec_*`). `Lower::interp` now queries `self.guard(site.0, site.1)?` and applies it to `v_interp_mov_f32`, `v_interp_p2_f32`, and `v_interp_p2_f16`. 2. **Preserving pre-`p1` `vdst` on shared-destination `p1 + p2` pairs:** When `v_interp_p1_*` and `v_interp_p2_*` target the same VGPR, `p1` is not emitted to DXIL and records `Val::Missing(_)`, which would otherwise collapse inactive lanes to `0` on `p2`. Added `Lower::interp_old` to trace back to `p1.read(Reg::V(reg))` when `bools.meet` proves `p1` never executed on lanes outside `p2`'s guard (and `reach[b] => reach[b1]`). 3. **Half-register writes (`v_interp_p2_f16`):** Factored `write_placed_with_old` and `write_half_with_old` so active lanes keep existing half-preservation/modifier behavior while inactive lanes preserve the full previous (or pre-`p1`) `vdst`. Leaves `omod`/`clamp`/`op_sel[3]` and `SV_Barycentrics` paths untouched to avoid conflicts with open PRs. ### Testing - Added `emit::tests::guarded_interpolation_preserves_inactive_lanes` in `crates/victory-shader/src/emit/mod.rs`, running 5 synthetic pixel shaders via `Host::draw` (verified failing before the fix and passing after on both NVIDIA RTX 3060 and WARP, with DXIL validation): - `v_interp_mov_f32` - `v_interp_p1_f32` + `v_interp_p2_f32` (shared `vdst`) - `v_interp_p1ll_f16` + `v_interp_p2_f16` (low half, separate `vdst`) - `v_interp_p1ll_f16` + `v_interp_p2_f16` (shared `vdst`) - `v_interp_p1ll_f16` + `v_interp_p2_f16` (`op_sel[3] = 1` high half, separate `vdst`) - `rustfmt --edition 2024 --check` — 0 diffs on all touched/added lines - `cargo clippy --workspace --all-targets -- -D warnings` — passed - `cargo check --workspace --all-targets` — passed - `cargo xtask policy` — passed (`asset policy: 191 files ok`) - `cargo test -p victory-shader --locked --lib emit::tests::` — passed (`18 passed; 0 failed`) ### Coordination & AI disclosure - Claimed in #1633. - AI-assisted (Antigravity / Gemini 4 Neon).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:08:46 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 10:27 UTC · original · approved these changes

Verified on RTX 5090 against origin/main (63bcca4):

  • cargo test -p victory-shader --lib guarded_interpolation_preserves_inactive_lanes -- --test-threads=1: passed.
  • cargo test -p victory-shader --lib emit::lower::tests:: -- --test-threads=1: 33/33 passed.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly honors EXEC guards in Lower::interp so inactive lanes preserve their prior VGPR values.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 10:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/3149#pullrequestreview-6072419241) · **approved these changes** Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib guarded_interpolation_preserves_inactive_lanes -- --test-threads=1`: passed. - `cargo test -p victory-shader --lib emit::lower::tests:: -- --test-threads=1`: 33/33 passed. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly honors EXEC guards in `Lower::interp` so inactive lanes preserve their prior VGPR values. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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