feat(shader): wave32 water tile slot allocation and scalar loop skips #326

Closed
wike1701 wants to merge 1 commit from upstream-pr/326 into main
wike1701 commented 2026-11-27 21:02:07 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by wike1701 on 2026-11-27T21:02:07Z.


Summary

Ports Wave32 (NVIDIA) water lighting fixes from xceless/victory-fork (GPL-3.0, commits cd93552 and 299fba, building on xss3009's transmission tile allocation idea):

  1. Per-lane water tile slot allocation (emit/water_tile_slots.rs): rewrites water_shading:CS_TransmissionVolumetrics_GenerateTiles on 32-lane hosts so each lane takes its own slot via uffer_atomic_add 1 instead of letting host wave 1 overwrite host wave 0's tile slots (fixes the 16×16 dark patches on open water; disable with VICTORY_WATER_TILE_SLOTS=0). Also wired into pps/victory/src/translate.rs via emit::host_form.
  2. Scalar-test loop skips kept for wave-wide lowering (ir::without_skips(..., loops_kept)): keeps skips around loops controlled by scalar comparisons (s_cmp_* / s_bitcmp) when lowering wave-wide compute shaders (VICTORY_WAVE_LOOP_SKIPS=0 to disable), preventing empty-EXEC slice loops from spinning to the iteration limit.
  3. CS_TransmissionVolumetrics_VolumePortalsOnly wave-wide: enables wave-wide lowering for the volume-portals-only water transmission shader (10179ab7eda0dc3).

(Note: LDS init hoisting from 299fba is already submitted separately in #35, and thread-ticket group counters from 854f57f are already in main.)

Verification

  • cargo test -p victory-shader --lib -- water_tile_slots:: ir::tests:: — 12 passed, 0 failed
  • cargo check -p victory — ok (0 new warnings)
  • cargo xtask policy — 288 files ok
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5533052100 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/326). Originally posted by [wike1701](https://github.com/wike1701) on 2026-11-27T21:02:07Z. --- ## Summary Ports Wave32 (NVIDIA) water lighting fixes from xceless/victory-fork (GPL-3.0, commits cd93552 and 299fba, building on xss3009's transmission tile allocation idea): 1. **Per-lane water tile slot allocation (emit/water_tile_slots.rs)**: rewrites water_shading:CS_TransmissionVolumetrics_GenerateTiles on 32-lane hosts so each lane takes its own slot via uffer_atomic_add 1 instead of letting host wave 1 overwrite host wave 0's tile slots (fixes the 16×16 dark patches on open water; disable with VICTORY_WATER_TILE_SLOTS=0). Also wired into pps/victory/src/translate.rs via emit::host_form. 2. **Scalar-test loop skips kept for wave-wide lowering (ir::without_skips(..., loops_kept))**: keeps skips around loops controlled by scalar comparisons (s_cmp_* / s_bitcmp) when lowering wave-wide compute shaders (VICTORY_WAVE_LOOP_SKIPS=0 to disable), preventing empty-EXEC slice loops from spinning to the iteration limit. 3. **CS_TransmissionVolumetrics_VolumePortalsOnly wave-wide**: enables wave-wide lowering for the volume-portals-only water transmission shader (10179ab7eda0dc3). *(Note: LDS init hoisting from 299fba is already submitted separately in #35, and thread-ticket group counters from 854f57f are already in main.)* ## Verification - cargo test -p victory-shader --lib -- water_tile_slots:: ir::tests:: — **12 passed, 0 failed** - cargo check -p victory — **ok** (0 new warnings) - cargo xtask policy — **288 files ok**
Yoshi-233 commented 2026-11-28 08:43:27 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Yoshi-233 on 2026-11-28T08:43:27Z.


I tried the scalar-loop part independently at this PR’s head, 0b881e0, using synthetic IR and loops_kept=true. All three inputs started with exactly one outer empty-EXEC skip. Both deep=false and deep=true gave the same result:

Loop inside the skip Outer skip after without_skips
v_readfirstlane_b32 supplies the initial value; scalar add, compare, branch on SCC0 Kept
v_cmp_gt_u32 followed by a VCCZ backedge to the compare Removed
Same compare followed by a VCCNZ backedge Removed

The first row verifies the scalar case on your head. The VCC cases give a small additional regression pair: with EXEC empty the comparison clears VCC, so the VCCZ backedge can keep taking the loop while VCCNZ exits immediately. The new fixture in #888 distinguishes them on current main. These are compiler results; I did not test this PR’s water-lighting changes in game.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7236768137 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/326#issuecomment-7236768137). Originally posted by [Yoshi-233](https://github.com/Yoshi-233) on 2026-11-28T08:43:27Z. --- I tried the scalar-loop part independently at this PR’s head, `0b881e0`, using synthetic IR and `loops_kept=true`. All three inputs started with exactly one outer empty-EXEC skip. Both `deep=false` and `deep=true` gave the same result: | Loop inside the skip | Outer skip after `without_skips` | | --- | --- | | `v_readfirstlane_b32` supplies the initial value; scalar add, compare, branch on SCC0 | **Kept** | | `v_cmp_gt_u32` followed by a VCCZ backedge to the compare | Removed | | Same compare followed by a VCCNZ backedge | Removed | The first row verifies the scalar case on your head. The VCC cases give a small additional regression pair: with EXEC empty the comparison clears VCC, so the VCCZ backedge can keep taking the loop while VCCNZ exits immediately. The new fixture in #888 distinguishes them on current main. These are compiler results; I did not test this PR’s water-lighting changes in game.
trustno1-coder commented 2026-11-28 19:22:50 +00:00 (Migrated from github.com)

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


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