Shaders: run the particle light atlas programs as local waves, not folded (indoor 4-8 fps -> 26-31 fps on NVIDIA) #3896

Manually merged
github merged 1 commit from github-bot/gh-3896 into gh-pr/3896/base 2026-11-30 14:14:37 +00:00 AGit
Owner

@⁠nyxctura on GitHub · 2026-11-30 10:48 UTC · original
nyxctura:pr-lightatlas → main · +17 −2 · 1 files · 1 commits · merged 2026-11-30 14:12 UTC

What this fixes

Indoors (shops, petrol stations, anywhere with many lights and some particles) the frame rate on NVIDIA fell to 4-8 fps. The card was the limit, and nearly all of its time went to one list: ptx_prerender:ptfx_CS_lightAtlas_Sprite (2561af9577c47289) and _Trail (c06aa62112ffba4c), which light the particles into the light atlas. The card meter put that list at 13 to 135 ms a frame.

This PR runs those two programs as local waves instead of folding them. Same picture, and the list drops out of the card meter's table entirely.

Why they were slow

Both are wave64 compute programs, and NVIDIA only has 32-lane waves, so since 05d1c564 they are folded (crate::fold): each host lane runs two console lanes and holds both lanes' registers. These two use 129 VGPRs, so the folded program needs 258+ registers a lane. That is past the 255 an NVIDIA thread can have, so it spills to local memory. On top of that, every step of the light loop does both halves' work.

This is not what #3501 fixed. #3501 removed the SAMPLED_MARKS atomics in this shader. Our runs already had VICTORY_SAMPLED_MARKS=0, and a build with #3501 merged in still hit 131.7 ms (c25 below).

Why local waves are exact here

Without folding, the translator falls back to local waves (APPROXIMATE) for these two, and that is usually a real approximation. For these two programs it isn't. From the console code (shader-info --disasm):

  1. The wave takes the min and max of its lanes' light-grid cells (v_min_u32/v_max_u32 over the wave, v_readlane) to see whether all lanes share a cell.
  2. For each 32-light word it ORs its lanes' light masks over the wave (v_or_b32 with DPP and v_permlanex16).
  3. It walks the set bits with s_ff1. Each lane only takes a light where its own mask has the bit (v_and_b32 with the lane's mask, then v_cmpx_ne_u32).

Every wave operation is a union of lane data, used only to decide which lights to visit. When each 32-lane half does this on its own, every lane still gets exactly its own lights; the half just skips lights none of its lanes need. There is no LDS and no barrier in either program. The WAVE64-RETRY messages for both point at exactly these reductions (a count or sum over the wave used as data, a wave OR used as data).

The wave-wide form is not a fallback here: the comment above wide_option already notes that it lost the card on exactly these two programs (runs 121-124). Turning folding off globally (VICTORY_WAVE_FOLDED=0) also lost the device for me, which is why this is limited to these two.

The change

fold_named already takes VICTORY_WAVE_FOLDED_SKIP. When that is unset, it now uses a default list, UNFOLDED_BY_DEFAULT = ["lightAtlas"]. Setting it to empty (VICTORY_WAVE_FOLDED_SKIP=) restores the old behaviour. The switch is already part of the shader cache key.

I checked which programs the text matches by translating every compute program with VICTORY_WAVE_FOLDED_ONLY=lightAtlas and VICTORY_WAVE_WHY=1: exactly these two get folded, nothing else. NonLocalLights_Sprite/_Trail aren't wave64, and CS_GenerateLightAtlasArguments is spelled with a capital L.

Results

RTX 5070 12 GB, Ryzen 7 7800X3D, 32 GB, Windows 11, game 1.0.2.1, Series S profile, DLSS Ultra Performance. Same base build and settings in every run; B only adds the skip. Numbers come from the log's 5-second fps lines and the card meter tables, over every window in the world.

A/B chart

run light atlas list, worst card time per frame, p95 time below 10 fps mean fps
A c24 (folded) 134.8 ms 219 ms 41 % 13.3
A c25 (folded, #3501 merged) 131.7 ms 253 ms 74 % 7.5
A c27 (folded) 124.3 ms 225 ms 35 % 13.7
B c29 (this PR) not in the table 61 ms 7 % 20.4
B c30 (this PR) not in the table 27 ms 7 % 20.4

The mean fps mixes indoors and outdoors. Outdoors the game is CPU bound at about 19-20 fps either way, so the gain is all indoors: 4-8 fps before, 26-31 fps after in the same kind of shop.

Same kind of place, both with the F3 panel (top left FPS is real frames):

A: folded, 6.5 fps, "your GPU is fully busy (238 of every 238 ms)" B: this PR, 27.8 fps, "your CPU (the GPU waits 6 of every 30 ms)"
before after

I saw no difference in particle lighting (sparks, smoke, fire) between A and B while playing.

From the bench tool, the same two runs over time (x: minutes since world entry; A solid, B dashed). A sits at 4-6 fps for over a minute indoors, B stays at 18-30:

bench compare

Testing

  • cargo test -p victory-shader --lib --release: 462 passed, 0 failed, 9 ignored
  • Offline: translate --warm of the three programs in the list with and without the skip. Folded: 129 console VGPRs, 84 and 88 KB of code. Skipped: local waves (APPROXIMATE), without early-outs: wave Some(32).
  • Preload with the skip: 196 programs that don't translate, the same as without it; 4129 of 4129 pipelines in the library.
  • In game: three A runs and two B runs, about 13 minutes in the world in total.

🤖 Generated with Claude Code

**@⁠nyxctura** on GitHub · 2026-11-30 10:48 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3896) `nyxctura:pr-lightatlas` → `main` · +17 −2 · 1 files · 1 commits · merged 2026-11-30 14:12 UTC ## What this fixes Indoors (shops, petrol stations, anywhere with many lights and some particles) the frame rate on NVIDIA fell to 4-8 fps. The card was the limit, and nearly all of its time went to one list: `ptx_prerender:ptfx_CS_lightAtlas_Sprite` (2561af9577c47289) and `_Trail` (c06aa62112ffba4c), which light the particles into the light atlas. The card meter put that list at 13 to 135 ms a frame. This PR runs those two programs as `local waves` instead of folding them. Same picture, and the list drops out of the card meter's table entirely. ## Why they were slow Both are wave64 compute programs, and NVIDIA only has 32-lane waves, so since 05d1c564 they are folded (`crate::fold`): each host lane runs two console lanes and holds both lanes' registers. These two use 129 VGPRs, so the folded program needs 258+ registers a lane. That is past the 255 an NVIDIA thread can have, so it spills to local memory. On top of that, every step of the light loop does both halves' work. This is not what #3501 fixed. #3501 removed the `SAMPLED_MARKS` atomics in this shader. Our runs already had `VICTORY_SAMPLED_MARKS=0`, and a build with #3501 merged in still hit 131.7 ms (c25 below). ## Why local waves are exact here Without folding, the translator falls back to `local waves (APPROXIMATE)` for these two, and that is usually a real approximation. For these two programs it isn't. From the console code (`shader-info --disasm`): 1. The wave takes the min and max of its lanes' light-grid cells (`v_min_u32`/`v_max_u32` over the wave, `v_readlane`) to see whether all lanes share a cell. 2. For each 32-light word it ORs its lanes' light masks over the wave (`v_or_b32` with DPP and `v_permlanex16`). 3. It walks the set bits with `s_ff1`. Each lane only takes a light where its own mask has the bit (`v_and_b32` with the lane's mask, then `v_cmpx_ne_u32`). Every wave operation is a union of lane data, used only to decide which lights to visit. When each 32-lane half does this on its own, every lane still gets exactly its own lights; the half just skips lights none of its lanes need. There is no LDS and no barrier in either program. The `WAVE64-RETRY` messages for both point at exactly these reductions (`a count or sum over the wave used as data`, `a wave OR used as data`). The wave-wide form is not a fallback here: the comment above `wide_option` already notes that it lost the card on exactly these two programs (runs 121-124). Turning folding off globally (`VICTORY_WAVE_FOLDED=0`) also lost the device for me, which is why this is limited to these two. ## The change `fold_named` already takes `VICTORY_WAVE_FOLDED_SKIP`. When that is unset, it now uses a default list, `UNFOLDED_BY_DEFAULT = ["lightAtlas"]`. Setting it to empty (`VICTORY_WAVE_FOLDED_SKIP=`) restores the old behaviour. The switch is already part of the shader cache key. I checked which programs the text matches by translating every compute program with `VICTORY_WAVE_FOLDED_ONLY=lightAtlas` and `VICTORY_WAVE_WHY=1`: exactly these two get folded, nothing else. `NonLocalLights_Sprite`/`_Trail` aren't wave64, and `CS_GenerateLightAtlasArguments` is spelled with a capital L. ## Results RTX 5070 12 GB, Ryzen 7 7800X3D, 32 GB, Windows 11, game 1.0.2.1, Series S profile, DLSS Ultra Performance. Same base build and settings in every run; B only adds the skip. Numbers come from the log's 5-second fps lines and the card meter tables, over every window in the world. ![A/B chart](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/12-lightatlas-chart.png) | run | light atlas list, worst | card time per frame, p95 | time below 10 fps | mean fps | |---|---|---|---|---| | A c24 (folded) | 134.8 ms | 219 ms | 41 % | 13.3 | | A c25 (folded, #3501 merged) | 131.7 ms | 253 ms | 74 % | 7.5 | | A c27 (folded) | 124.3 ms | 225 ms | 35 % | 13.7 | | **B c29 (this PR)** | not in the table | **61 ms** | **7 %** | **20.4** | | **B c30 (this PR)** | not in the table | **27 ms** | **7 %** | **20.4** | The mean fps mixes indoors and outdoors. Outdoors the game is CPU bound at about 19-20 fps either way, so the gain is all indoors: 4-8 fps before, 26-31 fps after in the same kind of shop. Same kind of place, both with the F3 panel (top left FPS is real frames): | A: folded, 6.5 fps, "your GPU is fully busy (238 of every 238 ms)" | B: this PR, 27.8 fps, "your CPU (the GPU waits 6 of every 30 ms)" | |---|---| | ![before](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/13-lightatlas-A-indoor.jpg) | ![after](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/14-lightatlas-B-indoor.jpg) | I saw no difference in particle lighting (sparks, smoke, fire) between A and B while playing. From the bench tool, the same two runs over time (x: minutes since world entry; A solid, B dashed). A sits at 4-6 fps for over a minute indoors, B stays at 18-30: ![bench compare](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/15-lightatlas-bench-compare.png) ## Testing - `cargo test -p victory-shader --lib --release`: 462 passed, 0 failed, 9 ignored - Offline: `translate --warm` of the three programs in the list with and without the skip. Folded: 129 console VGPRs, 84 and 88 KB of code. Skipped: `local waves (APPROXIMATE), without early-outs: wave Some(32)`. - Preload with the skip: 196 programs that don't translate, the same as without it; 4129 of 4129 pipelines in the library. - In game: three A runs and two B runs, about 13 minutes in the world in total. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ptfx_CS_lightAtlas_Sprite and _Trail are clustered-lighting loops whose wave
operations (min/max of the lanes' light-grid cells, OR of their light masks,
walking the set bits) are unions: each 32-lane half doing them alone gives
every lane the same lights, so local waves are exact for them (no LDS, no
barrier). Folded they need 2 x 129 VGPRs a host lane, past the 255 an NVIDIA
thread has, and cost 13-135 ms a frame of card time indoors on an RTX 5070.

VICTORY_WAVE_FOLDED_SKIP now defaults to ["lightAtlas"]; set it empty to fold
them again.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 10:51:55 +00:00
Author
Owner

@⁠Aniseto on GitHub · 2026-11-30 12:05 UTC · original

Ran the victory-shader suite at 38c1d10a on an NVIDIA Blackwell desktop part.

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40)
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: Rust 1.98.1 (48a229cea 2026-09-01, pinned by rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5
  • Build: release

Results

  • VICTORY_D3D12_ADAPTER=NVIDIA cargo test -p victory-shader --lib --release: 462 passed, 0 failed, 9 ignored (416.0 s).

What this adds
All tests pass on a real 32-lane NVIDIA host for the change that runs the two particle light-atlas programs as local waves instead of folding them. The thread has no comments yet, so this is the first datapoint in it and the first from an RTX 5070 Ti. This is a suite result only: I did not repeat the author's indoor FPS A/B and claim no FPS number.

Not tested
A retail title, an indoor FPS A/B, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the command above on this machine and wrote this report; no game data was used.

**@⁠Aniseto** on GitHub · 2026-11-30 12:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3896#issuecomment-7277928482) Ran the `victory-shader` suite at `38c1d10a` on an NVIDIA Blackwell desktop part. **System** - GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40) - CPU: Intel Core i5-12400F, 64 GB RAM - OS: Windows 11 Pro build 26200 x64 - Toolchain: Rust 1.98.1 (48a229cea 2026-09-01, pinned by `rust-toolchain.toml`), MSVC 14.44.35207, DXC 1.9.2609.5 - Build: release **Results** - `VICTORY_D3D12_ADAPTER=NVIDIA cargo test -p victory-shader --lib --release`: 462 passed, 0 failed, 9 ignored (416.0 s). **What this adds** All tests pass on a real 32-lane NVIDIA host for the change that runs the two particle light-atlas programs as local waves instead of folding them. The thread has no comments yet, so this is the first datapoint in it and the first from an RTX 5070 Ti. This is a suite result only: I did not repeat the author's indoor FPS A/B and claim no FPS number. **Not tested** A retail title, an indoor FPS A/B, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, game data. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - ran the command above on this machine and wrote this report; no game data was used.
github-bot changed target branch from main to gh-pr/3896/base 2026-11-30 14:14:25 +00:00
github manually merged commit 38c1d10acb into gh-pr/3896/base 2026-11-30 14:14:26 +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!3896
No description provided.