Shaders: under Wine a pipeline loaded from its blob keeps that blob #3556
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3556"
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 ivall/xcl. Originally posted by Royalflamejlh on 2026-12-01T02:53:42Z.
Under vkd3d-proton with
VKD3D_CONFIG=pipeline_library_app_cache, the offline pipeline pass replaced every full driver blob it loaded with a 112-byte one, and the pass after that compiled every pipeline again.build_with_blobcounts a pipeline as made from its stored blob only when the blob it hands back has the same length. vkd3d-proton frees the pipeline cache of a pipeline it made from a blob and returns its header and compatibility chunk alone (112 bytes), so each load looked like a stale blob and the short blob was written over the file. Under Wine such a blob, of a pipeline made from a full one, is now a hit. Part of #3067.What is in it
crates/xcl/src/shaders.rs:build_with_blobaskshanded_back: the same length, as before, or, underunder_wine()only, a vkd3d-proton blob without a SPIR-V or pipeline-cache chunk returned for a supplied blob that has one.vkd3d_metadata_onlywalks the chunk list after the 48-byte header; a blob it cannot walk is not counted. One new test ofhanded_back.Tested
master71cae091with eight local patches (none inlibs/vkd3d/cache.c; one adds the timing log used below), rustc 1.98.0, release build forx86_64-pc-windows-gnu, head9548353donmaind0832e61.cargo test -p xcl --lib --release --target x86_64-pc-windows-gnu -- --test-threads=8 build_with_blob: 12 passed, 0 failed. The same withshaders::: 97 passed, 0 failed, 14 SKIPPED. Both commands ran on Mesa lavapipe, without a D3D12 device.xcl shaders <pack> --precompile --only cs --pipelinesover one slice of a retail title's pack (XCL_PRECOMPILE_SLICE=0/64: 42 compute programs, 145 pipelines), three passes in a row on each tree from an empty blob folder, each pass a new process, withVKD3D_CONFIG=ignore_shared_fence,pipeline_library_app_cache,no_descriptor_heap XCL_DIRECT_DXIL=1 XCL_DEVICE_TYPE=lockhart XCL_PSO_DISK_CACHE=1and the NVIDIA disk cache off (__GL_SHADER_DISK_CACHE=0). 1 series per tree; the PR's series is ofe4954619, the same code as the head (see below). "Loaded" and "fresh" are the pass's closing lines (pipelines loaded from the driver cache,fresh GPU pipeline creations); driver time is the sum ofvkCreateComputePipelinesover all threads.maind0832e61e4954619mainthe second pass did load the blobs (1.0 s in the driver) and then stored the short ones: the folder went from 55.4 MB to 16,240 bytes. The third pass had nothing to load.9548353ddiffers frome4954619in a doc comment, the test's blob layout and the commit message. Passes 1 and 2 repeated on it: 145 fresh and 0 short files (23 s, 247 s in the driver), then 145 loaded and 0 short files (2 s, 1.2 s).a91ccd9e8adds a check that a blob starts with vkd3d-proton's magic (VKB\x05,cache.c) before it is read as one, with a test case;cargo test --lib shaders::on it: 97 passed, 0 failed (2 SKIPPED), RTX 4060 Ti. The passes above were not repeated on it.Regression run
RTX 5070 Ti 16 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 Pro 26300, release builds by
scripts/smoke.ps1, the same retail title for 60 s each.main:this PR's head:
Not tested
pipeline_library_app_cache.AI use
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:18:38Z.
Review (head
9548353d, diff read, not a merge-check: thePR descriptioncheck fails (no xcl-smoke pair), so not built or run here yet):handed_back(..., false)reduces to the length comparison main has (shaders.rs~2952, ~2973).vkd3d_metadata_only(~2978) doesn't check theVKB5version magic at offset 0, so under Wine any blob whose bytes after offset 48 walk as chunk types <= 6 counts as a vkd3d blob; checking the magic would close that (low risk, since both blobs must walk exactly to their end).Fine: it only changes the offline
build_with_blobpass under Wine, keeping the full blob file instead of overwriting it with the short one (nothing extra held in memory); the runtime path already counts a successful create with a blob as reused (real.rs~6435, ~9610). The 48-byte header, 8-byte chunk header and alignment, and chunk types 0-3 as SPIR-V / cache data vs 4-6 as metadata match vkd3d-proton'scache.con current master, andstate.cdestroys the pipeline cache and setspso_is_loaded_from_cached_blobwhen a blob was supplied, which explains the short blob. Unknown chunk types and blobs that can't be walked fall back to main's behaviour, the arithmetic is overflow-checked, and the test covers the hit, Windows and rebuilt-blob cases.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-01T08:05:03Z.
Thanks. Added: a blob whose first four bytes are not vkd3d-proton's magic (
VKB\x05,MAKE_MAGIC('V','K','B',5)at offset 0 ofstruct vkd3d_pipeline_blob) is no longer read as a vkd3d blob, with a test case that is red without the check. Heada91ccd9e8;cargo test --lib shaders::on it, RTX 4060 Ti under Wine: 97 passed, 0 failed, 2 SKIPPED. The whole suite and the smoke pair are still owed.AI use: Claude Code. Claude Opus 5.5 checked the header and wrote the change; Claude Fable 5.2 ran the tests on the card and wrote this reply.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:18:41Z.
Re-review (head
a91ccd9e, diff read, not a merge-check; draft,PR descriptionstill red). Follow-up to my review of9548353d.vkd3d_metadata_onlynow reads a blob only if it starts withVKB\x05(shaders.rs~2980), which matchesVKD3D_CACHE_BLOB_VERSIONand the 48-byte header in vkd3d-proton's cache.c, with a test for an older-version blob.shaders::ran on the new head, 97 passed, 2 skipped, and the offline passes weren't repeated on it). AI use names only Claude Fable 5.2, whilea91ccd9ecarries an Opus 5.5 trailer.Fine: Windows behaviour is unchanged (the same length comparison as main).
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:15:25Z.
Triage (#1607) – head
a91ccd9No open or merged PR makes this change. On main,
build_with_blobstill counts a reuse only by equal length. #3506 and #3507 (same issue #3067, same author) change other things: the v1 receipt import listing and the driver-cache name listing. This one addshanded_back, which under Wine also accepts vkd3d-proton's metadata-only blob for a full one supplied.No problems found in the diff. Off Wine it is the same length comparison as main.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-02T05:26:30Z.
merge-check claim
head:
a91ccd9e80Imported from ivall/xcl. Originally posted by throny on 2026-12-02T05:39:18Z.
merge-check
base: main
1c8b55147head:
a91ccd9e80merge: trial merge into base is clean (MERGEABLE)
build: cargo build --workspace on the merged tree: OK
tests: cargo test --workspace --no-fail-fast -- --test-threads=4: 2910 passed, 0 failed, 51 ignored; 25 SKIPPED lines (GPU tests that skip); 0 binaries ended abnormally
review: Diff read (+56 -3, scan clean). build_with_blob counts a reuse by equal length; under Wine it also accepts vkd3d-proton's metadata-only blob returned for a full blob supplied, checked by the VKB\x05 magic and a chunk walk with overflow checks. Windows behaviour is the same length comparison as main. The magic-check point from the earlier review is fixed and tested. The header and chunk layout was not compared with vkd3d-proton here; Wine paths were not exercised on this Windows machine. The PR author named only one model in AI use while a commit trailer names another (noted in an earlier review).
performance: not measured here; the PR's own smoke pair shows frames within a few percent of main and no removal
verdict: safe to merge (both xcl-smoke blocks are in the description and its check is green; our suite above covers the whole-suite gap; Wine paths not exercised here)
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300; Claude Code, Claude Sonnet 5.5 ran the build and the suite and read the diff; Claude Opus 5.5 checked this report
Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T10:54:37Z.
merge-check
base:
1c8b551475head:
a91ccd9e80merge: clean (trial-merge commit 341fb679cc3edeaae433ea89df7459910214d8e3, git diff --check clean)
build: cargo build --workspace ok; cargo build --release -p xcl ok
tests: 43 targets combined: 2910 passed, 0 failed, 51 ignored (+1 new test vs main baseline). Specifically, all 42 non-lib workspace targets under
cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapturepassed 148/0 (20 ignored, including gpu_two_pass_cache_e2e), andcargo test -p xcl --lib -- --test-threads=2passed 2762/0 (31 ignored;--test-threads=4hit the unrelated pre-existing ASLR collision on synthetic pointer 0x7c000041 in main's set_pipeline_state_goes_into_a_run_only_with_a_two_pass_pipeline -> real.rs:1237). All 12/12 shaders::build_with_blob_tests passed with 0 skips, including new under_wine_the_metadata_blob_of_a_pipeline_loaded_from_a_full_one_is_a_hit. 28 SKIPPED lines (host environment only: 22 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 2 no heap windows, 1 cannot disable the driver cache (Windows Developer Mode required)).review: Read the full merged diff (+56/-3 in crates/xcl/src/shaders.rs). Replaces the length-equality reuse check in
build_with_blobwithhanded_back(bytes, b.as_ref(), crate::util::under_wine()). On native Windows (!wine), behavior is unchanged (returned.len() == supplied.len()). Under Wine (wine == true), a returned vkd3d-protonVKB\x05blob containing only metadata chunks (chunk kinds 4..=6, no payload kinds 0..=3) is also recognized as a hit whensuppliedis a fullVKB\x05blob with payload chunks, preventing cache-miss replacement of valid blobs on reload.vkd3d_metadata_onlybounds-checks header length (> 48), chunk kind (<= 6), 8-byte-aligned chunk stepping withchecked_add, and exact end alignment (at == blob.len()). The new unit test covers Wine hit, Windows miss, rebuilt full-blob miss, truncated-blob miss, identical metadata hit, and version mismatch (VKB\x04). Note: native Windows host check; the Wine/vkd3d-proton branch is verified via unit tests and code review rather than live under Wine. No scope creep or UB.performance: 60 s retail smoke (title: 29640639, native Windows non-regression): 1655 frames (+13.2% vs
1c8b5514baseline 1462 frames), 14687 MB peak commit (-8.5% vs 16043 MB baseline), 0 device removals, 0 crashes.verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:06:41Z.
Code review location:
crates/xcl/src/shaders.rs; line 2974High: The rule that a short metadata-only blob means "loaded" isn't tied to the blob that was supplied. vkd3d-proton returns that short blob whenever it built the pipeline from any cached blob, including one from its own disk cache after it silently dropped ours, so a stale stored blob counts as a hit and is never replaced. Under Wine with vkd3d-proton's own disk cache on (the default, i.e. without
pipeline_library_app_cache) or withpipeline_library_ignore_mismatch_driver, a stored full blob from an older vkd3d build or another GPU is ignored ("Continuing as-if application did not provide cache"). vkd3d then takes the pipeline from vkd3d-proton.cache andGetCachedBlobreturns the 112-byte metadata blob, sohanded_backsays true andreused=true. The stale file isn't invalidated,warm_blobsrecords it as warm, and it's kept on every later run. Also requiring that the supplied and returned headers match (bytes 4..12 and 16..48: vendor, device, vkd3d build, shader interface key, cache UUID; skip the checksum at 12..16), and that their PSO_COMPAT chunks match, would tie the hit to our blob.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:06:41Z.
Code review location:
crates/xcl/src/shaders.rs; line 2975Medium: The same-length test is checked first, so under Wine a supplied metadata-only blob counts as a hit whenever a 112-byte blob comes back, but vkd3d-proton ignores such a supplied blob entirely, so it can never really be taken (the test at ~3053 asserts this case is a hit). Folders already full of the 112-byte files main wrote (pass 2 in the PR's table) are handed to vkd3d and discarded as dummies. If vkd3d's disk cache supplies the pipeline it returns 112 bytes again, so
reused=true, the useless file stays, gets a warm-blob stamp, and is counted as loaded from the driver cache.handed_backshould return false whenvkd3d_metadata_only(supplied) == Some(true).Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:06:41Z.
Review: COMMENTED
Review of
a91ccd9e: 4 finding(s) (2 high, 2 medium), most severe first.crates/xcl/src/shaders.rs:2974: The rule that a short metadata-only blob means "loaded" isn't tied to the blob that was supplied. vkd3d-proton returns that short blob whenever it built the pipeline from any cached blob, including one from its own disk cache after it si.... (inline)crates/xcl/src/shaders.rs:2964: see below.crates/xcl/src/shaders.rs:2975: The same-length test is checked first, so under Wine a supplied metadata-only blob counts as a hit whenever a 112-byte blob comes back, but vkd3d-proton ignores such a supplied blob entirely, so it can never really be taken (the test at .... (inline)crates/xcl/src/shaders.rs:2991: Not certain about this one:kind <= 3treats SHADER_IDENTIFIER (type 6) as metadata, but vkd3d-proton's ownd3d12_cached_pipeline_state_is_dummycounts it as content (along with PIPELINE_CACHE, SPIRV and both LINK types). (inline)On lines outside the diff:
crates/xcl/src/shaders.rs:2964: Both places that write a replacement blob (thiscreate(None)path, andreplacement: blob.filter(..)at ~2956) can still write vkd3d-proton's 112-byte metadata blob to disk, which is the overwrite this PR is meant to stop. Under Wine withoutpipeline_library_app_cache, once the title has filled vkd3d-proton.cache, a blob-less create, or a retry after a stored blob is refused with DRIVER_VERSION_MISMATCH, is served from vkd3d's cache.GetCachedBlobreturns 112 bytes anddriver_cache::writestores them over the path (or over the full blob that was refused). vkd3d treats such a blob as a dummy (d3d12_cached_pipeline_state_is_dummy), so once vkd3d-proton.cache is gone every pipeline compiles again from DXIL, as on main. Never keeping a blob wherevkd3d_metadata_only(blob) == Some(true)as a replacement would fix it at the source.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:06:42Z.
Code review location:
crates/xcl/src/shaders.rs; line 2991Medium: Not certain about this one:
kind <= 3treats SHADER_IDENTIFIER (type 6) as metadata, but vkd3d-proton's ownd3d12_cached_pipeline_state_is_dummycounts it as content (along with PIPELINE_CACHE, SPIRV and both LINK types). So a blob with PSO_COMPAT + SHADER_META + SHADER_IDENTIFIER chunks is classed metadata-only here while vkd3d loads it, and the hit/miss decision for those blobs no longer matches vkd3d.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:11:16Z.
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.