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

Manually merged
github merged 1 commit from gh-pr/636/head into gh-pr/636/base 2026-11-26 04:28:02 +00:00
Owner

@⁠ofc0urse on GitHub · 2026-11-24 02:45 UTC · original
ofc0urse:perf/compute-pso-driver-blob → main · +100 −3 · 1 files · 1 commits · merged 2026-11-24 02:49 UTC

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

**@⁠ofc0urse** on GitHub · 2026-11-24 02:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/636) `ofc0urse:perf/compute-pso-driver-blob` → `main` · +100 −3 · 1 files · 1 commits · merged 2026-11-24 02:49 UTC 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](https://claude.com/claude-code)
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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:28:01 +00:00
github manually merged commit b9f3d0f3a7 into gh-pr/636/base 2026-11-26 04:28:02 +00:00
Author
Owner

@⁠MesshM on GitHub · 2026-11-24 02:55 UTC · original

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.

**@⁠MesshM** on GitHub · 2026-11-24 02:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/636#issuecomment-7120599812) 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.
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-24 02:58 UTC · original

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.

**@⁠thehollowedone** on GitHub · 2026-11-24 02:58 UTC · [original](https://github.com/xcl-dev/xcl/pull/636#issuecomment-7120651134) **Tested** Confirmed a same-process D3D12 driver blob hit on merge [`dd2ae9a`](https://github.com/ivall/xcl/commit/dd2ae9a70af5eb5aad60f02d86e386b72abe1e95). 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.