Skip to content

Shaders: a title's preparation workers build split programs' whole forms - #2794

Open
joeypercia wants to merge 1 commit into
xcl-dev:nvidia-devfrom
joeypercia:shaders-worker-whole-forms
Open

joeypercia wants to merge 1 commit into
xcl-dev:nvidia-devfrom
joeypercia:shaders-worker-whole-forms

Conversation

@joeypercia

Copy link
Copy Markdown
Contributor

The workers that build a title's compute pipelines before it starts (pipelines_in_workers) never build split programs' whole forms. precompile builds a whole form only when it has a startup state, and the workers run it without one. The title then builds each whole form at the program's first ExecuteIndirect, on its own thread (Chain::whole): 15–25 s a program cold, for 750 KB – 1.1 MB of DXIL. With that, the newer retail title froze in its world load for minutes. @KDenKC found it and posted this change on #2624 as a suggestion, not a PR. This is that change, with a test.

What is in it (one commit)

  • crates/xcl/src/shaders.rs: precompile also builds the whole form of a split program in a preparation worker (XCL_PRECOMPILE_PARENT set, as worker_command sets it).
  • crates/xcl/tests/gpu_compute_e2e.rs: a_preparation_worker_also_builds_a_split_programs_whole_form. It runs the split program of offline_split_compute_pipeline_is_reused_by_a_second_process as a worker would. The precompile must make one pipeline more than the program has pieces, and keep a driver blob for each. Without the change it fails: "the whole form was not built" (7 pipelines with it, 6 without, for 6 pieces).

What it does in the title (one run per arm each)

The cost is a longer first preparation. Later launches find the whole forms in the driver cache.

Tested

  • NVIDIA GeForce RTX 4070 Ti (driver 621.40), and the AMD Radeon iGPU of a Ryzen 7 7800X3D (RDNA2) with XCL_ADAPTER=Radeon. Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.8.2502.11. Debug builds for the tests, release for the runs.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4, on this PR's head 3c4891dd and on its base af2cecc4:
    • RTX 4070 Ti: head 1746 passed, 6 failed, 48 ignored; base 1745 passed, 6 failed, 48 ignored.
    • RDNA2: head 1746 passed, 5 failed, 48 ignored; base 1745 passed, 5 failed, 48 ignored.
    • The failures are the same tests on head and base:
    • The new test ran on both adapters (... ok).

Regression run

RTX 4070 Ti (driver 621.40), release builds, 60 s each, scripts/smoke.ps1 -Game <folder> -Title retail-title on the newer retail title, with the same settings. All three ran with the NVIDIA shader-heap profile (#2590, 1 GiB) installed on this machine. The game reaches no ExecuteIndirect of a split program in 60 s, so this checks that nothing else changes. Base and PR ran one after the other; the base's run shared the GPU with a test suite of mine for part of it.

main (b49be183, merge base of main and nvidia-dev):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4070 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1426 (PresentX 1426)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17542 MB

nvidia-dev (af2cecc4, this PR's base):

xcl-smoke v1
commit: af2cecc40886a8682ecf3267f5328c6dc4b66ad7
gpu: NVIDIA GeForce RTX 4070 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1454 (PresentX 1454)
presents per 2 s (last 3): 60 47 32
device removals: 0
crashes: 0
peak commit: 20359 MB

PR:

xcl-smoke v1
commit: 3c4891dd4cf7d249d7f818aec05c7150a347504a
gpu: NVIDIA GeForce RTX 4070 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1557 (PresentX 1557)
presents per 2 s (last 3): 60 60 59
device removals: 0
crashes: 0
peak commit: 18699 MB

Not tested

AI use

The workers that build a title's compute pipelines before it starts
(pipelines_in_workers) run precompile without a startup state, and only
with one does it build a split program's whole form. The title then
built each whole form at the program's first ExecuteIndirect, on its own
thread (Chain::whole): 15 - 25 s a program cold, 750 KB - 1.1 MB of
DXIL. A retail title froze in its world load for minutes on them (RTX
5090, RTX 4070 Ti; KDenKC's finding and change, xcl-dev#2624).

precompile now builds the whole form in a preparation worker too
(XCL_PRECOMPILE_PARENT set). The first preparation takes longer; the
title then finds the whole forms in the driver cache.

Assisted-by: Claude Code (Claude Opus 5.5)
@ettehn

ettehn commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Independent Windows check of warm-cache reuse and recovery on 3c4891dd4cf7d249d7f818aec05c7150a347504a. The only local change was a synthetic test extending the six-piece fixture. Each row launched a fresh xcl shaders process. The ordinary and worker arms began with separate empty XCL caches.

Run Driver cache hits Result
Ordinary precompile, cold 0 Six piece blobs
Worker precompile, cold 0 Same six blob names plus one whole-form blob
Worker precompile, warm 7 All six pieces and the whole form reused
Worker precompile after replacing only the whole-form blob with invalid bytes 6 Each piece reused, whole-form blob rebuilt under its original name

All four runs reported zero refused pipelines. On Windows 11 build 26200, Ryzen 9 8945HX, RTX 5070 Ti Laptop 12 GB (621.24), Rust 1.97.1 MSVC debug, DXC 1.8.2502.11, XCL_ADAPTER=NVIDIA XCL_REQUIRE_GPU=wave64:

cargo test --locked --offline -p xcl --test gpu_compute_e2e -j 2 -- worker_reuses_and_recovers_the_whole_pipeline_blob a_preparation_worker_also_builds_a_split_programs_whole_form offline_split_compute_pipeline_is_reused_by_a_second_process split_compute_prefers_the_offline_whole_pipeline --test-threads=1 --nocapture

4 passed, 0 failed, 0 ignored, no reported skips. This covers the worker CLI cache path with a synthetic shader. A retail title’s first ExecuteIndirect and the full workspace suite were outside this run.

OpenAI Codex assisted with the test and verification. The exact model identifier was unavailable in this session.

@retrope13

Copy link
Copy Markdown

Independent RTX 4060 Laptop (8 GB, DXC 1.9.2602.17) full-suite verification and diff check of #2794 (3c4891dd) against base nvidia-dev (af2cecc4): full workspace suite passes with zero new failures. No title was run.

Tested

  • Hardware / Env: NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, Ada Lovelace, driver 32.0.16.2140, wave32), Intel Core i5-14500HX (14C/20T), 24 GB RAM, Windows 11 26H2 (build 26300.9818), rustc 1.100.0 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100.0 DXC 1.9.2602.17, XCL_ADAPTER=NVIDIA.
  • Targeted split-program tests (gpu_compute_e2e, debug):
    • cargo test --locked -p xcl --test gpu_compute_e2e -- a_preparation_worker_also_builds_a_split_programs_whole_form offline_split_compute_pipeline_is_reused_by_a_second_process split_compute_prefers_the_offline_whole_pipeline --test-threads=1 --nocapture: 3 passed, 0 failed, 0 skipped (4.40 s).
    • Under XCL_ADAPTER=Intel (Intel UHD Graphics, driver 32.0.101.7092): all 3 cleanly reported SKIPPED: no wave32 GPU.
  • Full workspace (debug): cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4:
    • Base af2cecc4: 1748 passed, 6 failed, 48 ignored
    • PR #2794 (3c4891dd): 1749 passed, 6 failed, 48 ignored (+1 new test, 0 regressions)
    • The 6 failures are identical on both base and head (the same 6 known pre-existing nvidia-dev failures listed in the PR description).

Diff Check (af2cecc4..3c4891dd)

  • Confirmed recomp::pso::console_to_dxil_in routes both cold translations and XCL_DXIL_CACHE hits through the same Ok(c) path in shaders.rs:2168-2178, where p.make(&c) builds only the split pieces and p.make_one(&c.dxil, &c.samplers, true, None) builds the whole form against dispatch_chain_root_signature.
  • The std::env::var_os("XCL_PRECOMPILE_PARENT").is_some() check at shaders.rs:2175 matches the existing worker check at shaders.rs:2097.

Not Tested

  • Live retail title preparation/runtime runs, AMD GPUs, release builds, and the 48 #[ignore] / SKIPPED tests.

AI disclosure: Antigravity (Gemini 4 Neon, XHigh) ran the builds/tests, checked the diff, and drafted this report.

@throny

throny commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Test report: on an RTX 4080 16 GB this removes the no-frame stretch at world entry. This is the stall I measured on nvidia-dev this morning (#2688, comment 7184950679, updates 3–5: two title threads in ExecuteIndirect → Chain::whole, 13–20 s a program).

Tested

before (same tree without this PR, runs of today) with this PR
"compute pipelines done" in the shader preparation 6–17 s 206 s in the first launch (0 of 20 workers failed), 17 s in the second
compute pipelines built on title threads with no saved blob ("driver blob absent") 97 in the first long run, then 28, 17, 7, 2, 5, 1, 7, 7 in the eight runs after it as the blobs piled up 0
time without a frame at world entry 1,109 s cold; 53 s, 2 s … on later runs 18 s (last 30 fps window at 150 s, first world frame at 168 s)
  • So the workers now build what the title used to build in its own call, and they did it once: 206 s at the first launch, cached at the second.
  • A side effect to know about for anyone scripting input: the first launch's preparation is 3 minutes longer, and the title starts that much later.

Not tested

  • A cold run from an empty blob cache (mine already held most whole forms from six earlier world runs, so the 206 s is for what was still missing plus whatever the workers build that the title had not asked for yet), the PR's e2e test, the suite, AMD.

AI use: Claude Code (Claude Fable 5.2) ran this on the owner's machine and wrote the report.

@imnicho

imnicho commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

RTX 5080 16 GB on a small PC (i7-7700K, 16 GB RAM), nvidia-dev af2cecc4, one run per arm. Not this PR's commit: a local change with the same test on XCL_PRECOMPILE_PARENT in precompile.

  • With the whole forms in the cache, 168 compute pipelines were created after the world start, all from a driver blob, 165 of them whole forms. Without them, 4 cold whole-form builds took 301 of the 364 s after the world start and nothing was presented.
  • Cost here, for sizing the first preparation on a small machine: about 69 s of process time per whole form, with 0.5 to 1.3 GB of RAM available while it ran. The title asked for 165 of them in its first 178 s in the world.

The table, the settings and what else differed between the two arms are in #2551 (comment).

Not tested: this PR's own commit and its new test; more than one run per arm.

AI use

Claude Code with Claude Fable 5.2 wrote the local change, ran the passes and the runs and wrote this text.

@ClosetPie107

Copy link
Copy Markdown

Independent test report under Wine/Proton (not native Windows) for head 3c4891dd, compared with base nvidia-dev (af2cecc4).

Tested

  • AMD Radeon RX 9070 (RDNA4, RADV GFX1201, Mesa 26.3.1), Ryzen 5 9600X, CachyOS Linux 7.3.5

  • Proton Experimental experimental-11.0-20261112, DXVK v3.1.1-209, DXC 1.9.2609.5, Rust 1.96.0, target x86_64-pc-windows-gnu, debug build for tests

  • vkd3d-proton master ec207194 (dxil-spirv b540c8a2) with a local patch that drops the lpVtbl identity checks in d3d12_command_allocator_from_iface / d3d12_command_list_from_iface, loaded with WINEDLLOVERRIDES=d3d12,d3d12core,dxgi=n,b, VKD3D_CONFIG=ignore_shared_fence, XCL_DIRECT_DXIL=1

  • cargo test -p xcl --test gpu_compute_e2e offline_split_compute_pipeline_is_reused_by_a_second_process a_preparation_worker_also_builds_a_split_programs_whole_form -- --test-threads=1: head 2 passed, 0 failed.

  • Control: the head's test binary run against the base's xcl.exe fails a_preparation_worker_also_builds_a_split_programs_whole_form with the whole form was not built … split compute programs: 1 (6 pieces). So the test catches the missing whole-form build, and the head fixes it.

Retail title (release build, 2 preparation workers, XCL_PREPARE_GRAPHICS=0, same seeded used-pipelines.txt on both runs, scripted input)

cold run cached run (180 s)
base af2cecc4 compute preparation done in 389 s, then 0xc0000005 in ucrtbase.dll while the title loaded compute preparation 16 s, 1,718 presents, exit 0
head 3c4891dd still preparing at the 780 s wall-clock cap (killed) compute preparation 29 s, 1,681 presents, exit 0

The head's cached run reused the partial cache its killed cold run left behind. The two cached runs therefore started from different cache histories, and their preparation times are not a clean comparison. Neither cached run crashed or lost the device. Chained split dispatches: 50 on base, 252 on head.

Not tested

  • Native Windows, NVIDIA (this PR targets nvidia-dev), stock Proton vkd3d-proton
  • A complete cold first launch of the head, entering the game world, the full workspace suite on this revision

AI use

  • Codex in T3 Code (gpt-6.2-sol) wrote the test scripts and ran the tests on this machine. Claude Code (Claude Opus 5.5) wrote this report from the logs.

@oni-swr

oni-swr commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

AMD Windows test report for head 3c4891dd4cf7d249d7f818aec05c7150a347504a (exact head, clean detached checkout, no local changes). Base: nvidia-dev af2cecc40886a8682ecf3267f5328c6dc4b66ad7. This answers the request for an AMD run on this PR.

Tested

  • AMD Radeon RX 7800 XT (RDNA3, driver 32.0.31035.1003), Ryzen 7 5700X3D, 64 GB, Windows 11 25H2 (26200), Rust 1.100.0 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (Windows Kit 10.0.26100.0). XCL_ADAPTER unset, so the physical GPU was used, not WARP. Own target dir, rebuilt from scratch for each tree.
  • cargo build --workspace -j 4: ok on both.
  • cargo test --workspace -j 4 --no-fail-fast -- --test-threads=4 --nocapture (debug):
tree passed failed ignored SKIPPED lines
base nvidia-dev af2cecc4 1747 7 48 8
this head 3c4891dd 1748 7 48 8

The one extra pass is the new a_preparation_worker_also_builds_a_split_programs_whole_form. The failures are the same on the base and on this head, so they are not caused by the PR: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722, res[30] = 0x1, CPU 0x7fffffff, the known AMD failure in #2115), hle::d3d12x::texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays and pieces_hold_the_texels_of_their_levels (attempt to multiply with overflow, texture_upload.rs:1002), and the e2e tests console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, async_compute_pso_registers_real_pso_and_not_standin and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (the last one counts in two test binaries, which is why 6 names make 7 failures). The 8 SKIPPED lines are the same on both: six f16/f32 per-lane refused cases and two no heap windows.

  • 60 s smoke (scripts/smoke.ps1, release builds, title run from a local copy). Order matters here: the first base run did the whole startup shader preparation cold (26503 records; about 2.5 h of wall time in two starts, because my first start's timeout cut it off and the cache carried over). Every later run, including this head's, started with that cache complete, so this smoke does not exercise the cold-cache preparation path the PR changes. It only shows that the head does not regress a warm run.
run frames shown peak commit removals / crashes
base af2cecc4, run 1 (cold preparation first) 1529 20623 MB 0 / 0
this head 3c4891d (warm cache) 1551 17565 MB 0 / 0
base af2cecc4, run 2 (warm cache) 1530 18868 MB 0 / 0
xcl-smoke v1
commit: af2cecc40886a8682ecf3267f5328c6dc4b66ad7
gpu: AMD Radeon RX 7800 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1530 (PresentX 1530)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18868 MB
xcl-smoke v1
commit: 3c4891dd4cf7d249d7f818aec05c7150a347504a
gpu: AMD Radeon RX 7800 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1551 (PresentX 1551)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17565 MB

title: is retail-title (the -Title option of smoke.ps1).

Not tested

  • The cold-cache preparation timing that the PR is about (an empty cache with the preparation workers on versus off): I did not run that comparison, so there is no AMD number for the stall this removes. The translation of all 26503 records ran only on the base, not on this head.
  • A merge with main: the PR targets nvidia-dev and was tested against it only.
  • NVIDIA, Intel, Linux/Wine, AMD RDNA2/RDNA4.

AI use: Claude Code (Claude Sonnet 5.5) ran the tests and drafted this report.

@3L1A5-1

3L1A5-1 commented Nov 26, 2026

Copy link
Copy Markdown

8 GB desktop NVIDIA, one run of 3c4891dd: more title time than base, but the run still ends in device removal (0x887a0005) at title 266 s. Adds the 8 GB class to the 16 GB reports above.

Tested

  • RTX 2060 SUPER 8 GB (driver 617.14), i5-9400F (6 cores), 16 GB RAM + 32 GB page file, Windows 11 26300.
  • Exact head 3c4891dd, clean detached worktree, release build. cargo test -p xcl --lib dispatch_chain 10 passed, pso_async 39 passed. Full suite not run (retrope13 covered it above).
  • One cold first launch (no blobs), title run ≤ 300 s, XCL_NETWORK=0. One run only: it shows the end state, not timing.

Results

base af2cecc4 (our earlier runs, same PC) 3c4891dd
Preparation, cold – ~24.5 min (compute part ~1 record/s on 2 workers)
Last present (title time) 172–244 s (stalls, no frames after) 264.7 s
fps, 100 s → end 8.8–11.6 14.8
End stall (4 runs), 1 run removed at ~445 s device removed at 266 s
  • The title threads still build compute pipelines at the end: 0 driver compiles on title threads until ~28 s before the end, then 161 on three title threads within ~18 s, all logged as compute PSO ... driver blob supplied, huge, ungated here. They come from blobs and are short (median ~70–100 ms, max 265 ms, 13.6 s in total). So the long cold compiles on the title threads are gone, but these 161 builds come in one burst. Presents drop to 0 over the same ~20 s, then the device is removed (raised by a CreatePlacedResourceX on a title thread). This matches imnicho's 168 pipelines after the world start.
  • Video memory at the end: local 11,072 MB against a 7,232 MB budget (153 %), sparse pools 4,608 MB. This run alone does not show whether the burst, memory pressure or something else triggers the removal. On this PC, removals happened at local values from 5.8 to 11 GB in earlier runs, so it is not a fixed ceiling.

Not tested: warm-cache runs, repeats, the full suite, AMD.

AI use: run, analysis and this report by Claude Code (Claude Opus 5.5), reviewed for accuracy against the run log.

@joeypercia

Copy link
Copy Markdown
Contributor Author

Thanks @3L1A5-1. A silent 0x887a0005 right after a burst of new compute pipelines is what #2403 describes: NVIDIA's shader-code heap (512 MB by default) running out. If the run did not have it, xcl nvprofile install --mb 2048 (#2590, needs an elevated prompt once) may be worth one run: on a 12 GB RTX 4070 Ti the removals went from 10 of 10 runs at the default to none in 2 of 2 at 2 GiB (#2403). With 11 GB of local video memory against a 7.2 GB budget, the run may still end for another reason, as you say.

AI use: Claude Code (Claude Opus 5.5) wrote this reply.

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.

8 participants