Shaders: visit resource::track blocks in reverse postorder #2420
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2422"
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 makmatvey on 2026-11-25T13:12:54Z.
What
resource::trackwalked blocks in vector index order. After CFG transforms that append blocks (for examplesplit_irreducible), a lower-indexed consumer could run before a higher-indexeds_loadproducer, soout.scalardid not yet hold the load when the consumer looked it up and waterfall / descriptor tracing missed it.Tracked as VIC-BT-024 in #1249. Focused slice of the stalled bundle in #1336 (needs rebase); does not include the SMEM alignment or lane-index pieces of that PR.
Change
In
crates/victory-shader/src/resource.rs, the main walk usesreverse_postorderso producers populateout.scalarbefore consumers.Tests
cargo test -p victory-shader --locked --lib track_visits_blocks_in_reverse_postorder— pass (fails onmainwithout the walk change)cargo test -p victory-shader --locked --lib resource::— 34 passedcargo clippy -p victory-shader --locked -- -D warnings— cleancargo xtask policy— okNo game data used.
Fixes VIC-BT-024 in #1249.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T13:18:40Z.
Review: APPROVED
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:resource::trackensures dominating definitions are seen before uses regardless of block layout.cargo test -p victory-shader resource::tests: 34/34 passed on RTX 5090 and WARP (includingtrack_visits_blocks_in_reverse_postorder).cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T13:25:23Z.
Review: APPROVED
Tested locally: merged into main
940d32f69b,cargo test -p victory-shader --lockedon macOS arm64 — 145 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — resource::track blocks visited in reverse postorder.Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T13:34:45Z.
WARP verification
Tested: PR head
750445401e3f486a75cb58a5dcfd4d1fd01c83e2, onorigin/main940d32f69b22265690a0b5a15d6ded572ba33baf(the PR is one commit on that base, so the merge was a no-op).Environment:
VICTORY_D3D12_WARP=1(software WARP), Windows 11 Pro 10.0.26200, rustc 1.98.1, DXC 1.9.0.5512 (dxcompiler), dxil.dll 1.8.2502.11 onPATH.cargo test -p victory-shader --lib --lockeddefect_test, all ignored on main too)cargo clippy -p victory-shader --all-targets --locked -- -D warningscargo xtask policyasset policy: 182 files ok, exit 0The new test
resource::tests::track_visits_blocks_in_reverse_postorderran and passed (not skipped).Diff review (
resource.rsonly):tracknow iteratescrate::ir::reverse_postorder(&p.blocks)instead of index order. It compiles against main as-is, so the helper already exists. There are no process, network or filesystem actions. I did not check what happens to blocks that are unreachable from the entry, which reverse postorder would not visit. That is worth confirming iftrackpreviously processed them.Limits: WARP only, no physical hardware GPU, no game files or dumps. The test uses synthetic instruction words only.
AI use: Claude Code (Claude Sonnet 5.5)
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:32:21Z.
Automated triage for the maintainers.
Needs work (test). This makes the main walk of
crates/victory-shader/src/resource.rstrackuseir::reverse_postorder, the order lowering already uses (emit/lower.rs); it is plausible and small, and unreachable blocks are now skipped, matching what lowering emits. Intrack, only one lookup depends on the order:out.scalar.iter().find(|s| s.0 == load), which decides whether an access joins the waterfall offset path (offset_at->waterfall.loads). The new test does not check that effect: it checks the order of entries inout.scalar(what the code does, not what the result should be), anddescriptors[0].source == Loaded { load: (2, 0), .. }, whichTracer::descriptorcomputes independently of the order, so it holds onmaintoo. Please add a test whose result differs onmain, for example a lower-indexed block reading a table offset throughv_readfirstlaneand loading the descriptor from a higher-indexed block, assertingr.waterfall.loads; ideally also name a shader that hits this. CI: passing.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T16:53:24Z.
Right fix for the ordering bug: index order isn't a topological order — a producer in a higher-indexed block (e.g. appended by
split_irreducible) was visited after a consumer that needed it. RPO gives producer-before-consumer for every reachable edge except irreducible-loop backedges, which is the best a forward dataflow can do anyway.ir::reverse_postorderexists and the regression test pins exactly the split-block scenario.Pull request closed