Shaders: paired Wave64 form for the wave64 compute programs no wave32 form takes (6b82bc7d22016cb5, 6871d6e4b3ac9a10), opt-in with VICTORY_WAVE_PAIRS=1 #348

Closed
grosterr wants to merge 7 commits from upstream-pr/348 into main
grosterr commented 2026-11-27 21:15:36 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by grosterr on 2026-11-27T21:15:36Z.


On a 32-lane host the translator refuses some wave64 compute programs ("no wave32 lowering for this wave64 program") and their dispatches are dropped. #101 takes four of them wave-wide and names one that is left: 6b82bc7d22016cb5 (vfx_triangleClip:CS_CollectTriangles_Meshlets, groups of 1,024, LDS past the host's 32 KiB in the meeting forms). The water program 6871d6e4b3ac9a10 (water_shading:CS_TransmissionVolumetrics) is refused for another reason: a floating-point wave reduction with no exact wave32 tree.

This brings the paired form from fxceless/victory-fork: one host thread runs two console lanes (lane and lane+32), so a console wave of 64 is one host wave of 32 and its cross-lane operations stay inside the thread. It is off by default and taken only with VICTORY_WAVE_PAIRS=1, as a last form after the existing ones.

Commits (authorship kept):

  • f134f48 (ByFxbian) — the paired lowering, fxceless/victory-fork#1397 (b27e0b1), which builds on PiloteCode's #854. Merged by hand into this tree's lower.rs / mod.rs (lane_regions_of, wave_base with a step of 64 for the pair, console_thread); the dispatch-spread hook that tree had is left out (this tree has none).
  • a1c0f9d — ordered paired FP32 reductions, from fxceless#1419 (cb4f23b, ByFxbian), taken in part: its move of lds_meetings / signature packing into files of their own is left out, and its fast-math guard (this tree has no fast-math pass).
  • 36b16ba (ByFxbian) — fxceless#1419 8d1162e, as is.
  • e9c13e6 (fxceless) — water programs in paired form, their wave64 sums replayed exactly (e3307c7); exact_floats / Cast::FpExt kept, the fast-math part not applied.
  • ad29fe0 — what the two programs still needed here: LDS reached through Lower::ds in the paired form; a memory-only barrier(8) for groups over 64 threads and LDS slot 0 reused when the group's LDS already fills 32 KiB; paired_with reusing the caller's io/res and a last-resort paired_fallback (exact RNE/FTZ FP32 replay); the v_add_f64 simulation in wave.rs (+0.0 identity, s_mov_b64) and the dead inactive-lane vdst read of v_permlane[x]16_b32 inside the FP32 replay; #854's two paired tests; and VICTORY_WAVE_PAIRS / VICTORY_WAVE_PAIRS_FP32 in the shader cache key.

Measured (RTX 3060 12 GB, driver 621.40, shaders.rpf of 1.0.2.1):

  • With VICTORY_WAVE_PAIRS=1: both programs translate with a 32-lane wave, pass DXIL validation and CreateComputePipelineState (6b82bc7d22016cb5 → c2978aea83f25a9c, "paired Wave64"; 6871d6e4b3ac9a10 → 7bd41fa916dfb216, "paired Wave64" with VICTORY_WAVE_PAIRS_FP32=non-ieee-rne-ftz, the same DXIL through the fallback without it). Over the whole archive "no wave32 lowering for this wave64 program" goes from 22 to 0 (25,667 → 25,689 translated).
  • Without the switch: all 25,667 programs translated before are byte-identical to the base (the translator has not changed upstream since d12eb1b, the base of that comparison).
  • In the game (about an hour over several runs with the switch on, mostly Series S with DLSS): the warm cache had no wave64 refusals left. One device removal happened, on Series X with VRAM over its budget (10.7 / 10.7 GB); it was not traced to these programs, and none happened on Series S. No frame-time change could be told from run-to-run noise; picture effects of the two programs (meshlet triangle culling, water transmission) were not compared side by side.
  • The two programs on this branch: translate --warm with VICTORY_WAVE_PAIRS=1 finds both in the cache made by the same translator (0 do not translate).
  • Tests: cargo test -p victory-shader 299 passed, 0 failed; cargo test -p victory-gpu --lib -- --test-threads=1 422 passed, 2 failed: indirect::tests::host_list_budget_starts_empty_at_each_submission and warp_batch_charges_every_execution, which fail on main as well (#67 fixes them).

Complements #101. Without #101 this form also takes its four programs (they are among the 22 above); with #101 merged they take its wave-wide form first, since the paired form is only tried after the others, and 6b82bc7d22016cb5 and 6871d6e4b3ac9a10 are left to this one. Both are merged together in our test build.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5533191549 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/348). Originally posted by [grosterr](https://github.com/grosterr) on 2026-11-27T21:15:36Z. --- On a 32-lane host the translator refuses some wave64 compute programs ("no wave32 lowering for this wave64 program") and their dispatches are dropped. #101 takes four of them wave-wide and names one that is left: `6b82bc7d22016cb5` (`vfx_triangleClip:CS_CollectTriangles_Meshlets`, groups of 1,024, LDS past the host's 32 KiB in the meeting forms). The water program `6871d6e4b3ac9a10` (`water_shading:CS_TransmissionVolumetrics`) is refused for another reason: a floating-point wave reduction with no exact wave32 tree. This brings the **paired form** from fxceless/victory-fork: one host thread runs two console lanes (lane and lane+32), so a console wave of 64 is one host wave of 32 and its cross-lane operations stay inside the thread. It is **off by default** and taken only with `VICTORY_WAVE_PAIRS=1`, as a last form after the existing ones. **Commits (authorship kept):** - `f134f48` (ByFxbian) — the paired lowering, fxceless/victory-fork#1397 (`b27e0b1`), which builds on PiloteCode's #854. Merged by hand into this tree's `lower.rs` / `mod.rs` (`lane_regions_of`, `wave_base` with a step of 64 for the pair, `console_thread`); the dispatch-spread hook that tree had is left out (this tree has none). - `a1c0f9d` — ordered paired FP32 reductions, from fxceless#1419 (`cb4f23b`, ByFxbian), taken in part: its move of `lds_meetings` / signature packing into files of their own is left out, and its fast-math guard (this tree has no fast-math pass). - `36b16ba` (ByFxbian) — fxceless#1419 `8d1162e`, as is. - `e9c13e6` (fxceless) — water programs in paired form, their wave64 sums replayed exactly (`e3307c7`); `exact_floats` / `Cast::FpExt` kept, the fast-math part not applied. - `ad29fe0` — what the two programs still needed here: LDS reached through `Lower::ds` in the paired form; a memory-only `barrier(8)` for groups over 64 threads and LDS slot 0 reused when the group's LDS already fills 32 KiB; `paired_with` reusing the caller's io/res and a last-resort `paired_fallback` (exact RNE/FTZ FP32 replay); the `v_add_f64` simulation in `wave.rs` (+0.0 identity, `s_mov_b64`) and the dead inactive-lane `vdst` read of `v_permlane[x]16_b32` inside the FP32 replay; #854's two paired tests; and `VICTORY_WAVE_PAIRS` / `VICTORY_WAVE_PAIRS_FP32` in the shader cache key. **Measured (RTX 3060 12 GB, driver 621.40, `shaders.rpf` of 1.0.2.1):** - With `VICTORY_WAVE_PAIRS=1`: both programs translate with a 32-lane wave, pass DXIL validation and `CreateComputePipelineState` (`6b82bc7d22016cb5` → `c2978aea83f25a9c`, "paired Wave64"; `6871d6e4b3ac9a10` → `7bd41fa916dfb216`, "paired Wave64" with `VICTORY_WAVE_PAIRS_FP32=non-ieee-rne-ftz`, the same DXIL through the fallback without it). Over the whole archive "no wave32 lowering for this wave64 program" goes from 22 to 0 (25,667 → 25,689 translated). - Without the switch: all 25,667 programs translated before are **byte-identical** to the base (the translator has not changed upstream since `d12eb1b`, the base of that comparison). - In the game (about an hour over several runs with the switch on, mostly Series S with DLSS): the warm cache had no wave64 refusals left. One device removal happened, on Series X with VRAM over its budget (10.7 / 10.7 GB); it was not traced to these programs, and none happened on Series S. No frame-time change could be told from run-to-run noise; picture effects of the two programs (meshlet triangle culling, water transmission) were not compared side by side. - The two programs on this branch: `translate --warm` with `VICTORY_WAVE_PAIRS=1` finds both in the cache made by the same translator (0 do not translate). - Tests: `cargo test -p victory-shader` 299 passed, 0 failed; `cargo test -p victory-gpu --lib -- --test-threads=1` 422 passed, 2 failed: `indirect::tests::host_list_budget_starts_empty_at_each_submission` and `warp_batch_charges_every_execution`, which fail on `main` as well (#67 fixes them). Complements #101. Without #101 this form also takes its four programs (they are among the 22 above); with #101 merged they take its wave-wide form first, since the paired form is only tried after the others, and `6b82bc7d22016cb5` and `6871d6e4b3ac9a10` are left to this one. Both are merged together in our test build. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ZanderOS1 commented 2026-11-27 22:12:51 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ZanderOS1 on 2026-11-27T22:12:51Z.


Works on my build and now all 22 wave64 shaders now translate cleanly.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7229127766 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/348#issuecomment-7229127766). Originally posted by [ZanderOS1](https://github.com/ZanderOS1) on 2026-11-27T22:12:51Z. --- Works on my build and now all 22 wave64 shaders now translate cleanly.
grosterr commented 2026-11-28 07:33:58 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by grosterr on 2026-11-28T07:33:58Z.


Updated onto main 63b902f (merge commit 3c87ac4); the conflicts were with main's LDS bounds and loop changes in lower.rs / mod.rs:

  • Main's LDS bounds (VICTORY_LDS_BOUNDS) and loop atomics stay on the unpaired LDS paths; the paired form keeps its own bounded LDS paths.
  • The paired branch of wave any/all comes before main's host-wide loop branch; halves and twin are checked together.
  • Main's emit / emit_once retry (without VICTORY_LOOPS_WAVE) wraps the paired tries; both cache-key lists are kept.

Checked on this branch: cargo test -p victory-shader 304 passed, 0 failed (twice; one earlier run stopped once without a failing test named, not reproduced); cargo test -p victory-gpu --lib -- --test-threads=1 453 passed, 0 failed.

Played on RTX 3060 12 GB with the same merge on top of main plus 19 other open PRs of this repository, VICTORY_WAVE_PAIRS=1, Series S, DLSS Quality: a warm cache of 25,782 shaders (203 do not translate, as before) and no wave64 program refused. Three runs (prologue cutscene, then the boat), no device loss.

Open question, being checked: with main's water light on (the default since 64d4931), dark rectangles show on the water around objects and the mission marker; they go away with VICTORY_WATER_LIGHT=0. Whether VICTORY_WAVE_PAIRS=1 plays a part (the water light's programs are wave64 with LDS) is the next run here; I will add the result.

Thanks to ZanderOS1 for testing it on their build.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7236021737 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/348#issuecomment-7236021737). Originally posted by [grosterr](https://github.com/grosterr) on 2026-11-28T07:33:58Z. --- Updated onto main `63b902f` (merge commit `3c87ac4`); the conflicts were with main's LDS bounds and loop changes in `lower.rs` / `mod.rs`: - Main's LDS bounds (`VICTORY_LDS_BOUNDS`) and loop atomics stay on the unpaired LDS paths; the paired form keeps its own bounded LDS paths. - The paired branch of wave any/all comes before main's host-wide loop branch; `halves` and `twin` are checked together. - Main's `emit` / `emit_once` retry (without `VICTORY_LOOPS_WAVE`) wraps the paired tries; both cache-key lists are kept. Checked on this branch: `cargo test -p victory-shader` 304 passed, 0 failed (twice; one earlier run stopped once without a failing test named, not reproduced); `cargo test -p victory-gpu --lib -- --test-threads=1` 453 passed, 0 failed. Played on RTX 3060 12 GB with the same merge on top of main plus 19 other open PRs of this repository, `VICTORY_WAVE_PAIRS=1`, Series S, DLSS Quality: a warm cache of 25,782 shaders (203 do not translate, as before) and no wave64 program refused. Three runs (prologue cutscene, then the boat), no device loss. Open question, being checked: with main's water light on (the default since `64d4931`), dark rectangles show on the water around objects and the mission marker; they go away with `VICTORY_WATER_LIGHT=0`. Whether `VICTORY_WAVE_PAIRS=1` plays a part (the water light's programs are wave64 with LDS) is the next run here; I will add the result. Thanks to ZanderOS1 for testing it on their build. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
grosterr commented 2026-11-28 07:46:50 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by grosterr on 2026-11-28T07:46:50Z.


Result of the open question above: the dark rectangles on the water are not from this form. They are there with VICTORY_WAVE_PAIRS=0 too and go away with VICTORY_WATER_LIGHT=0 (details in #739).

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7236157479 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/348#issuecomment-7236157479). Originally posted by [grosterr](https://github.com/grosterr) on 2026-11-28T07:46:50Z. --- Result of the open question above: the dark rectangles on the water are not from this form. They are there with `VICTORY_WAVE_PAIRS=0` too and go away with `VICTORY_WATER_LIGHT=0` (details in #739). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
johnthemistaker commented 2026-11-28 08:06:28 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by johnthemistaker on 2026-11-28T08:06:28Z.


Additional Wave32 data point for 6871d6e4b3ac9a10 on an RTX 5060 Ti (8 GB, host wave lanes 32..32).

Local change. In crates/victory-shader/src/emit/mod.rs (emit_once), I added this container to the existing digest allowlist for compute groups of exactly 64 threads. With VICTORY_WAVE_WIDE unset, it can reach the existing widen() fallback, which widens control flow so the two host waves can meet at group barriers. The explicit override still takes precedence. This is the wave-wide path. The paired path in this PR uses two console lanes per host lane and explicitly replays the FP32 reduction order.

Single-container controls. I used translate --list --validate --pipelines --jobs 1 with VICTORY_HOST_MAX_WAVE=32 and the same translation settings across the earlier local checkpoints:

  • b5cb122 with the default VICTORY_WAVE_WIDE setting refused the shader with no wave32 lowering for this wave64 program.
  • a5f464e with the allowlist entry and VICTORY_WAVE_WIDE unset emitted Wave32 DXIL, passed DXIL validation, and created a D3D12 compute PSO. The logged DXIL digest 6fcb55bcaf70cb2e matched the explicit VICTORY_WAVE_WIDE=1 control.
  • Setting VICTORY_WAVE_WIDE=0 on the candidate reproduced the refusal.

Current-base check. I ported the allowlist entry as local commit 1e65394 on 63b902f (v2026.11.28.01). The f0b9876 release build contains that port. Its offline run logged wave Some(32), widened 17 branches, emitted DXIL 6d256ff3bd7dc5bb, passed validation, and created the compute PSO. The 15 widened branches in the earlier checkpoint describe that checkpoint's output.

In-game observation. In f0b9876 with Series S, DLSS Balanced, and frame generation off, the log recorded first bind at frame 29800, then translation and host pipeline creation:

first bind ... frame=29800 stage="compute" ... hash=6871d6e4b3ac9a10
shader translated stage="compute" hash=6871d6e4b3ac9a10
host pipeline shaders=[compute 6871d6e4b3ac9a10]

This establishes that the single-hash wave-wide path can emit DXIL and create the host PSO on this card. Dispatch output, numerical equivalence to the paired FP32 reduction, and a matched visual comparison remain unverified.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7236367394 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/348#issuecomment-7236367394). Originally posted by [johnthemistaker](https://github.com/johnthemistaker) on 2026-11-28T08:06:28Z. --- Additional Wave32 data point for `6871d6e4b3ac9a10` on an RTX 5060 Ti (8 GB, host wave lanes 32..32). **Local change.** In `crates/victory-shader/src/emit/mod.rs` (`emit_once`), I added this container to the existing digest allowlist for compute groups of exactly 64 threads. With `VICTORY_WAVE_WIDE` unset, it can reach the existing `widen()` fallback, which widens control flow so the two host waves can meet at group barriers. The explicit override still takes precedence. This is the wave-wide path. The paired path in this PR uses two console lanes per host lane and explicitly replays the FP32 reduction order. **Single-container controls.** I used `translate --list --validate --pipelines --jobs 1` with `VICTORY_HOST_MAX_WAVE=32` and the same translation settings across the earlier local checkpoints: - `b5cb122` with the default `VICTORY_WAVE_WIDE` setting refused the shader with `no wave32 lowering for this wave64 program`. - `a5f464e` with the allowlist entry and `VICTORY_WAVE_WIDE` unset emitted Wave32 DXIL, passed DXIL validation, and created a D3D12 compute PSO. The logged DXIL digest `6fcb55bcaf70cb2e` matched the explicit `VICTORY_WAVE_WIDE=1` control. - Setting `VICTORY_WAVE_WIDE=0` on the candidate reproduced the refusal. **Current-base check.** I ported the allowlist entry as local commit `1e65394` on `63b902f` (`v2026.11.28.01`). The `f0b9876` release build contains that port. Its offline run logged `wave Some(32)`, widened 17 branches, emitted DXIL `6d256ff3bd7dc5bb`, passed validation, and created the compute PSO. The 15 widened branches in the earlier checkpoint describe that checkpoint's output. **In-game observation.** In `f0b9876` with Series S, DLSS Balanced, and frame generation off, the log recorded first bind at frame 29800, then translation and host pipeline creation: ```text first bind ... frame=29800 stage="compute" ... hash=6871d6e4b3ac9a10 shader translated stage="compute" hash=6871d6e4b3ac9a10 host pipeline shaders=[compute 6871d6e4b3ac9a10] ``` This establishes that the single-hash wave-wide path can emit DXIL and create the host PSO on this card. Dispatch output, numerical equivalence to the paired FP32 reduction, and a matched visual comparison remain unverified.
grosterr commented 2026-11-28 12:26:28 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by grosterr on 2026-11-28T12:26:28Z.


Pushed 5df24f4: with VICTORY_WAVE_PAIRS=1 the paired form no longer takes over programs that main's lowering already translates.

Before, =1 tried it first for every wave64 compute program with LDS, even one that had translated, and in the retry chain ahead of the exact forms with group barriers ("without skips", wave-wide branches). The water light's _Tiled and _Tiled_LocalLights then lost main's lowering (VICTORY_LOOPS_WAVE, VICTORY_LDS_FIRST_INIT), and on an RTX 3060 the open water came out dark (table in #739). Now:

  • The early try needs the plain translation to have failed.
  • In the retry chain the paired form comes after main's exact forms and before the approximate ones.
  • Unset, it stays the last fallback, as before.

Checked on this branch:

  • cargo test -p victory-shader: 304 passed, 0 failed.
  • translate with VICTORY_HOST_WAVE=32: 2,758 of 2,763 compute programs emitted, with and without the switch, the same as before the change.
  • VICTORY_WAVE_WHY shows the two water programs taking the wave-wide form (wave 32), as they do without the switch.

On our build the open water is blue with the switch unset, and the paired form still picks up the wave64 programs that do not translate otherwise (203 shaders do not translate, as with =1). So I run it unset now.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7239228856 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/348#issuecomment-7239228856). Originally posted by [grosterr](https://github.com/grosterr) on 2026-11-28T12:26:28Z. --- Pushed `5df24f4`: with `VICTORY_WAVE_PAIRS=1` the paired form no longer takes over programs that main's lowering already translates. Before, `=1` tried it first for every wave64 compute program with LDS, even one that had translated, and in the retry chain ahead of the exact forms with group barriers ("without skips", wave-wide branches). The water light's `_Tiled` and `_Tiled_LocalLights` then lost main's lowering (`VICTORY_LOOPS_WAVE`, `VICTORY_LDS_FIRST_INIT`), and on an RTX 3060 the open water came out dark (table in #739). Now: - The early try needs the plain translation to have failed. - In the retry chain the paired form comes after main's exact forms and before the approximate ones. - Unset, it stays the last fallback, as before. Checked on this branch: - `cargo test -p victory-shader`: 304 passed, 0 failed. - `translate` with `VICTORY_HOST_WAVE=32`: 2,758 of 2,763 compute programs emitted, with and without the switch, the same as before the change. - `VICTORY_WAVE_WHY` shows the two water programs taking the wave-wide form (wave 32), as they do without the switch. On our build the open water is blue with the switch unset, and the paired form still picks up the wave64 programs that do not translate otherwise (203 shaders do not translate, as with `=1`). So I run it unset now. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
futurepro62 commented 2026-11-28 23:08:12 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by futurepro62 on 2026-11-28T23:08:12Z.


Tested this PR on an RTX 5070 Ti (16 GB, host wave lanes 32..32), Windows 11 26300, Series X profile, shaders.rpf of 1.0.2.1. It works, but with one problem, and there's a small fix below.

Problem: two programs that already translate change output. The default-on fallback (VICTORY_WAVE_PAIRS unset) runs at the end of emit_once. emit calls emit_once twice: first with loops_wave, then again with LOOPS_OFF. So the fallback takes a program on the first try that the second try would have translated with main's wave-wide form. Two programs change this way:

  • 926c46bab3b86bd6 water_shading:CS_TransmissionVolumetricsSubmerged. This is the underwater program the comment on emit names for #539/#570.
  • 02384a60fda6f2d0 vfx_triangleClip:CS_DefragHeap_ComputeRelocations.

With VICTORY_WAVE_WHY=1, the head of this PR shows paired Wave64 (fallback): wave Some(32) for both. With VICTORY_WAVE_PAIRS=0 they take wave-wide branches: wave Some(32), as on the base.

Fix: move the fallback out of emit_once and into emit, after both tries have failed (paired_last_resort). Same conditions as before (wave32_compute, not WAVE_PAIRS_HERE, VICTORY_WAVE_PAIRS not 0). The commit is below, on top of this PR's head (5df24f4):

diff
diff --git a/crates/victory-shader/src/emit/mod.rs b/crates/victory-shader/src/emit/mod.rs
index e954cf6..f7c9fc3 100644
--- a/crates/victory-shader/src/emit/mod.rs
+++ b/crates/victory-shader/src/emit/mod.rs
@@ -601,21 +601,21 @@ pub fn emit(
     res: &resource::Resources,
 ) -> Result<HostShader, ShaderError> {
     let first = emit_once(c, native, p, st, io, res);
-    if !matches!(first, Err(ShaderError::Unsupported { .. })) || !loops_wave(native) {
+    if !matches!(first, Err(ShaderError::Unsupported { .. })) {
         return first;
     }
-    LOOPS_OFF.with(|off| off.set(true));
-    let again = emit_once(c, native, p, st, io, res);
-    LOOPS_OFF.with(|off| off.set(false));
-    match again {
-        Ok(shader) => {
+    if loops_wave(native) {
+        LOOPS_OFF.with(|off| off.set(true));
+        let again = emit_once(c, native, p, st, io, res);
+        LOOPS_OFF.with(|off| off.set(false));
+        if let Ok(shader) = again {
             if std::env::var_os("VICTORY_WAVE_WHY").is_some() {
                 eprintln!("WAVE-LOOPS left out: the program translates without them");
             }
-            Ok(shader)
+            return Ok(shader);
         }
-        Err(_) => first,
     }
+    paired_last_resort(c, native, p, io, res).map_or(first, Ok)
 }
 
 thread_local! {
@@ -938,23 +938,39 @@ fn emit_once(
     } else {
         original
     };
-    if matches!(&result, Err(ShaderError::Unsupported { .. }))
-        && wave32_compute
-        && !listed
-        && std::env::var_os("VICTORY_WAVE_PAIRS").is_none_or(|v| v != "0")
+    // (the paired fallback is [`emit`]'s, after both of its tries: not here, where it
+    // would take a program the try without `loops_wave` translates, as main does)
+    result
+}
+
+/// The paired form as a last resort, once [`emit`]'s tries left `p` unsupported.
+fn paired_last_resort(
+    c: &Container,
+    native: &NativeProgram,
+    p: &ir::Program,
+    io: &io::Io,
+    res: &resource::Resources,
+) -> Option<HostShader> {
+    let wave32_compute =
+        native.stage == HwStage::Cs && native.wave64 && lower::host_max_wave() == 32;
+    if !wave32_compute
+        || WAVE_PAIRS_HERE.get()
+        || std::env::var_os("VICTORY_WAVE_PAIRS").is_some_and(|v| v == "0")
     {
-        let again = paired_fallback(c, native, p, io, res);
-        if std::env::var_os("VICTORY_WAVE_WHY").is_some() {
-            match &again {
-                Ok((_, wave)) => eprintln!("WAVE64-RETRY paired Wave64 (fallback): wave {wave:?}"),
-                Err(e) => eprintln!("WAVE64-RETRY paired Wave64 (fallback): {e}"),
-            }
-        }
-        if let Ok((shader, Some(32))) = again {
-            return Ok(shader);
+        return None;
+    }
+    lower::take_needs();
+    let again = paired_fallback(c, native, p, io, res);
+    if std::env::var_os("VICTORY_WAVE_WHY").is_some() {
+        match &again {
+            Ok((_, wave)) => eprintln!("WAVE64-RETRY paired Wave64 (fallback): wave {wave:?}"),
+            Err(e) => eprintln!("WAVE64-RETRY paired Wave64 (fallback): {e}"),
         }
     }
-    result
+    match again {
+        Ok((shader, Some(32))) => Some(shader),
+        _ => None,
+    }
 }
 
 /// `p` (a console wave64 compute program on a host of 32-lane waves) with the per-lane

Offline check. Whole archive, VICTORY_HOST_WAVE=32 VICTORY_VIEW_LIMIT=1000000 victory translate shaders.rpf --validate --list, empty cache:

Build Validated "no wave32 lowering" Programs that translated before
base (our nightly, before this PR) 25,548 22
+ this PR 25,570 0 2 changed output (above)
+ this PR + fix 25,570 0 all byte-identical

The 22 that now translate include 6b82bc7d22016cb5, a10179ab7eda0dc3, 6871d6e4b3ac9a10, 9fe711566bec0d0a and 3b02415f67c6b0d8.

In game. One session of about 22 minutes on PR + fix, after a fresh victory warm: no shader does not translate lines. The session before, on the base, had two (6b82bc7d22016cb5 and a10179ab7eda0dc3). No device removal. Frame rate in line with the session before (game frames about 18 vs about 20 fps, different mission). The black props that remain are a different cause: the view heap cap, #638.

Not checked: a side-by-side picture of the water and meshlet programs, and cargo test.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7247224119 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/348#issuecomment-7247224119). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-28T23:08:12Z. --- Tested this PR on an RTX 5070 Ti (16 GB, host wave lanes 32..32), Windows 11 26300, Series X profile, `shaders.rpf` of 1.0.2.1. It works, but with one problem, and there's a small fix below. **Problem: two programs that already translate change output.** The default-on fallback (`VICTORY_WAVE_PAIRS` unset) runs at the end of `emit_once`. `emit` calls `emit_once` twice: first with `loops_wave`, then again with `LOOPS_OFF`. So the fallback takes a program on the first try that the second try would have translated with main's wave-wide form. Two programs change this way: - `926c46bab3b86bd6` `water_shading:CS_TransmissionVolumetricsSubmerged`. This is the underwater program the comment on `emit` names for #539/#570. - `02384a60fda6f2d0` `vfx_triangleClip:CS_DefragHeap_ComputeRelocations`. With `VICTORY_WAVE_WHY=1`, the head of this PR shows `paired Wave64 (fallback): wave Some(32)` for both. With `VICTORY_WAVE_PAIRS=0` they take `wave-wide branches: wave Some(32)`, as on the base. **Fix:** move the fallback out of `emit_once` and into `emit`, after both tries have failed (`paired_last_resort`). Same conditions as before (`wave32_compute`, not `WAVE_PAIRS_HERE`, `VICTORY_WAVE_PAIRS` not `0`). The commit is below, on top of this PR's head (`5df24f4`): <details><summary>diff</summary> ```diff diff --git a/crates/victory-shader/src/emit/mod.rs b/crates/victory-shader/src/emit/mod.rs index e954cf6..f7c9fc3 100644 --- a/crates/victory-shader/src/emit/mod.rs +++ b/crates/victory-shader/src/emit/mod.rs @@ -601,21 +601,21 @@ pub fn emit( res: &resource::Resources, ) -> Result<HostShader, ShaderError> { let first = emit_once(c, native, p, st, io, res); - if !matches!(first, Err(ShaderError::Unsupported { .. })) || !loops_wave(native) { + if !matches!(first, Err(ShaderError::Unsupported { .. })) { return first; } - LOOPS_OFF.with(|off| off.set(true)); - let again = emit_once(c, native, p, st, io, res); - LOOPS_OFF.with(|off| off.set(false)); - match again { - Ok(shader) => { + if loops_wave(native) { + LOOPS_OFF.with(|off| off.set(true)); + let again = emit_once(c, native, p, st, io, res); + LOOPS_OFF.with(|off| off.set(false)); + if let Ok(shader) = again { if std::env::var_os("VICTORY_WAVE_WHY").is_some() { eprintln!("WAVE-LOOPS left out: the program translates without them"); } - Ok(shader) + return Ok(shader); } - Err(_) => first, } + paired_last_resort(c, native, p, io, res).map_or(first, Ok) } thread_local! { @@ -938,23 +938,39 @@ fn emit_once( } else { original }; - if matches!(&result, Err(ShaderError::Unsupported { .. })) - && wave32_compute - && !listed - && std::env::var_os("VICTORY_WAVE_PAIRS").is_none_or(|v| v != "0") + // (the paired fallback is [`emit`]'s, after both of its tries: not here, where it + // would take a program the try without `loops_wave` translates, as main does) + result +} + +/// The paired form as a last resort, once [`emit`]'s tries left `p` unsupported. +fn paired_last_resort( + c: &Container, + native: &NativeProgram, + p: &ir::Program, + io: &io::Io, + res: &resource::Resources, +) -> Option<HostShader> { + let wave32_compute = + native.stage == HwStage::Cs && native.wave64 && lower::host_max_wave() == 32; + if !wave32_compute + || WAVE_PAIRS_HERE.get() + || std::env::var_os("VICTORY_WAVE_PAIRS").is_some_and(|v| v == "0") { - let again = paired_fallback(c, native, p, io, res); - if std::env::var_os("VICTORY_WAVE_WHY").is_some() { - match &again { - Ok((_, wave)) => eprintln!("WAVE64-RETRY paired Wave64 (fallback): wave {wave:?}"), - Err(e) => eprintln!("WAVE64-RETRY paired Wave64 (fallback): {e}"), - } - } - if let Ok((shader, Some(32))) = again { - return Ok(shader); + return None; + } + lower::take_needs(); + let again = paired_fallback(c, native, p, io, res); + if std::env::var_os("VICTORY_WAVE_WHY").is_some() { + match &again { + Ok((_, wave)) => eprintln!("WAVE64-RETRY paired Wave64 (fallback): wave {wave:?}"), + Err(e) => eprintln!("WAVE64-RETRY paired Wave64 (fallback): {e}"), } } - result + match again { + Ok((shader, Some(32))) => Some(shader), + _ => None, + } } /// `p` (a console wave64 compute program on a host of 32-lane waves) with the per-lane ``` </details> **Offline check.** Whole archive, `VICTORY_HOST_WAVE=32 VICTORY_VIEW_LIMIT=1000000 victory translate shaders.rpf --validate --list`, empty cache: | Build | Validated | "no wave32 lowering" | Programs that translated before | |---|---|---|---| | base (our nightly, before this PR) | 25,548 | 22 | | | + this PR | 25,570 | 0 | 2 changed output (above) | | + this PR + fix | 25,570 | 0 | all byte-identical | The 22 that now translate include `6b82bc7d22016cb5`, `a10179ab7eda0dc3`, `6871d6e4b3ac9a10`, `9fe711566bec0d0a` and `3b02415f67c6b0d8`. **In game.** One session of about 22 minutes on PR + fix, after a fresh `victory warm`: no `shader does not translate` lines. The session before, on the base, had two (`6b82bc7d22016cb5` and `a10179ab7eda0dc3`). No device removal. Frame rate in line with the session before (game frames about 18 vs about 20 fps, different mission). The black props that remain are a different cause: the view heap cap, #638. Not checked: a side-by-side picture of the water and meshlet programs, and `cargo test`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Yoshi-233 commented 2026-11-29 05:33:50 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Yoshi-233 on 2026-11-29T05:33:50Z.


I tested the last-resort paired lowering at 5df24f4f on an RTX 4070 Ti SUPER with 32-lane host waves. I limited the comparison to the two raster shadow-classification compute shaders eae3498e6553afa8 and b8f3f7979d6bbc50, with VICTORY_WAVE_PAIRS_FP32=0.

Both fail to translate on my previous .28.01-based player build and with pairing disabled. With pairing allowed for these two, the Microsoft DXIL validator passes both and D3D12 creates both compute pipelines in the game. Three control shaders (diffuse resolve, material lighting, and the particle draw) produced byte-identical DXIL across all three runs.

In a saved daylight interior I alternated recording and skipping both classification passes every 12 seconds in one process. Across four enabled and five skipped intervals with geometrically matched camera views, enabling them brightened the ceiling and cabinetry, while the sampled sunlit patch on the floor darkened. The rear window looked warmer. Small square boundaries on the floor remained in both modes. Median render frame times were 69.85 ms enabled and 69.30 ms skipped at 2560×1440 input, 3840×2160 output and 2× frame generation.

This confirms a visible lighting change from these two programs on Ada. Determining the intended exposure still requires native footage with matching camera, time and lighting.

Independently toggling the two shaders in a second, fixed dining-room view separated their effects. I kept eae3498e6553afa8 and b8f3f7979d6bbc50 on separate switches and captured two matched, pre-upscaling HDR inputs for each of the four combinations. At 550-pixel registration width the 90th-percentile geometry displacement stayed below 0.6 pixels across all eight images.

In the same 688×96 patch of floor, running eae3… produced 87–88 aligned 16-pixel edges above half a stop, with either setting of b8f3…. Skipping eae3… produced zero such edges in each of four samples. A neighbouring wall brightened from a median 33–34/255 to 67–77/255 when eae3… ran. This switch also changes the overall room lighting, so the lower edge count alone is insufficient to pick the correct shadow result. The original player can show floor grid artifacts with both shaders unavailable. The test isolates a change in this view, without identifying the unique cause of every grid artifact.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7251327345 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/348#issuecomment-7251327345). Originally posted by [Yoshi-233](https://github.com/Yoshi-233) on 2026-11-29T05:33:50Z. --- I tested the last-resort paired lowering at `5df24f4f` on an RTX 4070 Ti SUPER with 32-lane host waves. I limited the comparison to the two raster shadow-classification compute shaders `eae3498e6553afa8` and `b8f3f7979d6bbc50`, with `VICTORY_WAVE_PAIRS_FP32=0`. Both fail to translate on my previous .28.01-based player build and with pairing disabled. With pairing allowed for these two, the Microsoft DXIL validator passes both and D3D12 creates both compute pipelines in the game. Three control shaders (diffuse resolve, material lighting, and the particle draw) produced byte-identical DXIL across all three runs. In a saved daylight interior I alternated recording and skipping both classification passes every 12 seconds in one process. Across four enabled and five skipped intervals with geometrically matched camera views, enabling them brightened the ceiling and cabinetry, while the sampled sunlit patch on the floor darkened. The rear window looked warmer. Small square boundaries on the floor remained in both modes. Median render frame times were 69.85 ms enabled and 69.30 ms skipped at 2560×1440 input, 3840×2160 output and 2× frame generation. This confirms a visible lighting change from these two programs on Ada. Determining the intended exposure still requires native footage with matching camera, time and lighting. **Independently toggling the two shaders** in a second, fixed dining-room view separated their effects. I kept eae3498e6553afa8 and b8f3f7979d6bbc50 on separate switches and captured two matched, pre-upscaling HDR inputs for each of the four combinations. At 550-pixel registration width the 90th-percentile geometry displacement stayed below 0.6 pixels across all eight images. In the same 688×96 patch of floor, running eae3… produced 87–88 aligned 16-pixel edges above half a stop, with either setting of b8f3…. Skipping eae3… produced zero such edges in each of four samples. A neighbouring wall brightened from a median 33–34/255 to 67–77/255 when eae3… ran. This switch also changes the overall room lighting, so the lower edge count alone is insufficient to pick the correct shadow result. The original player can show floor grid artifacts with both shaders unavailable. The test isolates a change in this view, without identifying the unique cause of every grid artifact.
grosterr commented 2026-11-29 13:03:25 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by grosterr on 2026-11-29T13:03:25Z.


Closing this one: current main has made it unnecessary.

On the release 829188e (v2026.11.29.01), both programs this PR was for translate on an RTX 3060 12 GB (32-lane host waves) without VICTORY_WAVE_PAIRS. From the play log, Series S, DLSS Quality, FSR 3 FG 2x:

shader translated stage="compute" hash=7168dd781ca7efb9 user_data=3 samplers=2 ms=1
host pipeline shaders=[compute 7168dd781ca7efb9]
shader translated stage="compute" hash=6b82bc7d22016cb5 user_data=3 samplers=0 ms=1

There is no "no wave32 lowering" refusal for either. On e1f2eb6 (28.11) both were still refused. My guess is the exact fold of wave64 onto 32-lane hosts (VICTORY_WAVE_FOLDED, on by default, #1504) did it, but I haven't bisected that.

Thanks to futurepro62 for finding the emit_once fallback problem and providing the fix, and to Yoshi-233 for the detailed lighting comparison of the two shadow-classification programs. #2001 carries this work forward as an opt-in last resort, and already runs it after both of emit's tries, as futurepro62 suggested.

Posted by Claude Code on behalf of the machine's owner.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7256256142 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/348#issuecomment-7256256142). Originally posted by [grosterr](https://github.com/grosterr) on 2026-11-29T13:03:25Z. --- Closing this one: current `main` has made it unnecessary. On the release `829188e` (v2026.11.29.01), both programs this PR was for translate on an RTX 3060 12 GB (32-lane host waves) without `VICTORY_WAVE_PAIRS`. From the play log, Series S, DLSS Quality, FSR 3 FG 2x: ``` shader translated stage="compute" hash=7168dd781ca7efb9 user_data=3 samplers=2 ms=1 host pipeline shaders=[compute 7168dd781ca7efb9] shader translated stage="compute" hash=6b82bc7d22016cb5 user_data=3 samplers=0 ms=1 ``` There is no "no wave32 lowering" refusal for either. On `e1f2eb6` (28.11) both were still refused. My guess is the exact fold of wave64 onto 32-lane hosts (`VICTORY_WAVE_FOLDED`, on by default, #1504) did it, but I haven't bisected that. Thanks to futurepro62 for finding the `emit_once` fallback problem and providing the fix, and to Yoshi-233 for the detailed lighting comparison of the two shadow-classification programs. #2001 carries this work forward as an opt-in last resort, and already runs it after both of `emit`'s tries, as futurepro62 suggested. Posted by Claude Code on behalf of the machine's owner.

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