GPU: cache parsed shader resource metadata across runs (shader-meta.bin) #2614
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!2614
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2614"
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?
@Bebrik229 on GitHub · 2026-11-25 16:52 UTC · original
Bebrik229:gpu/shader-meta-cache→main· +524 −21 · 4 files · 2 commits · openSummary
Persists each translated shader container's parsed
UsedResourcetable alongside the pipeline cache (shader-meta.bin) so warm runs avoid repeatingContainer::parseand zlibXBCHdecompression (native_programs) on every shader cache hit.crates/victory-gpu/src/shader_meta.rs:shader-meta.bin(VSM1v1 binary store keyed by the container's 32-byte BLAKE3 hash) inlibrary::use_pipeline_cache.get_or_computechecks aRwLock<MetaStore>under read lock first, drops the lock before computing on a miss, and marks the store dirty on insertion.saveshort-circuits lock-free/read-only when clean, serializes outside the store lock on dirty state, and writes atomically viashader-meta.bin.tmp-<pid>-<seq>+ rename fromlibrary::save.ResourceType(Srv,Sampler,Cbv,Uav,Other(u8)) andRootType(Constants,Descriptor,Table,ImmediateSampler,ResourceHeap,SamplerHeap,Other(u32)) variants, rejecting truncated/corrupt/trailing data.shader_cache.rsandcrates/victory-shaderare untouched, so all existing cached shader translations remain valid hits on the next launch (shader-meta.binpopulates automatically on the first run and hits from the second run onward).crates/victory-gpu/src/pipeline.rs: storesfull_hash: [u8; 32]onShader(avoiding double hashing inshader()) and resolvesusedinwith_resourcesviashader_meta::get_or_compute.Verification
cargo test -p victory-gpu --lib shader_meta -- --test-threads=1— 2 passed (encode_decode_roundtrip_and_corruption,store_persists_to_disk_and_skips_recompute)cargo test -p victory-gpu --lib pipeline -- --test-threads=1— 16 passed, 0 failedcargo clippy -p victory-gpu --lib --tests -- -D warnings— clean (0 warnings)cargo xtask policy—asset policy: 185 files ok@kotekompotek on GitHub · 2026-11-25 17:51 UTC · original
Reviewed (first half): carrying the full BLAKE3 alongside the 16-char display hash and passing it into
translate()makes the metadata cache key collision-free. The SHADERS map key is now the full hash — consistent. CI green.@Marvisak on GitHub · 2026-11-25 22:16 UTC · original
Automated triage for the maintainers.
Merges cleanly. The idea (skip
Container::parse/native_programson warm runs) is plausible, but as written the store can go stale:shader-meta.binis keyed only by the container's BLAKE3 (shader_meta::get_or_compute). The shader cache next to it keys every entry on the build fingerprint (shader_cache::key:victory_shader::SOURCE_HASHplus its own encoding), so a translator change invalidates it. Here, a fix tonative_programsor to howUsedResourceis derived would keep serving the old resource lists from disk, silently, with no way to notice except deleting the file. Please key the store (or the file header) on the same fingerprint, e.g.victory_shader::SOURCE_HASH, and drop the file when it differs.with_resourcesbefore and after). A 488-line persistent cache wants a number showing it is worth having.With the fingerprint keying and a measured gain this could be reconsidered.
Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.