Shaders: loose-LDS fallback and 32-lane fixes (fork PR #799 by @Massive-Adrian, rebased onto 06702fe) #1287

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

@⁠Garu667 on GitHub · 2026-11-26 10:47 UTC · original
Garu667:pr/799-rebased → main · +119 −6 · 4 files · 1 commits · open

Rebase of #799 by @⁠Massive-Adrian onto current main (06702fe), his commit kept as co-author. The CBV clamp of #799 is left out (main has its own, #911); main's wave-wide last form is kept and the loose fallback comes after it; its helper moved to emit/loose_lds.rs so lower.rs stays under the asset policy's 512 KiB (a few of #799's comments shortened for the same reason).

RTX 3080 10 GB, boat mission, same build otherwise (runs 58 / 63):

main + this PR
compute pipelines refused in the scene 8 3 (only the 3 water volumetrics left)
now running — 2cc4 (reflection tiles: the blocky band on the boat is gone), 2da4 (window glass), 369c, 0238, 6b82
world fps 10.0 8.6

The fps cost is not the programs themselves: one of them writes the 2 KiB block at 0xdc07eab00 that fills read, so fill-ahead switches off for every fill (submit thread waiting on the card 8.2 → 24.3 ms/frame). With the per-piece waiting of #1224 (VICTORY_FILL_HOT; we measured the same idea locally) it comes back to 9.6 fps and 10.9 ms of waits.

The fallback is approximate, as #799 says, and on by default as in #799; VICTORY_WAVE_LDS_LOOSE=0 turns it off. No device loss; picture visibly better in our captures. Tests: victory-shader 219 passed, clippy clean.

🤖 Generated with Claude Code

**@⁠Garu667** on GitHub · 2026-11-26 10:47 UTC · [original](https://github.com/fxceless/victory-fork/pull/1287) `Garu667:pr/799-rebased` → `main` · +119 −6 · 4 files · 1 commits · open Rebase of #799 by @⁠Massive-Adrian onto current `main` (`06702fe`), his commit kept as co-author. The CBV clamp of #799 is left out (main has its own, #911); main's wave-wide `last` form is kept and the loose fallback comes after it; its helper moved to `emit/loose_lds.rs` so `lower.rs` stays under the asset policy's 512 KiB (a few of #799's comments shortened for the same reason). **RTX 3080 10 GB, boat mission, same build otherwise** (runs 58 / 63): | | main | + this PR | |---|---|---| | compute pipelines refused in the scene | 8 | **3** (only the 3 water volumetrics left) | | now running | — | `2cc4` (reflection tiles: the blocky band on the boat is gone), `2da4` (window glass), `369c`, `0238`, `6b82` | | world fps | 10.0 | 8.6 | The fps cost is not the programs themselves: one of them writes the 2 KiB block at `0xdc07eab00` that fills read, so fill-ahead switches off for every fill (submit thread waiting on the card 8.2 → 24.3 ms/frame). With the per-piece waiting of #1224 (`VICTORY_FILL_HOT`; we measured the same idea locally) it comes back to 9.6 fps and 10.9 ms of waits. The fallback is approximate, as #799 says, and **on by default as in #799**; `VICTORY_WAVE_LDS_LOOSE=0` turns it off. No device loss; picture visibly better in our captures. Tests: `victory-shader` 219 passed, clippy clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Console wave64 programs that read and write LDS inside one lane-branch
region were refused outright by a 32-lane host. As a last resort they are
now ordered between the two host waves only where the region is entered
and left (emit/loose_lds.rs; VICTORY_WAVE_LDS_LOOSE=0 turns it off;
approximate). Also from #799: s_pack_{ll,lh,hh}_b32_b16, s_bfm_b32 and the
s_mov_b64 32-bit literal as constant sources, the thread-group info SGPR,
f64 wave sums per host wave in local mode, VICTORY_SCC_LOCAL_ANY=1 (opt-in).

Rebase: #799's CBV clamp is left out (main has its own, PR #911); main's
wave-wide 'last' form is kept and the loose fallback comes after it; the
fallback's helper lives in its own file so lower.rs stays under the asset
policy's 512 KiB.

Co-authored-by: Massive-Adrian <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:19:53 +00:00
Author
Owner

@⁠slauko on GitHub · 2026-11-26 11:36 UTC · original

Ported to a Wine line (RTX 3080 Ti, vkd3d-proton ec20719, uiliannn's base, the cell at ~4,950 draws a frame). It does exactly what it says, and the price is real but smaller on this stack:

The refusals go. With the port, 02384a60fda6f2d0 and 2da4beb386509b77 get a host pipeline instead of Required WaveSize range [64, 64], but supported range is [32, 32] — the retry line says how: loose LDS + local waves (APPROXIMATE, any mask): wave Some(32) — and the dispatch that was dropped every frame with them is gone. Counts from the two runs: host pipeline refused 2 → 0, Required WaveSize range 2 → 0, dropped dispatch 1 → 0; the loose-LDS rung is reached by exactly those two programs out of 93 successful wave32 downgrades in the run.

The price, like-for-like. Same build, same environment, same stop, only VICTORY_WAVE_LDS_LOOSE differs: 276.7 ms a frame in the cell with it off against 295.9 with it on (medians of the last 8 frame lines, 266–316 and 270–318). The whole delta is card time (on the GPU +19 ms), preparing and the draw count flat — the two programs are on the hot path here too, as you found on the 5070 Ti (10.0 → 8.6 fps).

So my recipe leaves it off (VICTORY_WAVE_LDS_LOOSE=0) and the port stays in the tree for picture work: CS_AlphTransmissionPrefilterMip is the window-glass prefilter, and that is the part a player sees.

One thing that cost me an hour and may help the next porter: the shader cache is keyed on the translator's source hash, and a build script that found no source files wrote the empty FNV state into it, so every run was served stale DXIL and the port looked like a no-op. If a port seems to change nothing, check that the run's first translation line is not "0 translated, N already cached".

**@⁠slauko** on GitHub · 2026-11-26 11:36 UTC · [original](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7190944007) Ported to a Wine line (RTX 3080 Ti, vkd3d-proton `ec20719`, uiliannn's base, the cell at ~4,950 draws a frame). It does exactly what it says, and the price is real but smaller on this stack: **The refusals go.** With the port, `02384a60fda6f2d0` and `2da4beb386509b77` get a host pipeline instead of `Required WaveSize range [64, 64], but supported range is [32, 32]` — the retry line says how: `loose LDS + local waves (APPROXIMATE, any mask): wave Some(32)` — and the dispatch that was dropped every frame with them is gone. Counts from the two runs: `host pipeline refused` 2 → **0**, `Required WaveSize range` 2 → 0, dropped dispatch 1 → 0; the loose-LDS rung is reached by exactly those two programs out of 93 successful wave32 downgrades in the run. **The price, like-for-like.** Same build, same environment, same stop, only `VICTORY_WAVE_LDS_LOOSE` differs: **276.7 ms** a frame in the cell with it off against **295.9** with it on (medians of the last 8 frame lines, 266–316 and 270–318). The whole delta is card time (`on the GPU` +19 ms), `preparing` and the draw count flat — the two programs are on the hot path here too, as you found on the 5070 Ti (10.0 → 8.6 fps). So my recipe leaves it **off** (`VICTORY_WAVE_LDS_LOOSE=0`) and the port stays in the tree for picture work: `CS_AlphTransmissionPrefilterMip` is the window-glass prefilter, and that is the part a player sees. One thing that cost me an hour and may help the next porter: the shader cache is keyed on the translator's source hash, and a build script that found no source files wrote the *empty* FNV state into it, so every run was served stale DXIL and the port looked like a no-op. If a port seems to change nothing, check that the run's first translation line is not "0 translated, N already cached".
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 11:45 UTC · original

Thanks for porting it and for the like-for-like numbers (and the cache-key tip). Small precision: our 10.0 → 8.6 was on the RTX 3080 (Windows, native D3D12), and there the cost was not card time: one of the recovered programs writes the 2 KiB block at 0xdc07eab00 that fills read, so fill-ahead switched off for every fill (+16 ms of submit-thread waits). With per-piece waiting (#1224's idea) it came back to 9.6. Your +19 ms on the GPU is a different cost, so leaving it off by default on your stack makes sense.

**@⁠Garu667** on GitHub · 2026-11-26 11:45 UTC · [original](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7191136476) Thanks for porting it and for the like-for-like numbers (and the cache-key tip). Small precision: our 10.0 → 8.6 was on the RTX 3080 (Windows, native D3D12), and there the cost was not card time: one of the recovered programs writes the 2 KiB block at `0xdc07eab00` that fills read, so fill-ahead switched off for every fill (+16 ms of submit-thread waits). With per-piece waiting (#1224's idea) it came back to 9.6. Your +19 ms on the GPU is a different cost, so leaving it off by default on your stack makes sense.
Author
Owner

@⁠d0dev on GitHub · 2026-11-26 12:12 UTC · original

Tested on Windows 11, RTX 4070 Ti SUPER 16 GB (driver 616.92), Ryzen 7 5800X3D, 32 GB RAM. Clean build: main ceb9e1f + this PR only, same boat-mission save, close to the maintainer's test switches (TEXTURE_BACK, HEAP_WORKER, FILL_WAIT, RELAY=1, ASYNC_SUBMIT, QUEUE2, COPY_PLAIN, TEXTURE_NO_WAIT, INDIRECT_GATHER, BACK_OWN_VIEW, JOIN_PARTS, CARD_WINDOWS_MB=1024, LEVELS_ON_DEMAND, WINDOW_JUMP). Two launches, mean of the last 10 frame-log readings (~50 s on the boat) each:

  • with the loose fallback (default): 5.4 fps, GPU ~111 ms/frame. No visual glitches seen on the boat.
  • VICTORY_WAVE_LDS_LOOSE=0: 6.6 fps, GPU ~85 ms/frame. Glitches come back every 1–10 seconds: a patch of water under the boat vanishes for a moment, a shirt texture changes briefly.

Preparing (~50 ms) and copy-back (~18 ms) are the same in both. On this card the loose programs cost about 26 ms of GPU time per frame (~18 % of the frame rate).

**@⁠d0dev** on GitHub · 2026-11-26 12:12 UTC · [original](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7191700218) Tested on Windows 11, RTX 4070 Ti SUPER 16 GB (driver 616.92), Ryzen 7 5800X3D, 32 GB RAM. Clean build: `main` `ceb9e1f` + this PR only, same boat-mission save, close to the maintainer's test switches (`TEXTURE_BACK`, `HEAP_WORKER`, `FILL_WAIT`, `RELAY=1`, `ASYNC_SUBMIT`, `QUEUE2`, `COPY_PLAIN`, `TEXTURE_NO_WAIT`, `INDIRECT_GATHER`, `BACK_OWN_VIEW`, `JOIN_PARTS`, `CARD_WINDOWS_MB=1024`, `LEVELS_ON_DEMAND`, `WINDOW_JUMP`). Two launches, mean of the last 10 frame-log readings (~50 s on the boat) each: - with the loose fallback (default): **5.4 fps**, GPU ~111 ms/frame. **No visual glitches** seen on the boat. - `VICTORY_WAVE_LDS_LOOSE=0`: **6.6 fps**, GPU ~85 ms/frame. Glitches come back **every 1–10 seconds**: a patch of water under the boat vanishes for a moment, a shirt texture changes briefly. Preparing (~50 ms) and copy-back (~18 ms) are the same in both. On this card the loose programs cost about 26 ms of GPU time per frame (~18 % of the frame rate).
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 12:19 UTC · original

Thanks, that's a clear trade-off: on your 4070 Ti SUPER the fallback removes the glitches (water patch under the boat, flickering shirt texture) for ~26 ms of GPU time, and slauko saw +19 ms on a 3080 Ti, while on our 3080 the cost was a fill-ahead settle instead. Since it is likely one or two of the five recovered programs that carry most of that GPU time, I'll check which with VICTORY_SKIP_PIPELINES one at a time and post the split here; if one is both costly and invisible, it could stay refused while the rest keep the fix.

**@⁠Garu667** on GitHub · 2026-11-26 12:19 UTC · [original](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7191863624) Thanks, that's a clear trade-off: on your 4070 Ti SUPER the fallback removes the glitches (water patch under the boat, flickering shirt texture) for ~26 ms of GPU time, and slauko saw +19 ms on a 3080 Ti, while on our 3080 the cost was a fill-ahead settle instead. Since it is likely one or two of the five recovered programs that carry most of that GPU time, I'll check which with `VICTORY_SKIP_PIPELINES` one at a time and post the split here; if one is both costly and invisible, it could stay refused while the rest keep the fix.
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 12:37 UTC · original

Split as promised, RTX 3080 10 GB, ceb9e1f + this PR (+ #1002, #1279), boat mission, VICTORY_CARD_METER_PIPELINES=1, ~3 min standing: none of the five recovered programs (2cc4c197ee29e291, 2da4beb386509b77, 369cbe906ea72764, 02384a60fda6f2d0, 6b82bc7d22016cb5) shows up in the per-pipeline card-time table, whose cutoff is 0.33 ms a frame (80.4 ms over 1,230 pipelines in all). So here each costs under ~0.3 ms of card time, under ~1.6 ms together. The +19 ms (3080 Ti, vkd3d) and +26 ms (4070 Ti SUPER) look specific to those stacks or scenes; if either of you can run the same meter, the table would show which program carries it.

**@⁠Garu667** on GitHub · 2026-11-26 12:37 UTC · [original](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7192236550) Split as promised, RTX 3080 10 GB, `ceb9e1f` + this PR (+ #1002, #1279), boat mission, `VICTORY_CARD_METER_PIPELINES=1`, ~3 min standing: none of the five recovered programs (`2cc4c197ee29e291`, `2da4beb386509b77`, `369cbe906ea72764`, `02384a60fda6f2d0`, `6b82bc7d22016cb5`) shows up in the per-pipeline card-time table, whose cutoff is 0.33 ms a frame (80.4 ms over 1,230 pipelines in all). So here each costs under ~0.3 ms of card time, under ~1.6 ms together. The +19 ms (3080 Ti, vkd3d) and +26 ms (4070 Ti SUPER) look specific to those stacks or scenes; if either of you can run the same meter, the table would show which program carries it.
Author
Owner

@⁠d0dev on GitHub · 2026-11-26 14:04 UTC · original

Ran the meter as asked: clean build (ceb9e1f + this PR), RTX 4070 Ti SUPER, same boat save, VICTORY_CARD_METER=1 VICTORY_CARD_METER_PIPELINES=1 VICTORY_FRAME_LOG=1 (the frame log is needed in a release build for the tables to appear), ~3 min standing, last table of each run:

  • VICTORY_WAVE_LDS_LOOSE=0: 6.05 fps, GPU 93.6 ms; card time by pipeline 87.9 ms in 4,125 bindings
  • loose fallback on: 5.09 fps, GPU 123.9 ms; card time by pipeline 111.3 ms in 4,996 bindings

Same as on your 3080, none of the five recovered programs shows up in the table (cutoff ~0.5 ms here). Draws per frame are the same (3,923 vs 3,928), but the 44 pipelines in both tables go from 46.7 to 54.5 ms with ~14 % more bindings, and four compute pipelines appear only with the fallback on (6d7fe7745ab9c6d8 0.73 ms, c7feccae4e01e454 0.50, 915ed81ea580a276 0.47, 660814153af43185 0.47). So here the cost looks indirect: what the recovered programs produce makes the rest of the frame do more work, rather than the programs themselves being expensive. One run each, so take the split as indicative.

**@⁠d0dev** on GitHub · 2026-11-26 14:04 UTC · [original](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7194240716) Ran the meter as asked: clean build (`ceb9e1f` + this PR), RTX 4070 Ti SUPER, same boat save, `VICTORY_CARD_METER=1 VICTORY_CARD_METER_PIPELINES=1 VICTORY_FRAME_LOG=1` (the frame log is needed in a release build for the tables to appear), ~3 min standing, last table of each run: - `VICTORY_WAVE_LDS_LOOSE=0`: 6.05 fps, GPU 93.6 ms; card time by pipeline 87.9 ms in 4,125 bindings - loose fallback on: 5.09 fps, GPU 123.9 ms; card time by pipeline 111.3 ms in 4,996 bindings Same as on your 3080, none of the five recovered programs shows up in the table (cutoff ~0.5 ms here). Draws per frame are the same (3,923 vs 3,928), but the 44 pipelines in both tables go from 46.7 to 54.5 ms with ~14 % more bindings, and four compute pipelines appear only with the fallback on (`6d7fe7745ab9c6d8` 0.73 ms, `c7feccae4e01e454` 0.50, `915ed81ea580a276` 0.47, `660814153af43185` 0.47). So here the cost looks indirect: what the recovered programs produce makes the rest of the frame do more work, rather than the programs themselves being expensive. One run each, so take the split as indicative.
github-bot force-pushed github-bot/gh-1287 from 4eb3ac94d4 to cc6bde7083 2026-11-26 16:13:10 +00:00 Compare
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 16:07 UTC · original

Prologue cell check on the RTX 3080 (58de9bf vs 58de9bf + this PR, same save, standing at the cell window ~1.5 min, 2 launches with the PR):

  • without it the window is a flat dirty overlay with the yard sharp behind it; with it the glass is textured and refracts/blurs the yard, which matches the console footage of that window. Refused computes 8 → 3 (left: 5dc3b25986622949, 6f225b641c5b0708, a10179ab7eda0dc3).
  • cost in this scene: 7.7 fps → 6.7 / 7.0 (≈ -10 %), higher than the boat scene. No device loss.
  • I also tried porting codec_d's resource.rs fix from DoubleGhosty/cool_fox (f4b48ad: the descriptor/live() trace now honours the per-instruction EXEC guard, so 2da4beb386509b77 translates exactly as "without early-outs" instead of through the loose fallback). On top of this PR it made no visible difference and the same fps (6.9), so it's a correctness nicety, not needed for this window.
**@⁠Garu667** on GitHub · 2026-11-26 16:07 UTC · [original](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7197220994) Prologue cell check on the RTX 3080 (`58de9bf` vs `58de9bf` + this PR, same save, standing at the cell window ~1.5 min, 2 launches with the PR): - without it the window is a flat dirty overlay with the yard sharp behind it; with it the glass is textured and refracts/blurs the yard, which matches the console footage of that window. Refused computes 8 → 3 (left: `5dc3b25986622949`, `6f225b641c5b0708`, `a10179ab7eda0dc3`). - cost in this scene: 7.7 fps → 6.7 / 7.0 (≈ -10 %), higher than the boat scene. No device loss. - I also tried porting codec_d's resource.rs fix from DoubleGhosty/cool_fox (f4b48ad: the descriptor/`live()` trace now honours the per-instruction EXEC guard, so `2da4beb386509b77` translates exactly as "without early-outs" instead of through the loose fallback). On top of this PR it made no visible difference and the same fps (6.9), so it's a correctness nicety, not needed for this window.
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 16:11 UTC · original

Rebased onto 93db653 (cc6bde7). Heads-up: lower.rs on main is already 528,801 bytes, over the asset policy's 512 KiB, so repository_passes_policy fails there too. This PR now moves the lane analyses (lane_uniform, lane_regions, lds_meetings, lane_constant_masks) unchanged into a child module emit/lanes.rs: lower.rs drops to 519,928 bytes and cargo xtask policy passes. 222 shader tests pass.

**@⁠Garu667** on GitHub · 2026-11-26 16:11 UTC · [original](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7197316144) Rebased onto `93db653` (cc6bde7). Heads-up: `lower.rs` on main is already 528,801 bytes, over the asset policy's 512 KiB, so `repository_passes_policy` fails there too. This PR now moves the lane analyses (`lane_uniform`, `lane_regions`, `lds_meetings`, `lane_constant_masks`) unchanged into a child module `emit/lanes.rs`: `lower.rs` drops to 519,928 bytes and `cargo xtask policy` passes. 222 shader tests pass.
github-bot force-pushed github-bot/gh-1287 from cc6bde7083 to a047cb4b13 2026-11-26 16:23:38 +00:00 Compare
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 16:21 UTC · original

Change of plan: #1322 fixes the same size problem by moving lower.rs's tests out, so I took my move of the lane analyses back out of this PR to avoid a conflict with it. This PR is again only the loose-LDS change, rebased onto 93db653, 222 shader tests pass. Until #1322 is merged the size check stays red, as it is on main.

**@⁠Garu667** on GitHub · 2026-11-26 16:21 UTC · [original](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7197536540) Change of plan: #1322 fixes the same size problem by moving `lower.rs`'s tests out, so I took my move of the lane analyses back out of this PR to avoid a conflict with it. This PR is again only the loose-LDS change, rebased onto `93db653`, 222 shader tests pass. Until #1322 is merged the size check stays red, as it is on main.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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