Repository navigation
D3D12.X: a dispatch waits for its pipeline at the submit, not in the bind - #2118
Draft
Royalflamejlh wants to merge 1 commit into
Draft
Royalflamejlh wants to merge 1 commit into
Royalflamejlh wants to merge 1 commit into
Conversation
…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): no dispatch is skipped that was not skipped 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). The builds of put-off calls do not take turns among the big compiles: a build that starts after its call was put off runs beside the others, once the commit headroom it asks for is free. With them in the one-at-a-time lane the change finished no more builds than before. Where the headroom is not there (a 32 GB machine at the world start: the gate's commit wait does not end), that alone would leave them waiting until the submit reaches each. So the submit marks the next four of its put-off pipelines wanted as it goes, which a build takes as leave to go on without the headroom, as a title thread's own build does: about what the title's threads had in the driver at once 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:10
c2096cf to
33424af
Compare
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 pipelines a frame binds are built together on the workers. From cold driver caches a retail title finished 70 long builds in the 236 s after its world start against 34 (1 run each, Linux). No dispatch is skipped that was not skipped before, andXCL_PSO_WAIT_MSstill bounds the wait. 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: the GPU-wait watchdog's clock stands while a bind or submit is held for a build. Without it a queue waiting for a value whose list stood in such a submit was released after 5 s (3 lines a run in an earlier form, 0 now).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.SUBMIT_COMPILES: the lane a put-off call's build takes incompile_slotsinstead of a turn inBIG_COMPILES: together, each once its commit headroom is free (Shaders: size-based admission for big compute driver compiles #1774); programs of 4 MiB or more stay one at a time. Where the headroom does not come,record_deferredmarks the next four put-off pipelines wanted as it goes (WANTED_AT_ONCE), the leave a title thread's own build has today.title_list.rs:push_segment;can_splittakes a count; 256 extra segments per recording (two for each put-off call) instead of 32.pso_async.rs:need_by_submit,want.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.Reset,ClearState,KickoffX's re-open of the list andCreateCommandListwith a compute pipeline wait where they did.Beside #2001, #1652, #889. #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; #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. None moves the wait to the submit. On #2001's head1f1d681this commit conflicts inpso_async.rsonly; if it merges first I rebase onto it.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:maincbc296ac2096cfgpu::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.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, and for the second row this commit cherry-picked onto it (one conflict, the watchdog's constant). 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.Waittimeouts66896c9(without the lane, the watchdog clock, the four-wanted window and the last fixes).cargo test --workspace -- --test-threads=4in debug: 1151 passed, 4 failed, 46 ignored, 25 lines print SKIPPED; the four aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0to_3, which failed there onmain689f2dbthe same day.scripts/smoke.ps1: 1639 frames againstmaincbc296a's 1632,60 60 60on both, 0 removals, 0 crashes, peak commit 15786 MB against 15638 MB.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
c2096cfon Windows: the suite, the smoke pair and a title run there. The window of four is for a machine whose commit headroom does not come, and I have not run one.mainitself, or with D3D12.X: offload PSO builds, defer lazy compile-on-draw, and wire mmap ID3D12PipelineLibrary1 #2001 or D3D12.X: compute pipelines are built ahead of their first bind #889 merged in; AMD and Intel.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