Shaders: trace uniform v_mov_b32 and v_readfirstlane_b32 copies in resource tracking #2103
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!2103
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2103/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?
@fuzeofficlal on GitHub · 2026-11-25 05:00 UTC · original
fuzeofficlal:fix/shader-resource-copysource-vmov-728→main· +639 −66 · 1 files · 2 commits · closed without mergingRefs #728.
Summary
Tracer::copy_source/unguarded_copy): follow plain unguardedv_mov_b32andv_readfirstlane_b32copies only when the source holds a wave-uniform scalar or constant (!self.varies(t)), every lane reaching the block executes the instruction (lanes.guards[b][i].is_none()), andv_readfirstlane_b32reads no lane outside the block's reach.classify/first_lane_words/waterfall): when a subset of descriptor dwords folds to wave-uniform values while remaining dwords still vary across lanes, retain waterfall loop verification over the varying dwords instead of failing with"a descriptor partly read from the first lane".Testing
dxil.dll-validated tests (uniform_values_moved_through_vgprs_and_readfirstlane_are_tracked,uniform_vgpr_readfirstlane_descriptor_runs_on_gpu_and_warp) across NVIDIA RTX 5090, AMD Radeon RDNA2, and D3D12 WARP.divergent_or_masked_vgprs_are_not_folded_through_readfirstlaneverifying input VGPRs, source modifiers,EXEC-narrowed moves, non-loop divergentv_readfirstlane_b32, and mixed uniform/varying descriptors.cargo test -p victory-shader,cargo clippy --workspace --all-targets --all-features -- -D warnings, andcargo xtask policy.@fiestorra on GitHub · 2026-11-25 06:20 UTC · original
Ran the census: it changes nothing on this archive — which makes the evidence question the important one
A 585-line change to address tracking is a change whose value should be visible somewhere, so I measured the place this tree usually measures:
(same local 1.0.2.1 archive, 26,503 containers, validator SDK 10.0.26100
dxil.dll1.9; the 871 → 867 difference is the four programs that #1767'snote:reporting rewrites as a different class in my run, not a change of outcome — the totals and the class membership are the same.)So: no program that failed before passes now, on this corpus. That is not an argument against the change — it refs #728, which is a specific pattern — but it means the description has no measurable "before/after" available here, and a reviewer should ask for the evidence that does exist:
translate --count(#2115) — extra or fewer instructions — even when both versions validate? That is the only census-visible trace a change like this can leave when the modules already validated.What I can vouch for is the shape of the reasoning, which is the part I looked at hardest because it is where a wrong uniform copy turns into a wrong descriptor for every lane:
!self.varies(t)) — the condition that makes the whole thing sound;lanes.guards[b][i].is_none()), which is what keeps a guarded copy from being treated as uniform;v_readfirstlane_b32only when it reads no lane outside the block's reach, which is the subtle one:readfirstlanepicks the lowest active lane, and if that lane is not one the block executes, the "uniform" value it would propagate is a value from a lane that is not there.Those three are exactly the conditions I would have written, and they are stated in the description rather than left implicit — which is why I am reviewing this rather than guessing at it.
Two practical notes:
crates/victory-shader/src/resource.rs, and merges cleanly with the three LDS-atomic pull requests in this window (#2113, #2116, #2119) — I tried each one against it, all clean. So it does not add to that pile;classifyand the waterfall do together. If the parameter tracking table is the thing that breaks first, that is where I would look, and a test that pins a mixed descriptor — some dwords uniform, some not — is the one I would want in the patch rather than in a later bug report.No game data is involved: counts and code.
Written with an AI assistant.
@fiestorra on GitHub · 2026-11-25 06:21 UTC · original
Correction to the numbers in my comment above: both sides are 867, and the 871 I quoted was mine, not this comparison
I wrote that "the 871 → 867 difference is the four programs that #1767's
note:reporting rewrites as a different class". That is wrong, and I should not leave it standing.The figures for the two builds in this comment are:
So this pull request changes nothing in the census — not the class, not the total. The 871 was a number from an earlier census run of mine, taken on a different tree state, and quoting it here made it look as though something moved by four programs when nothing moved at all.
The substantive point of the review is unchanged and is now cleaner: 23,918 validated and the same class counts before and after, so the evidence for this change has to be the specific program or pattern it fixes, not a corpus number. My apology for putting a misleading pair in front of you.
No game data is involved: counts.
Written with an AI assistant.
@fuzeofficlal on GitHub · 2026-11-25 08:25 UTC · original
Thanks for running the census and for the correction — 23,918 before and after with identical class counts matches what I'd expect.
On the evidence question: the pattern is a wave-uniform value (a scalar, a constant, a table base or offset, or individual descriptor dwords) moved into a VGPR with
v_mov_b32and read back withv_readfirstlane_b32outside a waterfall loop, plus the waterfall case where only some of a descriptor's dwords still differ between lanes. It comes from part 4 of the branch in #728; the gains reported there were for the whole branch, and its other parts have since landed onmainseparately (0b35b7f,75677cb). I have no container showing this pattern failing on its own, and your census agrees, so this is preventive — fine to hold until a title needs it. I've said so at the top of the description.On the mixed-descriptor risk, I pushed
a_mixed_descriptor_proves_only_its_varying_dwords(d0a07fce): dword 0 is chosen per lane byv_cndmask_b32, dwords 1–3 are constants that reachv_readfirstlane_b32throughv_mov_b32, and the loop compares dword 0 only. It pins the traced source (a per-lane choice between the two built descriptors), one compare and one first-lane read in the waterfall proof; a variant comparing a constant dword instead must still be refused ("compares do not select the access's lanes"). Without the uniform folding the positive case is refused, and with the!variescondition dropped the source no longer traces per lane, so it covers both under- and over-folding.cargo test -p victory-shader --lockedpasses except the three hardware-dependent tests that also fail onmainon this non-RDNA2 machine; both clippy modes andcargo xtask policyare clean.@Marvisak on GitHub · 2026-11-25 10:39 UTC · original
Automated triage for the maintainers.
In
resource.rs,Tracer::copy_sourcenow followsv_mov_b32/v_readfirstlane_b32copies, andfirst_lane_words/classifytake mixed uniform/varying descriptors. The soundness conditions are there:!varieson the source;unguarded_copychecks for no guard and that EXEC stays within the block's reach;However, by the author's own account and a census, no title program changes (23,918 validated before and after). This is a 640-line preventive change to descriptor tracking, where a wrong fold gives every lane a wrong descriptor. It should be held until a title program needs it. A container or pattern from the title showing the failure would change the verdict. CI: passing.
Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-25 15:40 UTC · original
Closing per triage feedback: this multi-hop copy tracking is preventive with zero change on the current shader corpus. Happy to revisit if a title shader hits this pattern.
Pull request closed