Shaders: the preparation trusts the driver blobs it checked before #2951
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2951"
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 throny on 2026-11-27T03:55:21Z.
At every launch the shader preparation created each used compute pipeline again from its stored driver blob, only to apply its check (the driver makes a pipeline from the blob and returns a blob of the same size), and then dropped the pipeline. That is not free: on an RTX 4080 (driver 621.40) creating a large pipeline from its blob was measured to take as long as compiling it, so the preparation took minutes at every launch, also right after a launch that had completed it. This PR remembers that a blob passed the check and does not create its pipeline again. Part of #2088 (plan and discussion there; the content digest is @ettehn's point).
What is in it
crates/xcl/src/hle/d3d12x/real.rs(driver_cache): a marker<blob>.okbeside a blob that passed the check or was just written: the driver's identity (the one the graphics blobs use), the blob's length and an FNV-64 digest of its bytes.verifiedcompares all three with the file as it is now;removedeletes a refused blob together with its marker.crates/xcl/src/shaders.rs(Pipelines::make_one): a record whose blob matches its marker is counted ("pipelines whose blob an earlier pass verified, not created again N") and returns before the worker slot and the driver call. Anything else goes the present way and is marked afterwards.XCL_PREPARE_VERIFY=1applies the check to every blob again.a_verified_blob_is_trusted_until_it_changes_or_is_refused(other driver, changed length, same-length overwrite, missing blob, refusal), GPU testa_second_pass_trusts_the_blobs_the_first_verified, andgpu_compute_e2e::offline_compute_pipeline_is_reused_by_a_second_processextended across processes (trusted; a blob overwritten with zeros of the same length is rebuilt and trusted again). Two existing e2e tests list only.psofiles and run their reuse assertions withXCL_PREPARE_VERIFY=1, unchanged otherwise.README.md: one bullet for the markers and the switch.The marker says what the preparation's check said before, no more: it does not prove the driver used the blob (the comment at the check already notes a driver may compile from the DXIL and still succeed). It changes when the check runs, not what it proves.
Tested
cargo test --workspace --no-fail-fast -- --test-threads=4on 551bcb90 (this commit before a comment-only amend): 1825 passed, 8 failed, 48 ignored, 27 SKIPPED lines (mostly "no wave64", two "no heap windows"). The 8 failures are 6 tests that fail the same way on the clean baseecc0bb57on this machine, each rerun alone with and without the change: listed in https://github.com/xcl-dev/xcl/pull/2572#issuecomment-7208423689. None is in code this PR touches exceptgpu_compute_e2e, where the two failing tests fail at the same lines without it.cargo test -p xcl --lib driver_cache: 7 passed;--lib pipeline_cap_tests: 4 passed;--test gpu_compute_e2e: 5 passed, 2 failed (the two above).XCL_PREPARE_VERIFY=1(the present behaviour) 131 s (compute pipelines 120 s); the two launches after it, with the markers, 11 s and 11 s (compute pipelines 3 s). 4,203 markers were written.Regression run
On a commit of
main, on the base commit (nvidia-dev, which this PR is against) and on this PR's head, same title, 120 s:Not tested
XCL_PREPARE_VERIFY=1does.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T04:02:58Z.
On
40a14da3716bc28d0c34c86928de987a473192bb, the verified-blob marker and explicit pipeline-size cap behaved consistently across seven fresh Windows CLI processes on an RTX 5070. The test used one synthetic packed compute shader, 4,452 bytes of compiled DXIL, a 2,318-byte driver blob and one isolated cache. No code changes were needed..okmarker.All seven
xcl shaders --precompile --pipelinesruns exited successfully. This checks the interaction between same-length damage, the size cap and marker cleanup through the public CLI. It does not measure startup or first-dispatch latency in a retail title.AI use: OpenAI Codex with GPT-6.2 Astra prepared the synthetic checks and compared the CLI counters and cache files; Codex coordinated and prepared this report.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T04:03:33Z.
I checked whether marker-bypass savings shifted into the first native consumer PSO creation, using head
40a14da3716bc28d0c34c86928de987a473192bbplus a test-only fixture on RTX 5070 / driver 616.92. Twelve synthetic compute shaders were seeded with driver blobs and markers. Each of 32 fresh processes began with a separate copy; the implicit OS/driver cache remained warm and its contents were not inspected. Eight counterbalanced runs were made per arm.All 384 consumer creates succeeded. One 115.253 ms trust/supplied preparation outlier is retained. The paired subtotal excludes fixture/setup overhead. Consumer blob I/O and root-signature setup were outside the timed native calls; PSOs remained alive. This checks a small synthetic corpus on one device and shows little transfer of the preparation difference to first native creation in this setup. It does not establish which blob path a title uses, cold-driver behavior, GTA VI startup, dispatch correctness or frame time.
AI use: OpenAI Codex with GPT-6.2 Astra built and ran the synthetic measurement and audited the artifacts; Codex coordinated and prepared this report.
Imported from ivall/xcl. Originally posted by throny on 2026-11-27T04:15:16Z.
@andrewDoing thank you for both checks, in particular the second one: whether the saving just moves into the title's first creation was the open point in Not tested, and your 32 processes on driver 616.92 show little transfer for small programs. The size cap together with a same-length overwrite is a combination I had not run.
Status of the checks:
Build and test (Windows, no GPU)fails inhle::d3d12x::sparse::tests::a_gpu_write_into_a_gpu_view_lands_in_its_cpu_view, which this PR does not touch; the same check is red on the other open PRs againstnvidia-devI looked at (#2935, #2927, #2923), so it comes from the base.PR descriptionasks for a smoke block made on a commit ofmain; that run is in progress and I will add the block to the description.AI use: Claude Code (Claude Fable 5.2).
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T04:49:27Z.
Independent back-to-back verification on RTX 3060 Ti (8 GB) + Ryzen 5 5500 (6C/12T) (
40a14da3merged withnvidia-devecc0bb57, Series S /lockhartprofile).Setup
621.40), DXC1.9.2602.17.XCL_DEVICE_TYPE=lockhart XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_TEXTURE_LEVEL_PAGES=1 XCL_PSO_WAIT_MS=50 XCL_GFX_PSO_WAIT_MS=200 XCL_CS_PSO_WAIT_MS=50 XCL_PREPARE_GRAPHICS=0 XCL_DRED=1+XCL_PRESS_AT(18:A..74:A).Two consecutive 90 s runs on the same cache folder
lockhartsnapshot (1,572used shaders,3,206driver blobs, no.okmarkers yet)..okmarkers written by Run 1).90 s)first_2pass_mesh_tnvidia-dev(ecc0bb57, 2 runs)#2951Run 1 (creates.ok)43.3 swall)1 5 11)#2951Run 2 (trusts.ok)44 31 9)Not tested: driver update invalidation / tampered-blob fallback test on this machine, AMD/Intel adapters.
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-27T05:31:51Z.
Review: COMMENTED
On
40a14da3716bc28d0c34c86928de987a473192bb, the cold creation path marks a freshly exported blob verified as soon asdriver_cache::writesucceeds. That path cleareddesc.CachedPSOand built the pipeline from DXIL, so the newly written bytes have not passed the check described for this marker: importing them throughCreateComputePipelineState, then receiving a cached blob of the same size. On the next normal launchdriver_cache::verifiedreturns early and may never perform that check. Could the first pass round-trip the exported blob before marking it, or defer the marker untilfrom_cachesucceeds on a later pass? The new test currently expects a marker immediately after cold creation and would need to cover the intended cold → checked → trusted sequence. This is exact-head source review; I did not demonstrate a driver that rejects its own exported blob.AI use: OpenAI Codex (GPT-6.2 Sol) traced the cold and trusted paths and checked the discussion; OpenAI Codex (GPT-6.2 Astra) independently read the exact source and wrote this review.
Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-27T06:16:38Z.
amd-win check of
40a14da3(basenvidia-devecc0bb57), RX 7800 XT (RDNA3), driver 32.0.31035.1003, Windows 11 build 26200, Ryzen 7 5700X3D, 64 GB, release builds, DXC 1.8.2502.11.a_verified_blob_is_trusted_until_it_changes_or_is_refusedanda_second_pass_trusts_the_blobs_the_first_verified: 2 passed, 0 failed, 0 skipped.gpu_compute_e2e::offline_compute_pipeline_is_reused_by_a_second_process: 1 passed, 0 failed.xcl shaders <pack> --precompile --only cs --pipelines --used-only(331 used pipelines, 238 compute programs compiled),XCL_PSO_DISK_CACHE=1 XCL_PIPELINE_THREADS=4, run twice in a row per exe (first pass fills, second is the warm one):ecc0bb5740a14da3What this says for AMD: creating the pipelines from the stored blobs costs almost nothing here. The whole second pass of the base, translation included, takes 3.4 s for 238 pipelines (at most about 57 ms each on average with 4 threads), against 159 s for the first pass. So on this driver the marker saves about 0.1 s per launch and is neutral, in contrast to the 19.7 s per create reported on the RTX 4080. It also did no harm: 0 refused, 0 errors, identical pass 1 time.
Not tested: a title run, graphics pipelines, a driver or adapter change between passes, other AMD parts, NVIDIA. The AMD driver's own cache was warm from earlier runs (blobs here are names of entries in it), so this says nothing about a cold driver cache.
AI use: Claude Code (Claude Sonnet 5.5) ran the tests and runs and wrote this.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T08:46:01Z.
Following the fresh-export review point, I tried the smallest local resolution on #2951 head
40a14da3: write a newly exported blob without marking it, then mark it only after the next pass successfully re-imports that blob through the PR's existingfrom_cachecheck. The sequence is cold export → checked import → later trusted skip. This uses the check the marker claims to record; it does not add a second driver creation to the cold pass.On Windows 11 build 26300, RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Rust 1.99.1 MSVC, DXC 1.8.2502.11:
a_second_pass_trusts_the_blobs_the_first_verifiedtest on the unchanged production head failed as intended: 0 passed, 1 failed, 0 ignored, because the fresh export already had a marker. With the candidate fix, it passed 1/0/0.cargo test --offline --locked -j 4 -p xcl --lib pipeline_cap_tests -- --test-threads=1with the candidate: 4 passed, 0 failed, 0 ignored, no skips.cargo test --offline --locked -j 4 -p xcl --test gpu_compute_e2e offline_compute_pipeline_is_reused_by_a_second_process -- --nocapture --test-threads=1with the revised damaged-blob recovery expectation: 1 passed, 0 failed, 0 ignored, no skips. This runs the public CLI in fresh processes and uses synthetic shaders.Candidate diff for the author
The tradeoff is that the first later launch with a fresh blob must do the driver check; the next matching launch can skip it. The current second-launch timing claim should be remeasured if this is adopted. I did not run the full workspace suite or paired title smoke on this uncommitted candidate. AI use: Codex (GPT-6.2 Sol) traced the paths, wrote the local diff and ran these tests.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-27T12:17:37Z.
Tested
Clean
40a14da3716bc28d0c34c86928de987a473192bbon Windows 11 build 26200.9974, Ryzen 7 3800X, Rust 1.100.0 MSVC, Intel Arc A770 driver 32.0.101.9175, DXC/DXIL 1.9.2602.17. Built withcargo test --offline --locked -j 2 -p xcl --lib --test gpu_compute_e2e --no-run --message-format=json-render-diagnostics. Ran eight freshxcl shaders <synthetic-input> --precompile --pipelinesprocesses with separate Arc cache roots per control.shaders::pipeline_cap_tests::stale_blob_cannot_bypass_the_offline_pipeline_cap --exact --nocapture --test-threads=1passed. The stale blob was removed, the offline cap was recorded, and dispatch read back 42.All eight CLI controls and the libtest passed. Zero failures, ignores, or runtime skips. The pinned identity probe identified Arc PCI 8086:56a0. Each Arc process used the shared mutex separately.
Not tested
A real adapter or driver change, Arc performance, retail smoke and full suite.
AI use
T3 Code / Codex (
gpt-6.2-sol) ran the original verification, independently reproduced the cases reported here, and wrote this report.Imported from ivall/xcl. Originally posted by throny on 2026-11-27T14:39:35Z.
Marked ready for review: the description now has the smoke block on a commit of
mainnext to the base and head ones, andPR descriptionis green.Build and test (Windows, no GPU)is still red inhle::d3d12x::sparse::tests::a_gpu_write_into_a_gpu_view_lands_in_its_cpu_view, the same failure as on the other open PRs againstnvidia-dev, not in code this PR touches. Thanks to @andrewDoing and @LocranKing for the independent runs. AI use: Claude Code (Claude Fable 5.2).Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-27T19:21:04Z.
Test of
40a14da3on an RTX 5090 (driver 621.24), unmodified, on its basenvidia-devecc0bb57. One release binary, and the arms differ only byXCL_PREPARE_VERIFY: A =1(every blob created again, as the base does), B unset (.ok-verified blobs trusted). Order A B B A. Each run starts from a fresh copy of one frozen, fully prepared cache, stamped once by a verify pass (2,169.okmarkers), with one exe name, the same recorded title history, and the same frame-based input. 300 s cap.0x887a0005at 158 s0x887a0005at 113 s0x887a0005at 114 s0x887a0005at 133 s0x887a0005, no driver events) 95-140 s after the entry point, before the world-load marker, in both arms alike. That looks like the shader-heap limit (#2403) on this setup, not this PR.cargo test:a_verified_blob_is_trusted_until_it_changes_or_is_refused,a_second_pass_trusts_the_blobs_the_first_verifiedandsplit_compute_program_prebuilds_and_caches_chain_piecespassed.gpu_compute_e2e5 passed, 2 failed:async_compute_pso_registers_real_pso_and_not_standinandsplit_compute_prefers_the_offline_whole_pipelinefail the same way on the baseecc0bb57, so they're pre-existing.Not tested: the world-load first create (we didn't reach it); a cold cache; other GPUs.
AI use: Claude Code (Claude Opus 5.5) ran the arms (t12) and wrote this comment; Gemini (Antigravity) wrote the recipe and the safety review.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T07:03:52Z.
Additional marker-key finding on #2951 head
40a14da3:driver_cache::name_forkeys a compute blob by DXIL, flags and chain mode, whilePipelines::make_onealso builds its root signature from the static samplers. The.okmarker does not include those sampler words. Consequently, a marker checked for one root signature can cause preparation of a different root signature to return before its driver PSO check.I extended the existing synthetic GPU test with the same DXIL and point versus linear static samplers. After forcing a real cached-blob check for the point-sampler variant, the test confirmed two distinct root signatures, then failed on the unchanged head:
trustedrose from 1 to 2 for the linear variant (0 passed, 1 failed, 0 ignored). I did not measure an actual title's first-bind delay; the observed failure is the preparation bypass.The candidate below versions the marker and records the exact ordered sampler words and comparison flags, so older markers get checked again. With it, the GPU test passed (1/0/0);
pipeline_cap_testspassed (4/0/0), anddriver_cachepassed (7/0/0), with no skips on Windows 11 build 26300, RTX 3080 Ti / 621.35. This is independent of the earlier cold-export finding and candidate: both changes are needed for a marker to mean that this exact PSO was previously checked.Candidate diff against
40a14da3Update: rejected marker after forced verification
A second focused regression covers a marked blob rejected by a forced
XCL_PREPARE_VERIFY=1pass when its read-only file cannot be replaced. On the unchanged head, the invalid blob is rejected (reused = 0) but the existing marker still passesverifiedon the next ordinary pass: 0 passed, 1 failed, 0 ignored. Removing the marker as soon as cached re-import fails fixes that sequence without deleting a potentially concurrently replaced blob. With this added candidate, the regression passed 1/0/0 and allpipeline_cap_testspassed 5/0/0, no skips, on the same Windows/RTX 3080 Ti setup.Additional candidate diff against
40a14da3These two candidate diffs address separate marker invariants and can be adapted together with the earlier cold-export fix. I did not run the full workspace suite or paired title smoke on either uncommitted candidate. AI use: Codex (GPT-6.2 Sol) traced the paths, wrote and ran the synthetic regressions and candidates; Codex (GPT-6.2 Astra) independently reviewed the marker invariants.
Imported from ivall/xcl. Originally posted by kole07139 on 2026-11-28T11:46:32Z.
merge-check
base:
54225f5884(nvidia-dev)head:
40a14da371merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> the library test binary stops with exit code 0x7C10003 after
a_refused_gpu_upload_segment_becomes_custom(the fail-stop throny reported on #3041; the same on the base). Up to there: 1385 passed, 4 failed. Other binaries: 130 passed, 2 failed, 20 ignored. Library rerun with--skip a_refused_gpu_upload_segment_becomes_custom: 1773 passed, 6 failed, 28 ignored, 27SKIPPEDlines (base: 1771 passed, the same 6 failed, 28 ignored); that test alone: 1 passed. failing: the 6 library tests (placed_title_textures_share_vram_and_preserve_pixels, 3stream_recheck_*,d32s8_targets_take_their_own_size_of_video_memory,gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark) fail on the base too.gpu_compute_e2e::a_preparation_worker_also_builds_a_split_programs_whole_formfails on the merge only (finding 1).e2e::test_title_runs_and_game_folder_is_untouchedfailed once in the full run ([FAIL] … a texture in title memory (XG layout, #44) follows CPU writes: subresource 2 row 0 differs), then passed 3 of 3 alone on the merge; on the base it passed in the full run and 3 of 3 alone. This PR does not touch that path, so I count it as intermittent, not as this PR's.review:
nvidia-dev:gpu_compute_e2e::a_preparation_worker_also_builds_a_split_programs_whole_formcame in with #2794 after this PR's baseecc0bb57. It counts every file indriver/and now finds the.okmarkers too:left: 10, right: 5. It fails 3 of 3 on the merge and passes on the base. With the listing limited to.psofiles, as this PR already does for two other e2e tests, it passes 2 of 2 (a scratch edit, not pushed anywhere). A test-only change, but it needs a rebase onto currentnvidia-dev.nvidia-devthe blob's own name does not include them either (name_for: DXIL, flags, chain). Per #3044, NVIDIA accepts a blob made with other samplers without an error, so the base's check would pass the same blob. My reading is that onnvidia-devthis PR does not make that case worse. That is reasoned, not measured.mainnames compute blobs by their samplers (ba44b52c,name_for_root), so this matters whennvidia-devis merged intomain: the marker should follow that name.GetCachedBlobof a pipeline made from the same description, and a blob the title's driver refuses later is removed with its marker (note(false)→remove). I see this as minor.Claim, and it drops the root signature.verifiedreads and hashes the whole blob, which the base'sloadread anyway, so the only extra I/O is the small marker file.performance: reasoned, not measured. It is on by default. It removes pipeline creations from the preparation and adds nothing per frame. It adds one small
.okfile per blob. I made no title run on this machine.verdict: not yet:
a_preparation_worker_also_builds_a_split_programs_whole_formfails on the merge with currentnvidia-dev(finding 1). It needs a rebase with that test counting only.psofiles.hardware / tool and model: NVIDIA GeForce RTX 3070 8 GB (driver 617.42, wave32), Intel i9-9900K, 32 GB RAM, Windows 11 Pro N 26200, rustc 1.99.0, DXC 1.8.2502.11, debug. Claude Code (Claude Opus 5.5) ran the merge, build and tests, and wrote this check.
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-28T12:32:43Z.
@throny a whole-suite run of your head on an RTX 3090 (Ampere), against its own base on the same machine: no failure that the base doesn't have, and your two new tests pass.
Tested:
40a14da3and its basenvidia-devecc0bb57.XCL_*variable set.cargo test --workspace --no-fail-fast -- --test-threads=4 --skip uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom --skip uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment --skip uma_driver::tests::failed_restore_stops_before_importing_an_unbacked_window0x7c10003), on this card and on our RTX 5090, at every commit we ran. The skip lets the rest of the lib report.ecc0bb5740a14da3a_verified_blob_is_trusted_until_it_changes_or_is_refuseda_second_pass_trusts_the_blobs_the_first_verifiedoffline_compute_pipeline_is_reused_by_a_second_processoffline_split_compute_pipeline_is_reused_by_a_second_processsplit_compute_prefers_the_offline_whole_pipelinegpu_compute_e2e.rs:153)title_textures::tests::stream_recheck_keeps_the_whole_upload_baseline_over_partial_uploadsand…stream_recheck_partial_upload_without_an_entry_queues_a_whole_upload.PoisonError, a lock thatplaced_title_textures_share_vram_and_preserve_pixelsleaves when it fails on0x8007000Eearlier in the same process. That one fails on both trees.async_compute_pso_registers_real_pso_and_not_standin;console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly;texture_uploadtests (attempt to multiply with overflow,texture_upload.rs:1002);e2etest_title_runs_and_game_folder_is_untouched("Invalid bitcode signature");two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs.nvidia-dev54225f58on this machine, thetexture_upload, mesh-stream, async-PSO and two-pass ones pass. So they belong to the older base, not to this PR.Not tested:
nvidia-dev(the PR is onecc0bb57).AI use: an agent swarm: Claude Fable 5.2, Claude Opus 5.5, GPT-6.2-Sol and Gemini 4 Neon.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T21:00:01Z.
Current-base update for #2951 head
40a14da3: the PR now targetsmainand conflicts with it. Since the NVIDIA branch merge,mainhas a persistentwarm_blobsreceipt. The preparation skips a previously checked blob only when its filename, root layout (including ordered static sampler words and comparison flags), and blob contents match. Its cache naming also includes the sampler-dependent root signature.I built current
mainbeeb81beand rancargo test --offline --locked -j 4 -p xcl --lib static_sampler_root_signatures_have_distinct_compatible_names -- --test-threads=1and the same command withwarm_receipt_matches_only_the_validated_blob_and_layout: 1 passed / 0 failed / 0 ignored each, no skips. These are focused identity tests, not a performance or full-suite result.This addresses the sampler-key bypass in my earlier report on the old PR head. Before resolving the conflict, I suggest comparing the remaining behavior with
main's receipt path and keeping only a distinct, tested improvement, if one remains. Carrying the old.okmarker as-is would add a second verification mechanism.AI use: Codex (GPT-6.2 Sol) checked the current source and ran the focused tests; Codex (GPT-6.2 Astra) independently traced the cache identity.
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T23:26:41Z.
Closing as superseded, as @thehollowedone suggested. Since the merge of
nvidia-dev,mainhas its own receipt for checked driver blobs, and it is the stricter one: its stamp includes the root layout with the static samplers, where this PR's marker only had the driver, the blob length and the blob bytes, so a sampler or layout change with an unchanged blob would have been skipped here and is re-checked there.mainalso has what this PR lacked (one checksummed receipt merged across workers). The only thing here thatmaindoes not have is a switch to force the full check (XCL_PREPARE_VERIFY=1); if someone wants that onmainit is a few lines for a separate PR.AI use: Claude Code (Claude Fable 5.2); the comparison was read by Claude Sonnet 5.5.
Pull request closed