Shaders: one latch per loop in emitted DXIL (dxil-spirv asserts on two back edges and stalls the pipeline workers under vkd3d-proton) #257
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/fxceless--victory-fork!257
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-257"
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?
@Ortomanic on GitHub · 2026-11-24 23:01 UTC · original
Ortomanic:fx/dxil-single-latch→main· +243 −0 · 2 files · 3 commits · openChanges
vkd3d-proton's dxil-spirv asserts on both shapes (
cfg_structurizer.cpp:3492and:3486). Under Wine the assert ends the thread, so each failing program takes one pipeline worker with it. On4e17478all eight workers were gone by world entry, and about 2,100 pipelines stayed "being made" for the rest of the run, with a black world frame.This is a different failure from the one #210 documents (a merge block without a terminator in the legacy structurizer), and it does not replace that note. Here the converter asserts instead of emitting invalid SPIR-V, and the emitter change avoids it.
Validation
f2963ee2), RTX 5080, driver 620.73.04.4e17478: 8_wasserthits on 8 threads, no host pipeline logged afterwards, 2,111 pipelines still pending three minutes later.:3492assert in standalone dxil-spirv before the first commit and none after; the second commit clears the four batch-cull compute programs that hit:3486.cargo clippy --workspace --all-targets --locked -- -D warningsfor the Windows target, with and without--all-features, andcargo test -p victory-shader -p xtaskpass on this branch (cross-compiled from Linux with the pinned toolchain). One unit test is added.AI-assisted patch with local build and runtime validation.
@gingertonik on GitHub · 2026-11-25 05:08 UTC · original
Tested on Linux with an RTX 4080, on top of
c96b4f2(plus local Linux patches that do not touch the emitter). For our set, both commits are needed: the second is what fixes fdd56d97a806bcca.Offline gate. 935 compute programs saved from one world run (compute only, so not the whole pack), translated for 32-lane waves as the runtime does on this card, then each run through dxil-spirv 114e664e (the version inside vkd3d-proton 2576c0b4a), built natively, Release:
c96b4f2c96b4f2+ our own one-latch-per-loop change (its output is identical to this PR's on 931 of the 935)c96b4f2+ this PRcfg_structurizer.cpp:3492on the first three and at:3486on fdd56d97a806bcca. In Release, with asserts compiled out, the same shapes run on into unbounded recursion and the process dies of a stack overflow.In game (GE-Proton11-12's Wine, vkd3d-proton 2576c0b4a). Each failing program kills one pipeline worker ("has overflowed its stack"), and its pipeline is never built.
c96b4f2: 4 overflows and 4 pipelines "being made", in each of 4 runs.Not checked:
310c6eb).Environment: CachyOS, kernel 7.3.5, NVIDIA 620.73.04, RTX 4080; GE-Proton11-12 (Wine) with vkd3d-proton 2576c0b4a; offline dxil-spirv 114e664e.
AI-assisted (Hermes).
@Ortomanic on GitHub · 2026-11-25 15:11 UTC · original
Thanks @ErRusso and @gingertonik.
89f027a,a_block_continuing_two_loops_keeps_one_back_edge. A block with back edges to an inner and an outer header keeps one; the other goes through a block of its own, and that header's phis name the new block. It also checks that no block is left with back edges to two headers and that a second pass adds nothing.0b0074e. On the merged treecargo test -p victory-shader -p xtaskpasses (177) and both bitcode tests pass under Wine. Clippy with-D warningsfails on the merged tree, but with the same errors as0b0074ealone (dead code and two lints invictory-gpu; #982 and #841 are open for them); on the branch itself it passes in both feature sets.I did not rebase, so the reviewed commits are unchanged; the head is
39b17ebplus the test commit.AI-assisted (Claude Code); built and tested locally on CachyOS, Wine 11.22, RTX 5080.
@gingertonik on GitHub · 2026-11-25 15:26 UTC · original
Thanks. One more data point for current main, at the conversion level rather than unit tests.
On
0b0074ewith this PR's two commits, the same offline gate as before (compute programs saved from one world run, translated for 32-lane waves, each run through dxil-spirv 114e664e): 936 of 936 convert. One more program translates on main than onc96b4f2(ceb5eb68cd99cb07). The other 935 are byte-identical to this PR's output onc96b4f2.The tree I used carries local patches outside
victory-shader. Itsvictory-shader/srcmatches0b0074emerged with89f027a, except for the new test.Still not checked here: an image comparison of the four programs the second commit changes, and an in-game run on the merged tree (next).
Environment: CachyOS, kernel 7.3.5, NVIDIA 620.73.04, RTX 4080; offline dxil-spirv 114e664e.
AI-assisted (Hermes).
@ErRusso on GitHub · 2026-11-24 23:41 UTC · original · approved these changes
Reviewed at
39b17ebagainst2119b0e.The emitter now gives each loop one latch, redirecting multiple back edges through a latch block and joining the header's phis there. The extra via-block pass handles a block that continues two loops. The fold guard also prevents putting two back edges on one block.
Verified:
emit::bitcode::tests::single_latchespasses under Wine. The author's offline run over 505 title programs (none assert after, 505 before) and the live vkd3d-proton run are strong integration evidence.Non-blocking: the unit test covers the main multiple-back-edge case but not the via-block path (a block continuing two loops). A second bitcode test for that shape would protect the first pass.
LGTM.
@Filip722 on GitHub · 2026-11-26 19:35 UTC · original · edited 2026-11-26 19:45 UTC
Confirmed on a physical RTX 5060 Laptop 8 GB with Bazzite 44, NVIDIA 615.78.08, GE-Proton11-14 and vkd3d-proton 3.2.0 (cae8353ed7959c4+). I applied the three commits on top of the same main
52ac4eccompatibility build and matched the initial local caches, offline Series S checkpoint and launch settings.Four compute jobs on the baseline remained in CreateComputePipelineState for 97–98 seconds at the end of the diagnostic startup. The same jobs finished with #257, and the trace recorded actual native creation calls for all four. They took 0.388, 1.569, 1.648 and 1.723 seconds. Both runs used the default pipeline-worker stack.
Seven focused Windows bitcode tests passed under Proton, including both loop-latch regressions, and seven pipeline scheduler tests passed. Related baseline timing on #1312.
The #257 run also reached the rendered prison doorway, with visible camera movement from held input. A 54-second stationary sample counted 224 completed DXGI Presents (4.14 FPS, 196/432 ms median/p95). All nine scheduler samples in that window showed zero pending jobs. The patch was tested for pipeline completion and playable rendering. The longer replay is a single sample.
Assisted by Codex (GPT-6.2-Sol High).
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.