Repository navigation
Shaders: trace uniform v_mov_b32 and v_readfirstlane_b32 copies in resource tracking - #2103
fuzeofficlal wants to merge 2 commits into
Conversation
…source Follow plain unguarded `v_mov_b32` and `v_readfirstlane_b32` copies in `Tracer::copy_source` only when the source holds a wave-uniform scalar or constant (`!self.varies(t)`), every lane reaching the block runs the move (`lanes.guards[b][i].is_none()`), and `v_readfirstlane_b32` reads no lane outside the block's reach. Uniform table bases, offsets, and descriptors spilled or shuttled through VGPRs and read back via `v_readfirstlane_b32` now trace directly to their scalar or constant origin without demanding a waterfall loop, while truly per-lane or `EXEC`-narrowed VGPR values remain divergent (`varies == true`) and preserve all existing waterfall and partial-write checks. For descriptors where only a subset of dwords still varies across lanes, `classify`, `first_lane_words`, and `waterfall` keep proving the varying dwords alongside the uniform ones. Refs Marvisak#728
catminou4
left a comment
There was a problem hiding this comment.
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked.
146 passed / 0 failed / 2 ignored. Uniform v_mov_b32 and v_readfirstlane_b32 copy tracing (+2 tests) — uniform-move tracing for the readfirstlane path; relates to #1718's helper-lane readfirstlane fix.
|
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 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:
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:
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:
No game data is involved: counts and code. Written with an AI assistant. |
|
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 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. |
…lane_b32 copies in resource tracking
Dword 0 of a buffer descriptor is picked per lane by v_cndmask_b32 while dwords 1-3 are constants reaching v_readfirstlane_b32 through v_mov_b32. The loop compares dword 0 alone: the descriptor traces to a per-lane choice of two built descriptors, and the waterfall proof records that one compare and one first-lane read. Comparing a constant dword instead must still be refused, since the varying dword is then left unproven. Refs Marvisak#728
|
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 On the mixed-descriptor risk, I pushed
|
|
Automated triage for the maintainers. In
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 |
Refs #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.