Shaders: interpolations with any i/j by hand; barycentrics read as data #1681
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1682"
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 federalcontraband on 2026-11-24T20:43:16Z.
Stacked on #1451, so its first commit is that PR. Review only the second commit.
victory translate --validate --listover the title'sshaders.rpf, compared with #1451:Per program, 87 go from failing to validated: 77 had "computed barycentrics" and 10 read barycentrics directly. None go from validated to failing. Of the rest, 32 now stop at "an opaque lane mask", 3 reach a texture sample that fails "out of bound coord must be undef" (an existing sample-lowering issue), and 2 fail "Program Input Signature does not match".
What these programs do
#1451 handled
i = j = 0. The rest readi/jthrough a phi: v0/v1 are reused as scratch on one path, and the interpolation after the join reads the merged value. Per lane, that value is still the loadedi/jwherever the interpolation is active, but the IR can't prove it. So instead of proving it, this change computes what the hardware computes.Changes
io.rsv_interp_p2_f32and itsv_interp_p1_f32halves don't read one kind's loaded i and j (or two zeros), every half becomesInterp::ByHand { attribute, second }instead of failing.p1ll_f16/p2_f16) are still refused.emit/lower.rsByHandhalf is lowered as the instruction is defined:p1 = P0 + i·(P1−P0)andp2 = acc + j·(P2−P0).AttributeAtVertex.i/jare whatever the registers hold.manual_rows.SV_Barycentrics:iis.y(P1's weight) andjis.z.getand when filling phis, so only programs that read one declareSV_Barycentrics.The sum only uses
AttributeAtVertexandSV_Barycentricstogether, so it depends only on D3D12 giving both the same vertex order.Tests
emit::tests::an_interpolation_with_other_weights_is_computed_by_handemit::tests::barycentrics_read_directly_are_sv_barycentricsemit::tests::plain_interpolation_declares_no_barycentrics: checks the load is lazy.iotests now expectByHandhalves where they used to expect a refusal.The emit tests run
dxil.dllwhere it's present. All tests use hand-encoded instructions; no title data.cargo test --workspacepasses (348) and clippy is clean.Not verified
FMadper half, the same as the console's own two-step form.Tested on: Windows 11, RX 9060 XT (RDNA4), driver 32.0.31044.16.
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:40:12Z.
Review: APPROVED
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
ffe310e), cargo test -p victory-shader --locked → 102 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests.Interpolations with any i/j weights are computed by hand from SV_Barycentrics: rows read with mixed interpolation modes are declared flat and re-interpolated manually (manual_rows bitmask per row incl. fp16 pack2 row2), barycentrics read as data map to PerspectiveCenter/etc., and plain interpolation declares no barycentrics. +5 macOS tests (102 total). Big but well-tested.
upstream-sync referenced this pull request2026-11-24 23:05:38 +00:00
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T22:52:53Z.
NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, at the PR head
3b0c7da. Tests matchinginterpolat/barycentrics, including the six new ones: 9 passed, 0 failed.It is based on
ffe310eand GitHub shows conflicts withmain70564ae, so this is the head as it stands, not a merge.AI-assisted (Claude Code). Synthetic tests only.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:34:21Z.
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/lower.rs,crates/victory-shader/src/emit/shader.rs,crates/victory-shader/src/io.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by federalcontraband on 2026-11-25T08:44:22Z.
Closing this:
mainnow covers it. On currentmain(940d32f),victory translate --validateover the title's shaders shows 0 "computed barycentrics" and no mixed-mode row errors, usingjoined/unlessandsame_mode_per_row.What this PR would still add on top of
mainis three programs that read barycentrics as data ("barycentrics read directly": two bloom downsample pixel shaders andPS_SampleFromHigherResGrid). That isn't worth rebasing ~300 lines acrosslower.rs/io.rs/shader.rsfor. If it's wanted, I can send a small separate PR that only lowers those reads toSV_Barycentrics.Thanks for the triage, and thanks @upipibi for the NVIDIA run.
Pull request closed