Fix Wine pipeline worker overflows in shader translation #12

Open
gmankab wants to merge 70 commits from upstream-pr/12 into main
gmankab commented 2026-11-25 16:16:35 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by gmankab on 2026-11-25T16:16:35Z.


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

<!-- greyfinch-sync:PastiiJay/klbf-lab:issue:5494924646 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/12). Originally posted by [gmankab](https://github.com/gmankab) on 2026-11-25T16:16:35Z. --- 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
PastiiJay commented 2026-11-25 16:18:12 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-25T16:18:12Z.


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.

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7167769244 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/12#issuecomment-7167769244). Originally posted by [PastiiJay](https://github.com/PastiiJay) on 2026-11-25T16:18:12Z. --- 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.
HandshakeHackin commented 2026-11-26 08:35:20 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by HandshakeHackin on 2026-11-26T08:35:20Z.


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

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7186776973 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/12#issuecomment-7186776973). Originally posted by [HandshakeHackin](https://github.com/HandshakeHackin) on 2026-11-26T08:35:20Z. --- 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)
PastiiJay commented 2026-11-26 10:41:53 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-26T10:41:53Z.


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

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7189712266 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/12#issuecomment-7189712266). Originally posted by [PastiiJay](https://github.com/PastiiJay) on 2026-11-26T10:41:53Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/12:upstream-pr/12'
git switch 'upstream-pr/12'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/12'
git switch 'upstream-pr/12'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/12'
git switch 'upstream-pr/12'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/12'
git switch 'main'
git merge --squash 'upstream-pr/12'
git switch 'main'
git merge --ff-only 'upstream-pr/12'
git switch 'main'
git merge 'upstream-pr/12'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
PastiiJay/klbf-lab!12
No description provided.