The clustered local-light loop runs as local waves before the fold (interiors 4 fps) #3717

Closed
github-bot wants to merge 1 commit from github-bot/gh-3717 into main AGit
Owner

@⁠stasadance on GitHub · 2026-11-30 04:37 UTC · original
stasadance:perf/light-loop-local-waves → main · +35 −0 · 1 files · 1 commits · closed without merging

Related: #3173, #2261

What it changes

The clustered local-light shader (2561af9577c47289, c06aa62112ffba4c) loops over every light in its tile, so indoors, with many lights, it runs many trips. It was taking the folded wave64 form: two console lanes per host lane, 129 VGPRs, 308 KB of DXIL, spills and low occupancy. Indoors the card showed 98% busy at only 90 W and GPU time went from about 3 ms to over 200 ms a frame.

Those two programs now run as local waves before the fold is tried (99 KB and 95 KB of DXIL). The loop data itself is valid: no runaway bound, no atomics. VICTORY_LIGHT_LOOP_LOCAL=0 puts back the folded form.

How it was tested

  • GPU and profile: RTX 4090 on Linux (NVIDIA 620.73.04, kron4ek Wine 11.23, vkd3d-proton GE cae8353ed), DLSS + frame generation
  • Before (Series S profile): entering an interior took it to 3.6 to 10 fps, GPU 150 to 234 ms a frame (10 fps lines over 30 ms in that session).
  • After (Series X profile, a later 21-minute session of normal play; which interiors it visited isn't recorded): GPU peaked at 79.2 ms a frame, with 2 fps lines over 30 ms.
  • For shader changes, the wave sizes tested: 64 lanes (local waves instead of folded).
  • cargo test passed for the crates it touches: yes, cargo test -p victory-shader --lib (Linux host: 295 passed; the Windows-only emit tests not run). Windows clippy reports the same 4 errors as current main, none in this diff.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #3173 (heavy scenes 2-4 fps with folding), #2261 (exact Wave32 before folding), #1504.
**@⁠stasadance** on GitHub · 2026-11-30 04:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3717) `stasadance:perf/light-loop-local-waves` → `main` · +35 −0 · 1 files · 1 commits · closed without merging Related: #3173, #2261 ## What it changes The clustered local-light shader (`2561af9577c47289`, `c06aa62112ffba4c`) loops over every light in its tile, so indoors, with many lights, it runs many trips. It was taking the folded wave64 form: two console lanes per host lane, 129 VGPRs, 308 KB of DXIL, spills and low occupancy. Indoors the card showed 98% busy at only 90 W and GPU time went from about 3 ms to over 200 ms a frame. Those two programs now run as local waves before the fold is tried (99 KB and 95 KB of DXIL). The loop data itself is valid: no runaway bound, no atomics. `VICTORY_LIGHT_LOOP_LOCAL=0` puts back the folded form. ## How it was tested - GPU and profile: RTX 4090 on Linux (NVIDIA 620.73.04, kron4ek Wine 11.23, vkd3d-proton GE cae8353ed), DLSS + frame generation - Before (Series S profile): entering an interior took it to 3.6 to 10 fps, GPU 150 to 234 ms a frame (10 fps lines over 30 ms in that session). - After (Series X profile, a later 21-minute session of normal play; which interiors it visited isn't recorded): GPU peaked at 79.2 ms a frame, with 2 fps lines over 30 ms. - For shader changes, the wave sizes tested: 64 lanes (local waves instead of folded). - `cargo test` passed for the crates it touches: yes, `cargo test -p victory-shader --lib` (Linux host: 295 passed; the Windows-only emit tests not run). Windows clippy reports the same 4 errors as current main, none in this diff. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #3173 (heavy scenes 2-4 fps with folding), #2261 (exact Wave32 before folding), #1504.
Both are wave64 groups of 64 that the exact forms refuse (a wave min/max of
z-bins and an OR of tile masks). Folded, each host lane runs two console
lanes with 129 VGPRs: 308 KB of DXIL and indoor frames of 100-230 ms of card
time. Local waves keep each half's own min/max/OR, which only narrows the
lights a lane visits. VICTORY_LIGHT_LOOP_LOCAL=0: folded as before.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 04:44:53 +00:00
Author
Owner

@⁠nikitronick-crypto on GitHub · 2026-11-30 15:13 UTC · original

Tested on Windows on a 12 GB 30-series card, where this pass was the limit indoors: RTX 3080 Ti, Ryzen 5 7500F, Series X 1440p, DLSS Balanced, FSR FG 2x. This PR's one-file change applied on 41adb551, release build, shaders translated again from an empty state for the new translator.

Same interior, medians of the 5 s lines:

41adb551 41adb551 + this PR
the list with 2561af9577c47289 / cabb87599722e59a (card meter) 54-95 ms a frame no longer among the listed kinds (largest listed kind 1.7 ms)
card time of the title's lists 106.6 ms 33.5 ms
card busy; seconds at 95 % or more 100 %; 79 % 76 %; 0 %
fps 8.5 18.2 (lowest 5 s line 16.4)
draws 6,160 8,800

Both programs were bound in the run with the PR (first bind at frame 10994), so the pass runs. cabb87599722e59a is not in this PR's list but its list is cheap now too. 0 pipelines failed, 0 shaders untranslated. Picture over an 8-minute session indoors: lamps light the walls and floor, dust shows in the light, no blocks or flicker that I could see.

Caveats: one machine, one interior, the two runs were a few hours apart, and the second also had VICTORY_STORE_BESIDE=1 and VICTORY_TABLE_SAME=1 on, which do not touch card time. The measured four minutes had no remote-desktop client connected. Background and the earlier numbers are in my comment on #2415 (section 3), where I had been leaving the pair out with VICTORY_LEAVE_OUT; this is the better fix.

Run on my own PC; logs read and this written with an AI assistant (Claude).

**@⁠nikitronick-crypto** on GitHub · 2026-11-30 15:13 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3717#issuecomment-7282653336) Tested on Windows on a 12 GB 30-series card, where this pass was the limit indoors: RTX 3080 Ti, Ryzen 5 7500F, Series X 1440p, DLSS Balanced, FSR FG 2x. This PR's one-file change applied on 41adb551, release build, shaders translated again from an empty state for the new translator. Same interior, medians of the 5 s lines: | | 41adb551 | 41adb551 + this PR | |---|---|---| | the list with `2561af9577c47289` / `cabb87599722e59a` (card meter) | 54-95 ms a frame | no longer among the listed kinds (largest listed kind 1.7 ms) | | card time of the title's lists | 106.6 ms | 33.5 ms | | card busy; seconds at 95 % or more | 100 %; 79 % | 76 %; 0 % | | fps | 8.5 | 18.2 (lowest 5 s line 16.4) | | draws | 6,160 | 8,800 | Both programs were bound in the run with the PR (first bind at frame 10994), so the pass runs. `cabb87599722e59a` is not in this PR's list but its list is cheap now too. 0 pipelines failed, 0 shaders untranslated. Picture over an 8-minute session indoors: lamps light the walls and floor, dust shows in the light, no blocks or flicker that I could see. Caveats: one machine, one interior, the two runs were a few hours apart, and the second also had `VICTORY_STORE_BESIDE=1` and `VICTORY_TABLE_SAME=1` on, which do not touch card time. The measured four minutes had no remote-desktop client connected. Background and the earlier numbers are in my comment on #2415 (section 3), where I had been leaving the pair out with `VICTORY_LEAVE_OUT`; this is the better fix. Run on my own PC; logs read and this written with an AI assistant (Claude).
Author
Owner

@⁠CubeB on GitHub · 2026-11-30 18:23 UTC · original

A small thing I hit when merging this into my fork: the new switch VICTORY_LIGHT_LOOP_LOCAL is read by the translator (light_loop_local() in emit/mod.rs), but it is not in KEYED in crates/victory-gpu/src/shader_cache.rs. shader_cache::tests::every_switch_of_the_translator_is_in_the_key then fails ("switches the translator reads that the shader cache's key leaves out: ["VICTORY_LIGHT_LOOP_LOCAL"]"), and changing the switch would reuse translations made the other way.

The fix is one entry in KEYED plus the array length. Mine is CubeB/paradise-fork fbd3676e, next to VICTORY_WAVE_LOCAL.

🤖 Generated with Claude Code

**@⁠CubeB** on GitHub · 2026-11-30 18:23 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3717#issuecomment-7287787719) A small thing I hit when merging this into my fork: the new switch `VICTORY_LIGHT_LOOP_LOCAL` is read by the translator (`light_loop_local()` in `emit/mod.rs`), but it is not in `KEYED` in `crates/victory-gpu/src/shader_cache.rs`. `shader_cache::tests::every_switch_of_the_translator_is_in_the_key` then fails ("switches the translator reads that the shader cache's key leaves out: ["VICTORY_LIGHT_LOOP_LOCAL"]"), and changing the switch would reuse translations made the other way. The fix is one entry in `KEYED` plus the array length. Mine is CubeB/paradise-fork fbd3676e, next to `VICTORY_WAVE_LOCAL`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠nikitronick-crypto on GitHub · 2026-11-30 18:30 UTC · original

@⁠CubeB Good catch on the cache key, and it applies to anyone carrying this PR in a fork.

One thing to consider before fixing it there: upstream no longer has this switch.
VICTORY_LIGHT_LOOP_LOCAL is in neither v2026.11.30.01 (c71899d9) nor v2026.11.30.02 (84bd61e2).
The clustered local-light pair this PR targets (2561af9577c47289 / cabb87599722e59a) was fixed
upstream another way, through #3896 / #3871 (UNFOLDED_BY_DEFAULT with "lightAtlas"), which
needs no new switch and so no new entry in KEYED.

So for a fork based on current main, the simpler route is to drop this PR's change and take
upstream's fix. The KEYED entry is only needed if the fork stays on a base before v2026.11.30.01
and keeps this PR. On my 3080 Ti, clean v2026.11.30.01 without this PR no longer lists the pair
in the card meter indoors.

Checked and written with an AI assistant (Claude).Good catch on the cache key, and it applies to anyone carrying this PR in a fork.

One thing to consider before fixing it there: upstream no longer has this switch.
VICTORY_LIGHT_LOOP_LOCAL is in neither v2026.11.30.01 (c71899d9) nor v2026.11.30.02 (84bd61e2).
The clustered local-light pair this PR targets (2561af9577c47289 / cabb87599722e59a) was fixed
upstream another way, through #3896 / #3871 (UNFOLDED_BY_DEFAULT with "lightAtlas"), which
needs no new switch and so no new entry in KEYED.

So for a fork based on current main, the simpler route is to drop this PR's change and take
upstream's fix. The KEYED entry is only needed if the fork stays on a base before v2026.11.30.01
and keeps this PR. On my 3080 Ti, clean v2026.11.30.01 without this PR no longer lists the pair
in the card meter indoors.

Checked and written with an AI assistant (Claude).

**@⁠nikitronick-crypto** on GitHub · 2026-11-30 18:30 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3717#issuecomment-7287958040) @⁠CubeB Good catch on the cache key, and it applies to anyone carrying this PR in a fork. One thing to consider before fixing it there: upstream no longer has this switch. `VICTORY_LIGHT_LOOP_LOCAL` is in neither v2026.11.30.01 (c71899d9) nor v2026.11.30.02 (84bd61e2). The clustered local-light pair this PR targets (2561af9577c47289 / cabb87599722e59a) was fixed upstream another way, through #3896 / #3871 (`UNFOLDED_BY_DEFAULT` with "lightAtlas"), which needs no new switch and so no new entry in `KEYED`. So for a fork based on current main, the simpler route is to drop this PR's change and take upstream's fix. The `KEYED` entry is only needed if the fork stays on a base before v2026.11.30.01 and keeps this PR. On my 3080 Ti, clean v2026.11.30.01 without this PR no longer lists the pair in the card meter indoors. Checked and written with an AI assistant (Claude).Good catch on the cache key, and it applies to anyone carrying this PR in a fork. One thing to consider before fixing it there: upstream no longer has this switch. `VICTORY_LIGHT_LOOP_LOCAL` is in neither v2026.11.30.01 (c71899d9) nor v2026.11.30.02 (84bd61e2). The clustered local-light pair this PR targets (2561af9577c47289 / cabb87599722e59a) was fixed upstream another way, through #3896 / #3871 (`UNFOLDED_BY_DEFAULT` with "lightAtlas"), which needs no new switch and so no new entry in `KEYED`. So for a fork based on current main, the simpler route is to drop this PR's change and take upstream's fix. The `KEYED` entry is only needed if the fork stays on a base before v2026.11.30.01 and keeps this PR. On my 3080 Ti, clean v2026.11.30.01 without this PR no longer lists the pair in the card meter indoors. Checked and written with an AI assistant (Claude).
Author
Owner

@⁠VibeCodeGuy on GitHub · 2026-11-30 23:16 UTC · original · edited 2026-11-30 23:33 UTC

Offline corpus check (every shader container in a v1.0.2.1 dump: 25,699 unique programs), main e1251c31 against main + this PR at 1ec374d7.

  • Newly failing: 0. Newly passing: 0.
  • DXIL output changed: 0 programs.

How: victory translate <dump> --validate --list built for each side (release, cross-built with cargo-xwin, run under Wine), VICTORY_HOST_WAVE=32, plus the four shader-cache-key settings play starts with (VICTORY_EARLY_DEPTH=1, VICTORY_NAN_SCRUB=1, VICTORY_BVH_MISS=1, VICTORY_SAMPLED_MARKS=1). Validator: dxil.dll from DXC v1.9.2609. "Changed" compares translate's emitted hash of each module and its bindings. There was no GPU on this side, so no host pipelines were made and nothing was run on a card. On main the same run has 72 failures: 71 mesh programs over the 32 KiB output limit (the known shortcut in mesh_prologue) and CS_TraceShadowRays_FullAdaptive (#2993).

The two programs this targets are in the corpus. In this dump they are ptx_prerender:ptfx_CS_lightAtlas_Sprite (2561af9577c47289) and ptx_prerender:ptfx_CS_lightAtlas_Trail (c06aa62112ffba4c). Neither comes out different with this PR merged onto main e1251c31 at 32 lanes.

VICTORY_WAVE_WHY=1 on main (translate shaders.rpf --warm <these two> --jobs 1, same settings as above) shows why. Both already end in WAVE64-RETRY local waves (APPROXIMATE), without early-outs: wave Some(32), not the folded form, presumably since folding went off by default (VICTORY_WAVE_FOLDED=1 to opt in). So on current main with 32-lane waves this looks like a no-op. The 64-lane case the description tested was not checked here.

Edit: the reason is #3896 (merged today, "run the particle light atlas programs as local waves, not folded"). It already does this for the same two programs.

**@⁠VibeCodeGuy** on GitHub · 2026-11-30 23:16 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3717#issuecomment-7294914190) · edited 2026-11-30 23:33 UTC **Offline corpus check** (every shader container in a v1.0.2.1 dump: 25,699 unique programs), `main` e1251c31 against `main` + this PR at 1ec374d7. - Newly failing: **0**. Newly passing: **0**. - DXIL output changed: **0** programs. How: `victory translate <dump> --validate --list` built for each side (release, cross-built with cargo-xwin, run under Wine), `VICTORY_HOST_WAVE=32`, plus the four shader-cache-key settings `play` starts with (`VICTORY_EARLY_DEPTH=1`, `VICTORY_NAN_SCRUB=1`, `VICTORY_BVH_MISS=1`, `VICTORY_SAMPLED_MARKS=1`). Validator: `dxil.dll` from DXC v1.9.2609. "Changed" compares translate's `emitted` hash of each module and its bindings. There was no GPU on this side, so no host pipelines were made and nothing was run on a card. On `main` the same run has 72 failures: 71 mesh programs over the 32 KiB output limit (the known shortcut in `mesh_prologue`) and `CS_TraceShadowRays_FullAdaptive` (#2993). The two programs this targets are in the corpus. In this dump they are `ptx_prerender:ptfx_CS_lightAtlas_Sprite` (`2561af9577c47289`) and `ptx_prerender:ptfx_CS_lightAtlas_Trail` (`c06aa62112ffba4c`). Neither comes out different with this PR merged onto `main` e1251c31 at 32 lanes. `VICTORY_WAVE_WHY=1` on `main` (`translate shaders.rpf --warm <these two> --jobs 1`, same settings as above) shows why. Both already end in `WAVE64-RETRY local waves (APPROXIMATE), without early-outs: wave Some(32)`, not the folded form, presumably since folding went off by default (`VICTORY_WAVE_FOLDED=1` to opt in). So on current `main` with 32-lane waves this looks like a no-op. The 64-lane case the description tested was not checked here. Edit: the reason is #3896 (merged today, "run the particle light atlas programs as local waves, not folded"). It already does this for the same two programs.
github-bot closed this pull request 2026-12-01 02:14:31 +00:00
Author
Owner

@⁠stasadance on GitHub · 2026-12-01 02:13 UTC · original

Closing this: main now covers these programs through #3896 / #3871 (UNFOLDED_BY_DEFAULT = ["lightAtlas"] in emit/mod.rs), with no new switch and no cache-key entry. Thanks @⁠nikitronick-crypto for the 3080 Ti numbers and @⁠CubeB for catching the missing KEYED entry. Any fork still carrying this on a base before v2026.11.30.01 needs that entry, or should take main's fix instead.

**@⁠stasadance** on GitHub · 2026-12-01 02:13 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3717#issuecomment-7298374567) Closing this: main now covers these programs through #3896 / #3871 (`UNFOLDED_BY_DEFAULT = ["lightAtlas"]` in `emit/mod.rs`), with no new switch and no cache-key entry. Thanks @⁠nikitronick-crypto for the 3080 Ti numbers and @⁠CubeB for catching the missing `KEYED` entry. Any fork still carrying this on a base before v2026.11.30.01 needs that entry, or should take main's fix instead.

Pull request closed

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!3717
No description provided.