Shaders: DXIL bitcode clean-up passes (VICTORY_SHADER_OPT), census, and loop latch fixes #97
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/Belobug--VIctory-Belobug-AMD!97
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/97/head"
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?
@dutch2005 on GitHub · 2026-11-25 14:02 UTC · original
perf/dxil-bitcode-optimizer→main· +3548 −68 · 7 files · 2 commits · closed without mergingSummary
Ports and consolidates DXIL bitcode cleanup passes (
fxceless/victory-fork1684989),Module::reachable/live/replace_const/ empty-latch folding fixes (Zettrox/ztrx#110), and single-back-edge loop normalization (Zettrox/ztrx#119) ontoBelobug/VIctory-Belobug-AMD:emit/bitcode/opt.rs,VICTORY_SHADER_OPT): exact module cleanup passes before bitcode emission —DEAD(dead code elimination),FOLD(integer constant folding, identity simplification, constant branch pruning, single-incoming phi folding),REUSE(dominator-tree CSE for pure ops),FACTS(branch-condition and compare propagation), andLOADS(block-local load/lane reuse across non-writing ops) — plusModule::usage()pruning soShaderFlags/SFI0never declare features whose last use was removed.emit::shader_opt()invictory-gpu'sshader_cachebuild key, and addsemit::census+VICTORY_SHADER_CENSUS=<file>reporting inapps/victorytranslate.emit/bitcode.rs,emit/shader.rs):replace_constevicts the staleconst_idscache key before overwriting a constant (ztrx#110).reachable+live(&seen)ignore unreachable blocks and unreachable phi predecessors in both liveness and bitcode emission (ztrx#110).layout+one_back_edge_eachavoid folding two latches into one block / folding multi-latch headers and normalize multi-latch headers / multi-header latches prior to bitcode emission (ztrx#110,ztrx#119).Op::Allocahandled safely inoptandcensus(Effect::Lanes, never deduplicated).lower.rschanges: leftlower.rsuntouched (soTag::Guard/Tag::CounterandFIRSTare omitted here) to avoid conflicting with openlower.rssplit PRs (#72,#84).Verification
Tested locally in isolated worktree on Windows (AMD Radeon RX 6700 XT + WARP +
dxil.dll):cargo clippy -p victory-shader -p victory-gpu -p victory --no-deps --all-targets --lockedand--all-features: 0 warnings or errors in new/modified files (1 pre-existingint_valuedead-code warning inbitcode.rsunder--all-featureswithout tests).cargo check --workspace --all-targets --locked: passed.cargo test -p victory-shader --lib -- --test-threads=1: 280 passed, 2 failed, 6 ignored (all newbitcode::opt::testsincluding 400-seed randomized equivalence fuzz,bitcode::testsincludingwritten_bytes_unchanged&replace_const_evicts_old_cache_key,emit::shader::tests::{two_empty_latches_to_same_header_validate, phi_with_unreachable_predecessor_validates}, andemit::tests::the_clean_up_switch_parses_or_runs_every_passpassed; the 2 failures are pre-existing baseline Wave32 failures inemit::valu_tests::{scalar_counted_in_a_divergent_loop_read_after_it, scalar_counted_in_nested_divergent_loops}, covered by#52/#68).cargo xtask policy --staged:asset policy: 7 files ok.@jmal423 on GitHub · 2026-11-25 15:05 UTC · original
Tested this PR on Windows 11 / AMD Radeon RX 9070 XT (Series X target, on top of
01aadd1):With
VICTORY_SHADER_OPTenabled (default), all prison/corridor walls disappear and cellmates' skin renders with corrupted/confetti textures. Running the exact same binary withVICTORY_SHADER_OPT=0immediately restores all walls and fixes the cellmates' skin textures.@dutch2005 on GitHub · 2026-11-25 15:51 UTC · original
Addressed @jmal423's regression report and hardened tests against
cargo-mutants:VICTORY_SHADER_OPTnow defaults to0(opt-in) viaparse_shader_opt()incrates/victory-shader/src/emit/mod.rs, preventing the missing walls / confetti skin regression seen on RX 9070 XT while keepingon/allor pass bitmasks (0x01–0x10) available for bisecting individual clean-up passes.emit/mod.rs,emit/shader.rs,emit/bitcode/census.rs, andemit/bitcode.rs(coveringModule::tagunderVICTORY_SHADER_CENSUS=1,finish()/STENCIL_REF/live-op retention, empty-inner-latch folding, and 3-latch combining inone_back_edge_each).Verification (after final edit)
cargo test -p victory-shader --lib --locked -- --skip scalar_counted_in_: 288 passed, 0 failed, 6 ignored (2 pre-existing RDNA2 wave-size tests skipped)cargo test -p victory-gpu --lib --locked shader_cache::tests: 3 passed, 0 failedcargo test -p victory --bin victory --locked translate::tests: 1 passed, 0 failedcargo mutants --in-diff:census.rs: 52 caught, 0 missedmod.rs: 6 caught, 0 missedshader.rs: 17 caught, 3 unviable, 2 equivalent/test-helper (ATOMIC_TYPED64 | ATOMIC_HEAP64disjoint bits infinish_with; test helpervalidate_and_create_cs_pso)bitcode.rs: 67 caught, 7 unviable, 2 timeouts (infinite loops inreachable) + follow-up 3 caught on line 757; remaining 2 inlayout/ line 729 are equivalent (pos[h] < pos[b]withh != balready forced by!succs(*p).contains(&h);hs.len() <= 2because terminators have at most 2 successors)cargo xtask policy --staged: 6 files ok@ySKELLETONX on GitHub · 2026-11-25 16:36 UTC · original
Tested on an RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.32015.2008, Windows 11 Pro build 26300, Rust 1.98.1, at
8a0bcda:cargo test -p victory-shader --lib --locked: 290 passed, 0 failed, 6 ignored, hardware dispatch tests included (mainat01aadd1: 266 passed). Two runs, with #140 applied on top. Without it, parallelvictory-shaderruns here sometimes crash inside WARP (d3d10warp.dll, STATUS_ACCESS_VIOLATION).maindoes that too, so it has nothing to do with this PR, but it made the first run of this PR look broken. Workspace tests only; not run in the title.Pull request closed