Repository navigation
D3D12.X: a draw does not wait for a graphics pipeline still being built - #1798
isaacwingate wants to merge 1 commit into
Conversation
…till being built)
pso_async means a graphics pipeline still being built to go on with its stand-in, which draws nothing, while a worker builds it; only compute pipelines are waited for (a skipped dispatch would leave its outputs unwritten). But graphics_bound and ExecuteIndirect called resolve_wait, which waits for the build - and builds it on the title's thread when no worker has started it. With lazy pipelines that is every graphics pipeline's first draw. On an NVIDIA GPU the retail title of xcl-dev#505 had its threads held 1 - 5 s per draw in the driver's compiler as its world loaded: 25 graphics binds, 33.2 s in all within 25 s (counted with xcl-dev#899's log), and its hang watchdog ended the run. A test report on xcl-dev#889 (RTX 4080) found a title thread held in bind::execute_indirect -> resolve_wait at the abort. Draws and ExecuteIndirect now take their pipeline with resolve_for_bind: a graphics one still being built goes to the workers and the draw uses its stand-in (ExecuteIndirect skips, as it already did for a pending one); a compute one is waited for as before. With this, the same world load logged no graphics wait. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
141df97 to
55e7beb
Compare
|
Test report for #1798 on Linux / Wine / RADV, with the retail title of #505. Tested at head 141df97; the rebased head 55e7beb has the same patch. Without #1798, our longest earlier run (main + the local picks below, without #1798) ended with the title thread in Tested
Not tested
Written by Claude Code (Claude Opus 5.5) from the runs above. |
|
Instrumented retail comparison — RTX 5070 Ti / Proton The last logged wait snapshots show 20 graphics bind waits, 5,037 ms total on the base, and zero on the PR. The PR continued to log compute waits. The base completed the 150 s window, and the PR incurred a write access violation in Tested
The base exited Linux scope peaks were 15.17 and 16.00 GiB, with zero OOM kills. The runs are a locally instrumented comparison, and the early exit left the PR run without a completed smoke block. AI use — OpenAI Codex (GPT-6, exact variant unavailable) ran the tests, checked the logs, and drafted this report. |
|
I repeated the retail loading run from my earlier report with and without the #684 fix. The control reproduced the same
The compute times are cumulative across threads and the runs reached different points. Neither scope recorded an OOM kill. Peak scope memory was 15.71 GiB without #684 and 15.07 GiB with it. Both builds used RTX 5070 Ti (16 GB, driver 620.73.04), Ryzen 7 9700X, 32 GB DDR5, CachyOS 7.3.5-2-cachyos, Proton Experimental AI use — OpenAI Codex (GPT-6, exact variant unavailable) ran the tests, symbolized the crash, and drafted this report. |
|
Linux (Wine + vkd3d-proton) + NVIDIA test of Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging (Wayland driver), vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, Tested
The count line is printed when one of its counters reaches a power of two, so 40 and 128 are floors (128 means 128 to 255), and the warning for a skipped In the 100 s run with it the loading pictures at 40, 60, 66 and 74 s were whole (frames kept), the last of them after 23 draws had used a stand-in. I kept no frames of the runs without it. The skipped A third pair of 100 s runs was slower from the start (A at 22.2 and 18.4 s): presents stopped at 90.2 s with it and 92.2 s without, and neither run had the burst of dispatches or a skipped Read
Not tested: past the point where presents stop, where a skipped call would show; frames of the runs without it; the preload of #690 on; #1652 and #267, which change the same wait; the rest of the suite; AMD and Intel. AI use: Claude Code (Claude Fable 5.2) read the diff, built the trees, ran the tests and the six runs, compared the logs and frames and wrote this report. Posted without review by a person: the account owner was away and reads replies later. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
World-loading run of this PR on a 12 GB 32-lane NVIDIA card, where Setup: RTX 3060 12 GB (581.80), Windows 11 26200, 64 GB RAM, release, retail title. A pressed every 4 s from 20 s.
This PR's head
So on this card the draws no longer wait, and the title gets past the point where Written with Claude Code (Claude Opus 5.5) from runs on this machine. |
|
Code review on
Next step to unblock merge: Please rebase onto current |
|
Update: \Build and test (Windows, no GPU)\ is now green on \55e7beb\ (\CLEAN). One quick AMD confirmation on exact head \55e7beb\ (the prior RADV run was on \141df97) is all that remains before merge. |
|
Empirical verification on the Intel Arc A770 for the draw path with pending graphics pipelines.
Tested
19 failing tests25 SKIPPED messages from the full workspace runNot tested
AI use
|
|
A second RTX 3060 12 GB data point, adding to @Anon64's: the wait on my card was in Setup: RTX 3060 12 GB (617.42), i5-14600K, 32 GB RAM, Windows 11 26300, release, retail title in the Series S profile (
So the stall this PR removes was the one blocking world entry here. What removes the device afterwards is not settled by this run. Written with Claude Code (Claude Opus 5.5) from runs on this machine. |
|
RTX 5080 16 GB (Blackwell), driver 621.40, #2057's head + this PR: two 420 s runs, both kept presenting to the limit with no device removal and no stretch without frames. Without this PR the same tree had multi-minute stretches with no present in three of four runs. Applied on #2057 at Setup: NVIDIA GeForce RTX 5080 16 GB (driver 621.40), AMD Ryzen 9 9950X, 32 GB RAM (commit limit 97 GB), Windows 11 Pro 26200, release. Retail title of #505, 1.0.2.1, Every run:
Two runs only, so the absence of a removal in 420 s could still be luck (run 36, without this PR, also had none). The stretches with no frames, though, are gone in both, and match what @minimalhipster990 saw on the RTX 4090. Not tested: more runs; this PR on AI use: Claude Code (Claude Opus 5.5) built the trees, ran the title on this machine, read the logs and wrote this report. Update 1: one 1,200 s run of the same tree and switches (
AI use for this update: Claude Code (Claude Opus 5.5). |
|
RTX 3060 12 GB / 32 GB RAM, exact head Tested
Regression run
This PR,
Not tested
AI use: Claude Code (Claude Opus 5.5) built both commits, ran the suite and the two runs on my machine, read the logs and wrote this. |
|
RTX 2070 SUPER 8 GB, Windows, fully cold (XCL caches empty, NVIDIA / D3D12 implicit shader caches off), #1798 rebased onto current Setup
Trees
Results – the 10 min after the world load (the start of the first stretch of 20 s or more without a present after the game was started: A 110 s, B 110 s, C 96 s), from
Not tested: more than one run per tree; AMD; warm caches or after an offline precompile; #1798 without B on top of AI use: Claude Code with Claude Opus 5.5 ran the builds and the runs (through a local exclusive-run queue), resolved the conflict, measured from the logs and wrote this report; I started the game in each run. |
|
RTX 3090 (driver 621.40), compute and graphics caches warm, the same cache state for both runs: #1798 works as described, but it does not move the stall here. Both trees stop presenting about 2 s into the world, because the next wait is cold compute builds on the title's threads, not graphics. One run each. This is the case the earlier reports did not cover: @KOLESNiii's 2070 SUPER run was fully cold, so compute builds were in the way too. Setup
Result
What the title waits on instead (both runs): after the world starts, compute PSOs of 0.8–1.2 MB DXIL are built cold on title threads ( So with this cache state, #1798's change is visible (draws on PC pipelines instead of waits) but not what holds the frames. Not tested: more than one run per tree; a cold cache; a tree with #2404 / #2519 / #2551; other cards. AI use: Claude Code (Claude Opus 5.5) rebased the PR, ran both runs on my PC, read the logs and drafted this. |
…a helper A huge driver compile on an xcl-pso worker waits in big_compile_turn for one of the few slots (one at a time by default, 3 GB of free commit each) and keeps its worker thread while it waits. When the retail title of xcl-dev#505 starts its world, every worker takes one of its huge compute programs and waits there with one or two of them compiling, so the rest of the queue has no worker. A worker of the queue that has to wait now gets a helper thread in its place, and a helper that takes a huge program and parks too gets one of its own, so as many threads as the pool has keep serving the queue (at most 4 helpers per worker); a helper leaves once a parked thread is back. The slots and the commit check are unchanged, so no more driver compiles run at once than before. The queue is now one mutex and condvar holding the work and the counts of parked workers and helpers, instead of an mpsc channel. Nobody holds the lock while waiting for work, so an idle worker does not keep a helper from leaving, and a helper's leaving and a worker's parking are decided under the same lock, so a worker cannot park just as the last helper leaves and end up with none. Measured on an RTX 2070 SUPER from cold caches (empty XCL_DXIL_CACHE, NVIDIA / D3D12 implicit caches off), one run each: helpers start (32 in the run), but the pipelines built in the first 60 to 420 s after the world load match main's (336 against 342 at 420 s); frames do not come back in either run. Most of the title's own waiting is graphics pipelines built at a draw's first bind (xcl-dev#1798). Test: workers_parked_for_big_compiles_leave_the_queue_to_helpers fails without the change (the job queued behind the parked workers never runs); it parks every worker and as many helpers, twice, and waits for both counts to return to 0. With the helpers capped at the pool size, as before, the job queued behind them never runs. Part of xcl-dev#1269, xcl-dev#2088. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015csBcd63KUE2T1kW2P15nC
|
Reviewed
// Compile-verified conflict resolution in crates/xcl/src/hle/d3d12x/bind.rs on 8b957bec:
// 1. execute_indirect:
let raw_pso = with(this, |s| s.pso);
let unbuilt_compute = signature_dispatches(sig) && super::pso_async::is_pending(raw_pso) && super::real::is_console_compute(raw_pso);
if unbuilt_compute && super::list_x::defer(this, super::list_x::Deferred::Indirect(sig, max, args, args_off, count_buf, count_off)) {
return super::pso_async::need_by_submit(raw_pso);
}
let pso = pso_for_draw(raw_pso);
// 2. graphics_bound:
// a pipeline still being built in the background is not waited for (`pso_for_draw`)
let real = pso_for_draw(pso);
if !super::real::is_translated_graphics(real) {
if let Some(tp) = super::real::two_pass_of(real) {
count(DRAWS_SKIPPED);
static N: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);
if N.fetch_add(1, Ordering::Relaxed) < 4 {
crate::xlog_warn!(
"D3D12.X: draw with two-pass {} pipeline ({real:#x}) skipped – PC pipeline is a mesh shader",
tp.kind
);
}
return None;
}Checked by merging AI use: Antigravity (Gemini 4 Carbon High) resolved the |
pso_asyncmeans a graphics pipeline still being built to go on with its stand-in, which draws nothing, while a worker builds it; only compute pipelines are waited for (a skipped dispatch would leave its outputs unwritten). Butgraphics_boundandExecuteIndirectcalledresolve_wait, which waits for the build – and builds it on the title's thread when no worker has started it. With lazy pipelines that is every graphics pipeline's first draw. They now take their pipeline withresolve_for_bind, which waits for compute pipelines only. Part of #505.Related: #1652 (stacked on #1274, 10 files) also stops draws waiting, among other changes; #267 bounds the draw wait to 4 s. This is the small change on its own.
What is in it
crates/xcl/src/hle/d3d12x/bind.rs:pso_for_draw(=pso_async::resolve_for_bind) for draws (graphics_bound) andExecuteIndirect; a pending graphics pipeline's draw uses its stand-in, a pending one's ExecuteIndirect is skipped as before; compute is waited for as before. TheXCL_TRACE_FRAMElookup no longer waits either. Test:a_draw_does_not_wait_for_a_graphics_pipeline_still_being_built– fails without the change (the draw waited the build's 1.5 s and got the real pipeline).mainc4d37be: the only conflict was this test landing next toexecute_indirect_reads_the_arguments_written_before_it(both kept);execute_indirect'sfresh_indirect_argumentsis unaffected, both tests pass.Tested
cargo test --workspace -- --test-threads=4on 55e7beb: 960 passed, 0 failed, 43 ignored (SKIPPED:no wave64for the wave64 forms of the newlower/lower_dxilGPU tests,gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware; three wave32 per-lane cases off16_programs_on_the_gpu/f32_programs_on_the_gpurefused;heap_window_out_of_memory_falls_back_to_the_switch_form– no heap windows;pso_measurement_compiles_an_exact_synthetic_record– cannot disable the driver cache)XCL_NETWORK=0, with D3D12.X: log how long a bind waits for a pipeline still being built #899's wait log, through its world load (on main 1c87b1d, before this was rebased): without this, 25 graphics binds waited 33.2 s in all within 25 s as the world loaded (1 – 5 s each, mostly for a worker's build), next to the compute waits; with it, the same world load logged 0 graphics waits. On D3D12.X: compute pipelines are built ahead of their first bind #889 an RTX 4080 report found a title thread held inbind::execute_indirect→resolve_waitat the watchdog's abort.Regression run
Both with
XCL_COHERENT_MB=4095(without it the window is 512 MB or 4 GB depending on the commit free at the start, #284), one after the other.main:
PR:
Not tested
AI use
🤖 Generated with Claude Code