Skip to content

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

Open
misaka-20002 wants to merge 6 commits into
trustno1-coder:mainfrom
misaka-20002:upstream-fixes
Open

misaka-20002 wants to merge 6 commits into
trustno1-coder:mainfrom
misaka-20002:upstream-fixes

Conversation

@misaka-20002

Copy link
Copy Markdown

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 (shader: static Wave32 LDS alias and lane-private hazard analysis #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.

  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: GPU: shader cache keyed by LOOPS_WAVE and LDS_FIRST_INIT; F8/F7 let texture copies go by hand #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 queue: flights that may write pages land before a page-mapping copy remaps them #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 (Shaders: four more 64-thread LDS programs taken wave-wide on 32-lane hosts #101's shape). Widened, they translate.

How it was tested

Checked for overlap

🤖 Generated with Claude Code

misaka-20002 and others added 6 commits November 28, 2026 14:41
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 <noreply@anthropic.com>
…tno1-coder#631)

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 trustno1-coder#631; not measured on its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nostics)

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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
…osts

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 <noreply@anthropic.com>
…osts (VICTORY_LDS_WRITE_ONLY_OK=0 turns it off)

075785e (trustno1-coder#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 <noreply@anthropic.com>
@github-actions github-actions Bot added NVIDIA pr-fix Pull request: fixes a bug shaders Shader translation, preload or pipeline building labels Nov 28, 2026
@github-actions github-actions Bot changed the title [pr-fix][shaders][NVIDIA] Wave64 programs on 32-lane hosts again, the shader cache key's missing switches, a relay remap wait, list-thread sampling Wave64 programs on 32-lane hosts again, the shader cache key's missing switches, a relay remap wait, list-thread sampling Nov 28, 2026
@kibagami-nc

Copy link
Copy Markdown
Contributor

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.

@unueberlegt

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NVIDIA pr-fix Pull request: fixes a bug shaders Shader translation, preload or pipeline building

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants