Shader cache keyed by the translator (survives rebuilds), missing switches in the key, and a warm-up: translate --cache #544

Closed
github-bot wants to merge 1 commit from gh-pr/544/head into gh-pr/544/base
Owner

@⁠justrealyme on GitHub · 2026-11-25 02:04 UTC · original
justrealyme:pr-shader-cache-key → main · +190 −8 · 8 files · 1 commits · closed without merging

What

1. The shader cache keys on the translator, not the executable. shader_cache::build() hashed the whole victory.exe, so every rebuild, even one that leaves the translator alone, and every switch between the release and diagnostics builds started with an empty cache. The first run after that shows black screens and dropped draws while thousands of shaders translate. The key is now a hash of the translator's own sources (victory-shader's build script, taken from upstream VIctory c47b529 by Marvis, credited in the commit), plus the host settings and switches a translation depends on.

2. Three translation switches were missing from the key. VICTORY_WAVE_LOCAL, VICTORY_STRICT_JOINS and VICTORY_MESH_OUTPUT_STRICT change the translation but weren't hashed, so a run with one of them could be served translations made without it. They're in the key now, and so are the host's widest wave and capped view heap (set_host_max_wave, set_view_heap_limit), which the exe hash didn't cover either.

3. victory translate --cache <game dir>: a warm-up that translates every container into the shader cache run reads, through the same path a run takes (shader_cache::warm: the host device is created and the view heap cap probed first, since the translation and its key depend on them). Run it once after a translator change, with the same VICTORY_* switches you play with.

Checked

  • RTX 5070 Ti, driver 621.40, Windows 11, on this repo's code (the same change sits in my working copy, where I've been running it):
    • the warm-up translated 25,648 shaders in about 7 minutes;
    • a game run straight after took 2,378 shaders from the cache and translated none (shaders from the cache and translated so far hits=2378 misses=0), and reached the world sooner;
    • after rebuilds that didn't touch the translator, later runs kept hitting the cache (2,560 hits, 0 translated).
  • On this branch (on top of c96b4f2): translate --cache on the builder DLL twice into an empty cache: 49 translated now, then 49 were in the cache, 0 translated now.
  • cargo test --workspace: 505 passed. cargo clippy --workspace --all-targets --all-features -- -D warnings clean. Without --all-features, clippy stops on placed_filler_twins being unused (victory-gpu/src/resource.rs), which is already the case on main; this branch doesn't touch that file.

AI-assisted (Claude Code). No game data in the change or here.

🤖 Generated with Claude Code

**@⁠justrealyme** on GitHub · 2026-11-25 02:04 UTC · [original](https://github.com/fxceless/victory-fork/pull/544) `justrealyme:pr-shader-cache-key` → `main` · +190 −8 · 8 files · 1 commits · closed without merging ## What **1. The shader cache keys on the translator, not the executable.** `shader_cache::build()` hashed the whole `victory.exe`, so every rebuild, even one that leaves the translator alone, and every switch between the release and diagnostics builds started with an empty cache. The first run after that shows black screens and dropped draws while thousands of shaders translate. The key is now a hash of the translator's own sources (`victory-shader`'s build script, taken from upstream VIctory `c47b529` by Marvis, credited in the commit), plus the host settings and switches a translation depends on. **2. Three translation switches were missing from the key.** `VICTORY_WAVE_LOCAL`, `VICTORY_STRICT_JOINS` and `VICTORY_MESH_OUTPUT_STRICT` change the translation but weren't hashed, so a run with one of them could be served translations made without it. They're in the key now, and so are the host's widest wave and capped view heap (`set_host_max_wave`, `set_view_heap_limit`), which the exe hash didn't cover either. **3. `victory translate --cache <game dir>`**: a warm-up that translates every container into the shader cache `run` reads, through the same path a run takes (`shader_cache::warm`: the host device is created and the view heap cap probed first, since the translation and its key depend on them). Run it once after a translator change, with the same `VICTORY_*` switches you play with. ## Checked - RTX 5070 Ti, driver 621.40, Windows 11, on this repo's code (the same change sits in my working copy, where I've been running it): - the warm-up translated 25,648 shaders in about 7 minutes; - a game run straight after took **2,378 shaders from the cache and translated none** (`shaders from the cache and translated so far hits=2378 misses=0`), and reached the world sooner; - after rebuilds that didn't touch the translator, later runs kept hitting the cache (2,560 hits, 0 translated). - On this branch (on top of `c96b4f2`): `translate --cache` on the builder DLL twice into an empty cache: `49 translated now`, then `49 were in the cache, 0 translated now`. - `cargo test --workspace`: 505 passed. `cargo clippy --workspace --all-targets --all-features -- -D warnings` clean. Without `--all-features`, clippy stops on `placed_filler_twins` being unused (`victory-gpu/src/resource.rs`), which is already the case on `main`; this branch doesn't touch that file. AI-assisted (Claude Code). No game data in the change or here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The shader cache keyed on the BLAKE3 of the whole executable, so every
rebuild (even one that left the translator alone) and every switch
between the release and diagnostics builds started with an empty cache:
the first run then showed black screens while thousands of shaders
translated. Now the key is a hash of the translator's own sources
(victory-shader's build script, from upstream VIctory c47b529 by Marvis)
plus the host settings and switches a translation depends on. The host's
widest wave and capped view heap, and VICTORY_WAVE_LOCAL,
VICTORY_STRICT_JOINS and VICTORY_MESH_OUTPUT_STRICT, are now part of the
key too; before, a run with one of those switches could be served
translations made without it.

`victory translate --cache <game dir>` translates every container into
that cache through the same path a run takes (host device created and
view heap cap probed first), so a run finds them all.

Tested on an RTX 5070 Ti (driver 621.40): the warm-up translates 25,648
shaders in about 7 minutes; the 31 shaders a run of an earlier build had
cached were found by the warm-up (the cache survived the rebuild); the
next run into the world took 2,378 shaders from the cache and translated
none (358 ms/frame with the speed switches, no device removal). Clippy
clean in both configurations, cargo test --workspace: 496 passed,
asset policy ok.

Co-Authored-By: Marvis <[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 03:45:55 +00:00
github-bot closed this pull request 2026-11-26 03:45:55 +00:00
Author
Owner

@⁠justrealyme on GitHub · 2026-11-25 08:14 UTC · original

Closing this: 8dd30ab keys the cache on translation_fingerprint() (the translator's source hash plus every switch it reads) and adds translate --warm, which covers what this PR did and more. I've merged 8dd30ab into my fork instead.

AI-assisted (Claude Code).

**@⁠justrealyme** on GitHub · 2026-11-25 08:14 UTC · [original](https://github.com/fxceless/victory-fork/pull/544#issuecomment-7156784184) Closing this: 8dd30ab keys the cache on `translation_fingerprint()` (the translator's source hash plus every switch it reads) and adds `translate --warm`, which covers what this PR did and more. I've merged 8dd30ab into my fork instead. AI-assisted (Claude Code).
Author
Owner

@⁠Headache3318 on GitHub · 2026-11-25 08:32 UTC · original

Independent verification: PR #544 merges cleanly onto main (fast-forward). Build: success (17.7s). Tests: fail to compile on Linux host due to Windows-specific code paths gated by #[cfg(windows)] (victory-gpu host module and host_resource() not found). Environment/target mismatch rather than PR regression. Machine: Arch Linux, kernel 7.3.5-arch1-1, 3x RTX 4090 driver 620.73.04, Proton, AI-assisted.

**@⁠Headache3318** on GitHub · 2026-11-25 08:32 UTC · [original](https://github.com/fxceless/victory-fork/pull/544#issuecomment-7157162139) Independent verification: PR #544 merges cleanly onto main (fast-forward). Build: success (17.7s). Tests: fail to compile on Linux host due to Windows-specific code paths gated by #[cfg(windows)] (victory-gpu host module and host_resource() not found). Environment/target mismatch rather than PR regression. Machine: Arch Linux, kernel 7.3.5-arch1-1, 3x RTX 4090 driver 620.73.04, Proton, AI-assisted.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.