Fix Wine pipeline worker overflows in shader translation #12

Open
github-bot wants to merge 1 commit from github-bot/gh-12 into beta AGit
Owner

@⁠gmankab on GitHub · 2026-11-25 16:16 UTC · original
gmankab:fix/klbf-vkd3d-shader-loops → beta · +144 −20 · 5 files · 1 commits · open

This ports powplusplus's shader-loop normalization and pipeline worker stack size from Fxceless. The DXIL conversion path expects a single back edge per loop header. Joining multiple back edges through a block also joins their phi inputs.

On an RX 6800, the unpatched beta reported six pipeline-worker stack overflows with its default stack and six again with a verified 64 MiB reservation. With this patch, the longer run drained the startup pipeline queue, logged zero worker stack overflows, and rendered the prologue courtyard in Series S mode with FSR 3.1.6. The run later hit the null-write exception at title offset 0x23cf683, which also occurred in an earlier stable build.

The smoke and prologue tests used commit 7bcfe20 with the same executable source as this branch. The intervening beta commits only changed documentation. The runs used different warm cache states, so the main evidence here is queue completion and disappearance of the overflow reports.

Based-on: https://github.com/fxceless/victory-fork/pull/737
Tested-on: RX 6800, Fedora Linux 45, Wine/vkd3d-proton, FSR 3.1.6
Assisted-by: gpt-6.2 sol xhigh

**@⁠gmankab** on GitHub · 2026-11-25 16:16 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/12) `gmankab:fix/klbf-vkd3d-shader-loops` → `beta` · +144 −20 · 5 files · 1 commits · open This ports powplusplus's shader-loop normalization and pipeline worker stack size from Fxceless. The DXIL conversion path expects a single back edge per loop header. Joining multiple back edges through a block also joins their phi inputs. On an RX 6800, the unpatched beta reported six pipeline-worker stack overflows with its default stack and six again with a verified 64 MiB reservation. With this patch, the longer run drained the startup pipeline queue, logged zero worker stack overflows, and rendered the prologue courtyard in Series S mode with FSR 3.1.6. The run later hit the null-write exception at title offset `0x23cf683`, which also occurred in an earlier stable build. The smoke and prologue tests used commit `7bcfe20` with the same executable source as this branch. The intervening beta commits only changed documentation. The runs used different warm cache states, so the main evidence here is queue completion and disappearance of the overflow reports. Based-on: https://github.com/fxceless/victory-fork/pull/737 Tested-on: RX 6800, Fedora Linux 45, Wine/vkd3d-proton, FSR 3.1.6 Assisted-by: gpt-6.2 sol xhigh
vkd3d-proton's DXIL-to-SPIR-V converter keeps a single back edge per loop
header and treats additional back edges as forward edges, recursing
indefinitely over the resulting cycle in shaders with wave shuffles.
Large traversal shaders also overflow the default 2 MiB thread stack during
vkd3d-proton DXIL conversion under Wine, hanging the worker thread instead
of returning an error.

Add Module::single_latches() before bitcode emission to route multi-latch
loop headers through a single synthetic latch block joining their phi
values, and raise the pipeline worker stack size to 256 MiB (reserved
virtual space, committed on demand) in both victory-gpu and the translate
CLI.

Fixes all 6 previously hanging ray-tracing shadow shaders on RTX 3080
under Wine/vkd3d-proton (0 timeouts, 6/6 pipelines created).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:51:33 +00:00
Author
Owner

@⁠PastiiJay on GitHub · 2026-11-25 16:18 UTC · original

Thanks @⁠gmankab! Since this touches the shader translator for every card, we'll run it in game on our RX 9070 XT first (it goes into our next test build) and merge here once it holds. Will report back in this PR.

**@⁠PastiiJay** on GitHub · 2026-11-25 16:18 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/12#issuecomment-7167769244) Thanks @⁠gmankab! Since this touches the shader translator for every card, we'll run it in game on our RX 9070 XT first (it goes into our next test build) and merge here once it holds. Will report back in this PR.
Author
Owner

@⁠HandshakeHackin on GitHub · 2026-11-26 08:35 UTC · original

I checked the loop rewrite on native Windows with a synthetic compute shader whose two back edges update a counter and an accumulator differently. The fixture runs 128 threads, including eight that skip the loop. It validates the generated DXIL, dispatches it on WARP, and compares both values from every thread with a CPU reference.

All 256 output dwords matched in each of four runs on the parent (39cd1f4) and the PR (7b916df), each with optimizations off and at their default. The CPU reference took the two back edges 448 and 256 times respectively. This covers the values carried around the loop on Windows. Runnable test · Four Windows runs

**@⁠HandshakeHackin** on GitHub · 2026-11-26 08:35 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/12#issuecomment-7186776973) I checked the loop rewrite on native Windows with a synthetic compute shader whose two back edges update a counter and an accumulator differently. The fixture runs 128 threads, including eight that skip the loop. It validates the generated DXIL, dispatches it on WARP, and compares both values from every thread with a CPU reference. All 256 output dwords matched in each of four runs on the parent (`39cd1f4`) and the PR (`7b916df`), each with optimizations off and at their default. The CPU reference took the two back edges 448 and 256 times respectively. This covers the values carried around the loop on Windows. [Runnable test](https://github.com/HandshakeHackin/klbf-lab/blob/4b384728cba3ef8343872bda793993385223b840/crates/victory-shader/src/emit/latch_readback_tests.rs) · [Four Windows runs](https://github.com/HandshakeHackin/klbf-lab/actions/runs/45783596189/job/139784758430)
Author
Owner

@⁠PastiiJay on GitHub · 2026-11-26 10:41 UTC · original

Thanks for checking the loop rewrite on native Windows, that settles the Wine-only worry. We'll give it a run in game too.

**@⁠PastiiJay** on GitHub · 2026-11-26 10:41 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/12#issuecomment-7189712266) Thanks for checking the loop rewrite on native Windows, that settles the Wine-only worry. We'll give it a run in game too.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/12/head:github-bot/gh-12'
git switch 'github-bot/gh-12'

Merge

Merge the changes and update on Forgejo.
git switch 'beta'
git merge --no-ff 'github-bot/gh-12'
git switch 'github-bot/gh-12'
git rebase 'beta'
git switch 'beta'
git merge --ff-only 'github-bot/gh-12'
git switch 'github-bot/gh-12'
git rebase 'beta'
git switch 'beta'
git merge --no-ff 'github-bot/gh-12'
git switch 'beta'
git merge --squash 'github-bot/gh-12'
git switch 'beta'
git merge --ff-only 'github-bot/gh-12'
git switch 'beta'
git merge 'github-bot/gh-12'
git push origin 'beta'
This discussion has been locked. Commenting is limited to contributors.
No description provided.