Shaders: visit resource::track blocks in reverse postorder #2422

Open
github-bot wants to merge 1 commit from github-bot/gh-2422 into main AGit
Owner

@⁠makmatvey on GitHub · 2026-11-25 13:12 UTC · original
makmatvey:cursor/shaders-rpo-resource-track-a13d → main · +45 −1 · 1 files · 1 commits · open

What

resource::track walked blocks in vector index order. After CFG transforms that append blocks (for example split_irreducible), a lower-indexed consumer could run before a higher-indexed s_load producer, so out.scalar did 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 uses reverse_postorder so producers populate out.scalar before consumers.

Tests

  • cargo test -p victory-shader --locked --lib track_visits_blocks_in_reverse_postorder — pass (fails on main without the walk change)
  • cargo test -p victory-shader --locked --lib resource:: — 34 passed
  • cargo clippy -p victory-shader --locked -- -D warnings — clean
  • cargo xtask policy — ok

No game data used.

Fixes VIC-BT-024 in #1249.

**@⁠makmatvey** on GitHub · 2026-11-25 13:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/2422) `makmatvey:cursor/shaders-rpo-resource-track-a13d` → `main` · +45 −1 · 1 files · 1 commits · open ## What `resource::track` walked blocks in vector index order. After CFG transforms that append blocks (for example `split_irreducible`), a lower-indexed consumer could run before a higher-indexed `s_load` producer, so `out.scalar` did 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 uses `reverse_postorder` so producers populate `out.scalar` before consumers. ## Tests - `cargo test -p victory-shader --locked --lib track_visits_blocks_in_reverse_postorder` — pass (fails on `main` without the walk change) - `cargo test -p victory-shader --locked --lib resource::` — 34 passed - `cargo clippy -p victory-shader --locked -- -D warnings` — clean - `cargo xtask policy` — ok No game data used. Fixes VIC-BT-024 in #1249.
Index order missed scalar loads that live in higher-indexed blocks when a
lower-indexed consumer ran first (for example after split_irreducible). RPO
populates out.scalar before those consumers look it up.

VIC-BT-024 in #1249; focused slice of the stalled #1336 bundle.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:05:21 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 13:34 UTC · original

WARP verification

Tested: PR head 750445401e3f486a75cb58a5dcfd4d1fd01c83e2, on origin/main 940d32f69b22265690a0b5a15d6ded572ba33baf (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 on PATH.

Command Result
cargo test -p victory-shader --lib --locked ok: 248 passed, 0 failed, 3 ignored (two benchmarks and one defect_ test, all ignored on main too)
cargo clippy -p victory-shader --all-targets --locked -- -D warnings exit 0
cargo xtask policy asset policy: 182 files ok, exit 0

The new test resource::tests::track_visits_blocks_in_reverse_postorder ran and passed (not skipped).

Diff review (resource.rs only): track now iterates crate::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 if track previously 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)

**@⁠oni-swr** on GitHub · 2026-11-25 13:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2422#issuecomment-7163981377) **WARP verification** Tested: PR head `750445401e3f486a75cb58a5dcfd4d1fd01c83e2`, on `origin/main` `940d32f69b22265690a0b5a15d6ded572ba33baf` (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 on `PATH`. | Command | Result | |---|---| | `cargo test -p victory-shader --lib --locked` | ok: 248 passed, 0 failed, 3 ignored (two benchmarks and one `defect_` test, all ignored on main too) | | `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` | exit 0 | | `cargo xtask policy` | `asset policy: 182 files ok`, exit 0 | The new test `resource::tests::track_visits_blocks_in_reverse_postorder` ran and passed (not skipped). Diff review (`resource.rs` only): `track` now iterates `crate::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 if `track` previously 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)
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:32 UTC · original

Automated triage for the maintainers.

Needs work (test). This makes the main walk of crates/victory-shader/src/resource.rs track use ir::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. In track, 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 in out.scalar (what the code does, not what the result should be), and descriptors[0].source == Loaded { load: (2, 0), .. }, which Tracer::descriptor computes independently of the order, so it holds on main too. Please add a test whose result differs on main, for example a lower-indexed block reading a table offset through v_readfirstlane and loading the descriptor from a higher-indexed block, asserting r.waterfall.loads; ideally also name a shader that hits this. CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/2422#issuecomment-7166998829) <!-- victory-triage v1 head=750445401e3f486a75cb58a5dcfd4d1fd01c83e2 verdict=needs-work at=2026-11-25T15:36:00Z --> Automated triage for the maintainers. **Needs work (test).** This makes the main walk of `crates/victory-shader/src/resource.rs` `track` use `ir::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. In `track`, 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 in `out.scalar` (what the code does, not what the result should be), and `descriptors[0].source == Loaded { load: (2, 0), .. }`, which `Tracer::descriptor` computes independently of the order, so it holds on `main` too. Please add a test whose result differs on `main`, for example a lower-indexed block reading a table offset through `v_readfirstlane` and loading the descriptor from a higher-indexed block, asserting `r.waterfall.loads`; ideally also name a shader that hits this. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 16:53 UTC · original

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_postorder exists and the regression test pins exactly the split-block scenario.

**@⁠kotekompotek** on GitHub · 2026-11-25 16:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2422#issuecomment-7168684934) 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_postorder` exists and the regression test pins exactly the split-block scenario.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2422/head:github-bot/gh-2422'
git switch 'github-bot/gh-2422'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2422'
git switch 'github-bot/gh-2422'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2422'
git switch 'github-bot/gh-2422'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2422'
git switch 'main'
git merge --squash 'github-bot/gh-2422'
git switch 'main'
git merge --ff-only 'github-bot/gh-2422'
git switch 'main'
git merge 'github-bot/gh-2422'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2422
No description provided.