Repository navigation
Shaders: save offline compute pipelines to the runtime driver cache - #744
Conversation
The per-process staging pathname was shared by concurrent writes of one key. A writer paused after opening it could resume after another writer renamed that file into the cache, changing successfully published bytes through its older handle. Create an exclusive sibling file for each invocation using the process ID and an atomic sequence. Skip occupied names left by an earlier process and clean up only a staging file this invocation actually created. A deterministic Windows regression holding the real staging helper's open handle fails with the old writer and passes with this change. Focused Cargo writer tests: 4 passed, 0 failed, 0 ignored. Full GPU suite and retail smoke have not been run for this commit. Assisted-by: Codex (GPT-6, exact variant not exposed)
An offline build created compute pipelines but dropped the driver blobs. Save them under the same DXIL and flags key used at runtime. Retry a rejected blob without cached data, and report how many pipelines the driver accepted from disk. Assisted-by: Codex (GPT-6)
|
Verified Tested
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 AI use |
|
Test run of Tested
Review: Keying the file by DXIL and pipeline flags ( Not tested: no retail title or regression run (I have no unpacked game), no Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
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 Setup
Result:
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. |
|
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: Setup: RTX 4070 Ti 12 GB (driver 32.0.16.1062), i5-13600K, Windows 11 26300, DXC 1.8.2502. Offline:
Then the title (world loading reached by ~75 s each run):
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 Investigated with AI assistance; all numbers are from runs on my machine. |
|
Independent native Windows NVIDIA RTX 5080 build/test run and code review at head Code Review
Tested
Not tested
AI use: Antigravity (Gemini 4 Neon) performed the code review, ran the RTX 5080 workspace tests, and drafted this comment. |
|
@theaustinayers Can we get this merged too? Compiling the pipelines can take hours. Caching the blobs should speed up consecutive runs significantly. |
|
A full Tested
Not tested
AI use
|
|
On the newer retail title's shader pack (RTX 5080): the blobs are kept and taken back as described, but a full Tested
1. Full pass:
2. Pass with the biggest programs left out (a local 6-line filter,
3. The title on the cache from pass 2 (
Not tested
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. |
|
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 Not tested: a full |
|
Test report: blobs written by Tested 07c535d cherry-picked onto main 6efdabc, 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 Cause. With 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:
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, 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. |
|
Linux / RTX 4060 positive control for the NodeMask report above: with default Clean main
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 Same RTX 4060, same |
|
Test report (Linux, vkd3d-proton): blobs written by Linux, 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 6efdabc with this PR and other open PRs applied; then checked on unmodified main 930e8b4 (which has this PR). What happens. After a precompile pass the title creates the same compute pipelines again. XCL logs Cause. With Check on unmodified main 930e8b4. Empty scratch cache (
The 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. |
|
Test of Setup
Offline pass
Title runs afterwards (two, with the cache at 817 blobs)
For comparison, three runs of Not tested
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. |
… runtime The precompile pass stopped advancing on the biggest compute programs: their driver compile takes tens of minutes and gigabytes (three of 29-30 MB DXIL hung --precompile --only cs --pipelines for 33+ minutes on three machines, xcl-dev#744). Skip programs whose DXIL is over XCL_PIPELINE_MAX_KB (8 MiB by default; 0 turns the cap off) when no blob exists yet, count them, and report the total; the runtime still builds one when a title needs the pipeline. 8 MiB sits above the largest program that ever completes (~2.2 MB, the optimized class) and below the smallest that hangs (14.1 MB), so the pass now finishes. Part of xcl-dev#1269 (A19). Co-Authored-By: Claude Code <noreply@anthropic.com>
… runtime The precompile pass stopped advancing on the biggest compute programs: their driver compile takes tens of minutes and gigabytes (three of 29-30 MB DXIL hung --precompile --only cs --pipelines for 33+ minutes on three machines, xcl-dev#744). Skip programs whose DXIL is over XCL_PIPELINE_MAX_KB (8 MiB by default; 0 turns the cap off) when no blob exists yet, count them, and report the total; the runtime still builds one when a title needs the pipeline. 8 MiB sits above the largest program that ever completes (~2.2 MB, the optimized class) and below the smallest that hangs (14.1 MB), so the pass now finishes. Part of xcl-dev#1269 (A19). Co-Authored-By: Claude Code <noreply@anthropic.com>
Cap on by default where dxc switches to -O0 (xcl-dev#1269, xcl-dev#744); --max-source-mb 0 turns it off.
…eads The compute warm-up (`xcl shaders --precompile --only cs --pipelines`) sat for 20+ minutes at one record range with ~5 cores busy: each translating thread made its pipeline itself behind a gate of XCL_PIPELINE_THREADS (4), and three retail programs of 13-28 MB DXIL held 3 slots for 15+ CPU-minutes each. The other 13 translating threads each held a finished program waiting for the one slot left, and the DXC pool sat idle. Port of xcl-dev#256 onto the driver cache of xcl-dev#744: - A program whose driver blob is cached is made from it on the translating thread (a cheap create, no slot). The rest go to a queue served by driver threads of their own, XCL_PIPELINE_THREADS or half the logical CPUs. A push never waits: the queue holds the DXIL (a pack's compute programs come to a few GB at most). - Each driver thread takes the biggest waiting program that fits: 8 GB of commit and memory kept free, a compile counted as 1536 bytes per DXIL byte (64 MB - 1.5 GB), 3 GB for one over 8 MB; with nothing running any may go. - At most 2 programs over 8 MB at once, and one thread always left for the rest, so huge programs never hold every driver thread. - A status line every 15 s while compiles run; programs over 60 s are named. Assisted-by: omp (Claude Opus 5.5)
A title whose compute pipeline descriptions carry a node mask did not take the blobs `xcl shaders --precompile --pipelines` keeps for it (xcl-dev#744): the offline pass makes its pipelines with NodeMask 0, the title's are made with the title's mask, and both use one blob file (its name covers the DXIL and Flags). vkd3d-proton refuses a cached blob whose description hash differs ("PSO compatibility hash mismatch"; for a compute pipeline that hash is NodeMask and Flags), so the title refused every blob of the pass, removed the file and compiled the program again - and the pass in turn replaced the blobs the title had kept itself. XCL drives one adapter, where masks 0 and 1 mean the same, so the translated pipeline is made with 0. Measured on main 930e8b4 with a retail title that passes mask 1 (Wine 11.22, vkd3d-proton 30b0eb9b, RTX 3070): of 8 blobs the pass wrote for the programs the title builds in its first 100 s, the title took 0 and removed 8 before, and takes 8 with this change. Test: a_title_pipeline_with_a_node_mask_takes_the_offline_blob runs the offline pass on a program and then makes the same pipeline through the backend hook with NodeMask 1; the pass's blob has to stay as written. Under vkd3d-proton it fails without the change (the blob is removed). Assisted-by: Claude Code (Claude Fable 5.2)
`xcl shaders <pack> --precompile --pipelines` on a retail title's pack stops advancing right after record 22 600, its memory growing (reported on xcl-dev#505 / xcl-dev#744 from three machines, and on this one). The records there are three screen-probe compute programs of 13 - 29 MB of DXIL (88 863 console instructions for the biggest, unrolled). The NVIDIA driver alone had not built the smallest after 14 minutes; in the pass, the compiles queued behind them held up everything after, and the pass printed no name. Programs of GIANT_DXIL (4 MB) or more are now kept aside and made after all the others, one at a time, smallest first, each named with its size before the driver gets it and timed after. Stopping the pass there keeps everything made before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dev#1368) A title whose compute pipeline descriptions carry a node mask did not take the blobs `xcl shaders --precompile --pipelines` keeps for it (xcl-dev#744): the offline pass makes its pipelines with NodeMask 0, the title's are made with the title's mask, and both use one blob file (its name covers the DXIL and Flags). vkd3d-proton refuses a cached blob whose description hash differs ("PSO compatibility hash mismatch"; for a compute pipeline that hash is NodeMask and Flags), so the title refused every blob of the pass, removed the file and compiled the program again - and the pass in turn replaced the blobs the title had kept itself. XCL drives one adapter, where masks 0 and 1 mean the same, so the translated pipeline is made with 0. Measured on main 930e8b4 with a retail title that passes mask 1 (Wine 11.22, vkd3d-proton 30b0eb9b, RTX 3070): of 8 blobs the pass wrote for the programs the title builds in its first 100 s, the title took 0 and removed 8 before, and takes 8 with this change. Test: a_title_pipeline_with_a_node_mask_takes_the_offline_blob runs the offline pass on a program and then makes the same pipeline through the backend hook with NodeMask 1; the pass's blob has to stay as written. Under vkd3d-proton it fails without the change (the blob is removed). Assisted-by: Claude Code (Claude Fable 5.2)
Cap on by default where dxc switches to -O0 (xcl-dev#1269, xcl-dev#744); --max-source-mb 0 turns it off.
Stacked 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.