Pipelines: recover when a host compile thread dies (VICTORY_PIPE_FIX=1) #162
No reviewers
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX!162
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-162"
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?
@jtrudeau1530 on GitHub · 2026-11-26 08:33 UTC · original
jtrudeau1530:pipe-fix-dead-compile-threads→main· +416 −12 · 5 files · 3 commits · openProblem
On Linux (Wine + vkd3d-proton + RADV) a few compute programs, the screen-space and tiled ray-traced shadow traces among them, never get a host pipeline. vkd3d-proton's dxil-spirv recurses without bound on a loop header with several back edges in a program with lane shuffles (
flatten_subgroup_shuffles, then the dominator recursion), the thread creating the pipeline overflows its stack and Wine ends it silently (err:virtual:virtual_setup_exception stack overflow), as described in #111.That thread is a pipeline worker inside
Pending::make, so the pipeline stays "being made" for the rest of the run. Every first use then waits for it and spends the frame's whole wait budget (#73), every frame, and a worker is lost each time.Change
Behind
VICTORY_PIPE_FIX=1(off by default, read and explained inpipeline/make.rs):The host compile runs on a thread of its own (8 MiB stack, below-normal priority). The worker waits on the thread handle, which is signalled however the thread ends. If no result was sent, the compile thread died.
The pipeline is then compiled again with its shaders translated in another control-flow shape (
victory_shader::emit::CFG_FORM_RETRIES), each try on a new thread:CFG_ONE_LATCH: one back edge per loop header, through a new empty latch block (what DXC emits;ir::single_latches).CFG_ONE_LATCH | CFG_STOP_PER_LOOP: also one loop-limit return block per loop instead of one shared by every loop (lower.rs,abort_block).These retranslations bypass the shader cache, and a shape is used only if it binds exactly like the first translation (user data, samplers, root views). The draw tables are re-planned with
TablePlan::new.Only if every shape dies is the pipeline dropped: it becomes "made, none" instead of "being made" for ever. Diagnostics name it as "the host compile thread ended without an answer". A panic while making a pipeline also leaves it dropped instead of pending, and the worker survives.
With the switch off, nothing changes: the shape is a thread-local that is 0 outside
with_cfg_form, so normal translations and the translation fingerprint are unchanged.Measurements
Linux, Wine 11.18, RADV, RX 7900 XT, vkd3d-proton. Build: avatarmanz main
39031cbmerged into codec-d/cool_fox, plus this patch. 150 s runs at the opening of the story, same build and same other switches:VICTORY_PIPE_FIX=1None of our other switches was worth more than 5-10% each. Because the difference on Linux is this large, I'd suggest making it default-on there, or default-on everywhere if you agree. It only does anything when a compile thread dies. I left it off by default to follow the repo's convention for new switches.
I ported this onto current main (
0ce46d5) without the rest of our local patches. That port builds and passes the tests below. The fps numbers above come from the 39031cb-based build; I haven't rerun the game on this exact branch.Tests
ir::tests::a_loop_with_two_back_edges_gets_one_latch: two back edges to one header give a single empty latch, the same instructions, a header phi with two incoming values, and it is idempotent. A loop with one back edge is left alone.cargo test -p victory-shader(host): 210 passed, 0 failed, 2 ignored.cargo build --locked --profile diag -p victory --features diagnostics --target x86_64-pc-windows-msvc: OK.cargo clippy -p victory-gpu -p victory-shader --target x86_64-pc-windows-msvc -- -D warnings(with and withoutdiagnostics): clean.Refs #111, #73.
AI-assisted (Claude Code); tested on my machine.
@jtrudeau1530 on GitHub · 2026-11-26 08:40 UTC · original
Measured on this PR's own branch (
78f0b2e= main0ce46d5+ this change). Diag build; Linux, Wine 11.18 with the tree-index wineserver (#111), vkd3d-proton, RADV, RX 7900 XT, Series X profile. Two consecutive 150 s runs into the opening of the story, same switches; onlyVICTORY_PIPE_FIXdiffers.VICTORY_PIPE_FIX=1So the earlier cf-x6 numbers hold on the PR branch alone. On Linux/vkd3d-proton, six pipelines whose compile thread dies are enough to cost the full 500 ms pipeline-wait budget in every frame, which matches #73's description.
@compaccount1-coder on GitHub · 2026-11-26 16:28 UTC · original
Heads-up: merged onto current
main(c9c932c), this no longer compiles. Git reports no conflict, so the merge looks clean:maingaveShaderaprobe: Option<crate::lightprobe::Role>field inb4ba4bb(light and texture probes) after this branch's base (0ce46d5), and theShader { ... }this PR builds for the retranslated program doesn't set it. It's the same program's bytes, so the same role applies.RoleisCopy:With that line, this PR merged onto
mainbuilds, andcargo test -p victory-gpu --libpasses on an RX 6700 XT (380 passed). The one failure isviews_are_made_beside_the_heap_and_copied_in, which fails on every RDNA 2 card onmaintoo (#298). I found this while running every open GPU PR's tests on real hardware.AI-assisted: yes (Claude Code)
@jtrudeau1530 on GitHub · 2026-11-26 17:39 UTC · original
Thanks @compaccount1-coder, you're right. I merged current
main(c9c932c) into the branch and addedprobe: self.probe. It now builds clean (diag + diagnostics, x86_64-pc-windows-msvc, 0 warnings). We had already been running the same fix locally on ac9c932cmerge (our cf-x9/cf-x10 builds) since this morning, withVICTORY_PIPE_FIX=1in every run.AI-assisted (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.