Shaders: a stale-blob probe the driver takes is not created a second time #2940
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2940"
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 KOLESNiii on 2026-11-27T01:59:00Z.
Rebased onto
maine429936c(ported onto its claimed preparation, running permit and per-pipeline persistence outcomes; see the commit message).--pipelinesand startup shader preparation create a compute pipeline with the driver's blob of an earlier run. When the driver cannot use the blob but compiles from the DXIL and still succeeds (#1774), the size check on the returned blob dropped that pipeline and created it a second time without the blob, in the sameXCL_PIPELINE_THREADSslot. Now the pipeline from a successful probe is kept: one native create. Whether it counts as reused is unchanged (the returned blob has the size handed over). When it doesn't, its own blob replaces the stale one on disk. A refused blob is still compiled again without it, and over the cap it is still capped and removed.Fixes #2939
What is in it
crates/xcl/src/shaders.rs: the create-with-blob decision moves out ofPipelines::make_oneintobuild_with_blob, which takes the native create andGetCachedBlobas closures (the same pattern ascreate_graphics_pso_cachedinreal.rs).make_onekeeps the slot, counters and file handling. As onmain, a pipeline made without a blob is not asked for its blob when there is no cache path (XCL_PSO_DISK_CACHE=0), and the driver's blob is not copied:DriverBlobkeeps theID3DBlob, the hit check reads only its size, and a replacement is written from the driver's buffer.main. An earlier revision made a taken stale blob over the cap into a made pipeline. That broke the two over-cap tests in the full suite (see below) and went beyond #2939, so it was dropped.build_with_blob_tests(no GPU) drive the helper with a fake driver: stale blob taken (ettehn's 1,418 → 1,402 bytes) under and over the cap, akimfomin's same-size/different-bytes control (asserts one create only, leaving the hit rule open for discussion in #2939), the blob handed back, a pipeline without a blob, refused blob under and over the cap, no blob, and no cache path (no blob export).pipeline_cap_tests::a_stale_blob_the_driver_takes_is_made_with_one_create_and_replaced(GPU) repeats ettehn's reproducer on real D3D12: the stock pipeline's blob with 16 zero bytes appended, which must be made with one native create (test-only counter onPipelines) and replaced on disk. It reports SKIPPED when the driver refuses the padded blob.Tested
cargo test --workspace -- --test-threads=4onc9c6966a: 2138 passed, 9 failed, 48 ignored; 25SKIPPED(21 no wave64, 3 #1426, 1 no heap windows). The 9 failures are #3093's and fail the same onmaine429936c(2126 passed, 9 failed, 48 ignored), same skips.build_with_blob_testsandpipeline_persistence_tests(no GPU) onc9c6966a: 12 passede2615503, onmain8b957bec): the new GPU test failed onmainplus only the test-only create counter (creates=2 made=2 ... kept_blob=1626) and passed with the fix (creates=1). This negative check was not redone after the port:maine429936chas no such counter, and adding it again is part of this PR.ee919a64: NVIDIA RTX 5070 Ti (ettehn) and AMD RX 7800 XT (oni-swr) take the padded blob and make it with one create; Wine / vkd3d-proton / RADV refuses it, so the GPU test skips there (SzczepanGrela). See the comments.shaders::tests::pso_measurement_compiles_an_exact_synthetic_recordturns the driver's shader cache off withShaderCacheControlon the device that every test in the process shares, after which the driver takes anyCachedPSO, garbage included. Onmainthe size check hides this. It isn't fixed here.Regression run
RTX 2070 SUPER, the retail game, 60 s,
XCL_PRESS_AT=25:A,XCL_PREPARE=0(no startup preparation) on both, release builds, one after the other in one queue job; each run starts from the DXIL cache the run before it left. Startup preparation is skipped, so this does not reach the changed code (it runs in preparation and--pipelines): it is a regression check.Not tested
ee919a64. The successful-stale-probe path depends on the driver taking a blob it can't use.--pipelinespass or startup preparation after the port (asked for in the comments)real.rs) are unchanged. They count any successful probe as a hit and never replace the stale blob, see #2939 for the proposal.AI use
maine429936c. The reproducer and the same-size control come from ettehn's and akimfomin's comments in #2939.🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by akimfomin on 2026-11-27T02:04:27Z.
I ran the eight exact
build_with_blob_testsfromee919a6407afdaefeb295fa0bc3feb0d1868581cin an isolated Rust test binary: 8 passed. I also added a one-case callback counter: uncached success invokesblob_ofonce. At the calling site,XCL_PSO_DISK_CACHE=0gives no path, but that callback still callsGetCachedBloband copies its bytes. The old path skipped both operations when the path was absent.Returning
Nonefrom the callback whenpathis absent preserves that behavior. A regression can count zero exports/copies in that control. The separate warm-cache case also copies each blob into a Rust Vec before deciding by length and dropping it. A retained blob handle plus length would preserve the old no-copy path for equal-sized results. Performance impact is unmeasured. The one-create, fallback and cap controls passed in isolation. AI-assisted source review and isolated compilation with OpenAI Codex.Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T02:10:13Z.
I compared the native compute PSO path on parent
8b957bec6f82495aec940944c6bf47faa02db590and draft headee919a6407afdaefeb295fa0bc3feb0d1868581c, using trace-only instrumentation around the existing calls. All six synthetic runs made exactly one PSO and reported zero refusals.GetCachedBlob; the draft retrieved and copied a 3,070-byte blob that had no disk destination.GetBufferSizewithout reading the returned buffer; the draft copied the 3,070 bytes and discarded them after the size check.The draft's one-create result is preserved in all three cases. Keeping the returned blob handle through the size check and borrowing its contents only when a replacement must be written could avoid these copies; a no-destination cold build could skip retrieval. I did not measure latency, retail hit frequency, or GTA VI startup time. Trace printing itself occurred inside the limited pipeline slot, so these runs should not be used for timing.
AI use: OpenAI Codex with GPT-6.2 Astra instrumented and ran the checks and independently reviewed the source; Codex coordinated and prepared this report.
Imported from ivall/xcl. Originally posted by ettehn on 2026-11-27T02:10:18Z.
Independent native D3D12 run on exact
ee919a64: RTX 5070 Ti Laptop, NVIDIA 621.24, Windows 11, SDK DXC 1.8.2502.11.cargo test --offline --locked -p xcl --lib -- build_with_blob_tests pipeline_cap_tests --test-threads=1 --nocapture: 12 passed, 0 failed, 0 skipped. On the real padded-blob fixture, the 1,418-byte input took one native create and was replaced by a 1,402-byte blob (reused=0). The existing over-cap refusal test still reportedcapped=1,made=0.I also tried a local overlay for the review above: retain the
ID3DBloband its length through the decision, borrow its bytes only when writing a replacement, and skipGetCachedBlobwhen there is no cache path. The 12 tests passed with that overlay. I extended the native fixture to set the cap one byte below the synthetic DXIL length after seeding. The successful padded probe still used one native create and wrote the replacement, with no capped increment. No retail run or timing measurement in this check.OpenAI Codex (6.2sol) assisted with verification.
Imported from ivall/xcl. Originally posted by ettehn on 2026-11-27T02:20:24Z.
Thanks for turning the padded-blob reproducer I posted in #2939 into a GPU regression. Since that test is included in #2940, would you consider adding this co-author trailer for the reproducer and Windows verification?
Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-27T02:39:10Z.
amd-win check of
ee919a6407afdaefeb295fa0bc3feb0d1868581c(parent8b957bec), native Windows, AMD.cargo test --locked -p xcl --lib -- build_with_blob_tests pipeline_cap_tests --test-threads=1 --nocaptureon the head: 12 passed, 0 failed, 0 ignored, 0 skipped.... -- shaders::on the head: 19 passed, 0 failed. On the parent binary (run separately, built from its own checkout): 10 passed, 0 failed (the 9 new tests do not exist there).stale_blob_cannot_bypass_the_offline_pipeline_cap: capped=1, made=0, refused=0.Not tested: the parent's two-create count on AMD (the fixture is part of this PR, so I did not run it on the parent); a title run or a precompile;
cargo test -p xclin full; correctness on AMD of a driver-returned blob across runs (XCL does not keep AMD blobs on disk by default); no timing of the second create.AI use: Claude Code (Claude Sonnet 5.5) ran the tests and wrote this.
Imported from ivall/xcl. Originally posted by akimfomin on 2026-11-27T03:33:57Z.
The Radeon and NVIDIA runs both exercised the accepted padded-blob path. Intel’s behavior is still open. I put the exact
ee919a64fixture and return fields in Test Lab #114 and offered the run to a contributor who volunteered native D3D12 testing on Arc B580. If the Intel driver refuses the padded blob, we’ll record the refusal/skip separately from a successful one-create replacement. I’ll bring the credited result here if the run happens.Imported from ivall/xcl. Originally posted by SzczepanGrela on 2026-11-27T05:18:48Z.
Wine / vkd3d-proton / RADV result: this stack rejects the padded blob, so the native regression test skips the accepted-stale-probe branch. This differs from the native Windows AMD/NVIDIA results above.
Tested
ee919a6407afdaefeb295fa0bc3feb0d1868581c, mainc2ee10e4e905eb736e56953c52b749e18bcc7ede, and the PR applied to that main. Main'sshaders.rsis identical to the PR base8b957bec6f82495aec940944c6bf47faa02db590; integration changes only that file.26.3.1-arch3.5, Ryzen 7 7700, CachyOS7.3.0-5-cachyos. Windows GNU release, Rust1.97.1, GE-Proton11-12 / Wine 11.0 Staging, vkd3d-proton8293130ebe370b1+(local asserts-disabled build), DXC/DXIL1.9.2602.17.cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run --message-format=json-render-diagnostics.<unit.exe> build_with_blob_tests pipeline_cap_tests workflow_original_padded --nocapture --test-threads=1, then--test-threads=4.Every skip is the padded test's
the driver refuses a blob with bytes appended (0x887E0002): no successful stale probe on this adapter. It is not native coverage of the one-create replacement case. The eight helper tests pass on head/integration.Additional filter
<unit.exe> workflow_driver_blob_matrix --nocapture --test-threads=1, three fresh processes per source: 1 passed, 0 failed, 0 skipped in all nine runs. The fixture explicitly overrides isolated cache paths; globalXCL_PSO_DISK_CACHE=0. Its 3,080-byte synthetic compute shader yields a 112-byte blob; appending 16 zero bytes produces a rejected 128-byte blob. Both padded and corrupt inputs return0x887E0002in independent native acceptance probes.Across the eight-case runs: 72 cases and 81 measured native create attempts, plus seeding and separate acceptance probes. Native traces, counters, caps and exact blob files were independently verified and repeat byte-for-byte. The no-path export also matches the earlier review: main makes no
GetCachedBlobcall there; head/integration make one. No latency was measured.A separate native-wave64 dispatch per owned run verifies all 1,296 data/width/sentinel words across nine runs. This control creates its own PSO. Head and integration captures match. Inherited
XCL_*cleared; network off, RX 9070 selected, private enabled caches; no GPU/DXC-absence skip was accepted.Not tested
The successful native stale-blob probe central to this PR, dispatching the PSO returned by that probe, a real driver upgrade, full suite, native Windows, other GPUs, retail workload,
scripts/smoke.ps1, timing or FPS. Padded-blob refusal on this stack prevents reproducing the proposed two-create to one-create improvement.AI use
OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the diff, added test-only traces and the eight-case fixture, ran comparisons, independently verified skips, native calls, counters, blob files, GPU data and source/executable provenance, and drafted this report. Publication authorized by the account owner.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-27T10:09:12Z.
Thanks all. Pushed
e2615503(one commit, squashed):build_with_blobtakeskeep(path.is_some()). WithXCL_PSO_DISK_CACHE=0, a pipeline made without a blob is not asked for its blob, as onmain. New unit testwithout_a_path_a_pipeline_made_without_a_blob_is_not_asked_for_its_blobcounts zero exports there. Its counterpart with a path counts one.build_with_blobis generic over the blob. Inmake_oneit is aDriverBlobholding theID3DBlob, read in place: the hit check reads only its size, and a replacement is written from the driver's buffer. This is the overlay ettehn tried. Performance impact is still unmeasured.Co-authored-by: ettehnfor the padded-blob reproducer and the Windows verification.Hardware results so far, linked from the description: native one-create replacement seen on NVIDIA (ettehn, RTX 5070 Ti; mine on
ee919a64, RTX 2070 SUPER:creates=1,main2) and AMD RDNA3 (oni-swr, RX 7800 XT). Wine / vkd3d-proton / RADV refuses the padded blob, so the GPU test skips there and the refused path is what runs (SzczepanGrela). Intel is open (akimfomin's Test Lab #114).Tested on
e2615503: RTX 2070 SUPER, Windows 11 26300, debug.cargo test -p xcl --lib build_with_blob_tests: 11 passed, 0 failed, 0 ignored. The GPU tests (pipeline_cap_tests), the full suite and the smoke run on this head are queued; the description will get the results.AI use: Claude Code (Claude Opus 5.5) made the change, ran the tests and wrote this reply.
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T13:59:44Z.
Tested PR #2940 (
e2615503) on Windows 11 with an NVIDIA GeForce RTX 3060 Ti (8 GB, driver32.0.16.2140, Ryzen 5 5500, 32 GB RAM, Windows 11 Build 26300).Unit & GPU tests
cargo test --locked -p xcl --lib -- build_with_blob_tests pipeline_cap_tests --nocaptureone2615503:build_with_blob_testsunit tests (a_stale_blob_the_driver_takes_is_one_create_and_replaced,a_stale_blob_over_the_cap_the_driver_takes_is_capped_after_one_create,a_returned_blob_of_the_same_size_but_other_bytes_is_one_create,the_blob_the_driver_hands_back_is_a_hit_and_not_written_again, etc.) passed.pipeline_cap_testspassed, including the live GPU testa_stale_blob_the_driver_takes_is_made_with_one_create_and_replaced:adapter=NVIDIA GeForce RTX 3060 Ti good_blob=1450 padded_blob=1466 creates=1 made=2 refused=0 reused=0 kept_blob=1450cargo test --locked -p xcl --lib -- shaders::tests --nocapture:pso_measurement_compiles_an_exact_synthetic_recordskipped: Windows Developer Mode disabled0x887A002D).Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-28T00:36:45Z.
Tested
Clean
e26155031dabcc8755830cd1d642b435e4d985f0on native Windows 11 25H2 (26200.9974), Ryzen 7 3800X, Intel Arc A770 (PCI8086:56a0, driver32.0.101.9175), DXC/DXIL1.9.2602.17, Rust1.100.1MSVC debug. I reran the pinned stock libtest with<libtest.exe> --exact <test> --nocapture --test-threads=1.XCL_ADAPTER=A770under the shared GPU lock, ranshaders::pipeline_cap_tests::a_stale_blob_the_driver_takes_is_made_with_one_create_and_replaced. The A770 driver accepted the 2,179-byte padded blob. The stale-cache path made one native create and replaced it with a 2,163-byte blob. The fixture loggedcreates=1 made=2 refused=0 reused=0 kept_blob=2163.made=2includes the seed. Native and lock-wrapper exits were 0.shaders::build_with_blob_testscoveredwithout_a_path_a_pipeline_made_without_a_blob_is_not_asked_for_its_blob,a_stale_blob_the_driver_takes_is_one_create_and_replaced, anda_refused_blob_is_compiled_again_without_it.Total 4 passed, 0 failed, 0 ignored, 0 runtime skips.
Not tested
Dispatch of the returned PSO, startup timing, an actual driver upgrade, other Intel drivers or adapters, retail smoke, or the full suite.
AI use
T3 Code through the Codex harness (
gpt-6.2-sol) verified the executable and adapter, ran the existing tests and wrote this report.Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T13:24:28Z.
Help wanted: a full
--pipelinespass on a retail title's shader pack (several hours here, so I am asking rather than tying up my machine).c9c6966aports this PR ontomaine429936c(claimed preparation, running permit, per-pipeline persistence outcomes). On my RTX 2070 SUPER (debug) the whole suite gives 2138 passed, 9 failed, 48 ignored, 25 SKIPPED; the 9 are #3093's and fail the same onmaine429936c; my smoke runs skip startup preparation (XCL_PREPARE=0), so they do not reach the changed code, and a full pass takes hours here.If you have a title's shader pack, please run the offline pass (the same pipeline creation as startup preparation) twice on
maine429936cand twice onc9c6966a, each pair from its own emptyXCL_DXIL_CACHE:and post, for each pass, the summary lines it prints (pipelines made on the GPU / refused, loaded from the driver cache, fresh GPU pipeline creations with the driver-blob persistence counts, time), plus GPU, driver and commit. The interesting case is a warm pass after a driver update (stale blobs the driver takes): there this PR makes each such pipeline with one create instead of two.
— Claude Code (Claude Opus 5.5), on behalf of the PR author
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-29T14:50:18Z.
Current-main audit (2026-11-29): salvage/rebase; good cache-safe focused fix.
I read the full
build_with_blobrefactor and its tests. Keeping the successfully created PSO when a stale blob is accepted-but-recompiled removes a genuinely redundant native create, without changing DXIL, root signatures, descriptors, or cache naming. The helper retains the previous over-cap behavior and handles refused blobs separately. Native NVIDIA/AMD/Intel evidence is present in the thread.This head is stale relative to current preparation/pipeline-library work and its PR-description check is red, so it needs a current-main rebase and refreshed required checks. Keep it as the one focused stale-probe fix rather than folding it into broader cache work.
Cache impact: safe for existing PSO identities; it changes reuse/persistence behavior, not the key. Disposition: rebase and merge candidate.
Review assisted by Codex; exact model name was not exposed in this session. I did not rerun the GPU fixture.