victory-shader: build the per-instruction read/write lists once (ir::build -13%) #1033
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1033"
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 pes7 on 2026-11-24T15:14:12Z.
ir::buildallocates four times per instruction for lists of two to four registers. This builds them once, for 13% off the SSA pass and 4.7% off a translation, with byte-identical output.effects()collects each instruction's register lists asVec<Reg>- two allocations - and the caller immediately maps them intoVec<(Reg, Value)>, the shape the IR wants - two more allocations - and frees the first pair. On a 26k-instruction program that is ~100k allocations and ~50k copies that nothing reads.What changes
effects(),add_regs(), themask/indexedhelpers and the branch arms push(Reg, NONE)directly, the placeholder the SSA pass fills in. Two allocations per instruction instead of four.Inst,Phiand everything downstream are untouched; the placeholder value is the sameNONEit was mapped to a line later.Measured
The bench is the one added in #1002 (
crates/victory-shader/src/emit/bench_tests.rs, synthetic GFX10 compute programs, no game data). Ten interleaved rounds per arm, best of ten, nanoseconds per instruction:ir::buildbeforegfx10::decode(105-113 ns),structure,resource,ioandlowerare unchanged, which is the check that the change did what it claims and nothing else.The bench lives in #1002 and the numbers above were measured on top of it, but this branch is only the
ir.rschange - one file, +25/-25 - and applies tomainon its own; nothing here depends on #1002 landing first.Correctness
cargo test --workspace --locked: 342 passed, 0 failed, 7 ignored.-D warnings;cargo xtask policy: 173 files ok.No game data used.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T16:28:57Z.
Review: APPROVED
Pure refactor: effects() now returns (Reg, Value) pairs with NONE placeholders directly instead of Reg vecs + unset closure; the vector rule (VGPR writes auto-added to reads, 'lanes disabled in EXEC keep the old value') is preserved via .cloned(). No behavior change, existing 96 tests cover it. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main
ffe310e,cargo test -p <crate> --locked. Shader execution tests (valu_tests/host) are#[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. victory-shader: 96 passed, 0 failed.Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T16:30:31Z.
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
94cc038:cargo test -p victory-shaderpasses, 120 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 pes7 on 2026-11-24T22:03:47Z.
Rebased onto today's
main(70564ae), which conflicts onir.rs:buildbecamebuild_boundedandeffectsnow takesm0_max: Option<u8>to bound relative moves (v_movrel*). Both survive - the pairs this PR returns are still pairs, and the bound still cuts the range:Head is now
266f671.cargo test -p victory-shader --locked: 209 passed, 0 failed; both clippy configurations with-D warningspass, as doescargo xtask policy. The diff against this PR is unchanged (+25/-25, one file).@catminou4 - your approval is still shown on the PR, but the head moved because of the rebase, so re-check if you want the approval to be for this exact tree; the change itself is the same one you reviewed.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:19:17Z.
Automated triage for the maintainers.
Merge candidate. The head (
d809fb7) has not changed since the last review and still merges cleanly.effects()andadd_regs()incrates/victory-shader/src/ir.rspush(Reg, NONE)pairs directly, sobuild_boundedno longer converts eachVec<Reg>through theunsetclosure. The resulting IR is the same:NONEis the placeholder the closure added, theseen.containsdedup and them0_max-bounded indexed range are unchanged, and both functions are private to this file.Reply to the author: thanks for the corpus measurement (-3.2% wall time, output identical on all 26,084 programs). It confirms the earlier reading, so the verdict stays. #1623 is a separate decoder change and does not overlap.
CI: passing.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T11:54:22Z.
Review: APPROVED
Verified against
origin/main(940d32f):cargo test -p victory-shader ir::tests: 9/9 passed.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 pes7 on 2026-11-25T16:26:55Z.
Real corpus, same method as the note on #1002: the Xbox build's
shaders.rpf- 26 084 programs, 40 601 701 IR instructions -victory translate <shaders.rpf> --list, three binaries running at the same time on one thread each (--jobs 1) on a 32-core machine, so they share identical conditions and the control is common:mainmain940d32fd809fb7246c928So the claim holds on real programs and not only on the bench: -3.2% for the whole translation here, against the -4.7% the PR measured on synthetic programs (a real program is 1 557 instructions on average, so the SSA share is a little smaller there).
The output is identical to
mainon all 26 084 programs - every count in the summary and everyemit:/resources:line matches; only the(e.g. ...)examples differ between runs, because the thread that finishes first supplies the example.For the record, the same measurement says the earlier Fx-hasher change (#1002) is -0.3%, i.e. neutral, and I have closed it: whatever
lower's tables cost on synthetic programs, on this corpus they are not what the translation spends its time on.