Skip to content

D3D12.X: a dispatch waits for its pipeline at the submit, not in the bind - #2118

Merged
theaustinayers merged 4 commits into
xcl-dev:mainfrom
Royalflamejlh:fix/compute-bind-defer
Nov 25, 2026
Merged

theaustinayers merged 4 commits into
xcl-dev:mainfrom
Royalflamejlh:fix/compute-bind-defer

Conversation

@Royalflamejlh

@Royalflamejlh Royalflamejlh commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

A compute pipeline that is not built yet was waited for in SetPipelineState: the title's thread stood there, built it itself, and only then reached the next one. This moves that wait to ExecuteCommandLists, so the title's recording threads go on and the pipelines a frame binds reach the workers together. A dispatch whose pipeline fails to build is skipped and counted, as before, and XCL_PSO_WAIT_MS still bounds the wait. Alone it does not finish more builds (31 of 3 s or more after the world start against 34 from cold caches, 1 run each): the big ones still take turns. The lane that lets them run together is #2141, stacked on this; with both, 69. Part of #505 and #1833; scheduling under #2088.

SetPipelineState binds what is there. A Dispatch, or an ExecuteIndirect that dispatches, whose pipeline is still being built ends the list's segment, as a mid-list Wait after a Write64 already does, and gets a closed segment of its own between that one and the next; a translated dispatch sets its own root signature, views and pipeline, so it can be recorded later than the calls around it. At the submit (and KickoffX) each such segment is reset and its call recorded through the wait the bind used to make.

What is in it

  • list_x.rs: try_split_for_wait's body becomes split(list, dispatch), which opens the next segment without waiting for the bound pipeline (also for a mid-list Wait); defer, deferred_segment, record_deferred. A title list's deferred segments record on an allocator of its own (own_alloc), because the title's may be recording another list by the submit; on_release does not release it while the GPU may still run from it (alloc_pool::in_flight; it is then never released).
  • wait_expired: every armed GPU wait's clock restarts while any thread of the title waits for a build (pso_async::title_held), and runs again when none does. Without it a queue waiting for a value whose list stood in such a submit was released after 5 s, out of order (3 lines a run in an earlier form, 0 since). The watchdog still releases a stalled queue when no build is waited for: an earlier form with this logic, in a run with XCL_PSO_WAIT_MS=50 where no call was put off, logged 40 such releases (a run of the unchanged merge with that budget logged 36).
  • bind.rs: dispatch and execute_indirect put the call off when its pipeline is unbuilt; where the list cannot be split (a bundle, no wrapper, no allocator, predication set, the segments used up, or the call's own command list cannot be made, as on a vkd3d-proton without the relaxed-vtable change of Linux (Wine + vkd3d-proton): a retail game reaches what main reaches on Windows; the obstacle is replaced vtables — proposal: proxies #175) they wait where they are, as before. pass_arena: a list's segments share one argument arena (a 256 KiB block each filled the coherent window in an earlier form).
  • real.rs: cl_set_pipeline_state no longer waits; q_execute_command_lists and kickoff_x record a list's deferred segments first.
  • pso_async.rs: need_by_submit and NEEDED: the workers take a put-off pipeline before their queue (behind a start-up backlog the submit thread built them itself, one after another). want, used by record_deferred for the next four put-off pipelines as it goes (WANTED_AT_ONCE): the leave a title thread's own build has today, so about as many are in the driver at once as the title's threads had there.
  • title_list.rs: push_segment; can_split takes a count; 1,024 extra segments per recording (two for each put-off call) instead of 32 (the second commit, b7d0ef2; the first had 256).
  • real/dispatch_chain.rs, list_x.rs (the third commit, after pvfreis's review): at the submit, a put-off call's segment goes on in the split scratch of the segment recorded before it (list_follows, as a chain after a chain on one list does, with the UAV barrier that chain records), so main's bound on all split scratch (0829441) holds for them; and a title list's own allocator is reset at the list's next Reset once alloc_pool says the GPU is done with it, so their recordings do not outlive them.
  • Tests: a_dispatch_with_a_pipeline_still_building_waits_at_the_submit (a build that returns no pipeline, and not before the test lets it): without the change the dispatch waits for the build; with it 210 dispatches on one list are put off (421 segments), Close returns with the build still running, record_deferred waits for it and counts the dispatches as skipped, and the segments run on a queue. With 256 segments the 129th dispatch waits (dispatch 129 waited for the build). a_gpu_wait_does_not_expire_while_the_title_is_held_for_a_build. a_pipeline_a_submit_needs_is_built_before_the_queue (built 248th of 249 without the change). a_list_recorded_after_another_goes_on_in_its_scratch (red with list_follows doing nothing: the list after it made a scratch of its own, on the 8 GB Windows card in debug).
  • Behaviour that changes with it: a put-off call inside an occlusion query ends that query at the split, as KickoffX and the mid-list Wait split do, so it resolves as visible. Known and left: with XCL_ALLOC_SWAP=0 the segments' own allocator is reset without waiting for the GPU; that allocator is never released when its list is released with work still on the GPU.
  • Not in it: the console-list replay, Reset, ClearState, KickoffX's re-open of the list and CreateCommandList with a compute pipeline wait where they did.

Beside #2001, #1652, #2114, #889, #2130, #2096. #2001 also stops the bind waiting and waits at the first Dispatch instead, on the title's thread, with the build on a worker; #1652 bounds the bind's wait and skips, and #2114 (split from it) caps the waits per frame and then goes on with the stand-in, which skips dispatches where this skips none; #889 sends compute pipelines to the workers when they are made, and one it has not reached by its first use is still waited for in the bind. #2130 bounds the big-compile gate's commit wait and does not touch this. None moves the wait to the submit. This conflicts with #2001 and #2114 in pso_async.rs; #2096 edits pso_async.rs and real.rs too. Whichever merges first, I rebase.

Tested

lib, two skipped other test binaries
main 2898511 1277 passed, 5 failed, 26 ignored 76 passed, 3 failed, 20 ignored
d1e3e9b (this change rebased on it) 1282 passed, 4 failed, 26 ignored 76 passed, 3 failed, 20 ignored
compute builds of 3 s or more finished after the first #101 their build-seconds per second of them on title threads most at once queue.Wait timeouts dispatches skipped
without 34 1.56 21 4 0 0
with this 31 2.01 8 4 0 0
with this and the lane 69 4.70 3 7 0 0
  • Two more controls from the same state finished 36 and 33 such builds.
  • The first #101 came at 96.2, 105.3 and 99.5 s; over all runs of the evening it ranges from 74 to 113 s, so I read nothing into it. Without the change the presents stop within 2 s of it; with this alone they went on for 24 s (12 to 60 per 2 s) and then stopped; with the lane they stopped within 1 s. One run each: I do not know which of these would repeat. In every run the presents then stay stopped while builds go on, and with the change the dumps have a title thread in a graphics pipeline's build (under execute_indirect or a draw; D3D12.X: a draw does not wait for a graphics pipeline still being built #1798 is not in this tree). So this is not a title past its world start.
  • Native Windows. NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.01), Ryzen 7 5700X3D, Windows 11 Pro 26200, rustc 1.100.0. fb1a905: cargo test --workspace -- pso_async:: list_x:: title_list:: bind:: alloc_pool:: --test-threads=4 in debug, 48 passed, 0 failed. scripts/smoke.ps1 on it: 1577 frames against main cbc296a's 1568, 60 60 60 on both, 0 removals, 0 crashes, peak commit 14404 MB against 14458 MB. 33424af (an earlier form: this commit with the lane, before the two uncounted drops were counted): the same 48; scripts/smoke.ps1 1539 frames against main cbc296a's 1568, 60 60 60 on both, 0 removals, 0 crashes, peak commit 14485 MB against 14458 MB; a debug build of the title for 100 s presented to its end (2117 frames). NVIDIA GeForce RTX 5070 Ti 16 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 Pro 26300, rustc 1.99.1: on 66896c9 (before the watchdog clock, the workers' order and the window) the whole suite in debug, 1151 passed, 4 failed, 46 ignored, the four being gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0 to _3, which failed there on main 689f2db the same day; and on c2096cf (before the workers' order) a debug build of the title stopped presenting on its first screen and ended at 64.7 s, 1 run, which the workers' order is meant to answer.
  • That start again, on the 8 GB card: a debug build of the title for 100 s, 10 runs of main cbc296a with XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684 and 10 of 33424af with XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684, alternating, half of each with thread dumps at 45, 60 and 80 s. main: 10 of 10 presented through 100 s. With the change: 9 of 10; the tenth ended at 46 s in the thread dump itself (0xc0000005 in ntdll.dll+0x1ff2a 36 ms after the 45 s dump was due, the case of Runtime / Loader / Platform: static TLS alignment & attach races, eh::dump_threads deadlock & VEH bounds, C-unwind FFI boundaries, AVX2 check, and hybrid CPU affinity / PLS quota #106 and xcl run: thread dumps unwind a copy of each stopped thread's stack #253). The failed start did not come again. A 100 s run there ends before the world start.
  • D3D12.X: the builds a submit waits for do not take turns among the big compiles #2141 has a title run of both together on Windows from another tester (fewmet); nobody has run this one alone in the title on Windows.
  • The limit, in the title (the second commit, b7d0ef2). A local merge of main 568e7db with Recompiler: direct compact form stores a branch's target in the entry #2076, XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684, D3D12.X: the builds a submit waits for do not take turns among the big compiles #2141 and this pull request's first commit, the limit changed in place for the second run; Linux as above, but vkd3d-proton's dxil-spirv is e084e35c with four local patches; XCL_DIRECT_DXIL=1, XCL_PSO_DISK_CACHE=0, XCL_DXC_THREADS=4, XCL_SKIP_BINK=1, A pressed when the title takes it; 1 run each.
    • With 256 segments, 300 s: a temporary log line said segment limit 1.4 s after the first #101, and in the dumps at 120, 200 and 280 s both recording threads were in execute_indirect → resolve_wait, as on main. Two lists of the first world frame put off 207 and 209 dispatches (counted in a run with the limit out of the way).
    • With 1,024 segments and D3D12.X: a draw does not wait for a graphics pipeline still being built #1798's two changed lines, 1,050 s: 1,392 dispatches put off in the 2 s after the first #101, no segment limit line, no list reached 512 segments. The submitting thread waited in record_deferred from 64 s to 376 s while the workers built; then all 1,392 were recorded (0 skipped) and the title presented 2 frames.
    • 4 s after that, 50 GPU queue.Wait … did not complete within 5000 ms … released on CPU (q1 against q0, q2, q3 and q4 at one value) and the title's watchdog at 406 s. An earlier run with no call put off logged the same releases on the same queues (40, from 8 s after its first #101), so I read it as Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505's cycle and not as this change's; this run does not show the title past it.
  • d1e3e9b (as above) on native Windows (the 8 GB card above): cargo test --workspace -- pso_async:: list_x:: title_list:: bind:: alloc_pool:: dispatch_chain --test-threads=4 in debug, 77 passed, 0 failed; scripts/smoke.ps1: 726 frames, exit 0x0, 0 device removals, 0 crashes, peak commit 14685 MB, against 764 frames and 14710 MB on main 2898511 (both lower than the runs on 06c9f55, 1574 and 1577).

Regression run
Under Wine on Linux (RTX 4060 Ti; scripts/smoke.ps1 unchanged, run by PowerShell 7 with xcl.exe started through Wine: "peak commit" reads 0 MB there, exit: 0x89 is the wrapper ending Wine after XCL's own process ends, and RTX 4060 Ti 8GB is the name vkd3d-proton gives this 16 GB card).

main:

xcl-smoke v1
commit: 2898511af1c038a2ef809719e9b6f89e5675c422
gpu: NVIDIA GeForce RTX 4060 Ti 8GB
title: 1253b9d5
seconds: 60
exit: 0x89
frames shown: 1578 (PresentX 1578)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

PR (the head, 6044729):

xcl-smoke v1
commit: 6044729477db63730f46ddee576ad6f7e53f89e9
gpu: NVIDIA GeForce RTX 4060 Ti 8GB
title: 1253b9d5
seconds: 60
exit: 0x0
frames shown: 1571 (PresentX 1571)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

On d1e3e9b (see Tested), the same run gave 1526 frames, exit 0x89.

Not tested

  • Either commit on Windows beyond the named tests and the smoke pair above: the whole suite, a title run, a 16 GB card. The window of four and the workers' order answer what two Windows runs of earlier forms showed and are not confirmed there.
  • A title run on main itself, or with D3D12.X: offload PSO builds, defer lazy compile-on-draw, and wire mmap ID3D12PipelineLibrary1 #2001, D3D12.X: compute pipelines are built ahead of their first bind #889 or D3D12.X: a draw does not wait for a graphics pipeline still being built #1798 merged in; AMD and Intel; the default number of compile threads.
  • Memory: not recorded by the runs (peak commit reads 0 under Wine). The machine's least available memory was 17 GB in the run with this, 13 GB without and 12 GB with the lane.
  • More than one run of each row; GPU time once the pipelines are built.
  • A run with XCL_PSO_WAIT_MS set (that the bound holds at the submit is from the code).
  • KickoffX with a put-off call; a title list released while its put-off calls are still on the GPU; a deferred call recorded with a built pipeline in a test (the test's build returns none).
  • A list with more than 512 put-off calls: past that a dispatch waits in the bind, as before. What the command lists a title list keeps for its segments cost in memory (under Wine the test with 510 put-off dispatches against 10, 1,000 more command lists, peaked 55 MB higher: 566 against 511 MB, 3 runs each; not measured on Windows or in the title).

AI use

  • Claude Code (Claude Fable 5.2) wrote the change and the tests, made the runs and wrote this description; further instances checked earlier versions of it against the logs and the code.
  • The third commit and this version of the description: Claude Code (Claude Opus 5.5).

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
# Conflicts:
#	crates/xcl/src/hle/d3d12x/bind.rs
#	crates/xcl/src/hle/d3d12x/pso_async.rs
#	crates/xcl/src/hle/d3d12x/real.rs
@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@SzczepanGrela

Copy link
Copy Markdown

Linux/RADV + Wine GPU test report on PR #2118 head fb1a905 (fb1a9050f383349a5cdd94ba0b18efa841f6581b, local merge dbe4f76ad68df43f061f1afd67a37c634bd3f8eb onto origin/main 568e7db7729c8fa6c8f0f4b32d798faaf11462bb; note that main later moved to c55ba167295333c81b7024a307e654ec818c475f and PR #2118 currently shows CONFLICTING against live main).

Setup

  • OS/kernel: CachyOS Linux (7.3.0-5-cachyos)
  • GPU/driver: AMD Radeon RX 9070 (RADV GFX1201, native wave64) (device 0x7550, Vulkan 1.4.354, Mesa RADV 26.2.5-arch3.1)
  • Wine/DX: GE-Proton11-12 (wine-11.0 (Staging)), vkd3d-proton v3.1, DXVK dxgi.dll, DXC 1.9.2602.17 (21d28f72)
  • Build/env: rustc 1.97.1, cargo test --target x86_64-pc-windows-gnu --release --workspace --no-run (44.17s, exit 0, zero compiler warnings), XCL_REQUIRE_GPU=wave64 XCL_NETWORK=0

Results
Unit tests (cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib ...):

  • hle::d3d12x::pso_async -- --nocapture: 7 passed, 0 failed, 0 ignored (0.60s, exit 0; including new hle::d3d12x::pso_async::used_tests::a_pipeline_a_submit_needs_is_built_before_the_queue), vs baseline 568e7db 6 passed, 0 failed, 0 ignored (0.60s, exit 0). Also 7 passed, 0 failed, 0 ignored (0.60s, exit 0) under concurrent Vulkan GPU load (vk_tool burn burner.spv gfx 2048 4096 256 30).
  • hle::d3d12x::list_x::tests::a_gpu_wait_does_not_expire_while_the_title_is_held_for_a_build -- --exact --nocapture: 1 passed, 0 failed, 0 ignored (0.00s, exit 0; new in #2118).
  • hle::d3d12x::list_x::tests::a_dispatch_with_a_pipeline_still_building_waits_at_the_submit -- --exact --nocapture: 0 passed, 1 failed, 0 ignored in 2 of 2 runs (1.58s and 1.57s, exit 101; new in #2118). Both runs printed xcl: D3D12.X: Dispatch with a pipeline that has no translated console shader (0x7e57d001) skipped and panicked at crates/xcl/src/hle/d3d12x/list_x.rs:6351:13: the dispatch waited for the build (1.4999495s) on run 1 and the dispatch waited for the build (1.4999477s) on run 2.
  • hle::d3d12x::list_x -- --nocapture: abnormal exit (exit status: 5) after 25 passed tests (including a_gpu_wait_does_not_expire_while_the_title_is_held_for_a_build and cross_queue_cycle_and_same_queue_fifo_do_not_deadlock), matching baseline 568e7db abnormal exit (exit status: 5 after 22 passed tests).
  • hle::d3d12x -- --test-threads=4: 158 passed, 22 failed, 2 ignored (2.13s, exit 101), vs baseline 568e7db 156 passed, 21 failed, 2 ignored (1.63s, exit 101): +2 passed (a_pipeline_a_submit_needs_is_built_before_the_queue, a_gpu_wait_does_not_expire_while_the_title_is_held_for_a_build), +1 failed (a_dispatch_with_a_pipeline_still_building_waits_at_the_submit), and the same 21 pre-existing baseline failures.
  • Other hle::d3d12x sub-suites matching baseline 568e7db: title_list 1 passed, 0 failed, 0 ignored (0.06s), bind 4 passed, 2 failed, 0 ignored (0.16s, exit 101), alloc_pool 2 passed, 1 failed, 0 ignored (0.14s, exit 101), real -- --test-threads=1 45 passed, 1 failed, 0 ignored (1.32s, exit 101).

Integration binaries (cargo test --target x86_64-pc-windows-gnu --release --test <name>):

  • gpu_pso_e2e: 7 passed, 0 failed, 0 ignored (0.27s, exit 0, both default and under vk_tool Vulkan GPU load), matching baseline 568e7db 7 passed, 0 failed, 0 ignored (0.26s, exit 0).
  • console_dlls_e2e: 13 passed, 0 failed, 0 ignored (0.00s, exit 0), matching baseline 568e7db 13 passed, 0 failed, 0 ignored (0.00s, exit 0).
  • gpu_compute_e2e: 2 passed, 2 failed, 0 ignored (1.50s, exit 101), matching baseline 568e7db 2 passed, 2 failed, 0 ignored (1.03s, exit 101, same 2 pre-existing failures).
  • d3d12_resource_and_sync (default and -- --test-threads=1): 2 passed, 1 failed, 0 ignored (0.66s and 0.55s, exit 101), matching baseline 568e7db 2 passed, 1 failed, 0 ignored (0.25s and 0.26s, exit 101, same HRESULT(0x80070057) failure).

Not tested

  • No retail game workload and no scripts/smoke.ps1 (no retail title files locally).
  • XCL_HEAP_WINDOWS=1 (left unset) and --lib / --test targets outside those listed above.

AI use

  • Diff audit, test execution, and comment drafting used Antigravity (Gemini 4 Neon) multi-agent verification, reviewed by me before posting.

@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

@SzczepanGrela thank you. The same test fails here on NVIDIA with a vkd3d-proton built without the relaxed-vtable change from #175 and passes with it, so I read your failure as the vkd3d-proton build, not RADV.

Setup: b7d0ef2 (this pull request rebased on main 426a5a7), release, x86_64-pc-windows-gnu; Linux, RTX 4060 Ti 16 GB (driver 615.71.09), Wine 11.21 Staging. The lib test program was run beside two builds of vkd3d-proton v3.1-90-g30b0eb9b: one with the two-hunk change from #175 (built with dxil-spirv e084e35c and four patches), and one without that change (its own dxil-spirv 34f0ff8 with a local patch); neither test translates a shader. One run per cell.

test with the change from #175 without it
a_dispatch_with_a_pipeline_still_building_waits_at_the_submit (this pull request) ok FAILED: dispatch 1 waited for the build (10.0002102s)
mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares (a test main has too; run from this tree) ok the test program ends in a page fault (read at 0x2B28)

Read

  • A put-off dispatch gets a command list of its own, on an allocator XCL adopts, which replaces its vtable pointer (list_x.rs, deferred_segment). Stock vkd3d-proton returns NULL for such an allocator (d3d12_command_allocator_from_iface, libs/vkd3d/command.c, also at v3.1), so CreateCommandList returns E_INVALIDARG, defer returns false, and the dispatch waits for its build where it is, as on main. That is read from the source; the run logged no put off to the submit line.
  • Your message differs because the second commit changed the test: its build now runs until the test lets it go (10 s at most); at fb1a905 it slept 1.5 s. Your 1.4999 s is that whole build. Like yours, my failing run printed the (0x7e57d001) skipped line before the panic.

I have not changed the pull request for this: in your baseline run 21 of main's own hle::d3d12x tests fail as well. #867 (open) is for running on such a build; this test was not run with it.

Not tested: RADV or any AMD card; fb1a905; vkd3d-proton at the v3.1 tag (mine is 90 commits later); GE-Proton; main with the build without the change.

AI use: Claude Code: a session on Claude Fable 5.2 made the runs and the first draft; one on Claude Opus 5.5 checked them against the source and wrote this text.

Posted without review by a person: the account owner was away and reads replies later.

Royalflamejlh and others added 2 commits November 25, 2026 06:45
…bind

A compute pipeline that is not built yet was waited for at its bind: the
title's thread stood in SetPipelineState, built the pipeline itself, and
only then reached the next one. A title that binds many unbuilt compute
pipelines in one frame got them one after another.

SetPipelineState now binds what is there. A Dispatch, or an
ExecuteIndirect that dispatches, whose pipeline is still being built
ends the list's segment, as a mid-list Wait after a Write64 does, and
gets a closed segment of its own between that one and the next: a
translated dispatch sets everything it needs itself (root signature,
the six views, the pipeline), so it can be recorded later than the
calls around it. The title's threads go on recording, and the pipelines
the frame binds next reach the workers while this one is built. At
ExecuteCommandLists (and KickoffX) each such segment is reset and its
call recorded through the same wait the bind made (XCL_PSO_WAIT_MS
still bounds it). A dispatch whose pipeline fails to build is skipped
and counted, as before.

While a submit stands in that wait, the lists it carries and their
Write64 signals are not on the queue yet, and another queue's GPU wait
for one of them ran into the 5 s watchdog and was released on the CPU
(3 lines a run). The watchdog's clock now stands while a bind or submit
is held for a build.

A put-off pipeline goes before the workers' queue: behind a start-up
backlog the submit thread would build them itself, one after another,
where several title threads built at once before (a debug build on
Windows stopped presenting on its first screen that way).

At the submit the next four of its put-off pipelines are marked wanted
as it goes, the leave a title thread's own build has today, so about as
many are in the driver at once as the title's threads had there before.

The segments of a title list record on an allocator of that list's own,
because the title's may be recording another list by the submit; it is
not released while the GPU may still run from it. They share one
argument arena: a block each filled the coherent window.

A recording takes 256 extra segments (32 before), two for each such
call. Past that, on a list that cannot be split, and under predication
the call waits where it is, as before. The console-list replay, Reset,
ClearState and KickoffX's re-open wait where they did.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… puts off

A put-off dispatch takes two segments of its list, and a list had 256. The
retail title's first world frame records lists that put off 207 and 209
dispatches (Linux, RTX 4060 Ti): past the 128th the dispatch waited in the
bind again, and both recording threads stood in execute_indirect for the rest
of a 300 s run. With 1024 the same frame put off 1,392 dispatches, none
waited in a bind, and the submit recorded all of them.

The segments are command lists the title list keeps: 1,000 more of them cost
55 MB in the test under Wine.

The test puts off 210 dispatches on one list; with 256 the 129th waits.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@pvfreis

pvfreis commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

One point on b1e8457 merged onto main 68a284a (clean), by reading only, not run. It needs XCL_DIRECT_DXIL=1 and a put-off Dispatch of a split program.

main's total scratch bound (0829441, newer than your base) does not hold for put-off split dispatches.

  • SHARED gives the chains of one PC list one scratch. Each put-off call has a PC list of its own, so each makes a new buffer: up to 256 MiB while the total has room, then up to 2 MiB (one group if that is more). At 512 put-off calls on a list that is up to 1 GiB past the 384 MiB.
  • They stay: RECORDINGS keeps them under own_alloc's PC allocator, which only record_deferred resets. A list that stops putting calls off keeps its last ones until its release, which leaves less room for all others.

Two small changes, skipping nothing: in record_deferred, pass SHARED's entry from the last put-off segment to this one, where pass_arena is called; at the list's Reset, call dispatch_chain::allocator_reset for own_alloc's PC allocators once allocator_in_flight is false.

AI use: Claude Code (Claude Opus 5.5) found this; a second Claude Opus 5.5 re-derived it; Claude Fable 5.2 reviewed the text; checked by a person before posting.

@tiagonleal

Copy link
Copy Markdown
Contributor

Test report for #2118 on RTX 5070 Ti (Windows 11): no change to the world-load stop here, the compiles now run on several threads

Tested

  • PR head b1e84577dbd3dd4667729bf8e3211758957baa74, merged locally onto main 082944135cd2b96288470a595861fa608eee08dc (merge c43f9a8a550375afaa80ab93158c286d93f515ef; it merges cleanly there, but this is not current main). Release build. Baseline: 082944135cd2b96288470a595861fa608eee08dc unmodified.
  • Windows 11 Pro 10.0.26300 (Developer Mode on), NVIDIA GeForce RTX 5070 Ti 16 GB (driver 617.42, 32.0.16.1742), AMD Ryzen 7 9800X3D, 32 GB RAM.
  • Newer Retail Game, 300 s per run, XCL_DIRECT_DXIL=1 XCL_PSO_PRELOAD=0, A pressed at 15-100 s, XCL_PSO_WAIT_MS unset, memory guard on (commit > 70 GB, free RAM < 1 GB). Same executable name and compute cache for baseline and PR, so the driver cache is warm for both (the 2 PR runs came after 4 baseline runs, so they are slightly warmer; the copy of the PR binary was checked by hash).
baseline (4 runs) +#2118 (2 runs)
last present 70 / 66 / 64 / 64 s 66 / 68 s
driver compile in flight after the stop 91-96 % 100 %
compile sum after the stop 196-230 s 233 / 221 s
threads that compile after the stop 1 5+ at a time
device removal, guard cut, watchdog none none
released on CPU lines 0 0
process peak commit 29.0-29.6 GB 32.0 / 30.7 GB
minimum free RAM 3.2-3.6 GB 1.4 / 1.9 GB
  • The stop in the world (presents end, 64-70 s) does not move with D3D12.X: a dispatch waits for its pipeline at the submit, not in the bind #2118, and the total compile time during the stop stays about 220 s. Several compiles now overlap, but the presents still end at the same point. A run with XCL_PSO_WAIT_MS=50 on the baseline also stops at 66 s, so on this card the stop does not look like a thread blocked in a bind.
  • The memory cost is visible on 32 GB: free RAM went down to 1.4 GB (the guard limit is 1.0 GB), about 2-3 GB commit more than baseline.
  • Skipped dispatches: none counted.

Not tested

  • The PR on current main, AMD, a complete compute cache, runs longer than 300 s, the unit tests of the PR.

Run and written with Claude Code (Claude Fable 5.2 and Claude Sonnet 5.5).

theaustinayers and others added 2 commits November 25, 2026 13:51
main 2898511. Two files conflicted, three hunks:

- bind.rs, execute_indirect: main (5983162) keeps the title-facing
  pipeline as raw_pso so that a failed build behind a shared stand-in is
  still skipped. The put-off test of this branch and need_by_submit take
  raw_pso (the pending builds and the console-compute set are keyed by the
  object the title holds, not by the shared driver pipeline), then
  pso = resolve_wait(raw_pso) and main's code as it is.
- pso_async.rs: NEEDED / next_needed (this branch) and drop_unstarted_job
  (main, 5b97e22) both stay. build_queued uses drop_unstarted_job for a
  pipeline the title released meanwhile, so a waiter is woken on the queue
  path and on the path where a worker takes a needed pipeline first.

Nothing else was changed. Resolved for the author by a maintainer.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since 0829441 the chains of one PC list share a scratch, and all
recordings together are bounded by XCL_SPLIT_SCRATCH_TOTAL_MB. Each
dispatch put off to the submit records on a PC list of its own, so each
made a new buffer: up to 256 MiB while the total had room, then 2 MiB
each, past the bound. They stayed under the list's own allocator until
the next submit that put a call off reset it.

The segment recorded after another at the submit now goes on in its
scratch, as a chain after a chain on one list does (with the UAV barrier
that chain records), and the list's own allocator is reset at its next
Reset once the GPU is done with it.

Found by pvfreis, reading xcl-dev#2118 on main 68a284a.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@theaustinayers
theaustinayers merged commit e0d93c8 into xcl-dev:main Nov 25, 2026
2 of 4 checks passed
@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

@pvfreis thank you, both points hold. They are in 6044729, on top of the merge of main 2898511 made on the branch today.

  • At the submit, a put-off call's segment now shares the scratch of the segment recorded before it, as a chain after a chain on one list does (dispatch_chain::list_follows, called where pass_arena is), with the UAV barrier pso::record_dispatch_chain puts first. A segment without a split dispatch passes the entry on, so split, plain, split still share one.
  • At the title list's next Reset, the PC allocator its put-off calls last recorded on is reset if alloc_pool says the GPU is done with them, which drops those recordings and their scratch; one alloc_pool put aside while it was busy keeps them until it is taken again, as before. Without alloc_pool (XCL_ALLOC_SWAP=0) nothing says the GPU is done, so it is left to the next submit as before.

Tested (on d1e3e9b, the same change rebased by me on 2898511, the same source but for the order of two items in pso_async.rs): a_list_recorded_after_another_goes_on_in_its_scratch passes, and fails (the list after it made a scratch of its own) with list_follows made a no-op, in debug on an RTX 2070 SUPER (Windows 11). The suite under Wine on an RTX 4060 Ti: 1282 lib tests passed against 1277 on 2898511, and nothing fails that does not also fail there. Not tested: the reset at Reset (no test or run reaches it), the whole suite on Windows, and a title run with a put-off split dispatch, so the memory saved is not measured.

@tiagonleal thank you for the RTX 5070 Ti runs. On our Linux runs (RTX 4060 Ti; this pull request at its earlier head b7d0ef2 on main 426a5a7, with #684 and #1798; 1 run each) the first world frame came out only with XCL_HUGE_PSO_WANTED_CONCURRENCY=6 on an NVIDIA cache that four earlier runs had filled. At the default of 2 it did not: not within 300 s in three runs as that cache filled, and not within 1,050 s from an empty one. As in your table, this change moves which thread waits for the builds, not how much is built. The extra commit fits the source: at the submit up to four builds go on without the commit headroom check (WANTED_AT_ONCE, list_x.rs); that is read, not measured here.

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

Posted without review by a person: the account owner was away and reads replies later.

raylitebull added a commit that referenced this pull request Nov 25, 2026
Keep amd-dev 0 commits behind origin/main (#2118 deferred compute PSO wait at submit).
Resolved conflicts in bind.rs, list_x.rs, and pso_async.rs preserving our 3-tier PsoQueue, prelude indirect clamping, and format_alias::list_reset while wiring #2118's next_needed()/need_by_submit() into PsoQueue.

Assisted-by: Antigravity (Gemini 4 Neon High)
@fromthemoonx

Copy link
Copy Markdown

On main 6d12f58 (with this PR merged), the new a_dispatch_with_a_pipeline_still_building_waits_at_the_submit is flaky on native Windows when it runs in parallel with mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares. It fails at the segment count: the list before each dispatch, the dispatch, the list after it, left 9 or 11, right 421. So only 4 or 5 of the 210 dispatches were put off.

RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug; the lib test binary run directly:

failed runs
this test alone (--exact), 100 runs 0
hle::d3d12x::list_x::tests:: --test-threads=4, 200 runs 11 (this test; once together with rotating_queue_self_deadlock_and_non_monotonic_rescue_do_not_hang)
this test + mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares, --test-threads=2, 60 runs 3
this test + rotating_queue_self_deadlock_and_non_monotonic_rescue_do_not_hang, --test-threads=2, 60 runs 0
this test paired with each of the other 38 list_x tests, --test-threads=2, 10 runs each only the mid_list_write64… pair failed (1 of 10)

So the two tests share some process-wide split state (spare segments or the deferred-split bookkeeping, I have not found which). In a whole-suite run (--test-threads=4) it passed in the four runs I made today; the parallel list_x runs are where it shows.

Not tested: the cause; AMD; a release build.

AI use: Claude Code (Claude Opus 5.5) ran the repeats and pairings, and wrote this comment.

grahamster2 added a commit to grahamster2/xcl that referenced this pull request Nov 25, 2026
With XCL_PSO_WAIT_MS set, a Dispatch or dispatching ExecuteIndirect put
off to the submit (xcl-dev#2118) was recorded through resolve_wait, with the same
budget a bind has as the title records. A pipeline a bind had already
found late got the stand-in at once, one still building got it after the
budget, and the dispatch was counted as skipped and left out. Its segment
lies between the list's other work, so the list's Write64 labels, EOP
writes and fence signals still fired: the title saw the work as done
while its UAV outputs, counters and indirect argument buffers were never
written.

record_deferred now waits for the segment's compute pipeline
(pso_async::wait_for_submit) before it records the call, whether a bind
found it late or not. Without the budget this is the wait the submit
already made. With it, the submit leaves the build to the workers for
the budget first, as a bind does, so big compiles keep their turns on
the workers; one no worker has started by then is built on the
submitting thread, so a submit never waits for a free worker. One a
worker builds is waited for at most 30 s (SUBMIT_WAIT_MOST, the time a
retail title's watchdog lets its main thread stand still, xcl-dev#891):
title_held stops kernelx::Sleep and the GPU-wait watchdog, not every
clock a title reads. Past that the call goes on with the stand-in as
before, with a WARN ("deferred dispatch skipped after waiting 30 s for
its pipeline") and a count of its own.

A worker's build that panics now ends as a failed build (catch_unwind
around the job), so whoever waits for it goes on instead of waiting for
a done flag nobody sets.

Tests: a put-off dispatch of a translated console program whose build
ends 400 ms into the submit, with a 50 ms budget and the pipeline already
late, has its store and the Write64 after it in the list reach memory
(without the change the label is written and the store is not); a
submit's wait for a late pipeline no worker can start builds it itself;
a submit waits for a worker's build no longer than its bound and counts
it; a panicking build ends as failed.
raylitebull pushed a commit that referenced this pull request Nov 25, 2026
With XCL_PSO_WAIT_MS set, a Dispatch or dispatching ExecuteIndirect put
off to the submit (#2118) was recorded through resolve_wait, with the same
budget a bind has as the title records. A pipeline a bind had already
found late got the stand-in at once, one still building got it after the
budget, and the dispatch was counted as skipped and left out. Its segment
lies between the list's other work, so the list's Write64 labels, EOP
writes and fence signals still fired: the title saw the work as done
while its UAV outputs, counters and indirect argument buffers were never
written.

record_deferred now waits for the segment's compute pipeline
(pso_async::wait_for_submit) before it records the call, whether a bind
found it late or not. Without the budget this is the wait the submit
already made. With it, the submit leaves the build to the workers for
the budget first, as a bind does, so big compiles keep their turns on
the workers; one no worker has started by then is built on the
submitting thread, so a submit never waits for a free worker. One a
worker builds is waited for at most 30 s (SUBMIT_WAIT_MOST, the time a
retail title's watchdog lets its main thread stand still, #891):
title_held stops kernelx::Sleep and the GPU-wait watchdog, not every
clock a title reads. Past that the call goes on with the stand-in as
before, with a WARN ("deferred dispatch skipped after waiting 30 s for
its pipeline") and a count of its own.

A worker's build that panics now ends as a failed build (catch_unwind
around the job), so whoever waits for it goes on instead of waiting for
a done flag nobody sets.

Tests: a put-off dispatch of a translated console program whose build
ends 400 ms into the submit, with a 50 ms budget and the pipeline already
late, has its store and the Write64 after it in the list reach memory
(without the change the label is written and the store is not); a
submit's wait for a late pipeline no worker can start builds it itself;
a submit waits for a worker's build no longer than its bound and counts
it; a panicking build ends as failed.
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 26, 2026
…DispatchMesh & ExecuteIndirect)

Enables two-pass mesh execution for DispatchMesh and ExecuteIndirect
(superseding xcl-dev#724), paired with xcl-dev#541 (MS in AS slot). Reconciles
runner.rs, bind.rs, and console_list.rs with xcl-dev#2118, xcl-dev#2404, and xcl-dev#1428.

Assisted-by: Antigravity (Gemini 4 Neon)
koboshchan pushed a commit to koboshchan/xcl that referenced this pull request Nov 26, 2026
…he submit

With XCL_PSO_WAIT_MS set, a dispatch whose pipeline is still being built
is recorded at once instead of being put off to the submit (xcl-dev#2118): its
bind waits at most XCL_PSO_WAIT_MS on the title's thread, as before. The
submit's wait has the same bound, so the put-off only moved it. With
XCL_PSO_WAIT_MS=1 a retail title's world start put off thousands of
calls, a segment each; its command lists ran out of memory (Close:
E_OUTOFMEMORY) and the device was removed (0x887a0001). Unset (the
default), nothing changes.
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