shader: merge multiple loop back edges into one latch and raise pipeline stack #737

Open
github-bot wants to merge 1 commit from github-bot/gh-737 into main AGit
Owner

@⁠powplusplus on GitHub · 2026-11-25 06:06 UTC · original
powplusplus:shader/one-back-edge → main · +144 −20 · 5 files · 1 commits · open

Summary

Fixes vkd3d-proton hangs and stack overflows during D3D12 pipeline creation on large ray-tracing traversal shaders under Wine/Linux:

  1. Single latch per loop header (Module::single_latches): 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. Module::single_latches() runs before Module::write() and routes any loop header with 2+ back edges through a single synthetic latch block that joins their phi values (matching DXC output).
  2. 256 MiB pipeline worker stack (PIPELINE_STACK): Large traversal shaders overflow the default 2 MiB thread stack during vkd3d-proton's recursive DXIL conversion; under Wine the overflow hangs the worker thread instead of failing. Both victory-gpu pipeline workers (pipeline/make.rs) and victory translate workers (apps/victory/src/translate.rs) now reserve a 256 MiB stack (pages committed on demand).

Verification

  • Unit tests: cargo test -p victory-shader --lib (172 passed, 0 failed, including new a_header_with_two_back_edges_gets_one test).
  • Windows-target clippy (victory-shader -- -D warnings) and workspace check clean on 8dd30ab.
  • Hardware test (NVIDIA RTX 3080 12 GB, GE-Proton11-14 / vkd3d-proton, VICTORY_HOST_MAX_WAVE=32): all 6 previously timing-out ray-tracing shadow shaders now validate with dxil.dll and create D3D12 pipelines (6/6 created, 0 timeouts).
  • Live in-game verification: 893 shaders translated in-game with 0 pipeline worker hangs or stack overflows.
**@⁠powplusplus** on GitHub · 2026-11-25 06:06 UTC · [original](https://github.com/fxceless/victory-fork/pull/737) `powplusplus:shader/one-back-edge` → `main` · +144 −20 · 5 files · 1 commits · open ## Summary Fixes vkd3d-proton hangs and stack overflows during D3D12 pipeline creation on large ray-tracing traversal shaders under Wine/Linux: 1. **Single latch per loop header (`Module::single_latches`)**: 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. `Module::single_latches()` runs before `Module::write()` and routes any loop header with 2+ back edges through a single synthetic latch block that joins their phi values (matching DXC output). 2. **256 MiB pipeline worker stack (`PIPELINE_STACK`)**: Large traversal shaders overflow the default 2 MiB thread stack during vkd3d-proton's recursive DXIL conversion; under Wine the overflow hangs the worker thread instead of failing. Both `victory-gpu` pipeline workers (`pipeline/make.rs`) and `victory translate` workers (`apps/victory/src/translate.rs`) now reserve a 256 MiB stack (pages committed on demand). ## Verification - Unit tests: `cargo test -p victory-shader --lib` (172 passed, 0 failed, including new `a_header_with_two_back_edges_gets_one` test). - Windows-target clippy (`victory-shader -- -D warnings`) and workspace check clean on `8dd30ab`. - Hardware test (NVIDIA RTX 3080 12 GB, GE-Proton11-14 / vkd3d-proton, `VICTORY_HOST_MAX_WAVE=32`): all 6 previously timing-out ray-tracing shadow shaders now validate with `dxil.dll` and create D3D12 pipelines (6/6 created, 0 timeouts). - Live in-game verification: 893 shaders translated in-game with 0 pipeline worker hangs or stack overflows.
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 03:49:57 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 06:07 UTC · original · edited 2026-11-25 06:12 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T06:12:46.532839Z acd5702 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 06:07 UTC · [original](https://github.com/fxceless/victory-fork/pull/737#issuecomment-7154458573) · edited 2026-11-25 06:12 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"acd5702c38775595901fc828dd1e58a140ff6860","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-25T06:12:46.532839Z">2026-11-25T06:12:46.532839Z</relative-time> | `acd5702` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-25 11:59 UTC · original

Tested on AMD under Linux, since the description only has an NVIDIA result.

Setup: RX 7900 XT, RADV (Mesa 26.3.1), Wine 11.22 with vkd3d-proton from GE-Proton11-14, diagnostics build. Tree: main 9376fd6 merged into myokex/victory-amd, plus #857, myokex/victory-amd#6 and this PR picked on top.

Without this PR three compute pipelines never come back here: 559d9f0184e15fe3, a1b20bc47e3c9597, e8c962358d862e3f. Each keeps a worker busy until the run ends, so I have been skipping them with VICTORY_SKIP_PIPELINES.

With it, and no skip list, all three get a host pipeline. Two runs of about ten minutes each, from the start of the game into the first room (one with an empty shader cache, one warm). No hang, no device loss, and the picture of the first room is complete in both.

I didn't measure how long the three compiles take, and I haven't tried the two changes separately, so I can't say whether the latch or the bigger stack is what fixes it on this card.

**@⁠UwUCammie** on GitHub · 2026-11-25 11:59 UTC · [original](https://github.com/fxceless/victory-fork/pull/737#issuecomment-7161776770) Tested on AMD under Linux, since the description only has an NVIDIA result. Setup: RX 7900 XT, RADV (Mesa 26.3.1), Wine 11.22 with vkd3d-proton from GE-Proton11-14, diagnostics build. Tree: main `9376fd6` merged into myokex/victory-amd, plus #857, myokex/victory-amd#6 and this PR picked on top. Without this PR three compute pipelines never come back here: `559d9f0184e15fe3`, `a1b20bc47e3c9597`, `e8c962358d862e3f`. Each keeps a worker busy until the run ends, so I have been skipping them with `VICTORY_SKIP_PIPELINES`. With it, and no skip list, all three get a host pipeline. Two runs of about ten minutes each, from the start of the game into the first room (one with an empty shader cache, one warm). No hang, no device loss, and the picture of the first room is complete in both. I didn't measure how long the three compiles take, and I haven't tried the two changes separately, so I can't say whether the latch or the bigger stack is what fixes it on this card.
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/737/head:github-bot/gh-737'
git switch 'github-bot/gh-737'

Merge

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