Repository navigation
D3D12.X: a dispatch waits for its pipeline at the submit, not in the bind - #2118
Open
Royalflamejlh wants to merge 1 commit into
Open
Royalflamejlh wants to merge 1 commit into
Royalflamejlh wants to merge 1 commit into
Conversation
Royalflamejlh
force-pushed
the
fix/compute-bind-defer
branch
from
November 25, 2026 05:10
c2096cf to
33424af
Compare
…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>
Royalflamejlh
force-pushed
the
fix/compute-bind-defer
branch
from
November 25, 2026 05:48
33424af to
fb1a905
Compare
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
Contributor
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 toExecuteCommandLists, 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, andXCL_PSO_WAIT_MSstill 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.SetPipelineStatebinds what is there. ADispatch, or anExecuteIndirectthat dispatches, whose pipeline is still being built ends the list's segment, as a mid-listWaitafter aWrite64already 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 (andKickoffX) 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 becomessplit(list, dispatch), which opens the next segment without waiting for the bound pipeline (also for a mid-listWait);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_releasedoes 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 withXCL_PSO_WAIT_MS=50where no call was put off, logged 40 such releases (a run of the unchanged merge with that budget logged 36).bind.rs:dispatchandexecute_indirectput 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) 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_stateno longer waits;q_execute_command_listsandkickoff_xrecord a list's deferred segments first.pso_async.rs:need_by_submitandNEEDED: 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 byrecord_deferredfor 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_splittakes a count; 256 extra segments per recording (two for each put-off call) instead of 32.a_dispatch_with_a_pipeline_still_building_waits_at_the_submit(a build of 1.5 s that returns no pipeline): without the change the dispatch waits for the build; with it the list is three segments, Close returns with the build still running,record_deferredwaits for it and counts the dispatch as skipped, and the three segments run on a queue.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).KickoffXand the mid-listWaitsplit do, so it resolves as visible. Known and left: withXCL_ALLOC_SWAP=0the 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.Reset,ClearState,KickoffX's re-open of the list andCreateCommandListwith 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
Dispatchinstead, 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 inpso_async.rs; #2096 editspso_async.rsandreal.rstoo. Whichever merges first, I rebase.Tested
x86_64-pc-windows-gnu; vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from Linux (Wine + vkd3d-proton): a retail game reaches whatmainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175 and dxil-spirv#372.cargo build --workspacethencargo test --workspace --release --target x86_64-pc-windows-gnu --no-fail-fast -- --test-threads=4:maincbc296afb1a905gpu::dxil::round_tests::directed_reference_basics,gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu,gpu_depth_buffer_created_for_unordered_access_is_placed(lib);test_title_runs_and_game_folder_is_untouched,disk_free_space_ex_reports_pls_quota,set_predication_buffer_state_and_kickoff. The two skipped ared32s8_targets_take_their_own_size_of_video_memoryandreservable_agrees_with_the_driver, which hang under Wine on both (Tests: the D32S8 target test waits at most 10 s for its list #1706). 24 lines print SKIPPED on both, the same ones.tests/d3d12_resource_and_sync.rs(3 tests) ends in a page fault under Wine in some runs: run alone 14 times, 5 times onmaincbc296aand 5 times on an earlier form of this commit.XCL_DXC_THREADS=4, noXCL_PSO_WAIT_MS, XCL'sdxil/driverfolder emptied and a new__GL_SHADER_DISK_CACHE_PATH; the DXIL cache kept. The tree is a local merge ofmain4178e88with XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684, D3D12.X: title texture reads outside the coherent window use the safe copy #751, D3D12.X: retain deferred Write64 until the producer fence completes #850, D3D12.X: refresh fence mirrors after queued rewinds #906, Shaders: isolate DXC compiler heaps for parallel AOT #688, D3D12.X: a bind does not wait for a pipeline behind the workers' queue #1273, Recompiler: route compute programs through a compact backend (XCL_COMPACT_CS) #1316, Recompiler: compact cases share code whose branch targets differ #1448 and Recompiler: oversized structured code falls back to pc blocks (#1307) #1321, with this commit cherry-picked onto it for the second row (two conflicts: the watchdog's constant, and D3D12.X: a bind does not wait for a pipeline behind the workers' queue #1273's counters in the worker loop) and an earlier form of this commit with the lane of D3D12.X: the builds a submit waits for do not take turns among the big compiles #2141 for the third. The vkd3d-proton of these runs has three more dxil-spirv patches (the dominator numbering 0naku posted on [OFFICIAL] Looking for PRs with shaders optimization #1269, and two of ours), without which one 2.8 MB program does not finish there. Onmainalone the title waits at its world start for a 29 MB program (Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505); this change was not run there. "First#101" is the title's firstID3D12GraphicsCommandList10::#101call.#101queue.Waittimeouts#101came 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 (underexecute_indirector 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.fb1a905:cargo test --workspace -- pso_async:: list_x:: title_list:: bind:: alloc_pool:: --test-threads=4in debug, 48 passed, 0 failed.scripts/smoke.ps1on it: 1577 frames againstmaincbc296a's 1568,60 60 60on 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.ps11539 frames againstmaincbc296a's 1568,60 60 60on 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: on66896c9(before the watchdog clock, the workers' order and the window) the whole suite in debug, 1151 passed, 4 failed, 46 ignored, the four beinggpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0to_3, which failed there onmain689f2dbthe same day; and onc2096cf(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.maincbc296awith XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684 and 10 of33424afwith 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+0x1ff2a36 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.Regression run
Under Wine on Linux (RTX 4060 Ti;
scripts/smoke.ps1unchanged, run by PowerShell 7 withxcl.exestarted through Wine: "peak commit" reads 0 MB there,exit: 0x89is the wrapper ending Wine after XCL's ownprocess ends, andRTX 4060 Ti 8GBis the name vkd3d-proton gives this 16 GB card).main:
PR:
Not tested
fb1a905on 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.mainitself, 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.XCL_PSO_WAIT_MSset (that the bound holds at the submit is from the code).KickoffXwith 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).AI use