Shaders: fix duplicate latch folding, unreachable phi edges, and replace_const caching in DXIL bitcode #1145
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1145
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@hamdog0203 on GitHub · 2026-11-24 16:13 UTC · original
hamdog0203:fix/bitcode-latch-phi-const→main· +173 −36 · 2 files · 1 commits · openSummary
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.@Zipettte on GitHub · 2026-11-24 18:01 UTC · original
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).
@Marvisak on GitHub · 2026-11-25 01:17 UTC · original
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
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.