Shaders: LDS bounds and looped LDS atomics as the console does them (cloud tile sort, port of foxhound 9f8838b) #104

Closed
ballsimulation wants to merge 1 commit from upstream-pr/104 into main
ballsimulation commented 2026-11-27 18:09:51 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ballsimulation on 2026-11-27T18:09:51Z.


Port of the shader half of foxhound 9f8838b ("cloud tile sort fix"). It was not in this tree or in any open PR. Both changes concern CS_SortRayTiles, the cloud pass's sort of its ray tiles (256 threads a group), on 32-lane hosts:

  • LDS bounds (VICTORY_LDS_BOUNDS=0 turns it off): outside a program's own shared memory, reads give 0 and writes are dropped, as on the console. Without this, the host's group-shared memory past the program's dwords is undefined. In the sort, 31 of the 32 groups dispatched clear and read up to 32 KiB past their 2.5 KiB.
  • Looped LDS atomics (VICTORY_LDS_LOOP_ATOMICS=0 turns it off): LDS atomics in a loop with nothing but atomics leading in get no meeting of the host waves. A host wave that takes fewer rounds otherwise waits at the barrier behind the loop while the others wait inside it. The first then reads counts the others have not written yet, and tiles drop out of the sorted list. foxhound saw 971 of 1,068 tiles kept, and a tile out of the list shows as an 8x4 square of clear sky in a cloud.

The violet-probe filter from the same commit is already in this tree (826ba15). The rest of that commit (launcher, samplers, bcpack) is left out; static sampler order is #69.

Checked (RTX 4070, driver 610.74): applies on current main with one hunk placed by hand (lds_bounds() beside needs_every_lane); cargo test -p victory-shader and cargo clippy -p victory-shader --all-targets -- -D warnings pass; played in a build with it for about 30 minutes with no device loss.

Not checked by me: the clouds themselves. foxhound's evidence is captures cloud3/cloud4 on an RTX 4070 SUPER. A daytime look at the sky after a camera cut, with and without it, would settle it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5531161704 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/104). Originally posted by [ballsimulation](https://github.com/ballsimulation) on 2026-11-27T18:09:51Z. --- Port of the shader half of [foxhound 9f8838b](https://github.com/readmet3xt-lab/foxhound/commit/9f8838b10960c6d5a28bacd5499e7f4384c8c54b) ("cloud tile sort fix"). It was not in this tree or in any open PR. Both changes concern `CS_SortRayTiles`, the cloud pass's sort of its ray tiles (256 threads a group), on 32-lane hosts: - **LDS bounds** (`VICTORY_LDS_BOUNDS=0` turns it off): outside a program's own shared memory, reads give 0 and writes are dropped, as on the console. Without this, the host's group-shared memory past the program's dwords is undefined. In the sort, 31 of the 32 groups dispatched clear and read up to 32 KiB past their 2.5 KiB. - **Looped LDS atomics** (`VICTORY_LDS_LOOP_ATOMICS=0` turns it off): LDS atomics in a loop with nothing but atomics leading in get no meeting of the host waves. A host wave that takes fewer rounds otherwise waits at the barrier behind the loop while the others wait inside it. The first then reads counts the others have not written yet, and tiles drop out of the sorted list. foxhound saw 971 of 1,068 tiles kept, and a tile out of the list shows as an 8x4 square of clear sky in a cloud. The violet-probe filter from the same commit is already in this tree (826ba15). The rest of that commit (launcher, samplers, bcpack) is left out; static sampler order is #69. **Checked** (RTX 4070, driver 610.74): applies on current `main` with one hunk placed by hand (`lds_bounds()` beside `needs_every_lane`); `cargo test -p victory-shader` and `cargo clippy -p victory-shader --all-targets -- -D warnings` pass; played in a build with it for about 30 minutes with no device loss. **Not checked by me:** the clouds themselves. foxhound's evidence is captures cloud3/cloud4 on an RTX 4070 SUPER. A daytime look at the sky after a camera cut, with and without it, would settle it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
wasonidas commented 2026-11-27 19:22:33 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by wasonidas on 2026-11-27T19:22:33Z.


A measurement that may help, since the description says the clouds themselves were not checked. We ran our own port of the same foxhound commit (9f8838b) on an RTX 5080 (driver 621.24, 32-lane waves): Series X profile, 2560x1440, DLSS Quality, no frame generation, diagnostics build, a 300 s unattended run outdoors (the prologue, then the boat ride), its captures reviewed by eye against a run of the build before.

captures with squares or tiles (clouds and sea) before with the looped-atomics change
whole run 12 of 56 1 of 70 (2 counting a thin line)
boat ride only 7 of 42 1 of 60
  • No regressions in the review. The run was stable: no device removed, no out-of-memory lines, prologue 46.1 FPS, boat ride 28.4 FPS, peak commit 31.1 GiB. A release build of the same tree then ran 300 s outdoors without errors.
  • Not every case is gone: one capture (215.8 s) still had a square.

Two differences from this PR to keep in mind:

  1. Only the looped-atomics half was on in our runs. In our port VICTORY_LDS_BOUNDS is off unless asked for (it changes 480 programs on this profile), so the figures above say nothing about the bounds half, which this PR turns on by default. With bounds off, the change reached CS_SortRayTiles alone, as the description says.
  2. The shader cache's key. Our port adds VICTORY_LDS_LOOP_ATOMICS and VICTORY_LDS_BOUNDS to the switches listed in build() in crates/victory-gpu/src/shader_cache.rs (where VICTORY_THREAD_TICKET is). As far as I can see this PR does not touch that file, so =0 on a filled shader cache would still be served the translations made with the switch on. Worth a look before anyone does the with/without comparison on one cache folder.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7226464792 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/104#issuecomment-7226464792). Originally posted by [wasonidas](https://github.com/wasonidas) on 2026-11-27T19:22:33Z. --- A measurement that may help, since the description says the clouds themselves were not checked. We ran our own port of the same foxhound commit (9f8838b) on an RTX 5080 (driver 621.24, 32-lane waves): Series X profile, 2560x1440, DLSS Quality, no frame generation, diagnostics build, a 300 s unattended run outdoors (the prologue, then the boat ride), its captures reviewed by eye against a run of the build before. | captures with squares or tiles (clouds and sea) | before | with the looped-atomics change | |---|---|---| | whole run | 12 of 56 | 1 of 70 (2 counting a thin line) | | boat ride only | 7 of 42 | 1 of 60 | - No regressions in the review. The run was stable: no device removed, no out-of-memory lines, prologue 46.1 FPS, boat ride 28.4 FPS, peak commit 31.1 GiB. A release build of the same tree then ran 300 s outdoors without errors. - Not every case is gone: one capture (215.8 s) still had a square. Two differences from this PR to keep in mind: 1. **Only the looped-atomics half was on in our runs.** In our port `VICTORY_LDS_BOUNDS` is off unless asked for (it changes 480 programs on this profile), so the figures above say nothing about the bounds half, which this PR turns on by default. With bounds off, the change reached `CS_SortRayTiles` alone, as the description says. 2. **The shader cache's key.** Our port adds `VICTORY_LDS_LOOP_ATOMICS` and `VICTORY_LDS_BOUNDS` to the switches listed in `build()` in `crates/victory-gpu/src/shader_cache.rs` (where `VICTORY_THREAD_TICKET` is). As far as I can see this PR does not touch that file, so `=0` on a filled shader cache would still be served the translations made with the switch on. Worth a look before anyone does the with/without comparison on one cache folder.
ballsimulation commented 2026-11-28 12:47:01 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ballsimulation on 2026-11-28T12:47:01Z.


Closing this PR: main now has both halves. 64d4931b added VICTORY_LDS_BOUNDS and VICTORY_LDS_LOOP_ATOMICS, both on by default, and put both switches in the shader cache's key in shader_cache.rs. That also takes care of the cache point @wasonidas raised. Thanks for the cloud measurement.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7239463285 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/104#issuecomment-7239463285). Originally posted by [ballsimulation](https://github.com/ballsimulation) on 2026-11-28T12:47:01Z. --- Closing this PR: main now has both halves. 64d4931b added `VICTORY_LDS_BOUNDS` and `VICTORY_LDS_LOOP_ATOMICS`, both on by default, and put both switches in the shader cache's key in `shader_cache.rs`. That also takes care of the cache point @wasonidas raised. Thanks for the cloud measurement.

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