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

Closed
github-bot wants to merge 1 commit from github-bot/gh-282 into main AGit
Owner

@⁠Mikey970 on GitHub · 2026-11-27 20:40 UTC · original
Mikey970:pr/wave-wide-approx → main · +322 −3 · 4 files · 1 commits · closed without merging

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.
**@⁠Mikey970** on GitHub · 2026-11-27 20:40 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/282) `Mikey970:pr/wave-wide-approx` → `main` · +322 −3 · 4 files · 1 commits · closed without merging ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 20:42:55 +00:00
github-bot closed this pull request 2026-11-28 19:25:20 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-11-28 19:23 UTC · original

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.

**@⁠trustno1-coder** on GitHub · 2026-11-28 19:23 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/282#issuecomment-7244510692) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!282
No description provided.