victory-shader: handle unlinked v_interp_p1 in interp lowering #1099

Closed
bartikele wants to merge 1 commit from upstream-pr/1099 into main
bartikele commented 2026-11-24 15:43:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by bartikele on 2026-11-24T15:43:55Z.


Handle v_interp_p1_f32 / v_interp_p1ll_f16 / v_interp_p1lv_f16 when the interpolation site has no matching p2 in self.interps (e.g., dead or unlinked first half of an interpolation) by writing 0 instead of failing with the first half of an interpolation.

Using 0 rather than undef avoids DXIL validation errors (Instructions should not read uninitialized value) when downstream instructions read the destination register.

Tested with:

  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings
  • cargo test -p victory-shader --locked
<!-- greyfinch-sync:Marvisak/VIctory:issue:6585641837 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1099). Originally posted by [bartikele](https://github.com/bartikele) on 2026-11-24T15:43:55Z. --- Handle `v_interp_p1_f32` / `v_interp_p1ll_f16` / `v_interp_p1lv_f16` when the interpolation site has no matching `p2` in `self.interps` (e.g., dead or unlinked first half of an interpolation) by writing `0` instead of failing with `the first half of an interpolation`. Using `0` rather than `undef` avoids DXIL validation errors (`Instructions should not read uninitialized value`) when downstream instructions read the destination register. Tested with: - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` - `cargo test -p victory-shader --locked`
Aniseto commented 2026-11-24 16:05:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Aniseto on 2026-11-24T16:01:59Z.


Ran the whole victory-shader crate at 69695bd. The PR adds no test of its own, so this is a regression check rather than a proof of the new behaviour:

Environment: Windows 11 Pro build 26200 x64, Intel Core i5-12400F, 64 GB RAM, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only) driver 32.0.16.2124, Rust 1.98.1 (pinned by rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

cargo test -p victory-shader
120 passed; 0 failed; 1 ignored      (exit 0)

That matches main on this machine (ffe310e: 120 passed, 1 ignored), so the change does not disturb the existing lowering tests. What it cannot show is the new path itself: a frame where an unlinked v_interp_p1 appears would be the real check, and I have no game data here.

Not tested: the title (no game data), RDNA2/RDNA4 and Intel GPUs, release build.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - checked out the PR's head commit in a detached worktree, built it, ran the crate's tests, wrote this report; no game data was used.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137010495 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1099#issuecomment-7137010495). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-24T16:01:59Z. --- Ran the whole `victory-shader` crate at `69695bd`. The PR adds no test of its own, so this is a regression check rather than a proof of the new behaviour: Environment: Windows 11 Pro build 26200 x64, Intel Core i5-12400F, 64 GB RAM, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only) driver 32.0.16.2124, Rust 1.98.1 (pinned by `rust-toolchain.toml`), MSVC 14.44.35207, DXC 1.9.2609.5, debug build. ``` cargo test -p victory-shader 120 passed; 0 failed; 1 ignored (exit 0) ``` That matches `main` on this machine (`ffe310e`: 120 passed, 1 ignored), so the change does not disturb the existing lowering tests. What it cannot show is the new path itself: a frame where an unlinked `v_interp_p1` appears would be the real check, and I have no game data here. Not tested: the title (no game data), RDNA2/RDNA4 and Intel GPUs, release build. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash 1017** - checked out the PR's head commit in a detached worktree, built it, ran the crate's tests, wrote this report; no game data was used.
DoubleD17 commented 2026-11-24 17:03:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DoubleD17 on 2026-11-24T16:40:37Z.

Review: COMMENTED


On 69695bd, an unpaired v_interp_p1_f32 site can still have an observable result. The fallback writes zero when the site has no interpolation entry. The map tracks recognized pairs, so an absent entry alone does not establish that the destination is dead.

For example, if all three vertices carry the value 1, the RDNA 2 first interpolation step yields 1. A pixel shader that exports the p1 destination directly would receive 0 from the fallback. This follows from source inspection and the ISA formula. DXIL validation and GPU readback remain unverified. Could the fallback be limited to p1 results with no observable use outside a recognized pair? A directed export test with a matched p1/p2 control would check the difference.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:review:6043444186 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1099#pullrequestreview-6043444186). Originally posted by [DoubleD17](https://github.com/DoubleD17) on 2026-11-24T16:40:37Z. **Review:** COMMENTED --- On `69695bd`, an unpaired `v_interp_p1_f32` site can still have an observable result. The fallback writes zero when the site has no interpolation entry. The map tracks recognized pairs, so an absent entry alone does not establish that the destination is dead. For example, if all three vertices carry the value 1, the RDNA 2 first interpolation step yields 1. A pixel shader that exports the p1 destination directly would receive 0 from the fallback. This follows from source inspection and the ISA formula. DXIL validation and GPU readback remain unverified. Could the fallback be limited to p1 results with no observable use outside a recognized pair? A directed export test with a matched p1/p2 control would check the difference. AI-assisted.
Zipettte commented 2026-11-24 17:04:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T16:29:32Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 69695bd: cargo test -p victory-shader passes, 120 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137749025 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1099#issuecomment-7137749025). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T16:29:32Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 69695bd: `cargo test -p victory-shader` passes, 120 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
upstream-sync closed this pull request 2026-11-24 18:03:49 +00:00
mercuryVM commented 2026-11-24 18:03:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T17:08:34Z.

Review: CHANGES_REQUESTED


Tested 69695bd on Windows 11, RTX 5070, MSVC: builds; cargo test -p victory-shader -- --test-threads=1 120 passed, 0 failed. The finding is from reading plus package counts.

I compared victory translate shaders.rpf --list (the user's own package, counts only) on this PR merged into our fork's main against that main. VS/PS emitted goes from 12,559 to 12,587, and the 28 gained are exactly the 28 refused for "the first half of an interpolation". Nothing else changes.

The trouble is what those 28 are. A p1 whose only reader is its v_interp_p2 never caused this refusal before. When a non-effect instruction fails to lower, inst() turns its writes into Val::Missing(why) (lower.rs, the Err(why) => arm at the end of fn inst). The program is refused only when something actually reads that missing value, and the p2 lowering doesn't read the first half's result. So in each of the 28 programs, something other than a paired p2 consumes the p1 result: an ALU op, a phi that reaches one, or an export.

On hardware, that register holds P0 + I·(P1 − P0) for the attribute. With this change it holds 0, so these shaders translate and validate, but compute with a wrong value. The refusal was protecting against exactly that.

Suggested fix: keep the refusal for now. To support these programs, lower an unpaired first half to its real value, P0 + I·(P1 − P0), built from GetAttributeAtVertex (SM 6.1) for P0 and P1 and the I barycentric. Note that HLSL requires such an input to be declared nointerpolation, which conflicts when the same attribute is also interpolated normally, so that may need a second input element. Writing 0 is only safe when the result is provably dead, and the existing Missing path already handles that case.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6043879912 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1099#pullrequestreview-6043879912). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T17:08:34Z. **Review:** CHANGES_REQUESTED --- Tested 69695bd on Windows 11, RTX 5070, MSVC: builds; `cargo test -p victory-shader -- --test-threads=1` 120 passed, 0 failed. The finding is from reading plus package counts. I compared `victory translate shaders.rpf --list` (the user's own package, counts only) on this PR merged into our fork's main against that main. VS/PS emitted goes from 12,559 to 12,587, and the 28 gained are exactly the 28 refused for "the first half of an interpolation". Nothing else changes. The trouble is what those 28 are. A p1 whose only reader is its `v_interp_p2` never caused this refusal before. When a non-effect instruction fails to lower, `inst()` turns its writes into `Val::Missing(why)` (lower.rs, the `Err(why) =>` arm at the end of `fn inst`). The program is refused only when something actually reads that missing value, and the p2 lowering doesn't read the first half's result. So in each of the 28 programs, something other than a paired p2 consumes the p1 result: an ALU op, a phi that reaches one, or an export. On hardware, that register holds P0 + I·(P1 − P0) for the attribute. With this change it holds 0, so these shaders translate and validate, but compute with a wrong value. The refusal was protecting against exactly that. Suggested fix: keep the refusal for now. To support these programs, lower an unpaired first half to its real value, P0 + I·(P1 − P0), built from `GetAttributeAtVertex` (SM 6.1) for P0 and P1 and the I barycentric. Note that HLSL requires such an input to be declared `nointerpolation`, which conflicts when the same attribute is also interpolated normally, so that may need a second input element. Writing 0 is only safe when the result is provably dead, and the existing `Missing` path already handles that case. AI-assisted (Claude Code).
bartikele commented 2026-11-24 18:05:36 +00:00 (Migrated from github.com)

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


Closing this PR based on the review feedback from @mercuryVM and @DoubleD17 — dead v_interp_p1 sites are already skipped via Val::Missing, so the 28 programs actually consume the intermediate P0 + I*(P1 - P0) result, and writing 0 would silently compute wrong values. Keeping the refusal until proper GetAttributeAtVertex lowering is implemented. Thanks for catching that!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7138913788 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1099#issuecomment-7138913788). Originally posted by [bartikele](https://github.com/bartikele) on 2026-11-24T17:15:06Z. --- Closing this PR based on the review feedback from @mercuryVM and @DoubleD17 — dead `v_interp_p1` sites are already skipped via `Val::Missing`, so the 28 programs actually consume the intermediate `P0 + I*(P1 - P0)` result, and writing `0` would silently compute wrong values. Keeping the refusal until proper `GetAttributeAtVertex` lowering is implemented. Thanks for catching that!

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