gpu/pipeline: adapter-keyed PSO cache filenames and atomic rename (1/4 of #51) #56
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/56"
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 PastiiJay/klbf-lab. Originally posted by Vladimir-Human on 2026-11-26T00:26:00Z.
Part 1/4 of the split requested on #51, cleanly branched from
beta(78ad5711).Scope
crates/victory-gpu/src/pipeline/library.rs.AdapterKey(VendorId,DeviceId,Revision, andis_software;GetAdapterLuidis used only to locate the matching DXGI adapter, andSubSysIdis not part of the key) so WARP/iGPU/dGPU runs never overwrite or load an incompatible adapter's cache blob.VendorId == 0x1414 && DeviceId == 0x008c) as software (-sw) in addition toDXGI_ADAPTER_FLAG_SOFTWARE, so default Basic Render Driver runs (Flags == 0) share the-swcache with explicit WARP (Flags == 0x2) and never fall back to an unsuffixed legacyhost-pipelines.bin..tmp.<pid>.<seq>viastd::process::id()and an atomic sequence counter) + atomic rename/replace when persisting the library andearly-pipelines.txt, so concurrent processes saving either distinct or identical adapter keys in the same cache directory never clobber each other's temporary file before rename.host-pipelines.binfor hardware adapters without ever touching or reading it from software adapters.Verification
cargo test -p victory-gpu:159 passed; 0 failed; 3 ignored(includes all 9pipeline::library::tests::*tests:adapter_keys_produce_distinct_filenames_for_hardware_and_software,basic_render_driver_without_software_flag_isolates_from_legacy_and_shares_warp_cache,temp_files_are_unique_across_calls_and_processes,legacy_fallback_reads_hardware_cache_and_never_touches_it_on_warp,warp_save_does_not_discard_hardware_pipeline_library, etc.)VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --all-features --lib pipeline::library -- --test-threads=1:9 passed; 0 failedcargo clippy -p victory-gpu --all-targets: 0 warnings incrates/victory-gpu/src/pipeline/library.rscargo run -p xtask -- policy --staged: passed (library.rsis 65,140 bytes)Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-26T00:34:14Z.
Got it, part 1/4 is in the queue. One detail: the code still keys the filename on vendor, device, revision and the software flag (the LUID is only used to find the adapter), while the description lists SubSysId and AdapterLuid too, so the summary could use the same fix as #51.
Imported from PastiiJay/klbf-lab. Originally posted by Vladimir-Human on 2026-11-26T00:48:09Z.
Good catch, thanks @PastiiJay — updated the PR #56 description to list only
(VendorId, DeviceId, Revision, is_software)in the filename key and note thatAdapterLuidis only used to look up the DXGI adapter.Imported from PastiiJay/klbf-lab. Originally posted by HandshakeHackin on 2026-11-26T02:44:00Z.
I compared the split with the version we tested earlier.
pipeline/library.rsis byte-for-byte identical in356690cand7d31a81(Git blob9d948988). The earlier Windows WARP save/reopen run covered this file, including preserving both synthetic hardware and legacy cache files. Windows runOne detail for the PR description: two processes saving the same adapter key in the same cache directory derive the same
.tmppath. The test verified isolation between hardware and WARP. I’d narrow the concurrent-exit claim to distinct adapter keys unless there’s a separate same-key writer test. Filename construction · Save pathImported from PastiiJay/klbf-lab. Originally posted by HandshakeHackin on 2026-11-26T04:40:01Z.
I found a cache-isolation case with the default Microsoft Basic Render Driver on native Windows. DXGI returned
1414:008cwith flags0x0for the default device and the same IDs with flags0x2for explicit WARP. On356690c, the default device got the-hwfilename and opened all 30 bytes of a synthetic unsuffixed legacy file. Explicit WARP got-swand read zero bytes. BeforeThe attached commit recognizes the Basic Render Driver by its PCI ID as well as the software flag. Both devices then selected
-swand read zero legacy bytes. All seven library tests passed. I also checked that sharing this key works on the runner. A compute pipeline saved on one device reopened by name on the other, in both directions, with mapped and buffered storage (four cache hits). Cherry-pick91ef4c9· After · Cache round tripsImported from PastiiJay/klbf-lab. Originally posted by Vladimir-Human on 2026-11-26T09:25:14Z.
Pushed
a7ed242addressing all findings on #56:Microsoft Basic Render Driver (
1414:008cwithFlags == 0) ->-sw(@HandshakeHackin):AdapterKey::from_dxgi(vendor, device, revision, flags)which marksVendorId == 0x1414 && DeviceId == 0x008cassoftware = truealongsideDXGI_ADAPTER_FLAG_SOFTWARE.Flags = 0) and explicit WARP (Flags = 0x2) now produce the exact samehost-pipelines-1414-008c-rXX-sw.{bin,next}filenames withlegacy_fallback = false, so neither ever opens an unsuffixed legacyhost-pipelines.bin.basic_render_driver_without_software_flag_isolates_from_legacy_and_shares_warp_cacheand updatedadapter_keys_produce_distinct_filenames_for_hardware_and_software.Per-process / per-save unique
.tmp.<pid>.<seq>paths (@HandshakeHackin):.tmpfilename inLibraryFileswithLibraryFiles::temp_file()usingtmp.<pid>.<seq>(std::process::id()+ an atomicTMP_SEQcounter), generated per save insave()and cleaned up on rename failure.unique_tmp_suffix()scheme and failure cleanup towrite_atomically(early-pipelines.txt).temp_files_are_unique_across_calls_and_processes(spawns a child process + 8 concurrent threads / 128 calls).PR summary alignment (@PastiiJay, @HandshakeHackin):
AdapterKey(VendorId,DeviceId,Revision,is_software, withGetAdapterLuidonly for DXGI adapter lookup and noSubSysId), document Basic Render Driver1414:008c-swhandling, describe.tmp.<pid>.<seq>temp-file isolation, and update verification results (159 passed; 0 failed; 3 ignoredand9 passed; 0 failedunderVICTORY_D3D12_DEBUG=1).Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-26T10:41:56Z.
Thanks @Vladimir-Human, both points from review look covered in
a7ed242. We'll test it in game before merging.Imported from PastiiJay/klbf-lab. Originally posted by Vladimir-Human on 2026-11-28T18:09:02Z.
Superseded by #180 targeting
stable-amd(v26.11.6): https://github.com/PastiiJay/klbf-lab/pull/180Pull request closed