Shaders: honor EXEC guard on v_interp_* writes to preserve inactive lanes #3153

Open
github-bot wants to merge 3 commits from github-bot/gh-3153 into main AGit
Owner

@⁠reeledMarek on GitHub · 2026-11-26 10:27 UTC · original
reeledMarek:fix/shader-interp-exec-guard → main · +245 −8 · 3 files · 3 commits · open

Summary

  • Lower::interp in crates/victory-shader/src/emit/lower.rs previously passed None as the guard to both write_half (v_interp_p2_f16) and write (v_interp_mov_f32 / v_interp_p2_f32).
  • On RDNA hardware, v_interp_* instructions respect EXEC: inactive lanes in predicated/divergent pixel-shader control flow keep their prior destination VGPR value instead of being overwritten.
  • Pass self.guard(site.0, site.1)? to write_half and write_placed_with_old; for same-VGPR two-instruction VINTRP pairs (v_interp_p1_f32 + v_interp_p2_f32 under the same guard), step back over p1 (whose SSA write is Val::Missing) to recover the true pre-p1 VGPR value instead of zeroing inactive lanes.
  • Add synthetic pixel shader tests in crates/victory-shader/src/emit/lower/interp_guard_tests.rs covering guarded v_interp_mov_f32, guarded v_interp_p1_f32+v_interp_p2_f32 (with DXIL validation on Windows), and unguarded control.
**@⁠reeledMarek** on GitHub · 2026-11-26 10:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/3153) `reeledMarek:fix/shader-interp-exec-guard` → `main` · +245 −8 · 3 files · 3 commits · open ## Summary - `Lower::interp` in `crates/victory-shader/src/emit/lower.rs` previously passed `None` as the guard to both `write_half` (`v_interp_p2_f16`) and `write` (`v_interp_mov_f32` / `v_interp_p2_f32`). - On RDNA hardware, `v_interp_*` instructions respect `EXEC`: inactive lanes in predicated/divergent pixel-shader control flow keep their prior destination VGPR value instead of being overwritten. - Pass `self.guard(site.0, site.1)?` to `write_half` and `write_placed_with_old`; for same-VGPR two-instruction VINTRP pairs (`v_interp_p1_f32` + `v_interp_p2_f32` under the same guard), step back over `p1` (whose SSA write is `Val::Missing`) to recover the true pre-`p1` VGPR value instead of zeroing inactive lanes. - Add synthetic pixel shader tests in `crates/victory-shader/src/emit/lower/interp_guard_tests.rs` covering guarded `v_interp_mov_f32`, guarded `v_interp_p1_f32`+`v_interp_p2_f32` (with DXIL validation on Windows), and unguarded control.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:08:52 +00:00
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 11:21 UTC · original

One FP16 case still loses both halves of the previous VGPR on b8355be. I ran the same five 8×8 pixel shaders from #3149 on the common parent and both PR heads, twice per adapter. The RTX 5080 and Windows inbox WARP gave the same results.

Code under test Incorrect inactive pixels (out of 160) Incorrect active pixels (out of 160)
Common parent 63bcca4 160 0
#3153 b8355be 32 0
#3149 92a21a8 0 0

This PR fixes all pixels for the FP32 move, shared-destination FP32 pair, and both separate-destination FP16 cases. The remaining 32 pixels are columns 0–3 of all eight rows when v_interp_p1ll_f16 and v_interp_p2_f16 both write v3. After EXEC is restored, the first pixel reads (0.0, 0.0) for the low and high halves. The pre-pair value was (1.0, 2.0). #3149 recovers that value for every inactive pixel.

The FP16 path in this head returns from write_half before the shared-destination old-value handling below it. #3149 carries the pre-p1 value through the FP16 write as well. If the two fixes are consolidated, the shared-destination half case is worth keeping.

To reproduce the first failure in a disposable checkout of b8355be, bring over just Arkenoz's test module and run it:

git fetch https://github.com/Marvisak/VIctory.git refs/pull/3149/head
git restore --source=92a21a8eff6c44489459e258685ea4848b925290 -- crates/victory-shader/src/emit/mod.rs
cargo test --locked -p victory-shader --lib guarded_interpolation_preserves_inactive_lanes -- --nocapture --test-threads=1

For the counts above I let all five draw/readbacks finish and recorded mismatches by active/inactive half. Synthetic shaders, AI-assisted testing with Codex.

**@⁠steven-seagull27** on GitHub · 2026-11-26 11:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/3153#issuecomment-7190614044) One FP16 case still loses both halves of the previous VGPR on `b8355be`. I ran the same five 8×8 pixel shaders from #3149 on the common parent and both PR heads, twice per adapter. The RTX 5080 and Windows inbox WARP gave the same results. | Code under test | Incorrect inactive pixels (out of 160) | Incorrect active pixels (out of 160) | |---|---:|---:| | Common parent `63bcca4` | 160 | 0 | | #3153 `b8355be` | 32 | 0 | | #3149 `92a21a8` | 0 | 0 | This PR fixes all pixels for the FP32 move, shared-destination FP32 pair, and both separate-destination FP16 cases. The remaining 32 pixels are columns 0–3 of all eight rows when `v_interp_p1ll_f16` and `v_interp_p2_f16` **both write v3**. After EXEC is restored, the first pixel reads **(0.0, 0.0)** for the low and high halves. The pre-pair value was **(1.0, 2.0)**. #3149 recovers that value for every inactive pixel. The FP16 path in this head returns from `write_half` before the shared-destination old-value handling below it. #3149 carries the pre-p1 value through the FP16 write as well. If the two fixes are consolidated, the shared-destination half case is worth keeping. To reproduce the first failure in a disposable checkout of `b8355be`, bring over just Arkenoz's test module and run it: ```sh git fetch https://github.com/Marvisak/VIctory.git refs/pull/3149/head git restore --source=92a21a8eff6c44489459e258685ea4848b925290 -- crates/victory-shader/src/emit/mod.rs cargo test --locked -p victory-shader --lib guarded_interpolation_preserves_inactive_lanes -- --nocapture --test-threads=1 ``` For the counts above I let all five draw/readbacks finish and recorded mismatches by active/inactive half. Synthetic shaders, AI-assisted testing with Codex.
Author
Owner

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

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

  • cargo test -p victory-shader --lib interp_guard_tests:: -- --test-threads=1: passed.
  • cargo test -p victory-shader --lib emit::tests:: -- --test-threads=1: 17/17 passed.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

Cleanly honors EXEC guards on v_interp_* writes so inactive lanes preserve their values.

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

**@⁠Dukestar69** on GitHub · 2026-11-26 11:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/3153#pullrequestreview-6073393990) · **approved these changes** Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib interp_guard_tests:: -- --test-threads=1`: passed. - `cargo test -p victory-shader --lib emit::tests:: -- --test-threads=1`: 17/17 passed. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 192 files ok. Cleanly honors EXEC guards on `v_interp_*` writes so inactive lanes preserve their values. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠reeledMarek on GitHub · 2026-11-26 15:20 UTC · original

Great catch @⁠steven-seagull27 — thanks for testing all five cases on RTX 5080 and WARP!

Fixed in dbddcde: extracted interp_old_val() and write_half_with_old() so the FP16 path also steps back over a shared-destination v_interp_p1ll_f16 (preserving both halves of the pre-p1 VGPR on inactive lanes), and added a shared-destination v_interp_p1ll_f16 + v_interp_p2_f16 regression test in interp_guard_tests.rs.

**@⁠reeledMarek** on GitHub · 2026-11-26 15:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/3153#issuecomment-7196119188) Great catch @⁠steven-seagull27 — thanks for testing all five cases on RTX 5080 and WARP! Fixed in `dbddcde`: extracted `interp_old_val()` and `write_half_with_old()` so the FP16 path also steps back over a shared-destination `v_interp_p1ll_f16` (preserving both halves of the pre-p1 VGPR on inactive lanes), and added a shared-destination `v_interp_p1ll_f16` + `v_interp_p2_f16` regression test in `interp_guard_tests.rs`.
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/3153/head:github-bot/gh-3153'
git switch 'github-bot/gh-3153'

Merge

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