Shaders: a mesh phase loop sits inside if (pc < PC_YIELD) (fixes the NVIDIA hang in #9) #71

Manually merged
github merged 1 commit from github-bot/gh-71 into gh-pr/71/base 2026-11-28 12:19:01 +00:00 AGit
Owner

@⁠upipibi on GitHub · 2026-11-28 10:28 UTC · original
upipibi:fix/mesh-phase-if-guard → main · +8 −2 · 2 files · 1 commits · merged 2026-11-28 12:18 UTC

Fixes #9: the mesh hang on NVIDIA (ms_ngg_first_lane, and the barrier loop with supersteps: false).

What changed

StructuredBodyWriter.Phase emits if (pc < PC_YIELD) { before the phase's [loop] while (pc < PC_YIELD), and one more } after it. The class comment and docs/shader-translation.md now say why.

Why

dxc gives each phase one loop whose header (pc < PC_YIELD) is reached by two back-edges every round, one from every switch case and one from the barrier tail, through one latch. NVIDIA hangs on that shape (DXGI_ERROR_DEVICE_HUNG, nvlddmkm 153). With the guard, the cases go forward to the round tail and the only back-edge left is the barrier one. Every case already ends at a yield or the end, so nothing the program does changes. The while stays, because WARP's compiler needs it.

The bisect behind this (DXIL shapes, controls, and which variants hang) is in #9. You confirmed it on a 4090 (comment).

It changes the HLSL of every two-phase mesh program (you counted 8,765 in the corpus), so testers will retranslate them.

How it was checked

RTX 3070, driver 616.56 (32.0.16.1656), Windows 11 Pro 10.0.26100, Release, on main 139a62c9. Each hardware line ran as its own dotnet test process with FIVESTAR_TEST_ADAPTER=hardware.

Test main this PR (3 runs)
Counts_read_from_the_first_lane_are_exchanged_so_the_program_runs_on_narrower_waves (both rows) 0 of 2, device removed (0x887A0006) 2 of 2 each run
A_barrier_loop_draws_with_few_iterations_and_ends_at_the_round_bound_with_many 1 of 2 (supersteps: false removes the device) 2 of 2 each run

The whole solution's tests on the default (WARP) adapter give the same counts on main and on this PR:

Project Passed Failed Skipped
FiveStar.Shaders.Tests 606 0 14
FiveStar.Loader.Tests 577 1 20
FiveStar.Architecture.Tests 31 0 0
FiveStar.Formats.Tests 23 0 19
FiveStar.Cli.Tests 17 0 7
FiveStar.Debugger.Tests 2 0 0

The one Loader failure is the same on main: D3D12XStandInPipelineTests.A_first_use_is_held_while_the_shader_table_is_nearly_full.

Not checked: the WARP compiler crash that the class comment mentions, because the while is kept. Also not checked: AMD, Intel, and any real title or game file.

AI-assisted: Claude Code (Claude Opus 5.5) did the bisect, wrote the change and ran the tests above.

**@⁠upipibi** on GitHub · 2026-11-28 10:28 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/71) `upipibi:fix/mesh-phase-if-guard` → `main` · +8 −2 · 2 files · 1 commits · merged 2026-11-28 12:18 UTC Fixes #9: the mesh hang on NVIDIA (`ms_ngg_first_lane`, and the barrier loop with `supersteps: false`). ## What changed `StructuredBodyWriter.Phase` emits `if (pc < PC_YIELD) {` before the phase's `[loop] while (pc < PC_YIELD)`, and one more `}` after it. The class comment and `docs/shader-translation.md` now say why. ## Why dxc gives each phase one loop whose header (`pc < PC_YIELD`) is reached by two back-edges every round, one from every switch case and one from the barrier tail, through one latch. NVIDIA hangs on that shape (`DXGI_ERROR_DEVICE_HUNG`, nvlddmkm 153). With the guard, the cases go forward to the round tail and the only back-edge left is the barrier one. Every case already ends at a yield or the end, so nothing the program does changes. The `while` stays, because WARP's compiler needs it. The bisect behind this (DXIL shapes, controls, and which variants hang) is in [#9](https://git.gtahub.st/github/ThatRecompDev--five-star-recomp/issues/9). You confirmed it on a 4090 ([comment](https://git.gtahub.st/github/ThatRecompDev--five-star-recomp/issues/9)). It changes the HLSL of every two-phase mesh program (you counted 8,765 in the corpus), so testers will retranslate them. ## How it was checked RTX 3070, driver 616.56 (32.0.16.1656), Windows 11 Pro 10.0.26100, Release, on `main` `139a62c9`. Each hardware line ran as its own `dotnet test` process with `FIVESTAR_TEST_ADAPTER=hardware`. | Test | `main` | this PR (3 runs) | |---|---|---| | `Counts_read_from_the_first_lane_are_exchanged_so_the_program_runs_on_narrower_waves` (both rows) | 0 of 2, device removed (`0x887A0006`) | 2 of 2 each run | | `A_barrier_loop_draws_with_few_iterations_and_ends_at_the_round_bound_with_many` | 1 of 2 (`supersteps: false` removes the device) | 2 of 2 each run | The whole solution's tests on the default (WARP) adapter give the same counts on `main` and on this PR: | Project | Passed | Failed | Skipped | |---|---|---|---| | FiveStar.Shaders.Tests | 606 | 0 | 14 | | FiveStar.Loader.Tests | 577 | 1 | 20 | | FiveStar.Architecture.Tests | 31 | 0 | 0 | | FiveStar.Formats.Tests | 23 | 0 | 19 | | FiveStar.Cli.Tests | 17 | 0 | 7 | | FiveStar.Debugger.Tests | 2 | 0 | 0 | The one Loader failure is the same on `main`: `D3D12XStandInPipelineTests.A_first_use_is_held_while_the_shader_table_is_nearly_full`. Not checked: the WARP compiler crash that the class comment mentions, because the `while` is kept. Also not checked: AMD, Intel, and any real title or game file. AI-assisted: Claude Code (Claude Opus 5.5) did the bisect, wrote the change and ran the tests above.
dxc gives each phase of a two-phase mesh shader one loop whose header is
reached by two back-edges every round, from every switch case and from the
barrier tail, through one latch. NVIDIA GPUs hang on that shape
(DXGI_ERROR_DEVICE_HUNG, nvlddmkm 153): ms_ngg_first_lane and the barrier
loop with supersteps false, on an RTX 3070 and an RTX 4090 (#9). The guard
keeps the while (WARP's compiler needs it) but sends the cases forward to
the round tail, so the dispatch back-edge is gone. Every case already ends
at a yield or the end, so nothing the program does changes.

Fixes #9

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 10:31:09 +00:00
github-bot changed target branch from main to gh-pr/71/base 2026-11-28 12:18:58 +00:00
github manually merged commit 666f8ddf30 into gh-pr/71/base 2026-11-28 12:19:01 +00:00
Author
Owner

@⁠ThatRecompDev on GitHub · 2026-11-28 12:18 UTC · original

merged, thanks! ran it here on top of today's main first: full shader suite green (606 passed) and the two hang tests pass on the 4090, same as on your 3070.

one small thing: we keep commit messages on main free of AI trailers, so the squash dropped the Co-Authored-By line. your note in the PR description stays as it is, so the disclosure is still there for anyone who looks.

heads-up for everyone retranslating: this changes the translation of every two-phase mesh program, so the next run rebuilds those.

**@⁠ThatRecompDev** on GitHub · 2026-11-28 12:18 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/71#issuecomment-7239141708) merged, thanks! ran it here on top of today's main first: full shader suite green (606 passed) and the two hang tests pass on the 4090, same as on your 3070. one small thing: we keep commit messages on main free of AI trailers, so the squash dropped the Co-Authored-By line. your note in the PR description stays as it is, so the disclosure is still there for anyone who looks. heads-up for everyone retranslating: this changes the translation of every two-phase mesh program, so the next run rebuilds those.
This discussion has been locked. Commenting is limited to contributors.
No description provided.