Skip to content

D3D12.X: a translated compute program built again gets the driver's blob of its first build - #636

Merged
Mavixot merged 1 commit into
xcl-dev:mainfrom
ofc0urse:perf/compute-pso-driver-blob
Nov 24, 2026
Merged

Mavixot merged 1 commit into
xcl-dev:mainfrom
ofc0urse:perf/compute-pso-driver-blob

Conversation

@ofc0urse

@ofc0urse ofc0urse commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Part of #505. A retail title creates some of its big compute pipelines more than once while it loads its world (the "built once or twice" in #505). Each creation went through the driver's compiler again, with the title's thread waiting. On an RTX 4060 Ti, 14 programs of 105 – 222 KB of DXIL were each built twice: 3 – 6 s the first time, 13 – 30 s the second.

After a translated compute PSO of 16 KB of DXIL or more is built, its GetCachedBlob is kept in memory, keyed by the DXIL's hash, the root signature and the flags (512 MB in all at most). When the same program is built again, the blob goes in as CachedPSO. A blob the driver does not take is dropped and the program is compiled as before. Programs under 16 KB are not kept: the driver builds them in milliseconds.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: translated_compute_pso looks the program up (compute_blob), passes the blob as CachedPSO, falls back to a plain build when the driver refuses it (forget_compute_blob), and keeps the blob of a new build (keep_compute_blob, the adopted PSO's PC GetCachedBlob through orig_fn). A program waiting for a blob does not take a BIG_COMPILES slot. The PSO's log line now gives the build time and says when a blob was used.
  • Unit test a_blob_is_found_only_for_the_same_program_root_signature_and_flags_and_is_forgotten.

Tested

  • NVIDIA GeForce RTX 4060 Ti 8 GB (driver 621.24), Intel Core i5-14400F, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0. Tests in debug, runs in release.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 on b9f3d0f: 681 passed, 0 failed, 41 ignored. SKIPPED on this adapter (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • Retail title into its world loading, a local build with this change (and other local changes, including a BCPack decoder and the title's watchdog thread parked so the run goes past +0x23cf683): programs built a second time took 105004 B DXIL, 2 ms, the driver's blob of an earlier build and 31940 B DXIL, 0 ms, … where the same programs had taken 13 – 30 s the second time in the run before. No blob was refused by the driver.

Regression run
The 60 s run does not reach the world, where the title builds programs a second time, so these show the change does no harm early on; the first run of the PR head showed 1019 frames (its last 6 s at 5 fps), a second run 1417, the block below.

xcl-smoke v1
commit: 508a0c74d7c0625d6d2de8d24494e69dc2e1926f
gpu: NVIDIA GeForce RTX 4060 Ti
title: 83d1f0b1
seconds: 60
exit: 0x0
frames shown: 1408 (PresentX 1408)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14577 MB
xcl-smoke v1
commit: b9f3d0f3a7d717dcb17229ccac0d0a777bba83fd
gpu: NVIDIA GeForce RTX 4060 Ti
title: 83d1f0b1
seconds: 60
exit: 0x0
frames shown: 1417 (PresentX 1417)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14522 MB

Not tested

  • AMD GPUs and their drivers' GetCachedBlob / CachedPSO.
  • A GPU test that builds a translated compute PSO twice and checks the second build used the blob: the unit test covers the key and the bookkeeping only.
  • The world run above was on a local build with other changes, not on this branch alone.

AI use

  • Claude Code with Claude Opus 5.5: found the repeated builds in the logs, wrote the change, the test, the commit message and this description, ran the tests and the smoke runs. I checked the results on my machine.

🤖 Generated with Claude Code

…lob of its first build

A retail title creates some of its big compute pipelines more than once while loading (14 programs
of 105 - 222 KB DXIL, each twice). Every creation went through the driver's compiler again: 3 - 6 s
the first time, 13 - 30 s the second, with the title's thread waiting. After a translated compute
PSO of 16 KB of DXIL or more is built, its GetCachedBlob is kept (by DXIL hash, root signature and
flags; 512 MB at most) and passed as CachedPSO when the same program is built again. A blob the
driver does not take is dropped and the program is compiled as before. The PSO log line now says
how long the build took and whether a blob was used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mavixot
Mavixot merged commit dd2ae9a into xcl-dev:main Nov 24, 2026
1 check passed
@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of b9f3d0f3a7d717dcb17229ccac0d0a777bba83fd 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: 690 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 650 passed, 0 failed, 21 ignored
  • 0 SKIPPED; a_blob_is_found_only_for_the_same_program_root_signature_and_flags_and_is_forgotten passes. Nothing on this machine builds the same big compute program twice, so the reuse path itself was not exercised here.

Review: A refused blob is forgotten and the program compiled as before, and a reused build skips the BIG_COMPILES slot, which is right since no compile happens. Overlap with #634: both keep GetCachedBlob of translated compute PSOs and both edit translated_compute_pso around finish_pso, so they will conflict. This one keeps blobs in memory for the run, keyed by DXIL hash, root signature and flags; #634 keeps them on disk between runs, keyed by the DXIL alone. They could be one change (disk-backed, with this PR's fuller key), or stacked.

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.

@thehollowedone

Copy link
Copy Markdown

Tested

Confirmed a same-process D3D12 driver blob hit on merge dd2ae9a. I extended gpu_compute_e2e in a scratch copy with 320 additional output regions and built and dispatched the same synthetic shader twice through the stock XCL pipeline hook. With XCL_ASYNC_PSO=0, the translated shader was 31,916 bytes of DXIL. XCL logged the first build at 121 ms and the second at 39 ms with the driver's blob of an earlier build. Those timings are from one pair.

Both dispatches matched all 493,056 expected 32-bit values. The focused test passed (1 passed, 0 failed, no runtime skip). The D3D12 debug layer logged no errors and reported live objects at process exit.

Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, DXC 1.8.2502.11, Rust 1.99.1 MSVC, debug. Command 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.

Not tested

Async pipeline scheduling, blob rejection, AMD, and retail behavior.

AI use

Codex with GPT-6.2 Sol adapted the test, ran it, and drafted this report.

burber added a commit to burber/xcl that referenced this pull request Nov 24, 2026
…iver blob reuse, in-place detiling)

Conflict in bind.rs execute_indirect: upstream's skip of a still-building pipeline kept; with
xcl-dev#533 / xcl-dev#267 the bounded wait hands it the stand-in, which is then skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 24, 2026
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)
burber added a commit to burber/xcl that referenced this pull request Nov 24, 2026
…ner, then a stack overflow at 118 s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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)
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.

4 participants