Shaders: save offline compute pipelines to the runtime driver cache #744
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!744
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/744/head"
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?
@CallMeBrado on GitHub · 2026-11-24 04:25 UTC · original
CallMeBrado:perf/offline-compute-driver-cache→main· +140 −9 · 4 files · 2 commits · merged 2026-11-24 13:31 UTCStacked on #714. Only the top commit belongs to this PR.
Running
xcl shaders --precompile --pipelinesbuilt compute pipelines and then dropped the driver's compiled blobs. The next XCL process had no file to hand back to the driver. This saves those blobs using the runtime cache from #634. I ran into this while investigating #505.What is in it
XCL_PSO_DISK_CACHE=0disables both reads and writes.Tested
cargo build --locked --release --workspace --jobs 4passed.cargo test --locked --release --workspace --jobs 4 --no-fail-fast -- --test-threads=4 --show-outputreported 704 passed, 0 failed, 41 ignored. Two GPU tests reportedSKIPPEDfor missing native wave64 and one for missingxgameruntime.dll.Regression run
Main
This branch
Not tested
AMD and Intel GPUs. The 60-second game runs stayed at startup. I haven't measured a load-time improvement or seen this change take the game past its loading screen.
AI use
Codex (GPT-6) wrote the change and test, ran the checks on my PC, and drafted this description.
github-bot referenced this pull request2026-11-26 05:02:43 +00:00
@anes66 on GitHub · 2026-11-24 04:39 UTC · original
Verified
07c535d85dbf084ed6692cbd851744986483e6f3on Windows 10 Pro 19045, Ryzen 7 9800X3D, RTX 3060 12 GB / 32.0.16.2114, Rust 1.100.0 MSVC, DXC 1.9.2602.17, Agility SDK 1.620.2, debug.Tested
cargo build --locked --workspace -j 4: passed.cargo test --locked --workspace --no-fail-fast -j 4 -- --test-threads=4 --show-output: 704 passed, 0 failed, 41 ignored, exit 0.I also checked the cache's intended consumer, beyond the existing CLI-to-CLI test. 6880f7c adds 17 test-only lines directly on this head. A fresh child process opens the CLI's cache, creates the console pipeline through the runtime hook, and reuses the existing GPU dispatch/readback checks for all 768 threads. It must also report a runtime driver-blob hit, so successful recompilation alone cannot satisfy the test.
The extended focused test passed. As a negative control, disabling only the child's PSO disk cache left its shader execution passing but failed the new reuse assertion. That temporary change was restored. The full four-thread workspace suite with the extension passed 704/0/41, with the same two skips; the tested patch was committed unchanged.
Not tested
Retail title smoke runs, load-time improvements, large retail compute shaders, release builds, AMD/Intel or native-wave64 hardware. The cross-process test demonstrates reuse for this synthetic program, not a gameplay improvement.
AI use
Codex (GPT-6; exact variant unavailable) reviewed the changes, wrote the test extension, ran the tests and negative control, and drafted this report.
@MesshM on GitHub · 2026-11-24 04:39 UTC · original
Test run of
07c535d85dbf084ed6692cbd851744986483e6f3on AMD RDNA4. I merged it onto currentmain64b3f35locally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 704 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 662 passed, 0 failed, 21 ignoredSKIPPED;offline_compute_pipeline_is_reused_by_a_second_process,an_overlapping_writer_cannot_modify_the_published_blobandan_abandoned_staging_file_is_skipped_and_preservedpass.Review: Keying the file by DXIL and pipeline flags (
driver_cache::path(&dxil, flags)) is better than the DXIL alone (my note on #634). The root signature is still not part of the key: if the one the offline compiler builds with differs from the one the title uses, the driver refuses the blob and the pipeline is built and saved again, which wastes the offline work rather than breaking anything. Reviewed only the top commit, as the description asks (stacked on #714).Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@JoaoPauluu on GitHub · 2026-11-24 04:43 UTC · original
Test report: #744 under Wine, with vkd3d-proton as the driver whose blobs are cached (Linux, NVIDIA)
The description's run is NVIDIA's Windows driver. Under Wine, the cached-pipeline blobs come from vkd3d-proton (D3D12 on Vulkan), a different implementation of
GetCachedBlob/CachedPSO. The new test passes there: a second process is given its blob back, and an invalid blob still builds.Setup
experimental-11.0-20261112(wine-11.0), vkd3d-proton v3.1 (4522cc1a) + the patch from #257, DXVK from Proton, DXC 1.9.2609,DXVK_CONFIG="dxgi.hideNvidiaGpu = False"x86_64-pc-windows-gnu(mingw-w64-gcc 16.2.0), debug build of this PR's head07c535d(with #714's commit under it)Result:
gpu_compute_e2etest binary under Wine,--exact offline_compute_pipeline_is_reused_by_a_second_process: ok, in 2 of 2 runs (5.1 s and 4.9 s). That covers the disabled cache (nodriverfolder), the warm run (pipelines loaded from the driver cache 1, which the test asserts) and the invalid blob (pipelines made on the GPU 1, refused 0still holds).vkd3d_pipeline_library_init_disk_cache: Attempting to load disk cache from: vkd3d-proton.cache, in the working directory). So under Wine there are two caches. The test's assertions are on XCL's own counts, so they check XCL's cache, not vkd3d-proton's.Not tested
AI use: Claude Code (Claude Opus 5.5) built the test, ran it on the machine above and wrote this report. The results and log lines are pasted from those runs. The account owner asked for test reports to be posted while they were away and has not reviewed this one.
@burber on GitHub · 2026-11-24 05:08 UTC · original
Same approach tried with the retail title's world compute programs on an RTX 4070 Ti: the title takes the offline blobs at its first bind
I tried the same idea on a local branch before seeing this PR:
--precompile --pipelineskeeps each build's driver blob throughreal::driver_cache, under the same DXIL + flags name. Here is what it did with the retail title. It should apply to this PR as well.Setup: RTX 4070 Ti 12 GB (driver 32.0.16.1062), i5-13600K, Windows 11 26300, DXC 1.8.2502.
maine915150 + #533 + #267 + #708 + #640, plus the precompile change. Title 1.0.2.1.Offline:
xcl shaders <shaders.rpf> --precompile --only cs --pipelines --pipeline-min-kb 256.Then the title (world loading reached by ~75 s each run):
+0x23cf683)The blobs are accepted in the title (0 refused). They don't clear the world load yet, because the programs that stall had not been reached by the precompile when I stopped it; it is running to completion now.
One suggestion: a size filter (I used
--pipeline-min-kb) helps on NVIDIA. Every compute program is otherwise built, and only the ~256 KB+ ones take the driver seconds. #758 / #759's journal of a run's queued pipelines would target this even better.Investigated with AI assistance; all numbers are from runs on my machine.
@mastrr9 on GitHub · 2026-11-24 05:14 UTC · original
Independent native Windows NVIDIA RTX 5080 build/test run and code review at head
07c535d85dbf084ed6692cbd851744986483e6f3.Code Review
xcl shaders --precompile --pipelinesinto the runtimedriver_cache(<DXIL cache>\driver\) and hardensdriver_cache::writewith uniquecreate_new(true)staging files (tmp<pid>-<counter>) so overlapping writers and leftover staging files cannot corrupt published.psoblobs.invalid cached pipeline) and cross-process reuse cleanly.Tested
617.42/32.0.16.1742), Windows 11 Pro 25H2 (26200.9974),rustc 1.100.0 (0ef1bc386 2026-11-09), DXC from Windows SDK10.0.26100.0, debug build.cargo build --workspace && cargo test --workspace -- --test-threads=4ok):hle::d3d12x::real::driver_cache::tests::an_overlapping_writer_cannot_modify_the_published_blobhle::d3d12x::real::driver_cache::tests::an_abandoned_staging_file_is_skipped_and_preservedoffline_compute_pipeline_is_reused_by_a_second_process(tests/gpu_compute_e2e.rs, executed on RTX 5080, not skipped)gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64)gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)Not tested
AI use: Antigravity (Gemini 4 Neon) performed the code review, ran the RTX 5080 workspace tests, and drafted this comment.
@mikkelpetersen on GitHub · 2026-11-24 07:37 UTC · original
@theaustinayers Can we get this merged too? Compiling the pipelines can take hours. Caching the blobs should speed up consecutive runs significantly.
@throny on GitHub · 2026-11-24 11:03 UTC · original
A full
--precompile --only cs --pipelinesof a retail pack with this PR on an RTX 4080: it keeps the blobs as described, but the pass does not get through the pack here. It stops advancing at one point and its memory grows without bound.Tested
stable-x86_64-pc-windows-msvc; release.07c535dmerged ontomain077ce40(clean merge).xcl shaders <shaders.rpf> --precompile --only cs --pipelines(26 503 records; 4 memory windows, split wave64), DXIL and driver caches of the title's earlier runs present (369 driver blobs).XCL_DXC_THREADS/XCL_PIPELINE_THREADSmain(107–118 s), with two compute pipelines built in a bind for the first time (9.7 s and 15.6 s). Whether those two are programs the pass had not reached or ones it built in another form, I have not determined.Not tested
--only cswith a size filter; AMD.AI use
@larelgit on GitHub · 2026-11-24 12:28 UTC · original
On the newer retail title's shader pack (RTX 5080): the blobs are kept and taken back as described, but a full
--pipelinespass stops once the driver reaches the pack's biggest programs, as @throny saw on the RTX 4080. Stack samples of the stalled pass and a size cap that gets past it are below.Tested
main6efdabc+ this PR (07c535d, clean merge) + a local change that only deepens XCL's thread dumps. DXIL cache warm (all 2 689 compute programs of the pack precompiled earlier), 175 driver blobs from earlier title runs. For 2 and 3 also #902 (8427ced; one conflict inreal.rsdriver_cache, both sides kept, its 6driver_cachetests pass) and the local cap below.1. Full pass:
xcl shaders <shaders.rpf> --precompile --only cs --pipelines(XCL_PIPELINE_THREADSunset = 4)nvgpucomp64.dll→RtlAllocateHeap/RtlReAllocateHeap/RtlFreeHeap→RtlEnterCriticalSection, waiting. The other 9 workers waited inPipelines::makefor a compile slot. No thread was running. In the second sample, two of the four were in a different heap call, so the lock still changed hands, slowly.2. Pass with the biggest programs left out (a local 6-line filter,
XCL_PIPELINE_MAX_KB=1024, not part of this PR;XCL_PIPELINE_THREADS=2)3. The title on the cache from pass 2 (
XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_PSO_WAIT_MS=50, one run each)6efdabc(+ deeper dumps)+0x23cf683at 177 sNot tested
driver_cacheunit tests: 6 passed, with #902 also merged locally).XCL_PIPELINE_THREADS=1; pass 2 to the end of the pack; which of the big programs the first pass was stuck on (the CLI does not name it).AI use: Claude Code (Claude Opus 5.5) ran the passes and the title runs, sampled the stacks and wrote this report. Counts, sizes and XCL's own function names only.
@ivall on GitHub · 2026-11-24 13:31 UTC · original
Merged (with #714's commit under it) in
6cef69f– thanks, and thanks to everyone who tested it. It closes a gap in the runtime: without a kept blob a big pipeline counts as not built, and its background build waits for the slot and the commit for big builds even when the driver already has the code.Tested on the tree that went to
main(this PR and three commits on pipeline and shader compiles):cargo test --workspace --no-fail-fast -- --test-threads=4: 749 passed, 0 failed, 41 ignored, no SKIPPED; a retail title, 50 s at its menu without input: exit 0, no crash, no device removal.Not tested: a full
--precompile --pipelinespass over a retail pack with the PR. The stalls reported above are at the pack's few programs of 5 MB of DXIL and more; a size limit for that pass would be a welcome follow-up.@pr1sm-dev on GitHub · 2026-11-24 14:02 UTC · original
Test report: blobs written by
xcl shaders --pipelinesare refused by the title when it passes a non-zero NodeMaskTested
07c535dcherry-picked onto main6efdabc, with other open PRs applied (#688, #793, #1045, #1123) and local changes. Linux, Wine 11.22, vkd3d-proton master 30b0eb9b, RTX 3070 8 GB (driver 595.91.07), Ryzen 7 5800X, a retail title.What happens. After a precompile pass the title creates the same compute pipelines again. XCL logs
a driver blob kept on disk was refusedand removes the files (1,034 → 762 during one run). Compute pipelines made from blob files fell from 132 in a run before the pass to 15 in the run after it, because the tool had also replaced blobs the title had written itself.Cause. With
VKD3D_DEBUG=warn, vkd3d-proton reportsd3d12_cached_pipeline_state_validate: PSO compatibility hash mismatch. For a compute pipeline that hash covers onlynode_maskandflags(libs/vkd3d/cache.c). The title'sD3D12_COMPUTE_PIPELINE_STATE_DESChasNodeMask = 1;Pipelines::makeleaves it at 0. The blob file name covers the DXIL andFlags, so both forms share one file and each side refuses the other's.Check. Blob folder emptied, the tool alone run for 150 s (273 blobs), then two 25 s runs of the title on exactly those files:
translated_compute_psocreates the pipeline withNodeMask = 0So setting the mask to 0 on the title's side (one adapter) makes the tool's blobs usable here. Not tried: having the tool use the title's mask, or putting the mask into the file name.
Not tested. Windows, AMD, graphics pipelines, a native D3D12 driver (the check above is vkd3d-proton's; I do not know whether Windows drivers compare the mask), and a full run after a complete pass with the change.
Written with Claude Code (Claude Fable 5.2); the runs and logs are from the machine above.
@pr1sm-dev on GitHub · 2026-11-24 14:23 UTC · original
Test report (Linux, vkd3d-proton): blobs written by
xcl shaders --pipelinesare refused by the title when it passes a non-zero NodeMaskLinux, Wine 11.22, vkd3d-proton master 30b0eb9b, RTX 3070 8 GB (driver 595.91.07), Ryzen 7 5800X, a retail title. Seen first on main
6efdabcwith this PR and other open PRs applied; then checked on unmodified main930e8b4(which has this PR).What happens. After a precompile pass the title creates the same compute pipelines again. XCL logs
a driver blob kept on disk was refusedand removes the files. On the earlier tree that was 1,034 → 762 files during one run, and compute pipelines made from blob files fell from 132 in a run before the pass to 15 in the run after it, because the tool had also replaced blobs the title had written itself.Cause. With
VKD3D_DEBUG=warn, vkd3d-proton reportsd3d12_cached_pipeline_state_validate: PSO compatibility hash mismatch. For a compute pipeline that hash covers onlynode_maskandflags(libs/vkd3d/cache.c). The title'sD3D12_COMPUTE_PIPELINE_STATE_DESChasNodeMask = 1;Pipelines::makeleaves it at 0. The blob file name covers the DXIL andFlags, so both forms share one file and each side refuses the other's.Check on unmodified main
930e8b4. Empty scratch cache (XCL_DXIL_CACHE). The title ran 100 s and built 8 compute pipelines; its blobs were removed andxcl shaders <those 8 programs> --precompile --pipelines --only cswrote 8 blobs; then the title ran 100 s again on those files, once with each build:930e8b4930e8b4+copy.NodeMask = 0;intranslated_compute_psoThe same on the earlier tree with 273 tool-written blobs and 25 s runs: 157 mismatches and 0 pipelines from blobs without the change, 0 mismatches and 158 from blobs with it.
So setting the mask to 0 on the title's side (one adapter) makes the tool's blobs usable here. Not tried: having the tool use the title's mask, or putting the mask into the file name.
Not tested. Windows, AMD, graphics pipelines, and a full run after a complete pass with the change. The check that refuses the blobs is vkd3d-proton's: @burber's run above on the native NVIDIA driver had the title accept the tool's blobs (0 refused), so this looks specific to Wine / vkd3d-proton.
Written with Claude Code (Claude Fable 5.2); the runs and logs are from the machine above.
@ArturoWolff on GitHub · 2026-11-24 14:22 UTC · original · edited 2026-11-24 16:51 UTC
Linux / RTX 4060 positive control for the NodeMask report above: with default
NodeMask = 0and flags 0, a fresh D3D12.X runtime process accepted an offline-created compute pipeline above the 256 KiB threshold, dispatched it, and produced the expected output. I did not test mask 1; this does not contradict the RTX 3070 retail result.Clean main
930e8b49c1c2ec683d22c724a398b39111cd0e56; Ryzen 5 5600, RTX 4060 8 GB, NVIDIA 620.73.04, GE-Proton11-14 with patched vkd3d-proton 3.1.0, DXC 1.9.2609.5. Stock CLI and runtime library; test-only synthetic shader and hook harness, no title data.xcl.exe shaders input --precompile --only cs --windows 4 --split 1 --pipelines, one shader and one worker. DXIL container 286,200 B, executable bitcode 283,768 B, separate driver blob 112 B. Cold CLI: 1 made, 0 refused, 0 loaded from driver cache. Fresh warm CLI: 1 made, 0 refused, 1 loaded.CreateComputePipelineStatehook reported 1 on-disk hit, then dispatched the same input. 1,536/1,536 GPU readback words matched the CPU calculation, including the cross-wave shared-memory values. Exact hook test:console_wave64_compute_through_the_pso_hook_dispatch_and_read_back --exact --nocapture --test-threads=1, 1 passed / 0 failed / 0 ignored / 0 skipped / 1 filtered. The input, DXIL and blob hashes matched across the processes.This demonstrates acceptance and correct execution for this configuration, not a speedup, lower-layer cache independence, or retail progress. No native Windows or full-suite run. AI use: Hermes Agent, gpt-6.2-astra, extended the fixture, ran the tests and checked the logs.
Follow-up: accepted blob vs actual driver reuse. Following the RTX 3070 and 5070 Ti reports, I decoded the original 112-byte blob above against this vkd3d-proton build's
cache.c: a 48-byte header, one 8-byte chunk header and 56 bytes of PSO compatibility data. No SPIR-V or Vulkan pipeline-cache payload. The earlier hook result still establishes acceptance + correct dispatch, not avoided compilation.Same RTX 4060, same
930e8b49c1c2ec683d22c724a398b39111cd0e56CLI, same synthetic fixture and byte-identical 286,200-byte DXIL.xcl.exe shaders input --precompile --only cs --windows 4 --split 1 --pipelines, withXCL_PSO_DISK_CACHE=1,VKD3D_SHADER_CACHE_PATH=0,__GL_SHADER_DISK_CACHE=0andpipeline_library_log. Two fresh Wine processes / working directories, one pipeline each, zero refusals. The cold process wrote an 854,728-byte blob containing both a 173,054-byte pipeline-cache chunk and a 681,497-byte encoded SPIR-V chunk; Vulkan feedback reported no reuse, 8.03 s. The restore kept that blob and the same DXIL; vkd3d logged SPIR-V recovered from the cached PSO and Vulkan pipeline-cache reuse. XCL reported 9.2 s / 2.0 s for the whole CLI pass (one pair, not isolated driver timings). No retail run, new hook readback, full suite or native Windows test in this follow-up. No production code change. AI use: Hermes Agent (gpt-6.2-astra) ran the experiment, inspected the records and wrote this update.@NAbobo101 on GitHub · 2026-11-24 15:53 UTC · original · edited 2026-11-25 02:07 UTC
Test of
07c535d(with #714 under it) merged locally ontomain67a3735(clean merge, treefabf56e), on an 8 GB NVIDIA card with the retail title's whole shader pack. With two driver compiles at a time, the offline pass kept memory flat for two hours, unlike the stalls with growing memory reported above, and every blob it wrote was taken. In two title runs afterwards, about four fifths of the compute pipelines came from those blobs and the load got further than onmain, but neither run reached a visible world.Setup
cargo test --workspace --no-fail-fast -- --test-threads=4onfabf56e(debug): 738 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.Offline pass
XCL_DXC_THREADS=8 XCL_PIPELINE_THREADS=2 xcl shaders shaders.rpf --precompile --only cs --pipelines(release), stopped by me at a two-hour cap:pipelines: 475 made, 0 refused.xcl.exestayed around 1.6 GB.Title runs afterwards (two, with the cache at 817 blobs)
Retail 1.0.2.1, release,
XCL_PSO_WAIT_MS=50,XCL_NETWORK=0 XCL_ACTIVITY=1, menus walked withXCL_PRESS_A_AT=14,17,21,125,131,…,197(as in #505):0x887a0006), 486.6 s+0x23cf683), 423.9 sFor comparison, three runs of
main67a3735with the same settings on this machine ended at the watchdog at 347–396 s. Both runs here went further. In run 1, the loading-screen artwork was still up at 423 s and the title presented at 29 fps until about 430 s, while in themainruns the window went black at about 270 s. So the load got further, but neither run reached a visible world: run 1 ended with a blank window and then the device removal, and run 2 at the watchdog. About four fifths of the compute PSOs came from the blobs, but with the 50 ms wait the title still skipped 8955 and 8192 draws and 1024 and 583 dispatches whose pipelines weren't built yet.Not tested
XCL_PIPELINE_THREADS.AI use
Edit: corrected two counts. The blob column now counts only programs built from a blob (an earlier version also counted the log lines about blobs being saved), and the last column now gives the skipped draws and dispatches; an earlier "still building" column was miscounted.