Shaders: a first interpolation half read early is the interpolation #2355
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!2355
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2355/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?
@Calvix2k on GitHub · 2026-11-25 11:34 UTC · original
Calvix2k:codex/shader-interp-first-half→main· +46 −1 · 2 files · 1 commits · closed without mergingTwo pixel shaders of this title are dropped with a reason that names the place exactly:
(and
38bf0814e721a1b3at the same offset.)An interpolation is two instructions on the console:
v_interp_p1_f32makes the halfattr * i,v_interp_p2_f32completes it. The host has only the whole, soio::raiserecords the interpolation at the completing half and lists the first halves it completes inInterp::first. A shader that reads a half's dword before its completing half finds no interpolation at that site and the whole program is refused.What this does
Lowergains a second map,firsts, from eachv_interp_p1_f32site to the interpolation that completes it, andinterp()falls back to it. A first half is lowered as the interpolation itself: the completing half recomputes and stores the same value, so a title that stores the half early sees the finished value instead of the program being dropped.Scope
Only the 32-bit
v_interp_p1_f32.v_interp_p1ll_f16packs two 16-bit halves into one dword, and a read of the whole dword is not an interpolation —a_half_over_a_first_interpolation_half_reads_as_a_halfstill refuses those, and stays green.Verification
a_first_half_read_early_is_the_interpolation: a pixel shader that moves a first half's dword out (as these two do) and completes the interpolation afterwards now emits and validates.cargo test -p victory-shader --lib: 248 passed, 0 failed, 3 ignored (Windows 10 19045 / RX 7800 XT, SM 6.6 through the Agility runtime for the test binaries); clippy-D warningsclean.78f3f2fcand38bf0814now translate is pending — I will report it here as soon as a run is back.@Marvisak on GitHub · 2026-11-25 15:33 UTC · original
Automated triage for the maintainers.
Needs work (evidence). The change makes the shader translate, but the value it gives an early-read first half is not the console's. On GFX10,
v_interp_p1_f32writesP0 + P10·iandv_interp_p2_f32addsP20·j; with thefirstsfallback inLower::interp(crates/victory-shader/src/emit/lower.rs) the first half is lowered as the whole interpolation. In the new testa_first_half_read_early_is_the_interpolation,v4(moved out afterp1) therefore exportsP0 + P10·i + P20·jwhere the console exportsP0 + P10·i; the test only checks that the shader emits and validates, not the exported value. Please show what the two title shaders (78f3f2fc53a69531,38bf0814e721a1b3) do with the half around 0x1464, e.g. whether the moved dword is itself completed by a laterp2and only stored after that; if so,io::raiseshould follow the move so the completing half is found, rather than lowering every first half as the whole value. What would change the verdict: that disassembly context (described, not dumped) and a test that checks exported values. CI: passing.Generated by Claude Code
@Calvix2k on GitHub · 2026-11-25 16:27 UTC · original
I disassembled both programs the review names, from
translate --liston the title'sshaders.rpf(26,517 containers):PS_DeferredTextured_c5fd36bb_Wrapped(#38bf0814e721a1b3,@0x7be5e42) andPS_DeferredTextured_9e3a1555_Wrapped(#78f3f2fc53a69531,@0x7c2af0b), viashader-info --disasmon the pack. What is at0x1464in both:So the export reads two packed dwords built from v12/v23 and v13/v24. I then checked every half:
v_interp_p1*and 15v_interp_p2*. Each p2's accumulator (its destination for_f32,src[2]for_f16) is last written by its own p1 at the same register (v14, v6, v7, v12, v25, v26, v15, v35, v23, v34, v31, v29, v30, v0, and the seven f16 halves).v_mov_b32 v12, v14at0x860(after p2 v14 at0x274, which is itself rewritten at0x2c8),v_mov_b32 v40, v25at0x534,v_mov_b32 v39, v26at0x538,v_mov_b32 v21, v25at0x111c. None of them is used as the accumulator of a later p2.So the "moved dword completed later" pattern is not what these two programs do: by register, there is no early-read first half here. The reason at the export is a value the lowering had already marked
Missing("the first half of an interpolation"), i.e. av_interp_p2site thatio::raisedid not record ininterps(or a phi path through one), reachingv12/v23through the arithmetic chain. That needs the site named — the same treatment as #2365 — rather than a fallback at the read.That is also why I agree with the verdict: the
firstsfallback would exportP0 + P10*i + P20*jwhere the console exportsP0 + P10*i, so it should not land on this evidence. I am closing this PR rather than keeping a known-wrong value; the next step is a change inio::raisethat reports the p2 site it could not pair, which I can make once the diagnostic names it. The test and the two programs are in the thread for whoever picks it up.Pull request closed