fix(shader): folded light-atlas lane-mask joins (24/7 interior stall, #3835) #3871

Manually merged
github merged 2 commits from github-bot/gh-3871 into main 2026-11-30 14:14:38 +00:00 AGit
Owner

@⁠Still-Cam on GitHub · 2026-11-30 09:52 UTC · original
Still-Cam:fix/24-7-mesh-rest-stall → main · +302 −6 · 5 files · 2 commits · merged 2026-11-30 14:12 UTC

Summary

Fixes severe GPU stall inside 24/7 convenience store interiors on NVIDIA (#3835).

Open-world streets were playable (~20 fps), but walking into a 24/7 pinned the GPU (~143 ms/frame, 4–5 fps). Looking toward the store also dropped frame rate.

Cause

Folded wave64 compute for the particle light atlas (ptfx_CS_lightAtlas_Sprite, hash 2561af9577c47289) reads its EXEC lane-mask pair as a number to decide which half holds the first lane. Where that pair came through a join that only a loop header’s join reads, the join was not marked as read and its incoming masks became zero. From the second iteration on, the loop counter never advanced, so the loop ran to the 4096-iteration guard with the light’s whole body each round — tens of ms of GPU per dispatch, and lanes left without their store so the title kept asking for the same work every frame.

Same class of bug as open PR #2853 / issue #2750 (indoor light-atlas stall). This branch is a cherry-pick of that fix onto current main.

Fix

In victory-shader fill_phis, folded programs now also treat lane-mask joins as read (ballot form), so the back-edge mask is preserved. Other joins keep the previous shortcut. Of ~26k title programs, 18 emit differently (all folded): light atlas (2), shadow masks (6), water volume light (4), scattering gather (2), particle updates (4). All still translate.

Includes the synthetic regression tests from #2853 (CPU + host) for a loop whose header reads a mask join over its back edge.

Test plan

  • cargo test -p victory-shader --lib --locked folded_join — passed (a_folded_loop_header_reads_the_mask_join_on_its_back_edge)
  • Release build (cargo build --release --locked -p victory) on Windows MSVC
  • In-game A/B on real hardware (see Results)

Hardware / settings

  • GPU: NVIDIA GeForce RTX 4070 Ti (12 GB)
  • CPU: AMD Ryzen 7 7800X3D
  • Profile: Series X (1080→1440, DLSS, FrameGen 2x, no RT)
  • Build: this branch on top of 41adb551

Results

Before (v2026.11.29.05 / #3835) After (this branch)
24/7 interior ~4–5 fps, GPU ~142.8 ms/frame, GPU ~99% busy ~24.4 fps, ~41 ms/frame, 0.0 ms waiting on GPU
Streets ~20 fps Unchanged character (still heavier than interior; expected)

Before (from #3835):

victory_gpu::cardmeter: ... 142.8 ms in the title's 197 lists ...
victory_gpu::mesh_rest: ... (VICTORY_MESH_REST=Off): 462.6 bound, 0.0 rest ...

After (crowded 24/7 sample):

victory_gpu::host: 24.4 fps, 41.0 ms/frame (22.8 preparing: copies 10.8 ms ...; 0.0 on the GPU; ...)

Notes

  • Credits: original fix and tests from #2853 (wutzebaer / Peter Großmann et al.).

Fixes #3835

**@⁠Still-Cam** on GitHub · 2026-11-30 09:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3871) `Still-Cam:fix/24-7-mesh-rest-stall` → `main` · +302 −6 · 5 files · 2 commits · merged 2026-11-30 14:12 UTC ## Summary Fixes severe GPU stall inside **24/7 convenience store interiors** on NVIDIA (#3835). Open-world streets were playable (~20 fps), but walking into a 24/7 pinned the GPU (~143 ms/frame, 4–5 fps). Looking toward the store also dropped frame rate. ### Cause Folded wave64 compute for the particle light atlas (`ptfx_CS_lightAtlas_Sprite`, hash `2561af9577c47289`) reads its EXEC lane-mask pair as a number to decide which half holds the first lane. Where that pair came through a join that only a loop header’s join reads, the join was not marked as read and its incoming masks became **zero**. From the second iteration on, the loop counter never advanced, so the loop ran to the **4096-iteration guard** with the light’s whole body each round — tens of ms of GPU per dispatch, and lanes left without their store so the title kept asking for the same work every frame. Same class of bug as open PR #2853 / issue #2750 (indoor light-atlas stall). This branch is a cherry-pick of that fix onto current `main`. ### Fix In `victory-shader` `fill_phis`, folded programs now also treat **lane-mask joins** as read (ballot form), so the back-edge mask is preserved. Other joins keep the previous shortcut. Of ~26k title programs, **18** emit differently (all folded): light atlas (2), shadow masks (6), water volume light (4), scattering gather (2), particle updates (4). All still translate. Includes the synthetic regression tests from #2853 (CPU + host) for a loop whose header reads a mask join over its back edge. ## Test plan - [x] `cargo test -p victory-shader --lib --locked folded_join` — passed (`a_folded_loop_header_reads_the_mask_join_on_its_back_edge`) - [x] Release build (`cargo build --release --locked -p victory`) on Windows MSVC - [x] In-game A/B on real hardware (see Results) ### Hardware / settings - GPU: NVIDIA GeForce RTX 4070 Ti (12 GB) - CPU: AMD Ryzen 7 7800X3D - Profile: Series X (1080→1440, DLSS, FrameGen 2x, no RT) - Build: this branch on top of `41adb551` ### Results | | Before (v2026.11.29.05 / #3835) | After (this branch) | |---|---|---| | 24/7 interior | ~4–5 fps, GPU ~142.8 ms/frame, GPU ~99% busy | ~24.4 fps, ~41 ms/frame, **0.0 ms waiting on GPU** | | Streets | ~20 fps | Unchanged character (still heavier than interior; expected) | Before (from #3835): ``` victory_gpu::cardmeter: ... 142.8 ms in the title's 197 lists ... victory_gpu::mesh_rest: ... (VICTORY_MESH_REST=Off): 462.6 bound, 0.0 rest ... ``` After (crowded 24/7 sample): ``` victory_gpu::host: 24.4 fps, 41.0 ms/frame (22.8 preparing: copies 10.8 ms ...; 0.0 on the GPU; ...) ``` ### Notes - Credits: original fix and tests from #2853 (wutzebaer / Peter Großmann et al.). Fixes #3835
A folded wave64 compute program asks which half holds the first lane
wherever the console reads one (`s_cmp_lg_u32 E.lo, 0`), so it reads its
EXEC pair as a number. Where that pair came through a join that only a
loop header's join reads, the join was not marked as read and its
incoming masks became zero without a word (the shortcut
VICTORY_STRICT_JOINS names). From the second iteration on the read then
said "no lane in the lower half", took the upper half's first lane, and
with no lane there a stale value.

In `ptfx_CS_lightAtlas_Sprite` (2561af9577c47289) the counter of the
loop over the light mask's words is read that way: in every wave of 32
sprites or fewer it never moved, the loop ran to the iteration limit
(4,096) with a light's whole body in each round, 60-80 ms of the card a
dispatch, and its lanes left without their store, so the title asked
for the same sprites again in every frame.

In folded programs the joins of lane masks are now read too, whatever
the switch: a mask has a DXIL form, the ballot of its lanes. Other
joins keep the shortcut.

Of the title's 26,084 programs 18 come out otherwise, all folded: the
particles' light atlas (2), the shadow masks (6), the water's volume
light (4), the scattering gather (2) and the particle updates (4). All
26,084 still translate.

RTX 5090, Series X profile, 2560x1440, DLSS Quality, 32-lane waves, on
a deck at night facing a house: the card's time in the title's lists
40-77 ms a frame before, 22.5 ms after; the frame 78-112 ms before,
65-75 ms after (diagnostics build).
Tests for the folded form's joins of lane masks, written by SergDi in
the pull request's discussion (#2853): a loop whose header joins EXEC
from a join of EXEC that nothing else reads, and reads it as a number.

- CPU: the lowered module takes no 32-bit zero over the back edge.
  Without the fix it does ([(32, 0)]).
- Host: the first active lane's count reaches its limit for five masks,
  in both folded forms.

No title data. victory-shader's library tests: 465 passed, 9 ignored.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 09:57:07 +00:00
Author
Owner

@⁠JSa25 on GitHub · 2026-11-30 10:12 UTC · original

RTX 5090 data on the same two programs, in case it helps compare this fix with #2261. Setup: Ryzen 9 9950X3D, Series X profile, 2560x1440 with DLSS Quality, frame generation off, ray tracing off, the opening cell route.

On main (folded light atlas):

  • The route has a stretch of about 10 s, roughly 25 s into the world, where the card's time per frame goes from 15-17 ms to 29-92 ms. The worst second was 10.9 fps, and 7 seconds were under 20 fps.
  • It came back at the same point in two runs on 41adb551.
  • An earlier run with VICTORY_CARD_METER_PIPELINES=1 (main of Nov 29) timed the two programs:
    • ptfx_CS_lightAtlas_Trail (c06aa62112ffba4c): 11.4 ms per binding;
    • ptfx_CS_lightAtlas_Sprite (2561af9577c47289): 3.7 ms average and 6.4 ms at most;
    • the next compute program: about 0.5 ms.

A third route we tried, not the fold: a local, opt-in switch that sends just these two programs to the exact wave-wide form (widen, WidenMode::All) before the fold.

  • Both translate and pass dxil.dll validation. Sprite comes to 20,399 instructions per thread against the fold's 44,157.
  • In two runs the stretch did not happen. The card stayed at or under 20.5 ms a frame after the entry into the world, the worst second was 27.9 fps, and neither program appeared in the per-pipeline meter's top list.
  • A third run with it ended about 10 s into the world on "a host command list did not close (0x80070057)". We had not seen that in 21 earlier logs, and we could not identify the command (no debug layer).

Given the loop-guard bug found here, the fold may well be fine once its joins are read, which would explain the 29-92 ms on our side as well. We have not tried this branch yet, and can run the same route on it if that's useful.

**@⁠JSa25** on GitHub · 2026-11-30 10:12 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3871#issuecomment-7275274395) RTX 5090 data on the same two programs, in case it helps compare this fix with #2261. Setup: Ryzen 9 9950X3D, Series X profile, 2560x1440 with DLSS Quality, frame generation off, ray tracing off, the opening cell route. **On main (folded light atlas):** - The route has a stretch of about 10 s, roughly 25 s into the world, where the card's time per frame goes from 15-17 ms to 29-92 ms. The worst second was 10.9 fps, and 7 seconds were under 20 fps. - It came back at the same point in two runs on 41adb551. - An earlier run with `VICTORY_CARD_METER_PIPELINES=1` (main of Nov 29) timed the two programs: - `ptfx_CS_lightAtlas_Trail` (c06aa62112ffba4c): 11.4 ms per binding; - `ptfx_CS_lightAtlas_Sprite` (2561af9577c47289): 3.7 ms average and 6.4 ms at most; - the next compute program: about 0.5 ms. **A third route we tried, not the fold:** a local, opt-in switch that sends just these two programs to the exact wave-wide form (`widen`, `WidenMode::All`) before the fold. - Both translate and pass dxil.dll validation. Sprite comes to 20,399 instructions per thread against the fold's 44,157. - In two runs the stretch did not happen. The card stayed at or under 20.5 ms a frame after the entry into the world, the worst second was 27.9 fps, and neither program appeared in the per-pipeline meter's top list. - A third run with it ended about 10 s into the world on "a host command list did not close (0x80070057)". We had not seen that in 21 earlier logs, and we could not identify the command (no debug layer). Given the loop-guard bug found here, the fold may well be fine once its joins are read, which would explain the 29-92 ms on our side as well. We have not tried this branch yet, and can run the same route on it if that's useful.
Author
Owner

@⁠akimfomin on GitHub · 2026-11-30 10:21 UTC · original

@⁠JSa25 Your timed Trail/Sprite split is useful. I backported the fold fix onto our pinned control and ran a 15-second house walk on RTX 4070 Ti SUPER, Series X native 2560×1440, full stock RT, no DLSS or FG. One run came in at 13.01 median / 12.05 average rendered FPS, around the 13.42 median of the previous tuned control. This is a different route, and the fresh branch still deferred some pipelines, so it does not settle whether your opening-cell stall is fixed. If you can run the same cell on this PR, I’d be interested in the two per-program times and whether the 29–92 ms stretch disappears without the wave-wide override.

**@⁠akimfomin** on GitHub · 2026-11-30 10:21 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3871#issuecomment-7275482703) @⁠JSa25 Your timed Trail/Sprite split is useful. I backported the fold fix onto our pinned control and ran a 15-second house walk on RTX 4070 Ti SUPER, Series X native 2560×1440, full stock RT, no DLSS or FG. One run came in at 13.01 median / 12.05 average rendered FPS, around the 13.42 median of the previous tuned control. This is a different route, and the fresh branch still deferred some pipelines, so it does not settle whether your opening-cell stall is fixed. If you can run the same cell on this PR, I’d be interested in the two per-program times and whether the 29–92 ms stretch disappears without the wave-wide override.
github manually merged commit 1d82aac6ac into main 2026-11-30 14:14:38 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3871
No description provided.