Shaders: keep prior per-lane descriptor word across redundant masked moves (fixes #750) #1182
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1182"
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 R0D4X on 2026-11-24T16:21:52Z.
Summary
Fixes #750.
When a per-lane descriptor joined across control flow is followed by a plain predicated
v_mov_b32that re-writes one of its VGPR words with the exact value every active lane already holds,Tracer::lane_valuepreviously refused the program with"a per-lane descriptor written where some lanes may keep the old one".What changed
crates/victory-shader/src/resource.rs:Tracer::redundant_vmovandTracer::equals_under: whenTracer::runscannot prove that every lane inknownexecutes a plainv_mov_b32, check whether the destination VGPR's prior SSA value (inst.read(Reg::V(reg))) already equals the move's source on every feasible active lane (known ∧ reach[site] ∧ guard, walking forwardphis andv_cndmask_b32joins). If proven, the move is a no-op andlane_valuecontinues from the prior VGPR value; otherwise the conservative refusal is unchanged.Tracer::lanes_meet(with canonical purev_cmp*/v_cmpx*comparison keys and BDD-order backtrackingmeet_equiv, fast-pathing straight throughBools::meetwhen no two lane-compare atoms share a key) so repeated comparisons of identical SSA operands (including operand swaps and integer negations, without unsafe float NaN negations) are recognized as equivalent without mutatingstructure::Bools.resource::testscovering the exact #750 repro, a negated integer compare on theelsearm, and two negative cases (writing the other arm's word; writing under a wider predicate mask) that must still be refused.crates/victory-shader/src/emit/waterfall_tests.rs:lanes_sample_their_arm_after_a_redundant_masked_writeto verify DXIL lowering,dxil.dllvalidation, and end-to-end execution on both host GPU hardware and D3D12 WARP.Verification
cargo xtask policy: passed (154 files ok)cargo clippy --workspace --all-targets -- -D warningsand--all-features: passedcargo test --workspace: 347 passed, 0 failed (includingvictory-shader125/125, running the new waterfall test on RTX 5080 + WARP withdxil.dllvalidation)victory translate --listover 26,096 title programs): 0 regressions (25,736 / 26,096tracked before and after; no game data or dumps included).Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-24T17:27:25Z.
Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main
ffe310eplus #1017 (main's host build fails without it:E0425 host_resource), then the four-stage offline check over 768 programs (751-program world dump + 52-program BVH capture, 35 duplicate containers skipped).No program gained or lost and the failure table is identical to the base, reason for reason: nothing in this capture reaches the class you handle, so this is a no-regression result only (same 10 SPIR-V validation failures as the base).
Not tested: in-game.
Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:00:38Z.
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
8c94b5c:cargo test -p victory-shaderpasses, 125 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T18:36:06Z.
Review: APPROVED
Tested
8c94b5c3on Windows 11, RTX 5070, MSVC:cargo test -p victory-shader -- --test-threads=1passes on the head (125 passed, 1 ignored), including the new waterfall tests.clippy -D warnings(default and all features) are all clean.The reasoning is sound:
v_mov_b32(known ∧ reach ∧ guard). Lanes that don't run it keep the old value by definition, so proving old == src on the running lanes means the result is the old value everywhere.CompareKeyavoids the NaN trap of folding float compares.A static measurement on a full game package, counts only: no program there hits "a per-lane descriptor written where some lanes may keep the old one", either before or after this PR. So this frees nothing in that package, and changes nothing either (0 programs change result). Both the fork and upstream are neutral on it.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:34:04Z.
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Fix for #750 ('per-lane descriptor written where some lanes may keep the old one'): that refusal class is 0 in main after today's lane-condition fixes; same issue as #1229.
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed