Key cached shader translations by effective host wave width #35
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!35
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-35"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ryotdev on GitHub · 2026-11-24 20:42 UTC · original
ryotdev:codex/shader-cache-wave-width→main· +96 −20 · 3 files · 2 commits · openThe translator can emit different DXIL for the same input depending on the adapter’s wave width. The disk cache used the same key for both outputs. With a shared cache, a shader compiled on a 64-lane adapter could be returned on a 32-lane adapter that cannot create its pipeline.
I confirmed the distinction with a hand-built wave reduction. The two outputs validate with Microsoft’s DXIL validator and declare different required widths in PSV0. This change includes the translator’s effective wave32 setting in the cache key, bumps the converter version, and still reuses entries across adapters that choose the same lowering mode.
The regression reopens the cache four times, alternating modes. On the old key the second lookup returned the first mode’s output. With the fix each mode compiles once and subsequent lookups return the correct entry.
Verification on
90228a7plus this patch:AI-assisted. This fixes cache reuse across adapters. Our fresh-cache RTX 5070 run cannot demonstrate an in-game visual change from this patch.
@adriaespii on GitHub · 2026-11-24 21:04 UTC · original
Independent test run on commit
7545c97(AMD RDNA4):x86_64-pc-windows-msvc)cargo clippy --workspace --all-targets -- -D warnings: 0 warningscargo test --workspace: 497 passed, 0 failed, 7 ignored (victory-gpu: 111 passed, 0 failed, 1 ignored;victory-shader: 210 passed, 0 failed, 2 ignored)AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.
@arminkhaleghirod on GitHub · 2026-11-24 21:42 UTC · original
Merged onto main
90228a7and ranvictory translate --validateover the full title (26,148 programs) on Windows 11 / RTX 4080. Changes against main, by failure reason:No change: every failure count is the same as main, and no new reason appears. So no regression in translation. What this PR changes at run time isn't covered by this check.
@ericomeehan on GitHub · 2026-11-24 22:01 UTC · original
Three more inputs change the translation but aren't in the cache key. That's true on
main(4e17478), with this PR, and in #147's version of the list:VICTORY_WAVE_LOCAL, read atcrates/victory-shader/src/emit/mod.rs:338and:344.0turns the local-wave forms off,idiomrefuses the approximate ones. This runs inside the wave64-on-a-32-lane-host retry, so it changes the DXIL on the hosts this PR is about.VICTORY_STRICT_JOINS, read atcrates/victory-shader/src/emit/lower.rs:10624. It marks joins that are read only through other joins. Its comment says about 40 programs that translate today stop with it.VICTORY_MESH_OUTPUT_STRICT, read atcrates/victory-shader/src/emit/lower.rs:4021. It refuses mesh shaders whose outputs exceed the host's 32 KiB, instead of emitting them with lower maxima.crates/victory-gpu/src/shader_cache.rs:63-68keysVICTORY_WAVE_WIDE,VICTORY_WAVE_DEEP_SKIPS,VICTORY_WAVE_OWN_BITSandVICTORY_F16_NEARESTonly, and #147 keeps the same four (itsshader_cache.rs:69-72). So two runs of the same build, one with one of these set and one without, share entries. Failed translations aren't stored, so a run with a strict switch set is served the successful translation an earlier run cached without it. The comment above the list describes this case forVICTORY_WAVE_WIDE=0. The fix is three more names in that list:"VICTORY_WAVE_LOCAL", "VICTORY_STRICT_JOINS", "VICTORY_MESH_OUTPUT_STRICT",. Nothing changes for anyone who doesn't set them.This PR and #147 both change how the cache key is built in
shader_cache.rs(#147 replacesbuild()with akey(...)), so whichever merges second has to carry the other's inputs, in particular this PR's host-wave byte.Related: this PR also addresses the stale-cache explanation in #75, where a cache filled without the host's 32-lane setting serves
WaveSize(64)translations, which NVIDIA refuses. Whether that is what happened on the RTX 3070 there still depends on the empty-cache run asked for in that thread.I found all of this by reading the code; I haven't built or run it.
Written with an AI assistant (Claude).
@ryotdev on GitHub · 2026-11-25 03:20 UTC · original
@ericomeehan I reproduced the missing cache inputs in separate Windows processes and updated this branch in
7eebb263a6. The cache now distinguishes the default local-wave behavior fromVICTORY_WAVE_LOCAL=0andidiom, and includes both strict switches you identified.One additional case matters for integration with #544. The translator checks whether each strict variable exists, so even an empty value enables it. Adding their names to the old serialization still produced the same key for strictly enabled (empty) and unset. The new regression failed on that negative control and on the previous #35 head. With the fix the full Windows GPU suite on WARP passed 119 tests, with one ignored. AI-assisted.
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.Merge
Merge the changes and update on Forgejo.