Shader cache: a cache that cannot write still translates #389
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!389
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/389/head"
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?
@Kaairim on GitHub · 2026-11-24 02:52 UTC · original
Kaairim:shader-cache-write-failure→main· +75 −7 · 1 files · 1 commits · closed without mergingWhat
When the shader cache cannot store an entry,
host_shadernow returns the translation it just made instead of the cache's error. A warning is logged once. A translation that itself fails still fails, once, with the same message as before.Why
Cache::get_or_converttranslates, then creates the entry's folder, writes a temporary file and renames it. If any of those three fail (a full disk, a cache folder we may not write, a file held by a scanner), it returns an error andcachedpassed it on with?: the translation had been made and was dropped, so the shader – and the pipeline and draws using it – were lost for the whole run, every time.The converter now keeps its last output (and whether the translation itself failed), so
cachedcan tell the two errors apart and use the output when only the cache failed.Tested
Windows 11 (build 26300), Rust 1.98.1 (pinned toolchain), x86_64-pc-windows-msvc:
shader_cache::tests::a_cache_that_cannot_write_still_translates: a file where the cache folder was, so no entry can be written. Without the fix the first assert fails (Err); with it the shader comes back from the one translation made, and a failing translation is still an error, run once.cargo test --workspace --no-fail-fast: 265 passed, 0 failed, 4 ignored (main: 264 / 0 / 4).cargo clippy --workspace --all-targets: the same two warnings as main, none in this file.rustfmt --check --edition 2024 crates/victory-gpu/src/shader_cache.rs: clean.cargo xtask policy: ok.Not run: the title (I have no copy of it). The changed path only runs when the cache cannot write.
Improvements by William "kaairim" Deivid (wdcore). AI-assisted: Claude Code with Claude Opus 5.5 wrote the change, the test and this description; a second Claude Opus 5.5 agent reviewed the diff.
🤖 Generated with Claude Code
@jeremygold02 on GitHub · 2026-11-24 04:25 UTC · original
Thanks @Kaairim for preserving translation when cache writes fail. I tested head
c84e0e60bfc13de5e603c445ebaaf827690ae6cdwith:Result: 1 passed, 0 failed (44 filtered out). The test exercises shader translation with a cache configured so writes are unavailable, checking that the cache failure does not prevent translation. It does not exercise a game launch or persistent cache across processes.
@andrewpozdnakov7-jpg on GitHub · 2026-11-24 11:54 UTC · original
I checked the shader-cache pair from #813 at a later failure point than the existing shard-folder tests. In a temporary cache, the entry path was a directory. The shader translated, the temporary file could be written, and renaming it into place failed.
ffe310e369dc32c84e0e6All three cleaned up the temporary entry. After removing the obstruction, the next call wrote a valid entry and the following call hit it.
The incremental change below keeps the original
HostShaderin #389's converter. That removes the encoded-buffer clone and returns the original on a fresh miss, whether publication succeeded or failed. A cache hit still decodes the stored entry. The tests confirmed the original translator output was retained in both miss cases and that a subsequent hit did not invoke the translator.AI-assisted. Verified on Windows with synthetic cache entries.
Incremental patch on
c84e0e6Pull request closed