Shaders: guard divergent single-console-wave barriers on narrow-wave (NVIDIA) GPUs #109

Open
rivaldodev wants to merge 2 commits from upstream-pr/109 into main
rivaldodev commented 2026-11-26 03:42:09 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by rivaldodev on 2026-11-26T03:42:09Z.


Summary

Two focused improvements for narrow-wave (wave32) / capped-heap GPUs such as NVIDIA, tested live on hardware:

  1. Shaders: automatically guard divergent single-console-wave barriers on narrow-wave GPUs

    • Restricts automatic divergent barrier sync omission to single-console-wave groups (group_threads <= console_wave), preventing deadlocks on wave32 GPUs when only part of a console wave enters s_barrier.
    • Preserves memory fences (TGSM_FENCE / UAV_FENCE) and explicit VICTORY_GROUP_SYNC overrides.
    • Adds unit tests and a live narrow-wave hardware test (an_automatic_barrier_inside_a_lane_branch_runs_on_narrow_hardware).
  2. Tests: verify null heap clamp slot with small and exact-fit allocations

    • Extends view_heaps_keep_the_clamp_slot_null to verify small, exact-fit, and overflowing title heaps all keep the final clamp slot null on capped-heap GPUs (e.g., 1,000,000 views on NVIDIA).

Verification

  • cargo test --locked -p victory-shader an_automatic_barrier_inside_a_lane_branch_runs_on_narrow_hardware -- --nocapture — passed on live wave32 hardware (max wave 32: 1, 10, 32, 33 and 64 active lanes)
  • cargo test --locked -p victory-gpu clamp -- --nocapture — passed on live hardware (1000000 slots, 262144 dynamic slots; small, exact-fit and overflowing title heaps leave slot 999999 null)
  • cargo build --locked --profile diag -p victory --features diagnostics — passed
<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6619004015 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/109). Originally posted by [rivaldodev](https://github.com/rivaldodev) on 2026-11-26T03:42:09Z. --- ## Summary Two focused improvements for narrow-wave (wave32) / capped-heap GPUs such as NVIDIA, tested live on hardware: 1. **Shaders: automatically guard divergent single-console-wave barriers on narrow-wave GPUs** - Restricts automatic divergent barrier sync omission to single-console-wave groups (`group_threads <= console_wave`), preventing deadlocks on wave32 GPUs when only part of a console wave enters `s_barrier`. - Preserves memory fences (`TGSM_FENCE` / `UAV_FENCE`) and explicit `VICTORY_GROUP_SYNC` overrides. - Adds unit tests and a live narrow-wave hardware test (`an_automatic_barrier_inside_a_lane_branch_runs_on_narrow_hardware`). 2. **Tests: verify null heap clamp slot with small and exact-fit allocations** - Extends `view_heaps_keep_the_clamp_slot_null` to verify small, exact-fit, and overflowing title heaps all keep the final clamp slot null on capped-heap GPUs (e.g., 1,000,000 views on NVIDIA). ## Verification - `cargo test --locked -p victory-shader an_automatic_barrier_inside_a_lane_branch_runs_on_narrow_hardware -- --nocapture` — passed on live wave32 hardware (`max wave 32: 1, 10, 32, 33 and 64 active lanes`) - `cargo test --locked -p victory-gpu clamp -- --nocapture` — passed on live hardware (`1000000 slots, 262144 dynamic slots; small, exact-fit and overflowing title heaps leave slot 999999 null`) - `cargo build --locked --profile diag -p victory --features diagnostics` — passed
copilot-pull-request-reviewer[bot] commented 2026-11-26 03:42:17 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-26T03:42:17Z.


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:review:6068249742 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/109#pullrequestreview-6068249742). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-26T03:42:17Z. --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
avatarmanz commented 2026-11-26 07:36:34 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by avatarmanz on 2026-11-26T07:36:34Z.


Left open: same barriers on 64-lane AMD hosts, but the new default (auto) changes the shader cache key, so every AMD cache would be translated again once; maintainer's call.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7185640718 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/109#issuecomment-7185640718). Originally posted by [avatarmanz](https://github.com/avatarmanz) on 2026-11-26T07:36:34Z. --- Left open: same barriers on 64-lane AMD hosts, but the new default (auto) changes the shader cache key, so every AMD cache would be translated again once; maintainer's call.
juliptree commented 2026-11-26 07:50:11 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by juliptree on 2026-11-26T07:50:11Z.


Independently validated head 23921a7 on Windows with an RTX 5060 Ti 16 GB, driver 616.92. The shader test dispatched on the physical GPU with min/max wave width 32. All five cases (1, 10, 32, 33, and 64 active lanes) completed and returned the expected UAV value of 19.

The victory-gpu clamp filter passed all six matched tests. On the 5060 Ti, small, exact-fit, and overflowing title allocations all left slot 999999 reserved and initialized to null. A shader read from that slot was outside the scope of the test. I used temporary logging in a separate worktree to confirm the adapter and readbacks. No game files were used.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7185887552 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/109#issuecomment-7185887552). Originally posted by [juliptree](https://github.com/juliptree) on 2026-11-26T07:50:11Z. --- Independently validated head 23921a7 on Windows with an RTX 5060 Ti 16 GB, driver 616.92. The shader test dispatched on the physical GPU with min/max wave width 32. All five cases (1, 10, 32, 33, and 64 active lanes) completed and returned the expected UAV value of 19. The victory-gpu clamp filter passed all six matched tests. On the 5060 Ti, small, exact-fit, and overflowing title allocations all left slot 999999 reserved and initialized to null. A shader read from that slot was outside the scope of the test. I used temporary logging in a separate worktree to confirm the adapter and readbacks. No game files were used.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/109:upstream-pr/109'
git switch 'upstream-pr/109'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/109'
git switch 'upstream-pr/109'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/109'
git switch 'upstream-pr/109'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/109'
git switch 'main'
git merge --squash 'upstream-pr/109'
git switch 'main'
git merge --ff-only 'upstream-pr/109'
git switch 'main'
git merge 'upstream-pr/109'
git push origin 'main'
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
avatarmanz/VIctory-7900XTX!109
No description provided.