Shaders: a loop that branches back to the entry instruction translates #105
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!105
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-105"
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?
@tedin7 on GitHub · 2026-11-24 00:32 UTC · original
tedin7:vic-loop-entry→main· +64 −10 · 1 files · 1 commits · openWhat
Accept shader loops whose back edge targets byte offset zero. The IR builder now puts an empty entry block before the code when the first instruction is a jump or branch target, so the loop header has one edge for the initial register values and one for the loop-carried values.
Why
A valid shader whose first instruction is also its loop header was rejected with
Unsupported { offset: 0, what: "a branch to the program entry" }, because block 0 was both the entry and a loop header and SSA had no edge to carry the initial values into its phis. Every other loop shape already works. Only the entry-block handling changes. Block indices shift by one only when the program branches to offset 0.Tested
Linux x86_64 only, synthetic shader words only (no game files):
cargo test -j4 -p victory-shader ir::tests::loops_can_branch_to_offset_zeroon origin/main plus only the new test: FAILED withUnsupported { offset: 0, what: "a branch to the program entry" }.structure::structureaccepts the result.cargo test -j4 -p victory-shader: 52 passed, 0 failed.cargo clippy -j4 -p victory-shader --tests: no warnings in ir.rs; the 2 existing warnings elsewhere are unchanged.rustfmt --check --edition 2024 crates/victory-shader/src/ir.rs: clean.Not run: Windows runtime and any GPU execution. The emit path was not run on a real shader, only the IR and structuring steps.
@lordon1a on GitHub · 2026-11-24 00:51 UTC · original
Verified
6e6d3fc02on Windows 11 (x86_64-pc-windows-gnullvm,rustc 1.100.0, applied cleanly tomain@4c0bb89): pass.cargo xtask policy: 151 files okcargo test -p victory-shader -- --skip v_med3_f32_matches_rdna2_with_nan: 69 passed, 0 failed.AI-assisted.
@DaviTostes on GitHub · 2026-11-24 01:09 UTC · original
Tested
6e6d3fcon Arch Linux x86_64, rustc 1.98.1: pass.cargo test -p victory-shader: 52 passed, 0 failed (2 test binaries), including the 1 test this PR adds.victory-gpuE0425.@Marvisak on GitHub · 2026-11-25 00:24 UTC · original
Automated triage for the maintainers.
Merge candidate.
ir::build_boundedincrates/victory-shader/src/ir.rsrejected any program that branches to offset 0 ("a branch to the program entry"); it now puts an empty entry block in front of the code, giving SSA a separate edge for the initial register values (a standard preheader). Block indices (block_at, thepartition_pointmapping) shift consistently, programs that never target offset 0 are unchanged, andexitinemit/lower.rshandles an empty block. The test checks the block layout, both phi inputs and thatstructure::structureaccepts the result.CI: no check runs on the head commit.
Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-26 01:11 UTC · original
Code review and RTX 5090 + WARP + DXIL verification at head
6e6d3fc027d0merged cleanly ontomain(63bcca43c6a0;emit/lower.rsuntouched):crates/victory-shader/src/ir.rs:165-198):blocks[0](offset: 0, preds: [], exit: Exit::Jump(1)) when anyFlow::Jump(0) | Flow::Branch(0)targets offset 0 shifts machine block indices cleanly while keepingmachine.offset == 0intact fors_getpc_b64.lower.rs:1302-1345):self.block[0]maps toself.s.entry(including mesh shaders updatingorder[0]), and the loop header atblocks[1]receives initialp.inputs, loop counter0, and activeEXECalong the0 -> 1edge cleanly.dxil.dll10.0.26100.0,VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy:191 files ok;cargo clippy -p victory-shader --all-targets --locked -- -D warnings(default +--features diagnostics): 0 warningsir::tests(10/10, includingloops_can_branch_to_offset_zero),structure::tests(13/13, 1 ignored), andemit::tests(17/17 on both RTX 5090 and WARP) all passed.LGTM.
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.