perf(shader): isolate structural tables and dominator reuse #545
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!545
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-545"
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?
@tommiehansen on GitHub · 2026-12-05 02:41 UTC · original
tommiehansen:review-split/402-mechanical→main· +420 −201 · 1 files · 2 commits · merged 2026-12-05 17:28 UTCReview split from #402, based on current upstream main. The diff contains this one slice.
Linux shader suite: 298 passed and 2 ignored. The audit job failed the inherited launcher-switch documentation check tracked in #528.
Exact pinned CI evidence
No hardware timing or gameplay results. The original PR remains available until maintainers choose the integration order.
Post-review follow-up — 2026-12-05
Head:
ccfd8463fef495ec0629b4814cb9fa0dce324765.The follow-up preserves separate instruction and phi namespaces through a sparse lookup fallback for programs with unreachable blocks or a NONE value. Normal reachable SSA retains the dense table. Added regressions for a dead-write/live-phi collision and the NONE sentinel. This does not require #546 to be merged first, though #546 removes the underlying unreachable-block issue.
Fresh pinned debug/release CI started; new test and performance results must be reported at this head. Previous validation is retained at its original revision.
Standard CI raw-artifact follow-up (2026-12-05)
Identical output digest; reported 95% CI −2.90% to −2.24%. Four complete ABBA blocks, eight runs per arm. Independently checked all 16 raw checkpoint revisions, per-run sample concatenation, medians and digests against results.json. The Python review gate incorrectly interprets
rounds=8(runs per arm) as eight ABBA blocks; its automatic verdict remains inconclusive pending a harness fix. The CIs above, where stated, are the Rust report's per-workload estimates. Generic software Vulkan control passed with identical SPIR-V, not activation of this PR. No physical GPU or gameplay FPS claim. Pinned CI/artifacts.@Kal0s-design on GitHub · 2026-12-05 06:34 UTC · original
Checked
a6ca7d3on native Windows (one NVIDIA desktop card plus WARP, didn't run the game). Merge base isb581f7e, current main.I went through every changed function and it reads as a straight refactor to me. The inline reducibility check in
Lanes::new(structure.rs:1034) is the same loop asir::irreducible_edge, same edge order and samefromblock, so the error offset doesn't change, and the idom table is now computed once instead of twice.ir::idomsworks frompredswhere the oldcompute_idomsworked from the exits, which is only the same thing ifpredsis current. Every place that rewrites exits in ir.rs callslinkafter it, so it holds. Unreachable blocks come back asusize::MAXinstead ofNone, anddominatesand the dominator-chain walk in the owner pass check for that explicitly. Theexpect/unwrapthat becamedebug_assert_ne!(structure.rs:1202, 3357) still panic in release, because the nextindex[]lookup withusize::MAXis out of bounds, so a broken invariant doesn't go quiet. Moving the WQM discovery intostructure_wide(structure.rs:864) does the same work main'shelped()did on its ownLanes, then rebuilds a fresh one, so the BDD table starts clean as before. Inhelped_nowandcheck_joinsthe clones became index loops. That's fine becausemaskonly appends tojoins/phi_joinswhile the loop runs andresetcan't be reached from there, and the short-circuit order (and so the BDD node order) is the same.One difference only shows up on programs with dead blocks. Main kept
defsandphisin two maps, andlocs(structure.rs:1069) puts both in one slot per value. Dead blocks keep the stale value ids from the program they were cloned from, andrenamenever visits them. If such a stale write reuses the id of a live phi, the phi lookup now misses where main still found it. #546 prunes those blocks before rename, so with that merged nothing like this reachesstructure. The one suite program that does hitstructurewith a dead block had no such collision. Also, themax_valscan at structure.rs:1054 has noNONEguard, while #547 adds one to the same kind of scan. I couldn't find a way for aNONEphi or write value to reachstructure, but if one ever did,vec![DefLoc::None; max_val]would try to allocate tens of GB and abort instead of panicking.cargo test -p victory-shader --lib -- --test-threads=4(debug) gave 423 passed, 1 failed, 4 ignored. Main gave 419 passed, 1 failed, 4 ignored. The failure issize_tests::a_reused_descriptor_register_read_only_behind_its_flagon both, and it already fails on main. Apart from the four new tests, the set of passing tests is the same. The four new tests also pass on main, so they pin behaviour and don't reproduce a bug. Clippy with--lib --tests --examplesgives the same 12 warnings as main. rustfmt wants one change, thestructure_wide(&p, &HashSet::from([999]))...line inkept_wqm_with_empty_helped_uses_fresh_bdd_state(structure.rs:4748) needs wrapping.For the output I hashed every DXIL container the test suite produces, and all 840 of 840 are byte-identical to main. With a throwaway check inside
Lanes::newduring that run, all 1108Lanes::newcalls the suite makes got an idom table identical to main'scompute_idoms.predsmatched the exits every time, and no value was both a phi and an instruction result. One of those calls had unreachable blocks (ina_far_early_out_is_left_out_and_the_gate_counts_the_lanes_of_both_halves), so theusize::MAXpath ran once in the suite. To cover more of it I fuzzed 200k random CFGs, about 166k with unreachable blocks and about 15k irreducible.ir::idomsmatched main'scompute_idomson every block of every graph.Lanes::newrejected exactly the graphsirreducible_edgeflags, with the same offset, anddominatesanswered no for unreachable blocks as main does.On speed I couldn't measure a gain. I collected the 1046 distinct
ir::buildinputs the suite uses and replayedbuildplusstructurein release, interleaving main and PR over several rounds. On the 1044 small programs the medians were within about 3% of each other, and run-to-run noise was bigger than that. That timed region includesbuild, which this PR doesn't touch and which is over half of it, so a gain instructurealone could be bigger than the total shows. I didn't timestructureseparately. The two large programs (the 4096-layer diamond chains fromreverse_order_diamond_chain_eliminates_trivial_phis) take most of thestructuretime, and there the noise was also bigger than any difference. The test programs are tiny compared to real shaders, so this says little about the game. A run over a real shader cache would answer it better.The body says this is split from #402, and the commit title matches. Compared with #402's structure.rs, what's left out is the BDD memo and scratch work (
BddWork, the*_withhelpers), though I didn't go hunk by hunk. It merges cleanly with #546 and with #547. I didn't run the Linux suite. The body's 298 passed fits one shared baseline plus the four new tests, the same as #546's 298 and #547's 295. I didn't test real game shaders, a shader cache run, gameplay, release-build test behaviour, or AMD and other vendors' drivers.AI-assisted: yes
@tommiehansen on GitHub · 2026-12-05 10:18 UTC · original
Thanks @Kal0s-design! The stale SSA collision and NONE allocation concern are addressed at ccfd846: unreachable/sentinel cases retain separate sparse definition and phi maps, while ordinary SSA keeps dense lookup. Both new regression tests pass in debug and release. No performance claim beyond the measured data.