Wave64 programs on 32-lane hosts again, the shader cache key's missing switches, a relay remap wait, list-thread sampling #1575

Open
github-bot wants to merge 6 commits from github-bot/gh-1575 into main AGit
Owner

@⁠misaka-20002 on GitHub · 2026-11-28 21:52 UTC · original
misaka-20002:upstream-fixes → main · +276 −37 · 9 files · 6 commits · open

What it changes

Six commits, independent of each other: each builds on its own, so any can be taken without the others.

  1. Shaders: the LDS write-only shortcut on by default again on 32-lane hosts (VICTORY_LDS_WRITE_ONLY_OK=0 turns it off). 075785e (#43) made the legacy shortcut for write-only lane-branch regions opt-in. Since then, on a 32-lane host (NVIDIA), 19 wave64 compute programs no longer translate and their dispatches are dropped:

    • the tree culling passes (InstanceCulling:CS_Tree_*, six);
    • the indirect lighting gathers and screen-probe traces (six);
    • CS_VarianceFilterAlpha, CS_TraceShadowRays_Fullres, CS_ProjDecalReduceClassification_Scalarized and CS_Classification_Water;
    • three kernels in XboxBvhBuilder.dll.

    The strict analysis itself is unchanged. It still decides on 64-lane hosts and with =0. Its four tests turn the shortcut off for themselves.

    • Overlap: #1450 retries some known kernels with a scoped write-only policy. Measured the same way (below), it brings back 5 of these 19 programs. The other four tree passes, all six indirect lighting programs, the full-res shadow rays and the three BVH builder kernels stay refused. #1504 takes the same programs another way (exact forms), in a much larger change.
  2. Shader cache: the translator's switches that were not in its key. Six switches change what the translator makes but are not in the key, so a warm cache serves translations made without them: VICTORY_HDR_CLAMP, VICTORY_LDS_FIRST_INIT, VICTORY_LDS_INIT_HOIST, VICTORY_LOOPS_WAVE, VICTORY_SAMPLED_MARKS and VICTORY_DEFRAG. For example, VICTORY_HDR_CLAMP=0 on a warmed cache still clamps.

    • VICTORY_BVH_MISS is now keyed by whether it is on, as VICTORY_BVH_NO_HIT already is. VICTORY_BVH_BUILDER=1 (the F1 menu's ray tracing) turns it off, and before this both runs shared one key.
    • The list is now a constant. A test checks it against every switch the translator's source names (build.rs's list, now emit::SWITCHES), so a new switch fails the test until someone decides whether it is keyed.
    • Every key changes once, so the first run translates again.
    • Overlap: #1437 adds two of these (LOOPS_WAVE, LDS_FIRST_INIT) together with unrelated F7/F8 changes.
  3. Relay: a remap waits only for the landings that touch its range (follow-up to #631). In relay mode land_before_remap also waited while any landing was in hand. In relay mode line.written keeps the ranges of the flights being landed until relay_land is done, so waiting until no written range touches the remapped one is enough. Without relay it waits as before. Found in review; not measured on its own.

  4. Timeline: VICTORY_TIMELINE_LISTS=1 samples the list threads too (diagnostics builds only).

  5. Timeline: real call stacks for the list threads (diagnostics builds only). The sampler pauses a list thread only long enough to copy its registers and up to 64 KB of its stack. Once the thread runs on, it walks the copy with RtlLookupFunctionEntry and RtlVirtualUnwind, because Windows' unwinding takes locks the paused thread may hold. With this, time in the driver is charged to the call of ours that led there. On an RTX 5080 it showed that about 22–30% of the list threads' driver time is CreateShaderResourceView for buffer views.

  6. Shaders: two more 64-thread LDS programs taken wave-wide on 32-lane hosts. GpuParticleEmit:CS_Emit_Dynamic_Model (18d957e62926ed3e) and CS_Emit_Dynamic_Model_AttachMesh (407eca669212d400) join the scene_kernel digests (#101's shape). Widened, they translate.

How it was tested

  • GPU and profile: RTX 5080 (32-lane), Ryzen 7 9800X3D, GTA VI 1.0.2.1, Series X/S profiles at 1440p, DLSS. Items 1 and 6 were played on a local branch before 075785e reached it; those programs translated and drew right in play.

  • Before/after, victory translate --list <game> with VICTORY_HOST_WAVE=32 VICTORY_VIEW_LIMIT=737855 (every shader of the game, about 52,000 lines):

    Build "no wave32 lowering" refused in all
    main (77df871) 37 237
    main + #1450 32 232
    main + item 1 (VICTORY_LDS_WRITE_ONLY_OK=1 on main) 18 218
    main + item 6 35 235

    Items 1 and 6 were measured separately; together they should give 16.

  • For shader changes, wave sizes tested: 32 lanes (census above); the 64-lane path is unchanged (the shortcut is off unless the host's widest wave is 32).

  • cargo test: the victory-gpu shader_cache tests pass locally, including the new one. The workspace's clippy and tests are left to this PR's CI run. Main's clippy currently stops at two errors in lower.rs, before the tests; #1517 fixes them, so this PR's CI will be red there until #1517 (or #1527) is in.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1450, #1504, #733 (item 1); #1437, #1425 (item 2); #631 (item 3). Clippy and the size policy on main are left to #1517, #1527, #1493 and #1460.

🤖 Generated with Claude Code

**@⁠misaka-20002** on GitHub · 2026-11-28 21:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1575) `misaka-20002:upstream-fixes` → `main` · +276 −37 · 9 files · 6 commits · open ## What it changes Six commits, independent of each other: each builds on its own, so any can be taken without the others. 1. **Shaders: the LDS write-only shortcut on by default again on 32-lane hosts** (`VICTORY_LDS_WRITE_ONLY_OK=0` turns it off). 075785e (#43) made the legacy shortcut for write-only lane-branch regions opt-in. Since then, on a 32-lane host (NVIDIA), 19 wave64 compute programs no longer translate and their dispatches are dropped: - the tree culling passes (`InstanceCulling:CS_Tree_*`, six); - the indirect lighting gathers and screen-probe traces (six); - `CS_VarianceFilterAlpha`, `CS_TraceShadowRays_Fullres`, `CS_ProjDecalReduceClassification_Scalarized` and `CS_Classification_Water`; - three kernels in `XboxBvhBuilder.dll`. The strict analysis itself is unchanged. It still decides on 64-lane hosts and with `=0`. Its four tests turn the shortcut off for themselves. - Overlap: #1450 retries some known kernels with a scoped write-only policy. Measured the same way (below), it brings back 5 of these 19 programs. The other four tree passes, all six indirect lighting programs, the full-res shadow rays and the three BVH builder kernels stay refused. #1504 takes the same programs another way (exact forms), in a much larger change. 2. **Shader cache: the translator's switches that were not in its key.** Six switches change what the translator makes but are not in the key, so a warm cache serves translations made without them: `VICTORY_HDR_CLAMP`, `VICTORY_LDS_FIRST_INIT`, `VICTORY_LDS_INIT_HOIST`, `VICTORY_LOOPS_WAVE`, `VICTORY_SAMPLED_MARKS` and `VICTORY_DEFRAG`. For example, `VICTORY_HDR_CLAMP=0` on a warmed cache still clamps. - `VICTORY_BVH_MISS` is now keyed by whether it is on, as `VICTORY_BVH_NO_HIT` already is. `VICTORY_BVH_BUILDER=1` (the F1 menu's ray tracing) turns it off, and before this both runs shared one key. - The list is now a constant. A test checks it against every switch the translator's source names (`build.rs`'s list, now `emit::SWITCHES`), so a new switch fails the test until someone decides whether it is keyed. - Every key changes once, so the first run translates again. - Overlap: #1437 adds two of these (`LOOPS_WAVE`, `LDS_FIRST_INIT`) together with unrelated F7/F8 changes. 3. **Relay: a remap waits only for the landings that touch its range** (follow-up to #631). In relay mode `land_before_remap` also waited while any landing was in hand. In relay mode `line.written` keeps the ranges of the flights being landed until `relay_land` is done, so waiting until no written range touches the remapped one is enough. Without relay it waits as before. Found in review; not measured on its own. 4. **Timeline: `VICTORY_TIMELINE_LISTS=1` samples the list threads too** (diagnostics builds only). 5. **Timeline: real call stacks for the list threads** (diagnostics builds only). The sampler pauses a list thread only long enough to copy its registers and up to 64 KB of its stack. Once the thread runs on, it walks the copy with `RtlLookupFunctionEntry` and `RtlVirtualUnwind`, because Windows' unwinding takes locks the paused thread may hold. With this, time in the driver is charged to the call of ours that led there. On an RTX 5080 it showed that about 22–30% of the list threads' driver time is `CreateShaderResourceView` for buffer views. 6. **Shaders: two more 64-thread LDS programs taken wave-wide on 32-lane hosts.** `GpuParticleEmit:CS_Emit_Dynamic_Model` (`18d957e62926ed3e`) and `CS_Emit_Dynamic_Model_AttachMesh` (`407eca669212d400`) join the `scene_kernel` digests (#101's shape). Widened, they translate. ## How it was tested - GPU and profile: RTX 5080 (32-lane), Ryzen 7 9800X3D, GTA VI 1.0.2.1, Series X/S profiles at 1440p, DLSS. Items 1 and 6 were played on a local branch before 075785e reached it; those programs translated and drew right in play. - Before/after, `victory translate --list <game> ` with `VICTORY_HOST_WAVE=32 VICTORY_VIEW_LIMIT=737855` (every shader of the game, about 52,000 lines): | Build | "no wave32 lowering" | refused in all | |---|---|---| | main (77df871) | 37 | 237 | | main + #1450 | 32 | 232 | | main + item 1 (`VICTORY_LDS_WRITE_ONLY_OK=1` on main) | 18 | 218 | | main + item 6 | 35 | 235 | Items 1 and 6 were measured separately; together they should give 16. - For shader changes, wave sizes tested: 32 lanes (census above); the 64-lane path is unchanged (the shortcut is off unless the host's widest wave is 32). - `cargo test`: the `victory-gpu` `shader_cache` tests pass locally, including the new one. The workspace's clippy and tests are left to this PR's CI run. Main's clippy currently stops at two errors in `lower.rs`, before the tests; #1517 fixes them, so this PR's CI will be red there until #1517 (or #1527) is in. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1450, #1504, #733 (item 1); #1437, #1425 (item 2); #631 (item 3). Clippy and the size policy on main are left to #1517, #1527, #1493 and #1460. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Six switches the translator reads change what it makes but were not in
the shader cache key, so a warm cache served the translations made
without them to a run that set them (and the reverse): VICTORY_HDR_CLAMP,
VICTORY_LDS_FIRST_INIT, VICTORY_LDS_INIT_HOIST, VICTORY_LOOPS_WAVE,
VICTORY_SAMPLED_MARKS and VICTORY_DEFRAG. `VICTORY_HDR_CLAMP=0` on a
warmed cache still clamped, for one.

VICTORY_BVH_MISS is keyed by whether it is on, as VICTORY_BVH_NO_HIT is:
VICTORY_BVH_BUILDER=1 (the F1 menu's ray tracing) turns it off, and a run
with the builder on was served the misses of a run with it off.

The list is a constant (KEYED), and a test checks every switch the
translator's source names (build.rs, now emit::SWITCHES) against it, the
switches keyed in other ways, and those that change no translation
(tests, reports, the validator). A new switch fails the test until it is
put in one of the three.

Every cache key changes once: shaders are translated again on the first
run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
In relay mode land_before_remap waited while any landing was in hand
(line.settling), so a remap of title memory no landing writes still put
the title's mapping thread behind unrelated work. With relay, line.written
stays as it was until the landing is done (relay_land works it out anew
only then, from the flights still in the air), so the flights being landed
are still in it: waiting until no range of `written` touches the remapped
one is enough. Without relay, settling is still waited for as before.

Found in review of #631; not measured on its own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The timeline's sampler looked only at the title's submitting threads. Each
thread that translates lists now notes itself as it starts, and with the
switch the sampler pauses those as well, so a recording shows which of our
functions the list threads spend their time in. Diagnostics builds only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With VICTORY_TIMELINE_LISTS=1 the sampler copies up to 64 KB of a paused
thread's stack with its registers, lets it run on, and walks the copy with
RtlLookupFunctionEntry and RtlVirtualUnwind (Windows' unwinding takes locks
the paused thread may hold, so it is not done while it is paused). The
samples' stacks are then return addresses, so time in the driver can be put
on the call of ours that led there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
407eca669212d400 and 18d957e62926ed3e were refused on an RTX 5080 run of
1.0.2.1 (Series X, 1440p, DLSS); widened they translate (2 and 5 branches
taken wave-wide). Added to scene_kernel by digest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
075785e (#43, static LDS alias analysis) made the legacy shortcut for
write-only lane-branch regions opt-in. On a 32-lane host (NVIDIA) 19 wave64
compute programs of the game then no longer translate and their dispatches
are dropped: the tree culling passes (InstanceCulling:CS_Tree_*, six), the
indirect lighting gathers and screen-probe traces (six),
indirect_light_probes:CS_VarianceFilterAlpha, shadowmask:
CS_TraceShadowRays_Fullres, vfx_proj_decal_vbuffer:
CS_ProjDecalReduceClassification_Scalarized, water_shading:
CS_Classification_Water, and three kernels of XboxBvhBuilder.dll. They
translated with the shortcut before 075785e.

`victory translate --list` of 1.0.2.1 with VICTORY_HOST_WAVE=32
VICTORY_VIEW_LIMIT=737855: main refuses 37 programs with "no wave32
lowering for this wave64 program"; with this, 18.

The strict analysis is unchanged and still decides on 64-lane hosts and
with VICTORY_LDS_WRITE_ONLY_OK=0; the regions it can prove are taken as
before. The tests of the strict analysis turn the shortcut off for
themselves (lds::strict_for_test).

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

@⁠kibagami-nc on GitHub · 2026-11-28 21:59 UTC · original

A note on commit 2 (the shader cache key), so only one of the two goes in: it overlaps #807. #807 has been open since 2026-11-28 morning, and was rebuilt on 923e38c today. It keys the same six switches (HDR_CLAMP, LDS_FIRST_INIT, LDS_INIT_HOIST, LOOPS_WAVE, SAMPLED_MARKS, DEFRAG), the list is a constant there too, and it has the same test against emit::SWITCHES.

Your VICTORY_BVH_MISS part (keyed by whether it's on, with VICTORY_BVH_BUILDER=1 turning it off) isn't in #807. If the maintainer takes #807, that piece could stay here as its own commit.

On commit 1: #1590 takes the write-only shortcut as a last try instead of turning it on for every program. Your 19-program measurement is the confirmation #1435 needed, thanks.

**@⁠kibagami-nc** on GitHub · 2026-11-28 21:59 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1575#issuecomment-7246418326) A note on commit 2 (the shader cache key), so only one of the two goes in: it overlaps #807. #807 has been open since 2026-11-28 morning, and was rebuilt on 923e38c today. It keys the same six switches (`HDR_CLAMP`, `LDS_FIRST_INIT`, `LDS_INIT_HOIST`, `LOOPS_WAVE`, `SAMPLED_MARKS`, `DEFRAG`), the list is a constant there too, and it has the same test against `emit::SWITCHES`. Your `VICTORY_BVH_MISS` part (keyed by whether it's on, with `VICTORY_BVH_BUILDER=1` turning it off) isn't in #807. If the maintainer takes #807, that piece could stay here as its own commit. On commit 1: #1590 takes the write-only shortcut as a last try instead of turning it on for every program. Your 19-program measurement is the confirmation #1435 needed, thanks.
Author
Owner

@⁠unueberlegt on GitHub · 2026-11-28 22:37 UTC · original

Tested — it works, with an independent bisect data point and one finding from the first cold start.

Setup: GeForce RTX 5070 12 GB, 31 GB RAM, Windows 11 26300, dump of the title v1.0.2.1, Series X profile.

Bisect, independent of #1435's: from #1516's own two logs (the broken run refuses 13 wave64 compute programs, the release 3) I took the new hashes and used victory translate --list over the named containers as a bisect criterion (good v2026.11.28.03, bad HEAD). It lands on 075785e — the same commit your first commit flips the default of. The seven containers I checked are exactly the four CS_Tree_BatchCull_*, CS_VarianceFilterAlpha, CS_ProjDecalReduceClassification_Scalarized and CS_Classification_Water; the sweep over the whole dump also finds the two XboxBvhBuilder.dll kernels refusing, so your 19-program list matches what I see.

In the game: since your commit 1 is semantically identical to the change I had built and tested independently (the same default flip, VICTORY_LDS_WRITE_ONLY_OK=0 as the strict mode), the numbers below are from that build. After victory preload (all shaders + 2,614 pipelines), the game loads into the world. Trees and bushes along the road stand from a distance — walking past them, nothing pops in where the broken build showed nothing until touched. The log reads 1 wave64 refusal for the whole session (6b82bc7d22016cb5, the CS_CollectTriangles_Meshlets baseline failer that also refuses on the release), down from 13; frame lines in the world read dropped 172–190 without a host pipeline at 1,500–2,400 draws/frame, 20–22 fps.

First cold start, separate finding (not about this change): without any warming, the title killed itself ~60 s into the first load with its own watchdog (0xc0000005 at +0x23cf683 — the signature #1484 reports on Proton) while commit headroom read 452 MiB on this 31 GB machine and the card sat 1–2 % busy with "nothing of ours queued". The same start after victory preload loads and plays. With every translator change invalidating the cache, a first start without warming may keep hitting this on mid-RAM machines — maybe worth automating the preload there.

**@⁠unueberlegt** on GitHub · 2026-11-28 22:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1575#issuecomment-7246870260) Tested — **it works**, with an independent bisect data point and one finding from the first cold start. Setup: GeForce RTX 5070 12 GB, 31 GB RAM, Windows 11 26300, dump of the title v1.0.2.1, Series X profile. **Bisect, independent of #1435's:** from #1516's own two logs (the broken run refuses 13 wave64 compute programs, the release 3) I took the new hashes and used `victory translate --list` over the named containers as a bisect criterion (good `v2026.11.28.03`, bad HEAD). It lands on `075785e` — the same commit your first commit flips the default of. The seven containers I checked are exactly the four `CS_Tree_BatchCull_*`, `CS_VarianceFilterAlpha`, `CS_ProjDecalReduceClassification_Scalarized` and `CS_Classification_Water`; the sweep over the whole dump also finds the two `XboxBvhBuilder.dll` kernels refusing, so your 19-program list matches what I see. **In the game:** since your commit 1 is semantically identical to the change I had built and tested independently (the same default flip, `VICTORY_LDS_WRITE_ONLY_OK=0` as the strict mode), the numbers below are from that build. After `victory preload` (all shaders + 2,614 pipelines), the game loads into the world. Trees and bushes along the road **stand from a distance** — walking past them, nothing pops in where the broken build showed nothing until touched. The log reads **1** wave64 refusal for the whole session (`6b82bc7d22016cb5`, the `CS_CollectTriangles_Meshlets` baseline failer that also refuses on the release), down from 13; frame lines in the world read `dropped 172–190 without a host pipeline` at 1,500–2,400 draws/frame, 20–22 fps. **First cold start, separate finding (not about this change):** without any warming, the title killed itself ~60 s into the first load with its own watchdog (`0xc0000005` at `+0x23cf683` — the signature #1484 reports on Proton) while commit headroom read 452 MiB on this 31 GB machine and the card sat 1–2 % busy with "nothing of ours queued". The same start after `victory preload` loads and plays. With every translator change invalidating the cache, a first start without warming may keep hitting this on mid-RAM machines — maybe worth automating the preload there.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/shader_cache.rs
  • crates/victory-shader/src/emit/intersect.rs
  • crates/victory-shader/src/emit/lds.rs
  • crates/victory-shader/src/emit/mod.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/1575/head:github-bot/gh-1575'
git switch 'github-bot/gh-1575'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1575'
git switch 'github-bot/gh-1575'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1575'
git switch 'github-bot/gh-1575'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1575'
git switch 'main'
git merge --squash 'github-bot/gh-1575'
git switch 'main'
git merge --ff-only 'github-bot/gh-1575'
git switch 'main'
git merge 'github-bot/gh-1575'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!1575
No description provided.