Skip to content

D3D12.X: the driver's compile of a compute pipeline is kept on disk - #634

Merged
theaustinayers merged 1 commit into
xcl-dev:mainfrom
theaustinayers:driver-pso-cache
Nov 24, 2026
Merged

theaustinayers merged 1 commit into
xcl-dev:mainfrom
theaustinayers:driver-pso-cache

Conversation

@theaustinayers

@theaustinayers theaustinayers commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Rebased onto #636, which this now builds on. #636 keeps the driver's blob of a translated compute program in memory: its second build in one run is made from it. The first build of every run still goes through the driver's compiler. On an NVIDIA GPU that is seconds for each of a retail title's larger compute programs when its world loads (5 – 27 s each measured here, up to 0.5 MB of DXIL): the title dispatches without them meanwhile and is ended by its watchdog before all are built, so the next run starts the same compiles again. This writes those blobs to disk and reads them in the next run.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs, mod driver_cache: the file name (fnv64 of the DXIL, its length and the flags, in <DXIL cache>\driver\), reading a kept blob, writing one under a temporary name first, dropping one the driver refused, and the log lines (powers of two).
  • translated_compute_pso: when D3D12.X: a translated compute program built again gets the driver's blob of its first build #636's compute_blob has none, the blob kept on disk is passed as CachedPSO; refused (another driver, adapter or root signature), the file is removed and the program compiled as before. After a build without a blob, what keep_compute_blob kept is also written to disk when the build took 250 ms or longer. XCL_PSO_DISK_CACHE=0 turns it off.
  • Two unit tests: the file name follows the DXIL and the flags; a blob of a build of milliseconds is not kept, a kept one is read back, no temporary file is left, a refused one is removed.

Tested

  • RTX 5090 (driver 621.14), Ryzen 9 9950X3D, 128 GB, Windows 11 build 26300, rustc 1.100.0.
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4: 692 passed, 0 failed, 41 ignored.
  • SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • A retail title, release build of this commit (9182f27), two runs that went on into its world (with input, so not the smoke runs below). The first wrote blobs to disk, among them programs of 498724 B of DXIL built in 17000 ms, 363096 B in 5034 ms and 300756 B in 3162 ms. In the second, those three were made from the files in 8 ms, 5 ms and 6 ms. One program of 363096 B was compiled in 5402 ms in the second run (another program of that size, or other flags: not looked into). No blob was refused. Both runs still end in the title's world as main does (its watchdog, ~100 s in); this PR does not change that by itself.

Regression run

main:
```
xcl-smoke v1
commit: dd2ae9a
gpu: NVIDIA GeForce RTX 5090
title: NYCMain
seconds: 60
exit: 0x0
frames shown: 1611 (PresentX 1611)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14482 MB


this PR:
```
xcl-smoke v1
commit: 9182f275c0464942cc51fca52dc2a475d931b918
gpu: NVIDIA GeForce RTX 5090
title: NYCMain
seconds: 60
exit: 0x0
frames shown: 1615 (PresentX 1615)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14492 MB

Not tested

  • The smoke runs stay at the title's first menu (no input): no compute build takes 250 ms there, so they are a regression check only and do not reach the new path.
  • A refused blob on real hardware (a driver update or another adapter): covered by the unit test of note, not by a driver refusing one.
  • AMD and Intel GPUs. Graphics and mesh pipelines are not kept (compute only).
  • How much disk a whole playthrough uses: 13 files after these two runs to the start of the title's world (0.3 – 0.65 MB each).

AI use

  • Claude Code, Claude Fable 5.2: wrote the change, the tests and this description, and ran the builds, tests and runs above on the hardware named.

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of aab678916f8b6a0c77825b4d84913dea89e23061 on AMD RDNA4; the PR was tested on NVIDIA only. I merged it onto current main 18c105a locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 691 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 651 passed, 0 failed, 21 ignored
  • 0 SKIPPED; a_file_is_named_after_its_dxil and a_kept_blob_is_read_back_and_a_refused_one_is_dropped pass. No program here took 250 ms to build, so no blob was written and the disk path was not exercised.

Review: A refused blob is deleted and the pipeline built as before, inside BIG_COMPILES / wait_for_commit as now; the file is written under a temporary name and renamed, so a cut-short run leaves no half file. Two points: (1) the file is keyed by the DXIL alone. CachedPSO has to match the whole description, root signature and flags included, so if one DXIL is ever built with two root signatures (or under two adapters with XCL_ADAPTER), each build makes the driver refuse the other's blob, deletes it and writes its own: a miss every time instead of a hit. #636 keys by DXIL hash, root signature and flags. (2) Overlap with #636, which edits the same lines of translated_compute_pso for the in-memory version of the same idea; they will conflict.

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 onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

xcl-dev#636 keeps the driver's blob of a translated compute program in memory:
its second build in one run is made from it. The first build of every
run still goes through the driver's compiler. On an NVIDIA GPU (RTX
5090) that is 5 - 27 s for each of a retail title's larger compute
programs when its world loads: the title dispatches without them
meanwhile and is ended by its watchdog before all are built, so the
next run starts the same compiles again.

A blob whose build took 250 ms or longer is also written to the DXIL
cache directory (driver\, under the hash of the DXIL and the flags),
and a build that finds none in memory reads it from there. A blob the
driver refuses (another driver, adapter or root signature) is dropped
and the program compiled as before. XCL_PSO_DISK_CACHE=0 turns it off.

Assisted-by: Claude Code (Claude Fable 5.2)
@alpz1000

Copy link
Copy Markdown

Independent real-driver cache check on RTX 3060 12 GB, driver 610.88 (32.0.16.1088), i5-8400, Windows 11 Home 26200.9974, Rust 1.100.0 x86_64-pc-windows-msvc, SDK DXC 1.9.2602.17, debug.

Tested: unmodified aab678916f8b6a0c77825b4d84913dea89e23061 passed both driver_cache unit tests. Then I temporarily lowered only the save threshold from 250 ms to 0 ms so the bundled shader (1 ms here) would use the save path. With a fresh XCL_DXIL_CACHE, three separate processes ran cargo test --locked -p xcl --test gpu_compute_e2e console_wave64_compute_through_the_pso_hook_dispatch_and_read_back -- --exact --nocapture:

Run Observed
Cold, cache on Saved one 3,486-byte driver blob, GPU output check passed
Warm, same cache Driver accepted the saved blob, file timestamp stayed unchanged, GPU output check passed
Warm, XCL_PSO_DISK_CACHE=0 No driver-cache hit or save message, GPU output check passed

No skips. All three used the real RTX 3060 backend. The temporary threshold edit was reverted.

Not tested: default 250 ms save path on a long compile, real-driver rejection of a stale blob, full suite, or retail loading. This checks saving and reuse with a synthetic shader, with no speedup claim.

AI use: OpenAI Codex (GPT-6) ran the local checks and drafted this report.

@CryingLaughing

Copy link
Copy Markdown

Tested

  • Rebased head 9182f275c0464942cc51fca52dc2a475d931b918 with a scratch-only extension of gpu_compute_e2e.rs. NVIDIA GeForce RTX 4080, driver 621.01, Intel Core i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC x64, DXC 1.8.2502.11, debug. XCL_ADAPTER=4080, XCL_REQUIRE_GPU=1, XCL_ASYNC_PSO=0, XCL_PSO_DISK_CACHE=1, all XCL_SAMPLE_* variables unset.
  • cargo test -p xcl --test gpu_compute_e2e --locked -j 4 translated_compute_disk_cache_accepts_matching_and_rebuilds_rejected_blob -- --show-output --test-threads=1 passed 1/1 with zero skips. The fixture used its own cache directory. The target shader was 5,164 bytes of DXIL, below the 16 KiB in-memory retention threshold, and its disk key used pipeline flags 0x0.
  • The driver's original CreateComputePipelineState accepted the target program's 3,386-byte blob and refused the 1,450-byte blob from a different valid synthetic program on the same device with 0x80070057 (E_INVALIDARG). Both blobs came from GetCachedBlob.
  • With no blob, the XCL hook built a pipeline and all 1,536 output words matched. With the matching blob placed at the lookup path, XCL logged a cache hit, retained the file, and matched all 1,536 words. With the wrong-program blob at the same path, XCL logged refusal, removed the file, rebuilt the pipeline, and again matched all 1,536 words.
  • The pre-rebase head aab678916f8b6a0c77825b4d84913dea89e23061 also passed 1/1 with the same native rejection HRESULT and three matching readbacks, using that revision's disk key.

Not tested

  • Restart-to-restart performance, the slow-build write threshold, other adapters, the full workspace suite on this head, release builds, and retail titles. The scratch fixture seeded each driver file explicitly.

AI use

  • OpenAI Codex (GPT-6 family, exact variant unavailable) prepared the synthetic control, ran the test, and drafted the report.

@theaustinayers
theaustinayers merged commit 63cdc25 into xcl-dev:main Nov 24, 2026
4 checks passed
@thehollowedone

Copy link
Copy Markdown

Tested

On merge 63cdc25, a synthetic 155,996-byte translated compute shader crossed the stock 250 ms save threshold. The first process built it in 881 ms and left one 220,810-byte .pso file. A fresh process used that file, confirmed by XCL's kept on disk log, and built the PSO in 13 ms. A third process with XCL_PSO_DISK_CACHE=0 built it in 15 ms without a disk hit. Both later runs left the file unchanged. The cache-off control was also fast, so this verifies reuse without isolating a speedup.

All three dispatches matched 2,459,136 expected words each. A scratch extension to gpu_compute_e2e enlarged the shader and readback. XCL runtime code was stock. Each process completed cargo test --offline --locked -p xcl --test gpu_compute_e2e console_wave64_compute_through_the_pso_hook_dispatch_and_read_back -- --exact --nocapture --test-threads=1 with 1 pass, 0 failures, no runtime skips, and no D3D12 debug-layer errors. I used a fresh temporary DXIL cache for the first run and reused it for the controls, with XCL_ASYNC_PSO=0.

RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, Windows 11 build 26300, DXC 1.8.2502.11, Rust 1.99.1 MSVC, debug.

Not tested

Driver rejection, async builds, and retail behavior.

AI use

Codex with GPT-6.2 Sol adapted the scratch fixture, ran the tests, and drafted the report.

@MonkeyPython

Copy link
Copy Markdown

NVIDIA / wave32 retail data point: the on-disk driver-blob cache works across runs on an RTX 3080 Ti with GTA VI (Series 1.0.2.1).

Setup: Windows 11 Pro 26300, Ryzen 7 7800X3D, 32 GB, RTX 3080 Ti 12 GB (driver 621.01), main 91f9a5e (includes this PR), release, XCL_NETWORK=0 + firewall, scripted menu walk into loading (XCL_PRESS_AT).

Suite at this commit: 692 passed / 0 failed / 41 ignored, 2 internal SKIPPED (wave64 pair).

Run pair (150 s cap each):

  • Run 1: 1 / 2 / 4 / 8 driver blobs kept on disk for the next run (this one: 1035–2989 ms, 224–282 KB); 13 blob files appear under %LOCALAPPDATA%\xcl\dxil\driver\.
  • Run 2 (fresh process): 1 / 2 / 4 compute pipelines made from the driver's blob of an earlier run (kept on disk) — the second run reads what the first kept, on NVIDIA.

Both runs still end in the pre-existing #232 null write (113 s / 102 s); the cache neither causes nor prevents it.

Not tested: AMD/Intel, cache invalidation on driver change, other titles.

AI use: Gentle Shell (Pi coding agent), model qwen4-max: ran the suite and the run pair and wrote this report from the logs; a human reviews it before posting. No code changes.

theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 24, 2026
…l#486, ivall#574, ivall#602, ivall#634, ivall#636

Upstream's texture detiling and uploads replace the fork's (ivall#440 and the threaded detile); its disk cache of driver blobs (ivall#634) replaces the fork's first version.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 24, 2026
The page opened with the title and a paragraph; what a reader looks for
first (which games, how to build, where to ask) was a scroll away, and
the environment switches a user needs were spread over the text or only
in HANDOFF.md.

- a centred header: tagline, badges (Discord, CI, licence, platform),
  and links to the page's sections
- how XCL works as three rows (native code, console libraries, shaders)
- "Switches for a run": the eight variables a user is most likely to
  set, each checked against the code on main
- the Pipelines row names what main has since ivall#634 / ivall#636 / ivall#690

No statement about what works was changed. The test count (ivall#485) and a
Contributing section (ivall#453) are left to their open pull requests.

Assisted-by: Claude Code (Claude Fable 5.2)
burber added a commit to burber/xcl that referenced this pull request Nov 24, 2026
…; --pipeline-min-kb

The driver's compiled form of each compute pipeline the precompile builds is written where a
title's compute pipeline looks first (real::driver_cache, xcl-dev#634), under the same DXIL + flags
name. Programs already kept are skipped, so a long run resumes. --pipeline-min-kb N builds only
programs of at least N KB of DXIL (the slow driver compiles).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants