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

Open
github-bot wants to merge 1 commit from github-bot/gh-104 into main AGit
Owner

@⁠ballsimulation on GitHub · 2026-11-27 18:09 UTC · original
ballsimulation:port/foxhound-lds-bounds → main · +130 −12 · 2 files · 1 commits · open

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

**@⁠ballsimulation** on GitHub · 2026-11-27 18:09 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/104) `ballsimulation:port/foxhound-lds-bounds` → `main` · +130 −12 · 2 files · 1 commits · open 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)
Outside a program's own shared memory reads give 0 and writes are dropped
(VICTORY_LDS_BOUNDS=0: as before), and LDS atomics in loops with nothing
but atomics leading in get no meeting of the host waves
(VICTORY_LDS_LOOP_ATOMICS=0: as before). Both seen in CS_SortRayTiles, the
cloud pass's tile sort: tiles left out of the list showed as squares of
clear sky in clouds on 32-lane hosts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 18:11:05 +00:00
Author
Owner

@⁠HugoW5 on GitHub · 2026-11-27 19:08 UTC · original · approved these changes

**@⁠HugoW5** on GitHub · 2026-11-27 19:08 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/104#pullrequestreview-6092409571) · **approved these changes**
Author
Owner

@⁠wasonidas on GitHub · 2026-11-27 19:22 UTC · original

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.
**@⁠wasonidas** on GitHub · 2026-11-27 19:22 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/104#issuecomment-7226464792) 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.
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/lower.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/104/head:github-bot/gh-104'
git switch 'github-bot/gh-104'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-104'
git switch 'github-bot/gh-104'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-104'
git switch 'github-bot/gh-104'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-104'
git switch 'main'
git merge --squash 'github-bot/gh-104'
git switch 'main'
git merge --ff-only 'github-bot/gh-104'
git switch 'main'
git merge 'github-bot/gh-104'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.