fix(shader): try loop-barrier-free wave-wide form before approximate local waves (VICTORY_WAVE_WIDE_APPROX) #282

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

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


Problem

When a console wave64 compute shader on a 32-lane host cannot be lowered by the exact non-widened forms, emit falls directly back to local waves (APPROXIMATE) (where each 32-lane host wave ballots/counts only its own half), because global VICTORY_WAVE_WIDE=1 is unsafe for shaders whose widened barriers fall inside loops.

Fix

  • Adds VICTORY_WAVE_WIDE_APPROX=1 (opt-in, off by default; keyed in shader_cache.rs).
  • Before falling back to approximate local-wave lowering, tries the exact wave-wide form guarded by lower::watch_loop_barriers—accepting it only when it lowers to 32 lanes and puts no translator barrier inside a CFG loop (keeping ptfx_CS_lightAtlas_Sprite / _Trail on their safe path).
  • In offline testing across 1,333 shaders from settled cell frames, this safely promotes 5 shaders from approximate to exact wave-wide (shader_binning_utils:CS_GenerateShaderBinOffsets and lens_flares:CS_ScanMip0..3) while refusing all loop-barrier shaders.
  • (Note: includes the small watch_loop_barriers helper in lower.rs so this PR is standalone and can be reviewed/merged independently of the VICTORY_WAVE_WIDE_AUTO PR.)

Testing

  • Added emit::wide_approx_tests (a_count_in_a_kept_lane_branch_takes_the_wave_wide_form_before_an_approximate_one and a_count_in_a_kept_lane_branch_in_a_loop_keeps_its_form), both DXIL-validated and passing.
  • Verified cargo check -p victory-gpu passes.
  • Validated over 300 s release runs with zero errors, no device loss, and no frame-time regression.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5532820243 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/282). Originally posted by [Mikey970](https://github.com/Mikey970) on 2026-11-27T20:40:32Z. --- ## Problem When a console wave64 compute shader on a 32-lane host cannot be lowered by the exact non-widened forms, `emit` falls directly back to `local waves (APPROXIMATE)` (where each 32-lane host wave ballots/counts only its own half), because global `VICTORY_WAVE_WIDE=1` is unsafe for shaders whose widened barriers fall inside loops. ## Fix - Adds `VICTORY_WAVE_WIDE_APPROX=1` (opt-in, off by default; keyed in `shader_cache.rs`). - Before falling back to approximate local-wave lowering, tries the exact wave-wide form guarded by `lower::watch_loop_barriers`—accepting it only when it lowers to 32 lanes and puts **no** translator barrier inside a CFG loop (keeping `ptfx_CS_lightAtlas_Sprite` / `_Trail` on their safe path). - In offline testing across 1,333 shaders from settled cell frames, this safely promotes 5 shaders from approximate to exact wave-wide (`shader_binning_utils:CS_GenerateShaderBinOffsets` and `lens_flares:CS_ScanMip0..3`) while refusing all loop-barrier shaders. - *(Note: includes the small `watch_loop_barriers` helper in `lower.rs` so this PR is standalone and can be reviewed/merged independently of the `VICTORY_WAVE_WIDE_AUTO` PR.)* ## Testing - Added `emit::wide_approx_tests` (`a_count_in_a_kept_lane_branch_takes_the_wave_wide_form_before_an_approximate_one` and `a_count_in_a_kept_lane_branch_in_a_loop_keeps_its_form`), both DXIL-validated and passing. - Verified `cargo check -p victory-gpu` passes. - Validated over 300 s release runs with zero errors, no device loss, and no frame-time regression.
trustno1-coder commented 2026-11-28 19:23:39 +00:00 (Migrated from github.com)

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


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:7244510692 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/282#issuecomment-7244510692). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-11-28T19:23:39Z. --- 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!282
No description provided.