Skip to content

D3D12.X: an indirect dispatch does not build a split program's whole form in the call - #2893

Merged
Prime1997 merged 1 commit into
xcl-dev:nvidia-devfrom
Prime1997:contrib/nv-indirect-whole-off-thread
Nov 26, 2026
Merged

Prime1997 merged 1 commit into
xcl-dev:nvidia-devfrom
Prime1997:contrib/nv-indirect-whole-off-thread

Conversation

@Prime1997

@Prime1997 Prime1997 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Prime · project thread

An indirect dispatch of a split compute program runs its whole form, which was built at its first use on the title's thread (Chain::whole, under build_whole). With XCL_CS_PSO_WAIT_MS set, the whole form is now built once by a thread of its own, and until it is there the program's indirect dispatches are left out and counted as skipped, as those of any late compute pipeline. Unset, as before.

Part of #2688.

Why
On a retail title's first world frame (RTX 3060 Ti 8 GB) a render thread stood in bind::execute_indirect -> dispatch_chain::whole behind that lock at every thread dump (240, 300, 360 and 400 s) while the driver compiled 1.1 MB of DXIL: no present and no submit from 224 s to the end of the run at 420 s. With this change the title went on recording world frames in the same run (24,379 dispatches where there had been none after its first world frame).

What is in it

  • crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs: Whole (Plain / Ready / Late) and whole_ready, which spawns xcl-pso-whole once per chain (named like the pipeline workers, so a huge compile takes its turn at their gate) and falls back to building in the call if the thread cannot be made.
  • crates/xcl/src/hle/d3d12x/bind.rs: execute_indirect uses whole_ready; a late whole form skips the dispatch (counted, a line at powers of two).
  • crates/xcl/src/hle/d3d12x/pso_async.rs: cs_goes_on (whether XCL_CS_PSO_WAIT_MS is set).

Tested

  • NVIDIA GeForce RTX 3060 Ti 8 GB (driver 32.0.16.1714), Intel Core i5-10400, Windows 11 26200, rustc 1.100.0; debug tests, release smoke.
  • cargo test --locked --workspace --no-fail-fast -- --test-threads=4 with XCL_DXC_DIR set to DXC 1.9.2609.5: 1816 passed, 9 failed, 48 ignored. The 9 failures are the same tests that fail on nvidia-dev eae01502 itself (1816 passed, 9 failed, 48 ignored there, same command): async_compute_pso_registers_real_pso_and_not_standin, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, gpu::recomp::tests::gpu_compute_thread_limits_leave_the_lanes_past_them_out, hle::d3d12x::texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays, hle::d3d12x::texture_upload::tests::pieces_hold_the_texels_of_their_levels, split_compute_prefers_the_offline_whole_pipeline, two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs.
  • SKIPPED on this adapter: 28 (no wave64: 21, per-lane f16 form refused: 3, no dxc.exe: 1, no heap windows (opt-in: XCL_HEAP_WINDOWS=1): 1, cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depend: 1, no heap windows: 1).
  • GitHub's Build and test (Windows, no GPU) fails here on hle::d3d12x::sparse::tests::a_gpu_write_into_a_gpu_view_lands_in_its_cpu_view (the WARP device is removed, 0x887a0005). That test passes on the card above, on this branch and on eae01502, and fails the same way on the other open pull requests against nvidia-dev (kernelx: physical page homes in window 0 first, from the top, keeping 64 MB free (#2867) #2905, for one).

Regression run
A commit of main (b49be183, the last one before the shader preparation screen of #2555, which prepares every record before the title and so does not fit a 60 s run):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 363 (PresentX 363)
presents per 2 s (last 3): 16 17 16
device removals: 0
crashes: 0
peak commit: 15320 MB

The base of this PR, nvidia-dev eae01502:

xcl-smoke v1
commit: eae015021c639866ab061cdff2e9daf8ba9daac5
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 459 (PresentX 459)
presents per 2 s (last 3): 16 17 17
device removals: 0
crashes: 0
peak commit: 15366 MB

This PR's head:

xcl-smoke v1
commit: 20e38b05db33a5ce078535696ec063250f790a06
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 460 (PresentX 460)
presents per 2 s (last 3): 15 16 17
device removals: 0
crashes: 0
peak commit: 15479 MB

Not tested

  • No unit test of the spawn itself (it needs a split program and a device); the change is covered by the suite's existing indirect-dispatch tests with the switch unset and by the retail run above with it set.
  • A title whose split programs never get their whole form built (the thread fails): its indirect dispatches stay left out, and a line says so.

AI use
Claude Code (Claude Fable 5.2 and Claude Opus 5.5) wrote the code, ran the suite and the regression runs on the hardware above, and wrote this description; Prime asked for it and owns the account. We coordinate the 8 GB work on the XCL Discord too: https://discord.gg/gK3y7WRRY

🤖 Generated with Claude Code

…form in the call

An indirect dispatch of a split compute program runs its whole form, which
was built at its first use on the title's thread (Chain::whole, under
build_whole). On a retail title's first world frame a render thread stood in
bind::execute_indirect -> dispatch_chain::whole behind that lock (thread
dumps at 240, 300, 360 and 400 s of a run on an RTX 3060 Ti) while the
driver compiled 1.1 MB of DXIL: no present and no submit from 224 s to the
end of the run at 420 s.

Where compute dispatches go on without a pipeline still being built
(XCL_CS_PSO_WAIT_MS), the whole form is now built once by a thread of its
own, and until it is there the program's indirect dispatches are left out
and counted as skipped, as those of any late compute pipeline. Unset, as
before.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@Prime1997 Prime1997 self-assigned this Nov 26, 2026
@saintwolf

Copy link
Copy Markdown

Tested and reviewed commit 20e38b05 (merged cleanly onto nvidia-dev eae01502 alongside #2892, #2894–#2897, zero conflicts).

Tested

  • Hardware: NVIDIA GeForce RTX 4070 SUPER (12 GiB, driver 32.0.16.2140), AMD Ryzen 7 7800X3D, Windows 11 build 26300, rustc 1.100.0, debug test build
  • Built cleanly as part of cargo test -p xcl --lib on the merged nvidia-dev stack (#2892–#2897).

Review notes

  • OnceLock + AtomicBool::swap(true, AcqRel) synchronization for spawning the single xcl-pso-whole thread (64 MiB stack) when pso_async::cs_goes_on() is active looks race-free.
  • Minor compiler warning: crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs:132 now emits warning: function whole is never used since bind.rs switched to whole_ready.
  • Note: if the background whole() compile fails (e.g., transient OOM), whole_sent stays true and does not retry (appears intentional per the log message).

Not tested

  • No dedicated unit test for whole_ready yet
  • Full workspace test suite or retail-title smoke run on this PR

AI use

  • Antigravity (exact model name not provided to the agent): reviewed the diff, built the merged tree, and drafted this report (checked before posting).

@Prime1997
Prime1997 marked this pull request as ready for review November 26, 2026 22:59
@Prime1997
Prime1997 merged commit eff3bca into xcl-dev:nvidia-dev Nov 26, 2026
2 of 4 checks passed
@upipibi

upipibi commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Thanks for moving the whole-form build off the render thread. One question, by reading at eff3bcab, not run:

Chain::whole still opens pso_async::pc_call() (crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs:87; its comment at :85-86 says it is a compile on the title's thread). With XCL_CS_PSO_WAIT_MS set, whole_ready now runs that on xcl-pso-whole (:165), so the open PcCall belongs to a thread the title does not wait on. The other pc_call() sites are title-thread calls (real.rs:9012, device_x.rs:1100), and the pso_async workers don't open one.

As I read it, while that background compile runs, PcCalls::holds (pso_async.rs:546) makes title_held() true once 250 ms have passed since the last frame shown. Your world frames were 1 to 1.8 s, so that would hold for most of the compile. title_held() feeds wait_expired (list_x.rs:1823, called at :1881), which resets every armed GPU wait's clock while it is true. So the GPU-wait watchdog would not expire any wait for as long as a whole form is building in the background, even though the title is no longer held.

Is that intended? If not, would it be enough to open the PcCall only when whole() runs on the caller's thread (the cs_goes_on() false path and the spawn-failure fallback)?

AI-assisted (Claude Code, Claude Opus 5.5): read the code at eff3bcab and wrote this; nothing was run for these points.

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.

3 participants