Skip to content

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

Open
powplusplus wants to merge 1 commit into
fxceless:mainfrom
powplusplus:shader/one-back-edge
Open

powplusplus wants to merge 1 commit into
fxceless:mainfrom
powplusplus:shader/one-back-edge

Conversation

@powplusplus

Copy link
Copy Markdown

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.

…ine stack

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).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
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.

@UwUCammie

Copy link
Copy Markdown

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#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants