Skip to content

Shaders: prebuild split compute dispatch-chain pieces under --pipelines - #2338

Open
ChalanaGimhanaX wants to merge 1 commit into
xcl-dev:mainfrom
ChalanaGimhanaX:shaders/precompile-dispatch-chain
Open

ChalanaGimhanaX wants to merge 1 commit into
xcl-dev:mainfrom
ChalanaGimhanaX:shaders/precompile-dispatch-chain

Conversation

@ChalanaGimhanaX

Copy link
Copy Markdown

Follow-up to #2080 (Part of #1833, Part of #2088): xcl shaders --precompile --pipelines now prebuilds and caches every piece of a split direct-DXIL compute program (.chain.pso) under dispatch_chain_root_signature, instead of compiling the unused unsplit whole container under abi_root_signature_with (.pso).

When direct DXIL translation splits a large compute program into a DispatchChain (under XCL_DIRECT_DXIL=1, or automatically for enormous compute shaders on default settings), the runtime (dispatch_chain::build) builds each piece with dispatch_chain_root_signature and looks up <hash>-<len>-<flags>.chain.pso on disk; even the lazy Chain::whole() fallback uses chained = true (.chain.pso). Previously, Pipelines::make ignored Compiled::dispatch_chain and compiled only c.dxil to <whole>.pso, leaving 0 .chain.pso blobs for the runtime and hitting the slow unsplit compile (or XCL_PIPELINE_MAX_KB cap) offline. On a local retail shader pack (XCL_DIRECT_DXIL=1, wave32), 744 of 2,080 translated compute programs split into 7,100 pieces.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: add driver_cache::name_for and driver_cache::path_for so real::compute_container and offline precompile share the exact .pso / .chain.pso naming; extend driver_cache::tests::a_file_is_named_after_its_dxil_and_flags.
  • crates/xcl/src/shaders.rs: key Pipelines::signatures by (chained, samplers) using pso::dispatch_chain_root_signature for chained pieces; update Pipelines::make_with_cache_path / make_one to build and cache each piece of a split DispatchChain (pieces.len() >= 2) as .chain.pso across up to XCL_PIPELINE_THREADS workers with per-piece XCL_PIPELINE_MAX_KB capping; print split compute programs: N (M pieces) when non-zero; add GPU test split_compute_program_prebuilds_and_caches_chain_pieces (compiles space2 pieces that only dispatch_chain_root_signature accepts, verifies .chain.pso write/reuse, runtime CreateComputePipelineState acceptance, and per-piece cap enforcement).
  • crates/xcl/tests/gpu_compute_e2e.rs: add offline_split_compute_pipeline_is_reused_by_a_second_process exercising xcl shaders --precompile --pipelines end-to-end on a synthetic wave32 multi-block console CS container (XCL_DIRECT_DXIL=1, XCL_DIRECT_SPLIT_INSTRUCTIONS=12), verifying only .chain.pso blobs are written, warm reuse across processes, and recovery from a corrupted .chain.pso.

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.1714, wave32 only), Intel Core i5-10400F, 15.9 GB RAM, Windows 11 Pro Build 26200, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.8.2502.11 (Windows SDK 10.0.26100.0); debug for tests, release for precompile timing and smoke runs.
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4) on commit 2228be7: 1274 passed, 0 failed, 46 ignored. Both new GPU tests (split_compute_program_prebuilds_and_caches_chain_pieces and offline_split_compute_pipeline_is_reused_by_a_second_process) ran and passed on RTX 3060.
  • SKIPPED GPU tests (26 notices, unchanged from main): 21 wave64/no-wave64 tests (dispatch_chain_native_wave64_builds_whole, 4 lower::tests, 14 lower_dxil::tests wave64 cases, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware), 3 wave32 per-lane unsupported-op refusals in lower_dxil::tests (f16 arithmetic, f16 packed, f32 conversions), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), and pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache (Windows Developer Mode is required)).
  • Release A/B on two split compute records extracted locally from a retail shader pack (dca1b25b44878018: 1,231,896 B whole -> 14 pieces <= 156,380 B; 77229ada81e6f03f: 88,704 B whole -> 2 pieces <= 89,940 B; xcl shaders <dir> --precompile --only cs --pipelines --windows 4, XCL_DIRECT_DXIL=1, XCL_PIPELINE_THREADS=4, fresh XCL_DXIL_CACHE, NVIDIA implicit cache at OS default, measured on base 06c9f55 before rebasing onto 0829441):
    • main 06c9f55: 117.0 s (117.18 s wall) — 2 unused unsplit .pso files written, 0 / 16 .chain.pso files.
    • This change (cold, first time these pieces were compiled on this machine): 9.2 s (9.50 s wall) — 16 / 16 .chain.pso files written, 0 refused, 0 unsplit .pso files.
    • This change (warm repeat): 0.4 s (0.44 s wall) — 16 / 16 loaded from the driver cache.

Regression run
scripts/smoke.ps1 -Game <retail title> -Seconds 60, default settings, clean working trees, back-to-back on the same machine (main 0829441 then PR head 2228be7):

main:

xcl-smoke v1
commit: 082944135cd2b96288470a595861fa608eee08dc
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 645 (PresentX 646)
presents per 2 s (last 3): 2 13 16
device removals: 0
crashes: 0
peak commit: 14622 MB

PR:

xcl-smoke v1
commit: 2228be784e4ebd515b94a34afeaaee068ba865ae
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 565 (PresentX 566)
presents per 2 s (last 3): 2 16 17
device removals: 0
crashes: 0
peak commit: 14603 MB

Not tested

  • AMD and Intel GPUs, native wave64 GPUs, and Linux / Wine / vkd3d-proton.
  • Full retail world-load runtime pass measuring driver-cache hits after prebuilding all 744 split compute programs (the 60 s default smoke run stays on the startup/menu phase and does not exercise --pipelines).
  • Re-timing the two-shader A/B after rebasing onto 0829441 (which widened dispatch_chain_root_signature root constants from 4 to 8 dwords in e9ddf17; the unit and e2e GPU tests and smoke run above all ran on 2228be7 over 0829441).
  • XCL_HEAP_WINDOWS=1 and XCL_SAMPLE_* test suites.

AI use

  • Google Antigravity (Gemini 4 Neon): investigated the issue, implemented the fix and tests, ran the full test suite, two-shader A/B timing, and paired smoke runs on the hardware above, and drafted this PR description.

When direct DXIL translation splits a large compute program into a
dispatch chain (xcl-dev#2080, under XCL_DIRECT_DXIL=1 or automatically for
enormous compute shaders), the runtime builds each piece under
dispatch_chain_root_signature and caches its driver blob as .chain.pso.

xcl shaders --precompile --pipelines ignored Compiled::dispatch_chain
and instead built only the unsplit whole shader under
abi_root_signature_with (.pso), which neither the split runtime path
nor the Chain::whole() fallback loads. On two split retail compute
shaders (RTX 3060, XCL_DIRECT_DXIL=1, XCL_PIPELINE_THREADS=4), prebuild
wall time dropped from 117.0 s (0/16 .chain.pso blobs) to 9.2 s cold
and 0.4 s warm (16/16 .chain.pso blobs reused).

Part of xcl-dev#1833, xcl-dev#2088.

Assisted-by: Google Antigravity (Gemini 4 Neon)
@Aniseto

Aniseto commented Nov 25, 2026

Copy link
Copy Markdown

Ran the two new split-compute prebuild tests at 2228be7 (clean PR head on main 0829441):

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB), driver 32.0.16.2124
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: Rust 1.100.0 MSVC 14.44.35207, DXC/DXIL 1.9.2609.5, debug build
  • Adapter: XCL_ADAPTER=nvidia

Results

  • cargo test -p xcl --lib split_compute_program_prebuilds_and_caches_chain_pieces -- --nocapture: 1 passed, 0 failed, 0 ignored, 1229 filtered out (exit 0)
  • cargo test -p xcl --test gpu_compute_e2e offline_split_compute_pipeline_is_reused_by_a_second_process -- --nocapture: 1 passed, 0 failed, 0 ignored, 4 filtered out (exit 0)

What this adds
No comments or test reports in the thread yet. The author's run was an Ampere RTX 3060 with DXC 1.8.2502.11; this is a Blackwell wave32 part with DXC/DXIL 1.9.2609.5. Both new tests pass here: the library test checks the per-piece .chain.pso write/reuse and cap, and the e2e test covers the offline precompile path across two processes.

Not tested
The retail shader pack (including the 744 split programs named in the description), a release-profile timing A/B, a 60 s paired smoke run, AMD and Intel GPUs, native wave64, Wine, and XCL_HEAP_WINDOWS=1.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@DarkPanda69

Copy link
Copy Markdown

AMD run with native wave64 (listed as untested), to go with the NVIDIA run above: the new prebuild test passes on an RX 9070 XT, so the AMD driver reuses the prebuilt split pieces in a second process too.

Head 2228be7 applied on main 0829441, debug, Windows 11 Pro 26200:

  • RX 9070 XT (RDNA4, driver 32.0.32029.2010, waves 32..64):
    • cargo test -p xcl --test gpu_compute_e2e: 5 passed, 0 failed. offline_split_compute_pipeline_is_reused_by_a_second_process ok, and so are offline_compute_pipeline_is_reused_by_a_second_process and console_wave64_compute_through_the_pso_hook_dispatch_and_read_back. 1 SKIPPED, unrelated to this PR: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
    • cargo test -p xcl --lib -- gpu::: 641 passed, 2 failed, 22 ignored; the 2 failures are the AMD fuzz seeds tracked in DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115, the same on main.
  • RTX 3060 (driver 32.0.16.1088): gpu_compute_e2e 5 passed (same skip); gpu:: 643 passed, 0 failed.

Not tested: a title, the full 744-program prebuild, Intel.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@minimalhipster990

minimalhipster990 commented Nov 25, 2026 •

Copy link
Copy Markdown

RTX 4090 retail runtime check. On clean PR head 2228be784e4ebd515b94a34afeaaee068ba865ae, the game supplied a precompiled driver blob for all 66 split pieces it requested from the selected records. On the clean parent 082944135cd2b96288470a595861fa608eee08dc, the same 66 requests had no blob. All 66 completed on both builds, with zero retries.

Measurement Parent PR
Offline driver files for 16 compute records 16 whole 8 whole + 85 pieces
Matched piece calls supplied with a blob 0/66 66/66
Sum of driver-call times for those pieces 86.199 s 2.874 s
Median driver time per piece 1,274 ms 33.5 ms
Unsplit control records supplied with a blob 8/8 8/8
Last 2 s activity interval with any presents ended at 100.054 s 100.043 s
Total PresentX calls at 300 s 1,263 1,274

World loading. Both runs showed loading artwork and ended at the configured cutoff with exit code 0 and no logged device removal. No gameplay HUD or recognizable world geometry appeared in the captures. The first matched piece request came at 201.212 s on the parent and 196.818 s on the PR, well after the last active presentation interval in each. The driver times above sum overlapping calls. Both runs still built 789 pieces across 90 split programs in total.

Method. RTX 4090 24 GB, NVIDIA 621.40, Ryzen 7 5800X3D, 32 GB RAM, Windows 11 build 26300, Rust 1.99.1 MSVC. Each clean tree was built with cargo build --locked --release -p xcl --bin xcl. I selected 16 records seen in a previous retail run and ran xcl shaders <pack> --precompile --only cs --pipelines --used-only --split 1 --windows 4 with an empty driver cache per arm, XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1 and four pipeline and DXC threads. Both builds produced identical translation plans. Eight records split naturally into 85 pieces. Six of those records were requested during both runs, covering the same 66 pieces. Each runtime record hash and DXIL byte length identified exactly one piece in its saved plan.

For each 300 s xcl run <title>, I used the matching build’s offline cache, identical copies of the configured profile, the same 410 graphics blobs and 1,069-key runtime list, identical scripted input, XCL_PSO_TRACE=1, XCL_NETWORK=0 and one capture per 12 presents. One run per revision, parent first. NVIDIA’s internal cache was uncontrolled. AI assistance: OpenAI Codex (GPT-6) built and ran the comparison, matched the traces to the offline files, inspected the captures and drafted the report.

Follow-up on the last presents. I repeated the 300 s retail run twice on the same clean PR head (2228be78, RTX 4090, driver 621.40). In the earlier PR trace, 153 compute driver calls started before 100 s. I recovered the exact blobs for 74 of them, including 35 dispatch-chain pieces. These calls accounted for 149.789 of the original 156.102 cumulative driver seconds. The two new runs started with the same profile, scripted input and 520 common cache files. I added only those 74 XCL driver blobs to the second run.

Measurement Control With 74 blobs
Selected calls supplied with a blob 0/74 74/74
Cumulative driver time for the same 74 calls 172 ms 119 ms
Last selected driver call finished at 133.736 s 43.883 s
Last 2 s interval with presents ended at 156.417 s 102.046 s
PresentX calls at the 300 s cutoff 1,282 1,333

All 74 calls completed without a retry in both runs. In the second run, the game kept presenting for another 58 s after the last selected call finished. Neither run resumed presenting by 300 s. The captures showed loading artwork and no gameplay HUD or recognizable world geometry. No compute driver call overlapped the last active interval in either run. The four graphics driver calls overlapping it in the second run each took at most 3 ms.

This narrows the next trace to what the presentation thread was waiting for at the transition out of loading. The control ran first and NVIDIA's internal cache was uncontrolled. The 74 calls were already fast in the new control, so the difference in stop times cannot be attributed to the added files. Driver timings sum overlapping calls and exclude queue waits. AI assistance. OpenAI Codex (GPT-6) ran the comparison, checked the traces and captures, and drafted this update.

What the presenting thread waited for on 2228be78. I repeated the 300 s RTX 4090 run with the same executable and the same 594 initial cache files as the targeted-cache run above. The last PresentX returned at approximately 106.58 s. After that, worker 2 (TID 267752, job slot 37) successfully released one count on semaphore 0x1020 at 110.62 s. The presenting thread (TID 263232) returned from its wait in the same millisecond. Worker 2 then signalled its own completion event, and the coordinator returned from that wait. The presenter entered another infinite wait on 0x1020 at 110.70 s. No further title release on that semaphore or new PresentX was observed by cutoff.

The coordinator (TID 263228) completed 81 waits and then waited on event 0x1ac8. The event and job descriptor both matched slot 81 on worker 3 (TID 257776). That worker completed 60 calls from ExecuteIndirect to resolve_wait in 188.65 s, then entered a 61st at 297.44 s. Its job had not returned or signalled completion at cutoff. This identifies the worker responsible for the coordinator’s pending event. Whether completing that job would release the presenter’s semaphore remains open. All 378 Windows samples taken during the final waits confirmed the same semaphore and the same unsignalled auto-reset event. Handles and TIDs are local to this run.

The completed run used in-process tracepoints with the release PDB and exited normally at 300 s with 1,437 PresentX calls. A separate breakpoint-debugger attempt slowed presentation and was excluded. AI assistance. OpenAI Codex (GPT-6) ran the trace and verified the event sequence.

@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

One red on this lane.

  • gpu_ suite (--release --locked, --test-threads=2): 143 passed / 4 failed / 1 ignored. Three failures are the rig's baseline (fuzz seed 1003 of DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115, gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_depth_buffer_created_for_unordered_access_is_placed); the fourth, gpu_geometry_wave32_prefix_count_over_a_mask, is this rig's known flaky family (main reproduces it, solo reruns green).
  • New unit test shaders::pipeline_cap_tests::split_compute_program_prebuilds_and_caches_chain_pieces: passes on this lane.
  • New integration test offline_split_compute_pipeline_is_reused_by_a_second_process (crates/xcl/tests/gpu_compute_e2e.rs): fails on the Wine lane, deterministic (2/2 test runs). It fails at the first child-process assert (line 189): the spawned xcl shaders --precompile --pipelines --windows 1 (with XCL_DIRECT_DXIL=1, XCL_DIRECT_SPLIT_INSTRUCTIONS=12, XCL_PSO_DISK_CACHE=1) exits with status 5 without printing any error. Reproduced standalone outside the test harness on the same input the test builds: stdout ends after precompiling 1 shaders ... (23 compile threads; 1 memory windows) and the DXC version banner, stderr carries only DXVK startup noise, no xcl error line. The translated cache dir gets created before the child dies.

So the piece-prebuild path itself works in-process here, but the offline two-process reuse check does not complete under wine-11.0/vkd3d-proton. Note the child queries IDXCoreAdapter (interface f0db4c7f-fe5a-42a2-bd62-f2a6cf6fc83e), which this driver stack answers as unknown before falling back to CreateDXGIFactory2; whether that is related I cannot say from the outside. A diagnostic print on the child's failure path would help pin this down, since exit 5 currently carries no message.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

@SlopTart

Copy link
Copy Markdown

Follow-up to my report above, now with the child failure pinned down.

The silent exit 5 is an access violation inside the shim, not a hung or refused start. Re-ran with WINEDEBUG=warn+seh (the -all I normally use hides wine's own crash report): wine raises EXCEPTION_ACCESS_VIOLATION (0xc0000005) on the compile threads, and the full unwind is inside d3d12core.dll (+0x1AB118, +0x1784EC, +0x1A1676, +0x1A7852, +0x1A9450, +0x0DF8DB). Exit status 5 is 0xC0000005 truncated, hence the message-free failure.

Control that keeps this on the PR: running the whole gpu_compute_e2e binary on this same tree gives 4 passed / 1 failed / 1 skipped, and the failing test is only this PR's offline_split_compute_pipeline_is_reused_by_a_second_process; the pre-existing offline_compute_pipeline_is_reused_by_a_second_process passes in the same binary. So the environment is fine, the new prebuilt-split-piece path faults.

Also worth noting for whoever picks this up: the new dispatch_chain_transports_live_f16_and_f64_across_cuts in #2344 crashes at the same d3d12core.dll offsets on this Wine lane (reported there). Two different new split-chain pipeline paths, one fault site in the D3D12core shim, on vkd3d-proton 3.1 (XCL patch) + Mesa 26.2.5 + RADV. Native Windows runs from Aniseto and DarkPanda69 are green, so this only shows up here.

AI use: same as above (Hermes agent, local Qwen-class, checked before posting).

@b3IKK

b3IKK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

This runtime check matches what I see on an RTX 5080: the split pieces named in the offline cache are supplied (66/66 here, 86.2 s → 2.87 s), but the run still builds the other pieces (789 across 90 split programs above), and the world-load stop is unchanged.

The missing part is the records that were never precompiled. On main, the cold compute compiles after the 96 s stop fall 54 → 24 → 9 → 8 → 7 over five warm runs with disjoint record sets, but each remaining program is a whole 0.99–1.21 MB DXIL compile at 50–105 s, so no frame is presented after 96 s even with only seven left. This PR fixes the storage/naming for split pieces; the next lever is precompiling more of the set (or the whole pack) before the title runs. The warm-run timings are in #1380.

AI use: OpenCode, Claude Fable 5.2 compared this check with retail-run logs on this machine and wrote this.

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