Shaders: the water's tiled light is folded before the wave-wide branches even past the 126-VGPR cap (VICTORY_WAVE_FOLDED_FIRST), as its wave-wide form leaves dark tiles #4496

Closed
brunofgmag wants to merge 14 commits from upstream-pr/4496 into main
brunofgmag commented 2026-11-30 21:20:10 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by brunofgmag on 2026-11-30T21:20:10Z.


What it changes

The water's tiled light programs are folded before the wave-wide branches again, even past the 126-VGPR cap of #2261. They are water_shading:CS_TransmissionVolumetrics_Tiled (5dc3b25986622949), _Tiled_LocalLights (6f225b641c5b0708) and the submerged ones.

They are named in a short list, FOLDED_FIRST_BY_DEFAULT (TransmissionVolumetrics), next to UNFOLDED_BY_DEFAULT. VICTORY_WAVE_FOLDED_FIRST=<text>,... replaces the list, and an empty value turns it off. The switch is in the shader cache's key. Every other program goes through #2261's order as before.

Why

#2261 (qlfu) tries the wave32 forms it takes as exact before folding. It folds early only a program that fits in 126 console VGPRs. _Tiled_LocalLights holds 156, so it now skips the fold and takes the wave-wide branches. For this program that form is the one that leaves whole tiles of open water dark around boats, along shores and under bridges (#739). That is why #1926 (dheerajc8073) leaves the water light out on 32-lane cards. Folded, the program has no dark tiles.

What each build makes of the two programs, translated one at a time with VICTORY_WAVE_WHY=1, VICTORY_HOST_WAVE=32 and VICTORY_WAVE_FOLDED=1 (victory translate shaders.rpf --warm <hash> --jobs 1):

Program main e1251c31 this branch
5dc3b25986622949 (101 VGPRs) folded folded
6f225b641c5b0708 (156 VGPRs) wave-wide branches folded

How it was tested

  • RTX 4080, Proton, Series X at 4K output, DLSS performance, frame generation 2x.
  • On 2026-11-29 the first boat mission was played through with the water light on and both programs folded, before #2261 was merged. No dark tiles came back.
  • Card time against the wave-wide form on this branch is not measured yet. A folded program at 156 VGPRs spills (2 x 156 + 2 host registers).
  • New test emit::tests::the_waters_tiled_light_is_folded_first. #2261's emit_strict_prefers_exact_wave32_over_fold_and_defers_over_255_vgpr_fold and the 25 folded tests pass.
  • cargo clippy --workspace --all-targets -- -D warnings stops on three warnings that are on main already, none in this change: crates/victory-shader/src/emit/lower.rs:114 (loop_caps never read), crates/victory-gpu/src/shadow.rs:7197 (ranged never used) and crates/victory-gpu/src/host.rs:5092 (manual is_multiple_of).
  • #4201 (marquezlale-creator) names the transmission volumetrics (tiled, local lights, submerged) in VICTORY_WAVE_FOLDED_SKIP and reads their unfolded form as exact. For _Tiled_LocalLights the wave-wide form is the one with the dark tiles. With both merged, the skip list wins and this list does nothing for those programs.
  • #1935 (xss3009) gives the same two programs a paired Wave64 lowering, another way out of the dark tiles.
  • With this change, VICTORY_WATER_LIGHT=1 (WATER LIGHT in F1) runs the folded form. The default from #1926 is unchanged.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5573967901 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4496). Originally posted by [brunofgmag](https://github.com/brunofgmag) on 2026-11-30T21:20:10Z. --- ## What it changes The water's tiled light programs are folded before the wave-wide branches again, even past the 126-VGPR cap of #2261. They are `water_shading:CS_TransmissionVolumetrics_Tiled` (`5dc3b25986622949`), `_Tiled_LocalLights` (`6f225b641c5b0708`) and the submerged ones. They are named in a short list, `FOLDED_FIRST_BY_DEFAULT` (`TransmissionVolumetrics`), next to `UNFOLDED_BY_DEFAULT`. `VICTORY_WAVE_FOLDED_FIRST=<text>,...` replaces the list, and an empty value turns it off. The switch is in the shader cache's key. Every other program goes through #2261's order as before. ## Why #2261 (qlfu) tries the wave32 forms it takes as exact before folding. It folds early only a program that fits in 126 console VGPRs. `_Tiled_LocalLights` holds 156, so it now skips the fold and takes the wave-wide branches. For this program that form is the one that leaves whole tiles of open water dark around boats, along shores and under bridges (#739). That is why #1926 (dheerajc8073) leaves the water light out on 32-lane cards. Folded, the program has no dark tiles. What each build makes of the two programs, translated one at a time with `VICTORY_WAVE_WHY=1`, `VICTORY_HOST_WAVE=32` and `VICTORY_WAVE_FOLDED=1` (`victory translate shaders.rpf --warm <hash> --jobs 1`): | Program | `main` e1251c31 | this branch | | --- | --- | --- | | `5dc3b25986622949` (101 VGPRs) | folded | folded | | `6f225b641c5b0708` (156 VGPRs) | wave-wide branches | folded | ## How it was tested - RTX 4080, Proton, Series X at 4K output, DLSS performance, frame generation 2x. - On 2026-11-29 the first boat mission was played through with the water light on and both programs folded, before #2261 was merged. No dark tiles came back. - Card time against the wave-wide form on this branch is not measured yet. A folded program at 156 VGPRs spills (2 x 156 + 2 host registers). - New test `emit::tests::the_waters_tiled_light_is_folded_first`. #2261's `emit_strict_prefers_exact_wave32_over_fold_and_defers_over_255_vgpr_fold` and the 25 `folded` tests pass. - `cargo clippy --workspace --all-targets -- -D warnings` stops on three warnings that are on `main` already, none in this change: `crates/victory-shader/src/emit/lower.rs:114` (`loop_caps` never read), `crates/victory-gpu/src/shadow.rs:7197` (`ranged` never used) and `crates/victory-gpu/src/host.rs:5092` (manual `is_multiple_of`). ## Related - #4201 (marquezlale-creator) names the transmission volumetrics (tiled, local lights, submerged) in `VICTORY_WAVE_FOLDED_SKIP` and reads their unfolded form as exact. For `_Tiled_LocalLights` the wave-wide form is the one with the dark tiles. With both merged, the skip list wins and this list does nothing for those programs. - #1935 (xss3009) gives the same two programs a paired Wave64 lowering, another way out of the dark tiles. - With this change, `VICTORY_WATER_LIGHT=1` (WATER LIGHT in F1) runs the folded form. The default from #1926 is unchanged.
brunofgmag commented 2026-11-30 22:38:39 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by brunofgmag on 2026-11-30T22:38:39Z.


Checked in gameplay on top of this change (with #2261 merged), RTX 4080, Series X at 4K, DLSS performance, frame generation 2x:

  • Translated alone with VICTORY_WAVE_WHY=1, both 5dc3b25986622949 and 6f225b641c5b0708 come out folded.
  • With the water light on, the first boat mission's open water is light blue and has no dark tiles around the boat or along the shore.
  • Cost in the boat cutscene's scene-change part (two runs each): 25.2 to 25.4 fps with a 38.2 to 39.9 ms median folded, against 27.2 to 27.4 fps and 36.7 to 36.8 ms with _Tiled_LocalLights in the wave-wide form. That is about 2 fps for the spill of the 156-VGPR program.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7294116784 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4496#issuecomment-7294116784). Originally posted by [brunofgmag](https://github.com/brunofgmag) on 2026-11-30T22:38:39Z. --- Checked in gameplay on top of this change (with #2261 merged), RTX 4080, Series X at 4K, DLSS performance, frame generation 2x: - Translated alone with `VICTORY_WAVE_WHY=1`, both `5dc3b25986622949` and `6f225b641c5b0708` come out folded. - With the water light on, the first boat mission's open water is light blue and has no dark tiles around the boat or along the shore. - Cost in the boat cutscene's scene-change part (two runs each): 25.2 to 25.4 fps with a 38.2 to 39.9 ms median folded, against 27.2 to 27.4 fps and 36.7 to 36.8 ms with `_Tiled_LocalLights` in the wave-wide form. That is about 2 fps for the spill of the 156-VGPR program.
VibeCodeGuy commented 2026-12-01 00:25:35 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by VibeCodeGuy on 2026-12-01T00:25:35Z.


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

  • Newly failing: 0. Newly passing: 0.
  • DXIL output changed: 3 programs (3 Cs); 3 of them pass the validator.
The 3 changed programs
  • 926c46bab3b86bd6 Cs water_shading:CS_TransmissionVolumetricsSubmerged
  • 6f225b641c5b0708 Cs water_shading:CS_TransmissionVolumetrics_Tiled_LocalLights
  • a10179ab7eda0dc3 Cs water_shading:CS_TransmissionVolumetrics_VolumePortalsOnly

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

These 3 programs are the ones the description names: _Tiled_LocalLights (6f225b641c5b0708) and the submerged one, plus _VolumePortalsOnly, which also matches TransmissionVolumetrics. _Tiled (5dc3b25986622949) doesn't change, as the table says: main already folds it.

One thing to know before merging: without VICTORY_WAVE_FOLDED=1 the same comparison changes 0 programs, because the new path is behind fold::enabled(). Neither play's defaults nor any F1 item (WATER LIGHT sets only VICTORY_WATER_LIGHT) sets VICTORY_WAVE_FOLDED=1. So players who turn WATER LIGHT on still get the wave-wide form unless they also set that variable by hand. If the aim is to make WATER LIGHT usable on 32-lane cards, the list may need to apply without the global fold switch.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7296320295 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4496#issuecomment-7296320295). Originally posted by [VibeCodeGuy](https://github.com/VibeCodeGuy) on 2026-12-01T00:25:35Z. --- **Offline corpus check** (every shader container in a v1.0.2.1 dump: 25,699 unique programs), `main` e1251c31 against `main` + this PR at 2985b8ce, both with `VICTORY_WAVE_FOLDED=1`. - Newly failing: **0**. Newly passing: **0**. - DXIL output changed: **3** programs (3 Cs); 3 of them pass the validator. <details><summary>The 3 changed programs</summary> - `926c46bab3b86bd6` Cs `water_shading:CS_TransmissionVolumetricsSubmerged` - `6f225b641c5b0708` Cs `water_shading:CS_TransmissionVolumetrics_Tiled_LocalLights` - `a10179ab7eda0dc3` Cs `water_shading:CS_TransmissionVolumetrics_VolumePortalsOnly` </details> 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). These 3 programs are the ones the description names: `_Tiled_LocalLights` (`6f225b641c5b0708`) and the submerged one, plus `_VolumePortalsOnly`, which also matches `TransmissionVolumetrics`. `_Tiled` (`5dc3b25986622949`) doesn't change, as the table says: `main` already folds it. One thing to know before merging: **without** `VICTORY_WAVE_FOLDED=1` the same comparison changes **0** programs, because the new path is behind `fold::enabled()`. Neither `play`'s defaults nor any F1 item (WATER LIGHT sets only `VICTORY_WATER_LIGHT`) sets `VICTORY_WAVE_FOLDED=1`. So players who turn WATER LIGHT on still get the wave-wide form unless they also set that variable by hand. If the aim is to make WATER LIGHT usable on 32-lane cards, the list may need to apply without the global fold switch.
rvrvrvr221 commented 2026-12-01 08:35:59 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by rvrvrvr221 on 2026-12-01T08:35:59Z.


In-game test on an RTX 4090: v2026.11.30.03 against this PR at 2985b8ce

PC: Core i9-13900K, RTX 4090 24 GB (driver 621.40), 32 GB DDR5-6400, Windows 11 Pro (build 26300).
Every run: the launcher's defaults with -NoMenu (Series X, 2560x1440, DLSS Quality, frame generation off, ray tracing off), plus VICTORY_WATER_LIGHT=1. Same save in the first boat mission after the prologue: the buoys and mission marker, the bridge, the shore, one dive.

Run Build VICTORY_WAVE_FOLDED _Tiled_LocalLights form Seen fps, median of the log's 10 s lines in play
A v2026.11.30.03 unset wave-wide no dark tiles 36.3
B this PR unset wave-wide (same as A) no dark tiles 33.1
C1 v2026.11.30.03 1 wave-wide no dark tiles; terrain steady 35.1
C2 v2026.11.30.03 1 wave-wide no dark tiles; some white/grey flicker on the buoys; terrain steady 34.6
D1 this PR 1 folded no dark tiles; black flicker on the buoys; nearby terrain flickers, islands and distant shores disappear and come back; one freeze of about 1.5 s 36.4
D2 this PR 1 folded no dark tiles; terrain flickers again; no black flicker on the buoys 36.4

The forms were checked offline for each build and setting, each on an empty cache: victory translate shaders.rpf --warm <hashes> --jobs 1 with VICTORY_HOST_WAVE=32 VICTORY_WAVE_WHY=1. _Tiled_LocalLights comes out wave-wide in A, B and C and folded in D, as in the description's table.

What this shows, with only two runs a side and judged by eye:

  1. No dark tiles on this card in any run, including the release's wave-wide _Tiled_LocalLights (A, C1, C2): not at the buoys and marker, along the shore, or under water.
  2. Terrain flicker with this PR and folding on: in 2 of 2 runs (D), in 0 of 2 runs of the release with folding on (C). Nothing else differed between C and D. I can't explain it, since this PR only changes the water programs; a second pair of eyes on it would help.
  3. Confirms the comment above: without VICTORY_WAVE_FOLDED=1 nothing changes (B is A, offline and in game).
  4. No frame rate difference beyond run-to-run noise in the logs. This was not the controlled cutscene measurement above, so it does not contradict the 2 fps found there on an RTX 4080.
  5. With folding on, 2 of 6 starts ended at the end of the opening cutscenes with a host command list did not close (0x80070057) (one on each build), before either water program was first bound. None in the 2 starts without folding. That looks like #4575, not this PR.

Seen in every build, so not from this PR: foliage flicker, a bridge flickering white, some distant trees untextured, afterimages under water.

Not tested: ray tracing on, frame generation, Series S, a diagnostics build with VICTORY_D3D12_DEBUG=1.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7305532439 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4496#issuecomment-7305532439). Originally posted by [rvrvrvr221](https://github.com/rvrvrvr221) on 2026-12-01T08:35:59Z. --- **In-game test on an RTX 4090: v2026.11.30.03 against this PR at 2985b8ce** PC: Core i9-13900K, RTX 4090 24 GB (driver 621.40), 32 GB DDR5-6400, Windows 11 Pro (build 26300). Every run: the launcher's defaults with `-NoMenu` (Series X, 2560x1440, DLSS Quality, frame generation off, ray tracing off), plus `VICTORY_WATER_LIGHT=1`. Same save in the first boat mission after the prologue: the buoys and mission marker, the bridge, the shore, one dive. | Run | Build | `VICTORY_WAVE_FOLDED` | `_Tiled_LocalLights` form | Seen | fps, median of the log's 10 s lines in play | |---|---|---|---|---|---| | A | v2026.11.30.03 | unset | wave-wide | no dark tiles | 36.3 | | B | this PR | unset | wave-wide (same as A) | no dark tiles | 33.1 | | C1 | v2026.11.30.03 | `1` | wave-wide | no dark tiles; terrain steady | 35.1 | | C2 | v2026.11.30.03 | `1` | wave-wide | no dark tiles; some white/grey flicker on the buoys; terrain steady | 34.6 | | D1 | this PR | `1` | folded | no dark tiles; black flicker on the buoys; nearby terrain flickers, islands and distant shores disappear and come back; one freeze of about 1.5 s | 36.4 | | D2 | this PR | `1` | folded | no dark tiles; terrain flickers again; no black flicker on the buoys | 36.4 | The forms were checked offline for each build and setting, each on an empty cache: `victory translate shaders.rpf --warm <hashes> --jobs 1` with `VICTORY_HOST_WAVE=32 VICTORY_WAVE_WHY=1`. `_Tiled_LocalLights` comes out wave-wide in A, B and C and folded in D, as in the description's table. What this shows, with only two runs a side and judged by eye: 1. **No dark tiles on this card in any run**, including the release's wave-wide `_Tiled_LocalLights` (A, C1, C2): not at the buoys and marker, along the shore, or under water. 2. **Terrain flicker with this PR and folding on**: in 2 of 2 runs (D), in 0 of 2 runs of the release with folding on (C). Nothing else differed between C and D. I can't explain it, since this PR only changes the water programs; a second pair of eyes on it would help. 3. Confirms the comment above: **without `VICTORY_WAVE_FOLDED=1` nothing changes** (B is A, offline and in game). 4. **No frame rate difference** beyond run-to-run noise in the logs. This was not the controlled cutscene measurement above, so it does not contradict the 2 fps found there on an RTX 4080. 5. With folding on, **2 of 6 starts ended at the end of the opening cutscenes** with `a host command list did not close (0x80070057)` (one on each build), before either water program was first bound. None in the 2 starts without folding. That looks like #4575, not this PR. Seen in every build, so not from this PR: foliage flicker, a bridge flickering white, some distant trees untextured, afterimages under water. Not tested: ray tracing on, frame generation, Series S, a diagnostics build with `VICTORY_D3D12_DEBUG=1`.
trustno1-coder commented 2026-12-01 18:39:56 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:39:56Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321300116 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4496#issuecomment-7321300116). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:39:56Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

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