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

Closed
stasadance wants to merge 1 commit from upstream-pr/3717 into main
stasadance commented 2026-11-30 04:37:03 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by stasadance on 2026-11-30T04:37:03Z.


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.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5559077129 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3717). Originally posted by [stasadance](https://github.com/stasadance) on 2026-11-30T04:37:03Z. --- 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.
nikitronick-crypto commented 2026-11-30 15:13:54 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nikitronick-crypto on 2026-11-30T15:13:54Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7282653336 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3717#issuecomment-7282653336). Originally posted by [nikitronick-crypto](https://github.com/nikitronick-crypto) on 2026-11-30T15:13:54Z. --- 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).
CubeB commented 2026-11-30 18:23:48 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CubeB on 2026-11-30T18:23:48Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7287787719 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3717#issuecomment-7287787719). Originally posted by [CubeB](https://github.com/CubeB) on 2026-11-30T18:23:48Z. --- 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)
nikitronick-crypto commented 2026-11-30 18:30:48 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nikitronick-crypto on 2026-11-30T18:30:48Z.


@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).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7287958040 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3717#issuecomment-7287958040). Originally posted by [nikitronick-crypto](https://github.com/nikitronick-crypto) on 2026-11-30T18:30:48Z. --- @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).
VibeCodeGuy commented 2026-11-30 23:16:05 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by VibeCodeGuy on 2026-11-30T23:16:05Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7294914190 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3717#issuecomment-7294914190). Originally posted by [VibeCodeGuy](https://github.com/VibeCodeGuy) on 2026-11-30T23:16:05Z. --- **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.
stasadance commented 2026-12-01 02:13:18 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by stasadance on 2026-12-01T02:13:18Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7298374567 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3717#issuecomment-7298374567). Originally posted by [stasadance](https://github.com/stasadance) on 2026-12-01T02:13:18Z. --- 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

Sign in to join this conversation.
No reviewers
No labels
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.

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