GPU: a shader cache that cannot keep an entry still gives its translation #358
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!358
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/358/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?
@Dufftwt on GitHub · 2026-11-24 02:34 UTC · original
Dufftwt:fix/shader-cache-write-failure-keeps-translation→main· +32 −3 · 1 files · 1 commits · closed without mergingWhat's wrong
shader_cache::cachedgets a console shader's translation throughvictory-pipeline's cache. On a miss, the cache runs the converter (our translator) and then writes the entry: it creates the shard folder, writes a temporary file and renames it into place.If writing fails,
get_or_convertreturns an error, andcachedpasses it up with?as if the shader had failed:The translation, which worked, is thrown away.
pipeline.rsstores the shader as not translating for the rest of the run, logs "shader does not translate", and every draw or dispatch that uses it is dropped.Ways the write can fail on a user's machine:
The last one happens intermittently on Windows, so it would show up as random missing geometry in a run. The module's own documentation treats the cache as an optimisation ("an entry that does not read back is translated again"), not as something a shader depends on.
What the fix does
Translate) records that its translation worked.get_or_convertfails after a successful translation,cachedlogs a warning naming the cache error. It then leaves the cache loop and translates without the cache, the same path already used after two unreadable entries.In this rare case the shader is translated twice. I kept it that way to leave the cache interface unchanged.
How it behaves after the fix
A shader that translates is used whether or not its cache entry could be written. A warning (
shader cache entry not written, with the OS error) says the cache couldn't keep it. A shader that doesn't translate still fails with its own error.Tests
The new test
a_cache_that_cannot_keep_an_entry_still_gives_the_translation:cachedstill returns the translation;I ran
cargo test --workspaceon GitHub'swindows-latestwith Rust 1.98.1 fromrust-toolchain.toml:victory-gpuhas 44 passed (1 ignored), the other crates have 0 failed.main: it fails because the good translation comes back asErr("Cannot create a file when that file already exists. (os error 183)").--test-threads=1. With 4 threads, the shader crate's GPU tests sometimes crash on that runner (#181, #244).Not tested: a real disk-full or scanner case.
Related: #254 and #130 change
cachedtoo. #161 cleans up staging files after a failed write, but still returns the error.@jeremygold02 on GitHub · 2026-11-24 04:26 UTC · original
Tested PR #358 at head
369dc3246931ec4d0d9a1e0aaec0dae2da717d1c(state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at369dc3246931ec4d0d9a1e0aaec0dae2da717d1c.cargo test --locked -p victory-gpu a_cache_that_cannot_keep_an_entry_still_gives_the_translation— passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 44 filtered out; finished in 0.14s ); cases: shader_cache::tests::a_cache_that_cannot_keep_an_entry_still_gives_the_translation.Behavior covered: Checks an uncacheable shader-cache entry still returns the translation to the caller.
Code: crates/victory-gpu/src/shader_cache.rs
Pull request closed