Repository navigation
fix(shader): account for generated loop-cap returns in barrier and half-wave analyses - #408
Conversation
|
An in-game interaction worth knowing about before merge. M5 Pro, D3DMetal 4.0b3, Series X, own dump, diagnostics builds. Text only, no game data. We bisected a black world (only the HUD drawn) down to this PR in a local stack that also carries #435 (literal-halves retry) and #401. #408 and #435 conflict in
The 15 newly refused programs include the two tile-list passes ( So in this game the cap-escape refusal costs the picture, while the hang it guards against never showed up in our runs before #408. Two questions:
I can test any variant in-game here. Our merge resolution may differ from what you'd do, so treat the counts as indicative. Locally we've reverted #408 for now. Prepared with Claude Code. |
Following up on the review finding noted on #376: lowering turns an unconditional back edge (
LaneExit::Jumpto a loop header) into a conditional branch to a generated earlyreturnwhen the loop iteration limit is hit (crates/victory-shader/src/emit/lower.rs). Previously,in_step,branch_regionspostdominator analysis, and explicits_barrierlowering only considered the console CFG, allowing one wave/half to return early at the cap while another reached a half-wave exchange ors_barrier(GroupMemoryBarrierWithGroupSync) with missing participants.This change:
in_step(step_and_capincrates/victory-shader/src/emit/lower/barriers.rs) to treat a capped unconditional back edge(latch, header)as uniform only whenheader,latch, and every back edge sharingheader's loop counter run in step (with uniform branch conditions on conditional back edges). Otherwise marks blocks reachable fromheaderand divergent sibling arms (bounded at reconvergence points wherestep[p]holds) as not-in-step andcap_escaped.branch_regions(crates/victory-shader/src/emit/lower/halves.rs) for capped unconditional back edges so a closed self-loop does not make a sibling path a false postdominator/reconvergence point.s_barrierincap_escapedblocks (crates/victory-shader/src/emit/lower.rs), while preserving safe barriers before divergent cap branches, behind uniform branches, and after uniform capped loops.crates/victory-shader/src/emit/lower/tests.rscovering all hazard shapes (divergent inner capped loop, shared loop counter with a divergent conditional back edge, closed self-loop sibling exchange ands_barrier) and positive controls (uniform capped loops, conditional back edges, earlier joins, and+1emitted barrier verification againsts_nop).Tested locally on macOS ARM64 (no game files):
cargo test -p victory-shader(220 passed, 0 failed, 3 ignored)cargo clippy -p victory-shader --all-targetscargo xtask policy(262 files ok)Created with Mistral Large 4, GPT-6.2 Sol, and Gemini 4 Neon in T3 Code.