Shaders: interpolations with any i/j by hand; barycentrics read as data #1682
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1682
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1682/head"
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?
@federalcontraband on GitHub · 2026-11-24 20:43 UTC · original
federalcontraband:shaders-interpolate-any-barycentrics→main· +708 −46 · 6 files · 2 commits · closed without mergingStacked 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
@upipibi on GitHub · 2026-11-24 22:52 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 01:34 UTC · original
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
@federalcontraband on GitHub · 2026-11-25 08:44 UTC · original
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