fix(shader): structural wave-wide lowering for cascade-shadow rasters (VICTORY_WAVE_WIDE_AUTO) #281

Closed
Mikey970 wants to merge 1 commit from upstream-pr/281 into main
Mikey970 commented 2026-11-27 20:40:29 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Mikey970 on 2026-11-27T20:40:29Z.


Problem

On 32-lane hosts, VICTORY_WAVE_WIDE is off globally because widening shaders that place translator barriers inside loops (e.g. ptfx_CS_lightAtlas_Sprite / _Trail) causes device loss. As a result, the 18 cascadeshadows_rendering:CS_ShadowRenderTiled* raster variants fall back to without skips, scalars followed, where a cross-half exchange runs after per-lane branching with no barrier—producing an 8-px sun-shadow staircase and lit-through tiles on walls and hair.

Fix

  • Splits ir::without_skips into skips_left_out and adds ir::deep_skip_holds to detect when earlier forms stop at a cross-half exchange kept from every lane only by a deep-only s_cbranch_execz skip (an inner skip sharing its join with an outer skip).
  • Adds lower::watch_loop_barriers / reset_loop_barriers / note_barrier to reject any wave-wide lowering that places a translator group barrier inside a CFG cycle (keeping ptfx_CS_lightAtlas_* safe).
  • Adds VICTORY_WAVE_WIDE_AUTO (on by default when VICTORY_WAVE_WIDE is unset; =0 restores old order): tries wave-wide before without skips, scalars followed when deep_skip_holds matches and no translator barrier lands in a loop.
  • Extends VICTORY_WAVE_WIDE to accept a comma-separated list of container digest hex prefixes (>= 8 digits) for targeted testing without affecting 0/1, and adds diagnostic VICTORY_WAVE_BALLOT_SYNC=1 (off by default).
  • Keys both VICTORY_WAVE_WIDE_AUTO and VICTORY_WAVE_BALLOT_SYNC in shader_cache.rs.

Testing

  • Added unit tests emit::wave64_tests::a_count_behind_a_skip_that_ends_with_an_outer_one_takes_the_wave_wide_form (validates DXIL and covers deep-skip selection, own-join skip, and loop-barrier rejection) and emit::barycentric_tests::wide_digest_list_matches_prefixes_and_leaves_flags_alone (both passed).
  • Verified cargo check -p victory-gpu passes.
  • Validated in-game: removes the window-wall/hair shadow staircase with ~0 ms release frame-time overhead and no device loss.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5532819460 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/281). Originally posted by [Mikey970](https://github.com/Mikey970) on 2026-11-27T20:40:29Z. --- ## Problem On 32-lane hosts, `VICTORY_WAVE_WIDE` is off globally because widening shaders that place translator barriers inside loops (e.g. `ptfx_CS_lightAtlas_Sprite` / `_Trail`) causes device loss. As a result, the 18 `cascadeshadows_rendering:CS_ShadowRenderTiled*` raster variants fall back to `without skips, scalars followed`, where a cross-half exchange runs after per-lane branching with no barrier—producing an 8-px sun-shadow staircase and lit-through tiles on walls and hair. ## Fix - Splits `ir::without_skips` into `skips_left_out` and adds `ir::deep_skip_holds` to detect when earlier forms stop at a cross-half exchange kept from every lane only by a deep-only `s_cbranch_execz` skip (an inner skip sharing its join with an outer skip). - Adds `lower::watch_loop_barriers` / `reset_loop_barriers` / `note_barrier` to reject any wave-wide lowering that places a translator group barrier inside a CFG cycle (keeping `ptfx_CS_lightAtlas_*` safe). - Adds `VICTORY_WAVE_WIDE_AUTO` (on by default when `VICTORY_WAVE_WIDE` is unset; `=0` restores old order): tries wave-wide before `without skips, scalars followed` when `deep_skip_holds` matches and no translator barrier lands in a loop. - Extends `VICTORY_WAVE_WIDE` to accept a comma-separated list of container digest hex prefixes (>= 8 digits) for targeted testing without affecting `0`/`1`, and adds diagnostic `VICTORY_WAVE_BALLOT_SYNC=1` (off by default). - Keys both `VICTORY_WAVE_WIDE_AUTO` and `VICTORY_WAVE_BALLOT_SYNC` in `shader_cache.rs`. ## Testing - Added unit tests `emit::wave64_tests::a_count_behind_a_skip_that_ends_with_an_outer_one_takes_the_wave_wide_form` (validates DXIL and covers deep-skip selection, own-join skip, and loop-barrier rejection) and `emit::barycentric_tests::wide_digest_list_matches_prefixes_and_leaves_flags_alone` (both passed). - Verified `cargo check -p victory-gpu` passes. - Validated in-game: removes the window-wall/hair shadow staircase with ~0 ms release frame-time overhead and no device loss.
trustno1-coder commented 2026-11-28 19:22:32 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-28T19:22:32Z.


Thanks for this. I'm closing it without merging because it conflicts with the current main in several places (main has moved a lot since it was opened, with about 100 pull requests merged today), and I can't resolve that safely on your behalf. If you'd still like it in, please rebase it on the current main and open a new pull request.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7244496798 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/281#issuecomment-7244496798). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-11-28T19:22:32Z. --- Thanks for this. I'm closing it without merging because it conflicts with the current main in several places (main has moved a lot since it was opened, with about 100 pull requests merged today), and I can't resolve that safely on your behalf. If you'd still like it in, please rebase it on the current main and open a new pull request.

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