Shaders: under Wine a pipeline loaded from its blob keeps that blob #3556

Merged
Royalflamejlh merged 1 commit from upstream-pr/3556 into main 2026-12-02 17:40:13 +00:00
Royalflamejlh commented 2026-12-01 02:53:42 +00:00 (Migrated from github.com)

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_blob counts 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_blob asks handed_back: the same length, as before, or, under under_wine() only, a vkd3d-proton blob without a SPIR-V or pipeline-cache chunk returned for a supplied blob that has one. vkd3d_metadata_only walks the chunk list after the 48-byte header; a blob it cannot walk is not counted. One new test of handed_back.

Tested

  • Linux only: Wine 11.21 Staging, RTX 4070 12 GB (driver 615.71.09), vkd3d-proton master 71cae091 with eight local patches (none in libs/vkd3d/cache.c; one adds the timing log used below), rustc 1.98.0, release build for x86_64-pc-windows-gnu, head 9548353d on main d0832e61.
  • cargo test -p xcl --lib --release --target x86_64-pc-windows-gnu -- --test-threads=8 build_with_blob: 12 passed, 0 failed. The same with shaders::: 97 passed, 0 failed, 14 SKIPPED. Both commands ran on Mesa lavapipe, without a D3D12 device.
  • xcl shaders <pack> --precompile --only cs --pipelines over 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, with VKD3D_CONFIG=ignore_shared_fence,pipeline_library_app_cache,no_descriptor_heap XCL_DIRECT_DXIL=1 XCL_DEVICE_TYPE=lockhart XCL_PSO_DISK_CACHE=1 and the NVIDIA disk cache off (__GL_SHADER_DISK_CACHE=0). 1 series per tree; the PR's series is of e4954619, 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 of vkCreateComputePipelines over all threads.
Tree Pass Pass time Loaded Fresh 112-byte files after, of 145 Driver time
main d0832e61 1 20 s 0 145 0 262 s
2 2 s 0 145 145 1.0 s
3 14 s 0 145 0 279 s
e4954619 1 23 s 0 145 0 340 s
2 1 s 145 0 0 1.1 s
3 2 s 145 0 0 1.0 s
  • On main the 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.
  • The head 9548353d differs from e4954619 in 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).
  • The head a91ccd9e8 adds 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.
  • The times are from a shared machine with a test build running during part of the first two series; the counts are the result.
  • What was run is the offline pass, the command the launch pass starts for its workers; the launch pass itself was not run.

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:

xcl-smoke v1
commit: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f
gpu: NVIDIA GeForce RTX 5070 Ti
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1620 (PresentX 1621)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15476 MB

this PR's head:

xcl-smoke v1
commit: a91ccd9e80029935ecad4a5fe7a96be88f15aafa
gpu: NVIDIA GeForce RTX 5070 Ti
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1656 (PresentX 1656)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16144 MB

Not tested

  • Windows: nothing.
  • AMD / RADV.
  • The title itself with this change, and its launch pass: only the offline pass over one slice of 64.
  • Stock vkd3d-proton, and the pass without pipeline_library_app_cache.
  • The whole suite.

AI use

  • Claude Code. Claude Fable 5.2 found the bug, wrote the change and the test, made the runs and wrote this description. Claude Opus 5.5 added the magic check and its test case.
<!-- greyfinch-sync:ivall/xcl:issue:5577991613 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3556). Originally posted by [Royalflamejlh](https://github.com/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_blob` counts 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_blob` asks `handed_back`: the same length, as before, or, under `under_wine()` only, a vkd3d-proton blob without a SPIR-V or pipeline-cache chunk returned for a supplied blob that has one. `vkd3d_metadata_only` walks the chunk list after the 48-byte header; a blob it cannot walk is not counted. One new test of `handed_back`. **Tested** - Linux only: Wine 11.21 Staging, RTX 4070 12 GB (driver 615.71.09), vkd3d-proton `master` `71cae091` with eight local patches (none in `libs/vkd3d/cache.c`; one adds the timing log used below), rustc 1.98.0, release build for `x86_64-pc-windows-gnu`, head `9548353d` on `main` `d0832e61`. - `cargo test -p xcl --lib --release --target x86_64-pc-windows-gnu -- --test-threads=8 build_with_blob`: 12 passed, 0 failed. The same with `shaders::`: 97 passed, 0 failed, 14 SKIPPED. Both commands ran on Mesa lavapipe, without a D3D12 device. - `xcl shaders <pack> --precompile --only cs --pipelines` over 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, with `VKD3D_CONFIG=ignore_shared_fence,pipeline_library_app_cache,no_descriptor_heap XCL_DIRECT_DXIL=1 XCL_DEVICE_TYPE=lockhart XCL_PSO_DISK_CACHE=1` and the NVIDIA disk cache off (`__GL_SHADER_DISK_CACHE=0`). 1 series per tree; the PR's series is of `e4954619`, 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 of `vkCreateComputePipelines` over all threads. | Tree | Pass | Pass time | Loaded | Fresh | 112-byte files after, of 145 | Driver time | |---|---|---|---|---|---|---| | `main` `d0832e61` | 1 | 20 s | 0 | 145 | 0 | 262 s | | | 2 | 2 s | 0 | 145 | 145 | 1.0 s | | | 3 | 14 s | 0 | 145 | 0 | 279 s | | `e4954619` | 1 | 23 s | 0 | 145 | 0 | 340 s | | | 2 | 1 s | 145 | 0 | 0 | 1.1 s | | | 3 | 2 s | 145 | 0 | 0 | 1.0 s | - On `main` the 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. - The head `9548353d` differs from `e4954619` in 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). - The head `a91ccd9e8` adds 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. - The times are from a shared machine with a test build running during part of the first two series; the counts are the result. - What was run is the offline pass, the command the launch pass starts for its workers; the launch pass itself was not run. **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`: ``` xcl-smoke v1 commit: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f gpu: NVIDIA GeForce RTX 5070 Ti title: 5330474d seconds: 60 exit: 0x0 frames shown: 1620 (PresentX 1621) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 15476 MB ``` this PR's head: ``` xcl-smoke v1 commit: a91ccd9e80029935ecad4a5fe7a96be88f15aafa gpu: NVIDIA GeForce RTX 5070 Ti title: 5330474d seconds: 60 exit: 0x0 frames shown: 1656 (PresentX 1656) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16144 MB ``` **Not tested** - Windows: nothing. - AMD / RADV. - The title itself with this change, and its launch pass: only the offline pass over one slice of 64. - Stock vkd3d-proton, and the pass without `pipeline_library_app_cache`. - The whole suite. **AI use** - Claude Code. Claude Fable 5.2 found the bug, wrote the change and the test, made the runs and wrote this description. Claude Opus 5.5 added the magic check and its test case.
Foniass commented 2026-12-01 07:18:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:18:38Z.


Review (head 9548353d, diff read, not a merge-check: the PR description check fails (no xcl-smoke pair), so not built or run here yet):

  • The whole suite wasn't run (the PR says Linux only) and there's no smoke pair, which CONTRIBUTING items 2-3 need even though on Windows handed_back(..., false) reduces to the length comparison main has (shaders.rs ~2952, ~2973).
  • Minor: vkd3d_metadata_only (~2978) doesn't check the VKB5 version 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_blob pass 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's cache.c on current master, and state.c destroys the pipeline cache and sets pso_is_loaded_from_cached_blob when 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.

<!-- greyfinch-sync:ivall/xcl:comment:7303901793 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3556#issuecomment-7303901793). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:18:38Z. --- Review (head 9548353d, diff read, not a merge-check: the `PR description` check fails (no xcl-smoke pair), so not built or run here yet): - The whole suite wasn't run (the PR says Linux only) and there's no smoke pair, which CONTRIBUTING items 2-3 need even though on Windows `handed_back(..., false)` reduces to the length comparison main has (`shaders.rs` ~2952, ~2973). - Minor: `vkd3d_metadata_only` (~2978) doesn't check the `VKB5` version 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_blob` pass 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's `cache.c` on current master, and `state.c` destroys the pipeline cache and sets `pso_is_loaded_from_cached_blob` when 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.
Royalflamejlh commented 2026-12-01 08:05:03 +00:00 (Migrated from github.com)

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 of struct vkd3d_pipeline_blob) is no longer read as a vkd3d blob, with a test case that is red without the check. Head a91ccd9e8; 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.

<!-- greyfinch-sync:ivall/xcl:comment:7304850701 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3556#issuecomment-7304850701). Originally posted by [Royalflamejlh](https://github.com/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 of `struct vkd3d_pipeline_blob`) is no longer read as a vkd3d blob, with a test case that is red without the check. Head `a91ccd9e8`; `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.
Foniass commented 2026-12-01 08:18:41 +00:00 (Migrated from github.com)

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 description still red). Follow-up to my review of 9548353d.

  • Magic check: fixed. vkd3d_metadata_only now reads a blob only if it starts with VKB\x05 (shaders.rs ~2980), which matches VKD3D_CACHE_BLOB_VERSION and the 48-byte header in vkd3d-proton's cache.c, with a test for an older-version blob.
  • Still open: the smoke pair and the whole suite (only 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, while a91ccd9e carries 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.

<!-- greyfinch-sync:ivall/xcl:comment:7305149751 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3556#issuecomment-7305149751). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:18:41Z. --- Re-review (head a91ccd9e, diff read, not a merge-check; draft, `PR description` still red). Follow-up to my review of 9548353d. - **Magic check: fixed.** `vkd3d_metadata_only` now reads a blob only if it starts with `VKB\x05` (`shaders.rs` ~2980), which matches `VKD3D_CACHE_BLOB_VERSION` and the 48-byte header in vkd3d-proton's cache.c, with a test for an older-version blob. - Still open: the smoke pair and the whole suite (only `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, while a91ccd9e carries 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.
Foniass commented 2026-12-01 10:15:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:15:25Z.


Triage (#1607) – head a91ccd9

No open or merged PR makes this change. On main, build_with_blob still 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 adds handed_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.

<!-- greyfinch-sync:ivall/xcl:comment:7307908079 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3556#issuecomment-7307908079). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T10:15:25Z. --- **Triage (#1607)** – head a91ccd9 No open or merged PR makes this change. On main, `build_with_blob` still 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 adds `handed_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.
throny commented 2026-12-02 05:26:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-02T05:26:30Z.


merge-check claim
head: a91ccd9e80

<!-- greyfinch-sync:ivall/xcl:comment:7335937059 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3556#issuecomment-7335937059). Originally posted by [throny](https://github.com/throny) on 2026-12-02T05:26:30Z. --- merge-check claim head: a91ccd9e80029935ecad4a5fe7a96be88f15aafa
throny commented 2026-12-02 05:39:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-02T05:39:18Z.


merge-check
base: main 1c8b55147
head: a91ccd9e80
merge: 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

<!-- greyfinch-sync:ivall/xcl:comment:7336155891 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3556#issuecomment-7336155891). Originally posted by [throny](https://github.com/throny) on 2026-12-02T05:39:18Z. --- merge-check base: main 1c8b55147 head: a91ccd9e80029935ecad4a5fe7a96be88f15aafa merge: 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
Decodere commented 2026-12-02 10:54:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T10:54:37Z.


merge-check
base: 1c8b551475
head: a91ccd9e80
merge: 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 --nocapture passed 148/0 (20 ignored, including gpu_two_pass_cache_e2e), and cargo test -p xcl --lib -- --test-threads=2 passed 2762/0 (31 ignored; --test-threads=4 hit 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_blob with handed_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-proton VKB\x05 blob containing only metadata chunks (chunk kinds 4..=6, no payload kinds 0..=3) is also recognized as a hit when supplied is a full VKB\x05 blob with payload chunks, preventing cache-miss replacement of valid blobs on reload. vkd3d_metadata_only bounds-checks header length (> 48), chunk kind (<= 6), 8-byte-aligned chunk stepping with checked_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 1c8b5514 baseline 1462 frames), 14687 MB peak commit (-8.5% vs 16043 MB baseline), 0 device removals, 0 crashes.

xcl-smoke v1
commit: 341fb679cc3edeaae433ea89df7459910214d8e3
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1655 (PresentX 1655)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 14687 MB

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)

<!-- greyfinch-sync:ivall/xcl:comment:7343154346 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3556#issuecomment-7343154346). Originally posted by [Decodere](https://github.com/Decodere) on 2026-12-02T10:54:37Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: a91ccd9e80029935ecad4a5fe7a96be88f15aafa merge: 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 --nocapture` passed 148/0 (20 ignored, including gpu_two_pass_cache_e2e), and `cargo test -p xcl --lib -- --test-threads=2` passed 2762/0 (31 ignored; `--test-threads=4` hit 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_blob` with `handed_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-proton `VKB\x05` blob containing only metadata chunks (chunk kinds 4..=6, no payload kinds 0..=3) is also recognized as a hit when `supplied` is a full `VKB\x05` blob with payload chunks, preventing cache-miss replacement of valid blobs on reload. `vkd3d_metadata_only` bounds-checks header length (> 48), chunk kind (<= 6), 8-byte-aligned chunk stepping with `checked_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 1c8b5514 baseline 1462 frames), 14687 MB peak commit (-8.5% vs 16043 MB baseline), 0 device removals, 0 crashes. ``` xcl-smoke v1 commit: 341fb679cc3edeaae433ea89df7459910214d8e3 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1655 (PresentX 1655) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 14687 MB ``` 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)
bmjask commented 2026-12-02 14:06:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:06:41Z.

Code review location: crates/xcl/src/shaders.rs; line 2974

@@ -2968,6 +2968,32 @@ fn build_with_blob<P, B: AsRef<[u8]>, E>(cached: Option<&[u8]>, keep: bool, over
     }
 }
 
+/// Whether `returned`, the blob of a pipeline made from `supplied`, says the driver took `supplied`:
+/// the same length, or under Wine vkd3d-proton's blob of a pipeline it loaded from a full one.
+fn handed_back(supplied: &[u8], returned: &[u8], wine: bool) -> bool {
+    returned.len() == supplied.len() || (wine && vkd3d_metadata_only(returned) == Some(true) && vkd3d_metadata_only(supplied) == Some(false))

High: 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 with pipeline_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 and GetCachedBlob returns the 112-byte metadata blob, so handed_back says true and reused=true. The stale file isn't invalidated, warm_blobs records 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.

<!-- greyfinch-sync:ivall/xcl:review-comment:4770793902 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3556#discussion_r4770793902). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T14:06:41Z. **Code review location:** `crates/xcl/src/shaders.rs`; line 2974 ~~~~diff @@ -2968,6 +2968,32 @@ fn build_with_blob<P, B: AsRef<[u8]>, E>(cached: Option<&[u8]>, keep: bool, over } } +/// Whether `returned`, the blob of a pipeline made from `supplied`, says the driver took `supplied`: +/// the same length, or under Wine vkd3d-proton's blob of a pipeline it loaded from a full one. +fn handed_back(supplied: &[u8], returned: &[u8], wine: bool) -> bool { + returned.len() == supplied.len() || (wine && vkd3d_metadata_only(returned) == Some(true) && vkd3d_metadata_only(supplied) == Some(false)) ~~~~ --- **High**: 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 with `pipeline_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 and `GetCachedBlob` returns the 112-byte metadata blob, so `handed_back` says true and `reused=true`. The stale file isn't invalidated, `warm_blobs` records 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.
bmjask commented 2026-12-02 14:06:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:06:41Z.

Code review location: crates/xcl/src/shaders.rs; line 2975

@@ -2968,6 +2968,32 @@ fn build_with_blob<P, B: AsRef<[u8]>, E>(cached: Option<&[u8]>, keep: bool, over
     }
 }
 
+/// Whether `returned`, the blob of a pipeline made from `supplied`, says the driver took `supplied`:
+/// the same length, or under Wine vkd3d-proton's blob of a pipeline it loaded from a full one.
+fn handed_back(supplied: &[u8], returned: &[u8], wine: bool) -> bool {
+    returned.len() == supplied.len() || (wine && vkd3d_metadata_only(returned) == Some(true) && vkd3d_metadata_only(supplied) == Some(false))
+}

Medium: 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_back should return false when vkd3d_metadata_only(supplied) == Some(true).

<!-- greyfinch-sync:ivall/xcl:review-comment:4770793915 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3556#discussion_r4770793915). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T14:06:41Z. **Code review location:** `crates/xcl/src/shaders.rs`; line 2975 ~~~~diff @@ -2968,6 +2968,32 @@ fn build_with_blob<P, B: AsRef<[u8]>, E>(cached: Option<&[u8]>, keep: bool, over } } +/// Whether `returned`, the blob of a pipeline made from `supplied`, says the driver took `supplied`: +/// the same length, or under Wine vkd3d-proton's blob of a pipeline it loaded from a full one. +fn handed_back(supplied: &[u8], returned: &[u8], wine: bool) -> bool { + returned.len() == supplied.len() || (wine && vkd3d_metadata_only(returned) == Some(true) && vkd3d_metadata_only(supplied) == Some(false)) +} ~~~~ --- **Medium**: 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_back` should return false when `vkd3d_metadata_only(supplied) == Some(true)`.
bmjask commented 2026-12-02 14:06:41 +00:00 (Migrated from github.com)

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.

  1. High 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)
  2. High crates/xcl/src/shaders.rs:2964: see below.
  3. Medium 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)
  4. Medium crates/xcl/src/shaders.rs:2991: Not certain about this one: kind <= 3 treats SHADER_IDENTIFIER (type 6) as metadata, but vkd3d-proton's own d3d12_cached_pipeline_state_is_dummy counts it as content (along with PIPELINE_CACHE, SPIRV and both LINK types). (inline)

On lines outside the diff:

  1. High crates/xcl/src/shaders.rs:2964: Both places that write a replacement blob (this create(None) path, and replacement: 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 without pipeline_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. GetCachedBlob returns 112 bytes and driver_cache::write stores 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 where vkd3d_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.

<!-- greyfinch-sync:ivall/xcl:review:6152379935 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3556#pullrequestreview-6152379935). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T14:06:41Z. **Review:** COMMENTED --- Review of `a91ccd9e`: 4 finding(s) (2 high, 2 medium), most severe first. 1. **High** `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) 2. **High** `crates/xcl/src/shaders.rs:2964`: see below. 3. **Medium** `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) 4. **Medium** `crates/xcl/src/shaders.rs:2991`: Not certain about this one: `kind <= 3` treats SHADER_IDENTIFIER (type 6) as metadata, but vkd3d-proton's own `d3d12_cached_pipeline_state_is_dummy` counts it as content (along with PIPELINE_CACHE, SPIRV and both LINK types). (inline) **On lines outside the diff:** 2. **High** `crates/xcl/src/shaders.rs:2964`: Both places that write a replacement blob (this `create(None)` path, and `replacement: 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 without `pipeline_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. `GetCachedBlob` returns 112 bytes and `driver_cache::write` stores 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 where `vkd3d_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._
bmjask commented 2026-12-02 14:06:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:06:42Z.

Code review location: crates/xcl/src/shaders.rs; line 2991

@@ -2968,6 +2968,32 @@ fn build_with_blob<P, B: AsRef<[u8]>, E>(cached: Option<&[u8]>, keep: bool, over
     }
 }
 
+/// Whether `returned`, the blob of a pipeline made from `supplied`, says the driver took `supplied`:
+/// the same length, or under Wine vkd3d-proton's blob of a pipeline it loaded from a full one.
+fn handed_back(supplied: &[u8], returned: &[u8], wine: bool) -> bool {
+    returned.len() == supplied.len() || (wine && vkd3d_metadata_only(returned) == Some(true) && vkd3d_metadata_only(supplied) == Some(false))
+}
+
+/// A vkd3d-proton pipeline blob without SPIR-V or driver cache data; `None`: not such a blob.
+fn vkd3d_metadata_only(blob: &[u8]) -> Option<bool> {
+    const HEADER: usize = 48;
+    if !blob.starts_with(b"VKB\x05") {
+        return None;
+    }
+    let word = |at: usize| blob.get(at..at + 4).map(|b| u32::from_le_bytes(b.try_into().unwrap()) as usize);
+    let mut at = HEADER;
+    let mut payload = false;
+    while at < blob.len() {
+        let (kind, size) = (word(at)? & 0xffff, word(at + 4)?);
+        if kind > 6 {
+            return None;
+        }
+        payload |= kind <= 3;

Medium: Not certain about this one: kind <= 3 treats SHADER_IDENTIFIER (type 6) as metadata, but vkd3d-proton's own d3d12_cached_pipeline_state_is_dummy counts 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.

<!-- greyfinch-sync:ivall/xcl:review-comment:4770793926 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3556#discussion_r4770793926). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T14:06:42Z. **Code review location:** `crates/xcl/src/shaders.rs`; line 2991 ~~~~diff @@ -2968,6 +2968,32 @@ fn build_with_blob<P, B: AsRef<[u8]>, E>(cached: Option<&[u8]>, keep: bool, over } } +/// Whether `returned`, the blob of a pipeline made from `supplied`, says the driver took `supplied`: +/// the same length, or under Wine vkd3d-proton's blob of a pipeline it loaded from a full one. +fn handed_back(supplied: &[u8], returned: &[u8], wine: bool) -> bool { + returned.len() == supplied.len() || (wine && vkd3d_metadata_only(returned) == Some(true) && vkd3d_metadata_only(supplied) == Some(false)) +} + +/// A vkd3d-proton pipeline blob without SPIR-V or driver cache data; `None`: not such a blob. +fn vkd3d_metadata_only(blob: &[u8]) -> Option<bool> { + const HEADER: usize = 48; + if !blob.starts_with(b"VKB\x05") { + return None; + } + let word = |at: usize| blob.get(at..at + 4).map(|b| u32::from_le_bytes(b.try_into().unwrap()) as usize); + let mut at = HEADER; + let mut payload = false; + while at < blob.len() { + let (kind, size) = (word(at)? & 0xffff, word(at + 4)?); + if kind > 6 { + return None; + } + payload |= kind <= 3; ~~~~ --- **Medium**: Not certain about this one: `kind <= 3` treats SHADER_IDENTIFIER (type 6) as metadata, but vkd3d-proton's own `d3d12_cached_pipeline_state_is_dummy` counts 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.
bmjask commented 2026-12-02 14:11:16 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:ivall/xcl:comment:7348130753 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3556#issuecomment-7348130753). Originally posted by [bmjask](https://github.com/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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3556
No description provided.