victory-shader: handle unlinked v_interp_p1 in interp lowering #1099
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1099"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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_f16when the interpolation site has no matchingp2inself.interps(e.g., dead or unlinked first half of an interpolation) by writing0instead of failing withthe first half of an interpolation.Using
0rather thanundefavoids 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 warningscargo test -p victory-shader --lockedImported from Marvisak/VIctory. Originally posted by Aniseto on 2026-11-24T16:01:59Z.
Ran the whole
victory-shadercrate at69695bd. 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.That matches
mainon 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 unlinkedv_interp_p1appears 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.
Imported from Marvisak/VIctory. Originally posted by DoubleD17 on 2026-11-24T16:40:37Z.
Review: COMMENTED
On
69695bd, an unpairedv_interp_p1_f32site 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.
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-shaderpasses, 120 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T17:08:34Z.
Review: CHANGES_REQUESTED
Tested
69695bdon Windows 11, RTX 5070, MSVC: builds;cargo test -p victory-shader -- --test-threads=1120 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_p2never caused this refusal before. When a non-effect instruction fails to lower,inst()turns its writes intoVal::Missing(why)(lower.rs, theErr(why) =>arm at the end offn 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 declarednointerpolation, 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 existingMissingpath already handles that case.AI-assisted (Claude Code).
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_p1sites are already skipped viaVal::Missing, so the 28 programs actually consume the intermediateP0 + I*(P1 - P0)result, and writing0would silently compute wrong values. Keeping the refusal until properGetAttributeAtVertexlowering is implemented. Thanks for catching that!Pull request closed