GPU: cache parsed shader resource metadata across runs (shader-meta.bin) #2612
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by Bebrik229 on 2026-11-25T16:52:54Z.
Summary
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 okImported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T16:54:15Z.
Review: CHANGES_REQUESTED
TMP_SEQgives each save a unique temporary file. The snapshots can still be published out of order:{A}, clearsdirty, and pauses before rename.Barrives. The shutdown save snapshots{A, B}and publishes it.{A}snapshot over it. The store is clean, soBhas no pending retry.Even without
B, shutdown can seedirty == falsewhile the worker is still writing, skip the save, and terminate the process before the rename.Could
save_intake a save mutex before checkingdirtyand hold it through rename? The map lock can still be released before disk I/O. A test that pauses the worker before rename would cover the ordering.Static review only.
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T17:51:39Z.
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.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:16:55Z.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.