Skip to content

Shaders: --precompile --pipelines also builds a split program's whole form - #2551

Open
DTsordas wants to merge 1 commit into
xcl-dev:mainfrom
DTsordas:precompile-chain-whole
Open

DTsordas wants to merge 1 commit into
xcl-dev:mainfrom
DTsordas:precompile-chain-whole

Conversation

@DTsordas

Copy link
Copy Markdown

xcl shaders --precompile --pipelines now also builds a split compute program's whole form under the dispatch-chain root signature (.chain.pso), next to its pieces. Part of #1833, follows #2338.

A split program keeps its whole form for what its pieces cannot run (an ExecuteIndirect, a dispatch without scratch). The runtime builds it in Chain::whole with chained = true, on the title's thread, the first time it is needed. #2338 prebuilds only the pieces, so every whole form was still compiled cold there.

On a retail title (RX 9060 XT, XCL_DIRECT_DXIL=1, all compute pipelines precompiled except the whole forms), the title's submit thread built 3–6 of them at its world start, 0.8–1.15 MB of DXIL each, 41–55 s each, and presented nothing meanwhile. With the whole forms precompiled, those binds loaded the blob in 3–4 ms and no compute pipeline was built cold after the world start. #2404 avoids the whole form for an ExecuteIndirect on the GPU side; this covers the whole form wherever the runtime still builds it, and works with or without #2404.

What is in it

  • crates/xcl/src/shaders.rs: after the pieces, make_with_cache_path builds c.dxil with chained = true (the cap and the cached-blob reuse apply as for a piece). The unit test now expects the whole form's .chain.pso too, checks that the runtime's chain root signature accepts it, and reuses all three blobs on the second pass.
  • crates/xcl/tests/gpu_compute_e2e.rs: offline_split_compute_pipeline_is_reused_by_a_second_process counts the whole form's blob with the pieces' (5 pieces + 1 whole form).

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.32029.2010), Ryzen 5 5600X, 64 GB, Windows 11 build 26300, Rust 1.100.0, debug for the suite, release for the runs.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 at 3567b2e: 1421 passed, 2 failed, 46 ignored. The two failures, gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722) and _3 (seed 1599), fail the same way on main e1d84b7 on this card; they are not touched here.
  • SKIPPED on this adapter: no D3D12 debug layer / d3d12SDKLayers.dll (3), f16_programs_on_the_gpu and f32_programs_on_the_gpu per-lane forms (6), no heap windows (1).
  • Retail title, before and after: cold compute builds on the title's thread after the world start went from 3–6 per run (41–55 s each; 3 runs) to 0 (5 runs of 6 minutes; 10–19 graphics pipelines are still built cold there). These runs were made on an earlier tree with the same change (main 06c9f55 + an equivalent commit, plus local diagnostics and a local switch that leaves compute programs of 1.2 MB of DXIL or more unbuilt), not on this branch.

Regression run

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: AMD Radeon RX 9060 XT
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1343 (PresentX 1343)
presents per 2 s (last 3): 33 59 44
device removals: 0
crashes: 0
peak commit: 18667 MB
xcl-smoke v1
commit: 3567b2efdc94617de71e50be77e107991a6bd41c
gpu: AMD Radeon RX 9060 XT
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1438 (PresentX 1439)
presents per 2 s (last 3): 52 40 15
device removals: 0
crashes: 0
peak commit: 19252 MB

The 60 s smoke run ends before the world start, so it does not reach the whole forms; the numbers above the blocks come from the longer runs.

Not tested

AI use

  • Claude Code with Claude Opus 5.5: found the cause in the runs' logs, wrote the change and the test updates, ran the suite and the smoke runs, and wrote this description.

🤖 Generated with Claude Code

… form

A split compute program keeps its whole form for what its pieces cannot run
(an ExecuteIndirect, a dispatch without scratch). The runtime builds that form
under the dispatch-chain root signature (Chain::whole, chained, .chain.pso) on
the title's thread the first time it is needed. xcl-dev#2338 prebuilds only the pieces,
so every whole form was still compiled cold in the title.

On a retail title (RX 9060 XT, XCL_DIRECT_DXIL=1), after a full compute
precompile without the whole forms, the title's submit thread built 3-6 of them
(0.8-1.15 MB of DXIL) at its world start, 41-55 s each, presenting nothing
meanwhile; with them prebuilt, those binds loaded the blob in 3-4 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@futurepro62

futurepro62 commented Nov 25, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 3567b2e (on its base e1d84b7).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1411 passed, 0 failed, 44 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, dispatch_chain_native_wave64_builds_whole, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • No new #[test] functions in the diff.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1422 passed, 0 failed, 46 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main e1d84b7 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.

Thanks!

— Devin

@thehollowedone

Copy link
Copy Markdown

Independent Windows integration check of 3567b2e merged locally, without a commit, onto current main b49be18 (#2371). The merge had no conflicts.

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

  • cargo test -p xcl --test gpu_compute_e2e -- --nocapture --test-threads=1: 7 passed, 0 failed, 0 ignored, no skips. Both offline_split_compute_pipeline_is_reused_by_a_second_process and the newly merged split_compute_prefers_the_offline_whole_pipeline passed.
  • cargo build --workspace: passed.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1,435 passed, 0 failed, 47 ignored; 24 GPU skip notices.

The merged #2371 path tries an offline whole PSO with the ordinary compute root signature; this PR also prepares the chain-root whole form used by Chain::whole. The combined synthetic tests pass on this adapter. Not tested: a clean PR-head retail smoke pair on the new base, cold driver-cache time, AMD hardware, or title world entry. This local uncommitted merge is integration evidence, not a replacement for the PR's required rebased-head regression blocks.

AI use: Codex (GPT-6.2 Sol) reviewed the combined paths, ran these tests on this machine, and drafted this report. AI-assisted.

@afpruivo

Copy link
Copy Markdown

NVIDIA world data for this PR: RTX 3090 (driver 621.40), retail 1.0.2.1. With this PR's precompile the cold compute builds on title threads at the world start went from 30 to 0, and the title presented in the world until the next wall (#2403). One run per state; the runtime is the same main binary throughout, only the cache differs.

Setup

  • RTX 3090 24 GB, NVIDIA 621.40, i5-13600K, Windows 11 26300, release.
  • Runtime: main 08db802 (+ xcl run: xcl nvprofile puts xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) #2590, which is not called at run time), XCL_DIRECT_DXIL=1 XCL_DRED=1 XCL_NETWORK=0 XCL_ACTIVITY=1, 480 s, A pressed every 4 s from 20 s, no driver profile for the exe.
  • Precompiler: xcl shaders … --precompile --only cs --pipelines --used-only with XCL_DIRECT_DXIL=1, first from main, then from this PR (3567b2e merged onto 08db802, no conflicts). This PR's pass added 117 whole-form blobs (.chain.pso) next to the pieces, 2,666 pipelines, 0 refused.

Result

precompile cold compute builds after the world start what the title did
main 30 (0.8–1.2 MB DXIL, 11–17 s each, huge, ungated here, about 387 s in the driver) 20 presents, then none for the rest of the run
this PR 0 (146 compute pipelines from blobs) presented for about 28 s in the world (186 presents), then the device was removed at 102.5 s (0x887a0005, DRED page fault at VA 0x0 with no allocations): the #2403 shader-heap limit, with no build in flight

So on NVIDIA, as in your RX 9060 XT runs, the whole forms were what the title waited on at the world start once the pieces were cached.

Not tested: more than one run per state; --precompile without --used-only; other cards; the heap-windows path.

AI use: Claude Code (Claude Opus 5.5) ran the precompiles and the runs on my PC, read the logs and drafted this.

@bielfreedom

bielfreedom commented Nov 26, 2026 •

Copy link
Copy Markdown

AMD Windows cost of this PR's offline pass: on an RX 9070 XT, the six whole forms in a 26-program set take 17–34 s each in AMD's driver. That doubles the --precompile --pipelines driver time for the set (about 110 s → 230–247 s) and raises peak memory from 1.47 to 2.17 GB. All whole forms built; none was refused. If they would otherwise be built on the title's thread at world start, as in the description, that is time moved out of the title. It is the right trade, but on AMD the offline pass gets noticeably longer.

Setup

  • GPU: RX 9070 XT 16 GB (RDNA4, native wave64), AMD driver 32.0.32029.2010.
  • CPU and memory: Ryzen 7 7700 (16 threads), 32 GB RAM, Windows 11, release.
  • Builds, each with a local timing patch that writes every CreateComputePipelineState time and result to a file:
    • main b49be18;
    • this PR at 3567b2e merged onto it.
  • Offline: xcl shaders <retail shaders.rpf> --precompile --only cs --pipelines, limited to 26 large compute programs, with:
    • XCL_DIRECT_DXIL=1, switch windows, XCL_PSO_DISK_CACHE=0;
    • one driver thread;
    • a fresh translation cache and a fresh exe name for every run (the AMD driver keys its own cache on the exe name, so every build is cold).
  • Two interleaved rounds (main, PR, then PR, main).
build pipelines made / refused driver time r1 / r2 peak memory
main 76 / 0 109.6 / 110.5 s 1.47 GB
this PR 82 / 0 247.3 / 230.1 s 2.17 GB

The six extra pipelines are the whole forms of the six split programs in the set, built with chained = true:

program whole-form DXIL driver ms r1 / r2
84eee477d68b6fdf 958,940 B 18,541 / 17,586
ed2f8fa2e996c6a6 873,976 B 17,938 / 17,725
b3618a0fd76af79c 851,060 B 34,011 / 30,187
c6f8ee0f53ed5709 795,920 B 29,036 / 28,577
d8435f454a510270 742,348 B 25,538 / 24,839
b5cc5a57995e563b 122,884 B 1,493 / 1,299

The other 76 pipelines (56 pieces and 20 unsplit programs) took 120.7 / 110.0 s with this PR against 109.6 / 110.5 s on main. The first round's extra 10 s looks like load on the machine. Times on this machine run about 30 % higher today than in my earlier reports because it is busier; the two builds ran interleaved.

Not tested: a title run and the reuse of these blobs at run time (I ran with the disk cache off).

AI use: Claude Code (Claude Opus 5.5) built the binaries, ran the measurements and wrote this report; I posted it.

@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).

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
No new test functions in this PR (precompile plumbing); the suite above is the confirmation on this lane.

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.

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.

7 participants