shader: SafeSingleWave widening for 64-lane compute shaders and IC SH integration #1006

Merged
whoalin1 merged 1 commit from upstream-pr/1006 into main 2026-11-29 08:16:57 +00:00
whoalin1 commented 2026-11-28 10:59:10 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by whoalin1 on 2026-11-28T10:59:10Z.


Summary

Adds WidenMode::SafeSingleWave in crates/victory-shader/src/emit/mod.rs for single-wave64 compute shaders (threads == 64), and adds CS_IrradianceCache_IntegrateIrradianceSH_cb05754f (eb1c062c...) to scene_kernel.

Problem

Without VICTORY_WAVE_WIDE=1, 64-lane compute shaders needing wave-wide branch widening fell back to local waves (approximate, no cross-half synchronization), breaking cross-half prefix sums, LDS reductions, and lane-63 broadcasts in GI and bin-offset passes (e.g., CS_GenerateShaderBinOffsets_84edd24c produced 269 overlapping shader-bin intervals; CS_IrradianceCache_* broke outdoor auto-white-balance / irradiance integration). Full WidenMode::All cannot be turned on globally because widening inside divergent loops can deadlock at group barriers.

Change (crates/victory-shader/src/emit/mod.rs)

  • Replace active_loop_only: bool on widen with WidenMode::{All, SafeSingleWave, DriverLoop}.
  • Add safe_single_wave_widen, which only permits widening forward branches in RPO (never loop latches) and rejects any natural loop enclosing a meeting/widened block if it is irreducible, has End/Indirect exits, or has non-Uniform loop exits/back-edges.
  • Register CS_IrradianceCache_IntegrateIrradianceSH_cb05754f (eb1c062c..., 5-stage LDS tree reduction + bounded uniform-exit SH loop) in scene_kernel.

Verification

Verified on Windows (x86_64-pc-windows-msvc, RTX 4070 SUPER):

  • git diff --check origin/main..HEAD — clean
  • cargo run --locked -p xtask -- policy — asset policy: 294 files ok
  • cargo clippy --workspace --all-targets --locked & --all-features — 0 new warnings in crates/victory-shader/src/emit/mod.rs (1 pre-existing let_and_return on untouched line 2961)
  • cargo test --release -p victory-shader --locked --lib -- --test-threads=1 — 293 passed, 0 failed, 5 ignored (including all 13 wave64_tests)
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5539407687 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1006). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-28T10:59:10Z. --- ## Summary Adds `WidenMode::SafeSingleWave` in [`crates/victory-shader/src/emit/mod.rs`](crates/victory-shader/src/emit/mod.rs) for single-wave64 compute shaders (`threads == 64`), and adds `CS_IrradianceCache_IntegrateIrradianceSH_cb05754f` (`eb1c062c...`) to `scene_kernel`. ## Problem Without `VICTORY_WAVE_WIDE=1`, 64-lane compute shaders needing wave-wide branch widening fell back to `local waves` (approximate, no cross-half synchronization), breaking cross-half prefix sums, LDS reductions, and lane-63 broadcasts in GI and bin-offset passes (e.g., `CS_GenerateShaderBinOffsets_84edd24c` produced 269 overlapping shader-bin intervals; `CS_IrradianceCache_*` broke outdoor auto-white-balance / irradiance integration). Full `WidenMode::All` cannot be turned on globally because widening inside divergent loops can deadlock at group barriers. ## Change (`crates/victory-shader/src/emit/mod.rs`) - Replace `active_loop_only: bool` on `widen` with `WidenMode::{All, SafeSingleWave, DriverLoop}`. - Add `safe_single_wave_widen`, which only permits widening forward branches in RPO (never loop latches) and rejects any natural loop enclosing a meeting/widened block if it is irreducible, has `End`/`Indirect` exits, or has non-`Uniform` loop exits/back-edges. - Register `CS_IrradianceCache_IntegrateIrradianceSH_cb05754f` (`eb1c062c...`, 5-stage LDS tree reduction + bounded uniform-exit SH loop) in `scene_kernel`. ## Verification Verified on Windows (`x86_64-pc-windows-msvc`, RTX 4070 SUPER): - `git diff --check origin/main..HEAD` — clean - `cargo run --locked -p xtask -- policy` — `asset policy: 294 files ok` - `cargo clippy --workspace --all-targets --locked` & `--all-features` — 0 new warnings in `crates/victory-shader/src/emit/mod.rs` (1 pre-existing `let_and_return` on untouched line 2961) - `cargo test --release -p victory-shader --locked --lib -- --test-threads=1` — 293 passed, 0 failed, 5 ignored (including all 13 `wave64_tests`)
Bj0rnis commented 2026-11-28 12:47:18 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Bj0rnis on 2026-11-28T12:47:18Z.


Independent RTX 5070 Ti 16 GB (Blackwell, Wave32 host) verification on 101cdf28 (Windows 11, Ryzen 7 9800X3D, 32 GB RAM, driver 621.24, Rust 1.98.1, --release build from source).

Automated checks & Wave32 shader corpus:

  • Clean merge-tree on main (63b902f); cargo xtask policy: 294 files ok.
  • cargo test --release --locked -p victory-shader --lib -- --test-threads=1: 293 passed, 0 failed, 5 ignored (233.35 s, including all wave64_tests and bvh::tests).
  • Full Wave32 shader pre-translation (VICTORY_HOST_WAVE=32): 25,763 translated / 222 failed vs 25,760 / 225 on main (63b902f) — unsupported wave64→wave32 count dropped 22 → 19 (+3 shaders lowered cleanly, 0 new translation errors).

Live gameplay check (~4 min, opening diner → prison cell → prison break room; Series X, 2560×1440, DLSS Quality, FG off):

  • Stability (barrier/deadlock check): 0 device removals / TDRs, 0 OOMs, 0 refused pipelines.
  • Performance: 28.9 fps median in mid-scenes (3.5k–6.5k draws, avg 4,941 — vs 27.6 fps on main), 27.3 fps in break room (avg 9,849 draws; RAM 27.0 GB, VRAM 12.8/14.3 GB), 27.4 fps overall world median (35 samples).
  • Visuals: No regressions or artifacts; window lighting looked noticeably cleaner / less milky than earlier runs.

Not tested: VICTORY_BVH_BUILDER=1 (RT) or VICTORY_WAVE_WIDE=1 comparison. No game data, shader hashes, logs, or captures attached.

AI-assisted test run and summary.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7239466680 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1006#issuecomment-7239466680). Originally posted by [Bj0rnis](https://github.com/Bj0rnis) on 2026-11-28T12:47:18Z. --- Independent RTX 5070 Ti 16 GB (Blackwell, Wave32 host) verification on `101cdf28` (Windows 11, Ryzen 7 9800X3D, 32 GB RAM, driver `621.24`, Rust 1.98.1, `--release` build from source). **Automated checks & Wave32 shader corpus:** - Clean merge-tree on `main` (`63b902f`); `cargo xtask policy`: **294 files ok**. - `cargo test --release --locked -p victory-shader --lib -- --test-threads=1`: **293 passed, 0 failed, 5 ignored** (233.35 s, including all `wave64_tests` and `bvh::tests`). - Full Wave32 shader pre-translation (`VICTORY_HOST_WAVE=32`): **`25,763` translated / `222` failed** vs `25,760` / `225` on `main` (`63b902f`) — unsupported wave64→wave32 count dropped **`22 → 19`** (+3 shaders lowered cleanly, 0 new translation errors). **Live gameplay check (~4 min, opening diner → prison cell → prison break room; Series X, 2560×1440, DLSS Quality, FG off):** - **Stability (barrier/deadlock check):** **0 device removals / TDRs, 0 OOMs, 0 refused pipelines.** - **Performance:** `28.9 fps` median in mid-scenes (`3.5k–6.5k` draws, avg `4,941` — vs `27.6 fps` on `main`), `27.3 fps` in break room (avg `9,849` draws; RAM `27.0 GB`, VRAM `12.8/14.3 GB`), `27.4 fps` overall world median (`35` samples). - **Visuals:** No regressions or artifacts; window lighting looked noticeably cleaner / less milky than earlier runs. *Not tested:* `VICTORY_BVH_BUILDER=1` (RT) or `VICTORY_WAVE_WIDE=1` comparison. No game data, shader hashes, logs, or captures attached. *AI-assisted test run and summary.*
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!1006
No description provided.