Shaders: fix duplicate latch folding, unreachable phi edges, and replace_const caching in DXIL bitcode #1145
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1145"
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 hamdog0203 on 2026-11-24T16:13:34Z.
Summary
Fixes three bugs in DXIL bitcode emission (
crates/victory-shader/src/emit/bitcode.rs) with byte-identical output preserved for existing reachable single-latch shaders (written_bytes_unchangeduntouched):pand target the same loop headerh, folding both merged them into the same predecessor blockp, producing duplicate incoming block entries with different values inh'sOp::Phi(rejected bydxil.dll). Track(p, h)pairs infolded_edges(and require neither endpoint is already folded) so at most one empty latch folds per(p, h)edge.live()andOp::Phi: Computereachable()beforelive(&seen), skip unreachable blocks/phi-edges during liveness propagation, and omit unreachable incoming edges when writingOp::Phiinstead of panicking on unnumbered values.Module::replace_const: Remove the old(ty, Const)entry fromconst_idswhen overwritingoldwithnew, preventing subsequent requests for the old constant from aliasing the replacement value.Verification
Tested on Windows 11 (Build 26200), NVIDIA GeForce RTX 4060 (driver
621.35, 32-lane waves), Rust1.98.1, Windows SDKdxil.dll(10.0.26100.0), and WARP:cargo clippy --workspace --all-targets --locked -- -D warnings: passcargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passcargo test --workspace --locked(RTX 4060): all tests pass (victory-shader: 123 passed, 0 failed, 1 benchmark ignored; includingwritten_bytes_unchanged,dxil.dllvalidation, andHost::compute_pipelineon RTX 4060 and WARP)VICTORY_WARP=1 cargo test -p victory-shader --locked: 123 passed, 0 failed, 1 ignoredcargo xtask policy: 154 files okmain(ffe310e): all 3 new regression tests (replace_const_evicts_old_cache_key,phi_with_unreachable_predecessor_validates,two_empty_latches_to_same_header_validate) fail on unpatchedmain.Synthetic tests,
dxil.dll, WARP, and RTX 4060 hardware only; no game data. AI-assisted.Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:01:19Z.
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
ea633e7:cargo test -p victory-shaderpasses, 123 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
upstream-sync referenced this pull request2026-11-24 19:03:41 +00:00
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:17:41Z.
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/bitcode.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.