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

Open
Garu667 wants to merge 1 commit from upstream-pr/1287 into main
Garu667 commented 2026-11-26 10:47:39 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Garu667 on 2026-11-26T10:47:39Z.


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

<!-- greyfinch-sync:fxceless/victory-fork:issue:6624967149 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1287). Originally posted by [Garu667](https://github.com/Garu667) on 2026-11-26T10:47:39Z. --- 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)
slauko commented 2026-11-26 12:07:19 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by slauko on 2026-11-26T11:36:30Z.


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".

<!-- greyfinch-sync:fxceless/victory-fork:comment:7190944007 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7190944007). Originally posted by [slauko](https://github.com/slauko) on 2026-11-26T11:36:30Z. --- 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".
Garu667 commented 2026-11-26 12:07:20 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Garu667 on 2026-11-26T11:45:53Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7191136476 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7191136476). Originally posted by [Garu667](https://github.com/Garu667) on 2026-11-26T11:45:53Z. --- 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.
d0dev commented 2026-11-26 13:05:52 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by d0dev on 2026-11-26T12:12:17Z.


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).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7191700218 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7191700218). Originally posted by [d0dev](https://github.com/d0dev) on 2026-11-26T12:12:17Z. --- 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).
Garu667 commented 2026-11-26 13:05:53 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Garu667 on 2026-11-26T12:19:52Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7191863624 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7191863624). Originally posted by [Garu667](https://github.com/Garu667) on 2026-11-26T12:19:52Z. --- 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 commented 2026-11-26 13:05:53 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Garu667 on 2026-11-26T12:37:08Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7192236550 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7192236550). Originally posted by [Garu667](https://github.com/Garu667) on 2026-11-26T12:37:08Z. --- 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.
d0dev commented 2026-11-26 15:04:06 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by d0dev on 2026-11-26T14:04:32Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7194240716 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7194240716). Originally posted by [d0dev](https://github.com/d0dev) on 2026-11-26T14:04:32Z. --- 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.
Garu667 commented 2026-11-26 16:07:49 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Garu667 on 2026-11-26T16:07:49Z.


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.
<!-- greyfinch-sync:fxceless/victory-fork:comment:7197220994 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7197220994). Originally posted by [Garu667](https://github.com/Garu667) on 2026-11-26T16:07:49Z. --- 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 commented 2026-11-26 16:11:57 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Garu667 on 2026-11-26T16:11:57Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7197316144 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7197316144). Originally posted by [Garu667](https://github.com/Garu667) on 2026-11-26T16:11:57Z. --- 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 commented 2026-11-26 16:21:30 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Garu667 on 2026-11-26T16:21:30Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7197536540 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1287#issuecomment-7197536540). Originally posted by [Garu667](https://github.com/Garu667) on 2026-11-26T16:21:30Z. --- 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 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/1287:upstream-pr/1287'
git switch 'upstream-pr/1287'

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/1287'
git switch 'upstream-pr/1287'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1287'
git switch 'upstream-pr/1287'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1287'
git switch 'main'
git merge --squash 'upstream-pr/1287'
git switch 'main'
git merge --ff-only 'upstream-pr/1287'
git switch 'main'
git merge 'upstream-pr/1287'
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
fxceless/victory-fork!1284
No description provided.