Repository navigation
Conversation
A lazy graphics pipeline goes to the workers at SetPipelineState, but the ExecuteIndirect recorded right after it called resolve_wait, which took the build before a worker had started it and ran it on the title's thread. A title that records bind A, ExecuteIndirect A, bind B, ... built its graphics pipelines one after another on that thread and could not bind B before A was built: with cold graphics blobs a retail title's world start had 65 cold graphics builds (93 s of driver time) on one title thread, the xcl-pso-* workers idle. As xcl-dev#2118 does for a dispatch, a drawing ExecuteIndirect whose pipeline is still being built gets a segment of its own, recorded at the submit: the title's thread goes on to its next binds, the builds run on the workers together, and the submit waits for each as a bind did, so no draw is left out. Measured on that title (RTX 5090): title-thread graphics builds 65 -> 2, up to 18 graphics builds at once, no skipped draws. Only signatures whose arguments only draw (Draw, DrawIndexed, DispatchMesh, noted at their creation) are put off: vertex / index buffer views and root arguments an ExecuteIndirect sets stay on the list after it. Nothing is put off while a query other than a timestamp is open on the list, so a query's Begin and End stay in one PC list. The put-off segment gets the list's graphics state back after its Reset (bindings, depth bias, index buffer, depth bounds; split's block for the last three moves into restore_direct), keeps the title's pipeline as its bound_pso, and starts with its pipeline bound, so a call whose build failed goes to the PC with its stand-in, as in its list. Part of xcl-dev#2088. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Update for head AMD run (listed as untested): the new test passes on an RX 9070 XT, with no skip. Head
Not tested: this test on the machine's RTX 3060 (it always uses the default adapter), a title, Intel, Wine / vkd3d-proton. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! — Devin |
|
Independent baseline for comparison on RTX 3090 Ti (Ampere), NVIDIA 621.40, Windows 10, 32 GiB RAM. This run used a locally instrumented XCL build based on
This corroborates serial waits on distinct graphics pipelines on Ampere, in the same code path as the RTX 5090 report. An A/B on this GPU can compare eligible deferred calls, recording-time wait, submit-time wait, time to the next Present, and peak private memory under the same native cache. AI use: OpenAI Codex (GPT-6) helped correlate scheduler and driver events and draft this report. Ampere follow-up with the PR applied. I backported
The backport reached that point sooner in this pair. The launcher stopped it just afterward at 350 MiB available physical RAM with 6.88 GiB system commit headroom. The control later reached Present #1,720 and also stopped for physical memory pressure. Neither run had a matching device removal or Windows display reset. The capture through #1,676 still showed a loading spinner. No 3D world geometry was verified. The runs had different system memory headroom, so this pair cannot assign the earlier memory stop to the PR or establish an end-to-end improvement. The timing identifies where the visible waits moved. The deferral count is per call, so the 104 deferrals represent 24 cold pipeline IDs, not 104 driver compilations. Low-memory follow-up on the local two-pass mesh backport. With the same #2611 executable and native cache, disabling only This is from our older local baseline, which has a two-pass console mesh implementation. It holds one record buffer per PC command list, so deferring those commands into separate segments can increase scratch allocations. That mechanism is a hypothesis from the code and the timing. I am checking it separately by retaining classic draw deferral while keeping the emulated mesh path on its title recording. Narrowed deferral retest. On the same local base with preload still off and the same 6,569 native blobs, I kept the emulated two-pass mesh signatures on the ordinary recording path and retained #2611 for classic draws. That is a one-condition change in the local backport. The original graphics-deferral GPU regression still passed, including pixel readback. In the retest the runtime recorded over 8,192 two-pass mesh calls in its normal path, advanced past Present #1,536, and reached #1,544 at 163.446 s. It passed the previous 99 s failure without a 32 MiB scratch allocation failure, device removal, or matching Windows display reset in that interval. Near the previous failure point, XCL reported 9,801 MiB of target pages and 17,573 MiB of DXGI local usage in the retest, versus 9,787 MiB of target pages and 31,652 MiB local usage in the failed run. DXGI usage is a driver-reported accounting value, not a count of resident VRAM. The difference is consistent with the per-segment scratch concern. This retest corroborates the interaction with the locally combined two-pass mesh path and leaves upstream #2611's classic-draw benefit intact. It still has no confirmed 3D world frame. |
|
AMD RDNA2 run of the new test, with the adapter shown. Head
With @DarkPanda69's RX 9070 XT run, that is RDNA2 and RDNA4. Not tested: RDNA3, Intel, a title run on AMD. AI use: Codex (GPT-6.1-Sol) wrote the temporary fixture change and ran the test; Claude Code (Claude Opus 5.5) checked the log and wrote this comment. |
|
Tested: current PR head merged onto current
Not tested: retail titles (no title data on this lane, counts only). AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting. |
luckyteagirl
left a comment
There was a problem hiding this comment.
Could deferred graphics keep a snapshot of the RTV/DSV descriptors? Bindings retains CPU handles, and restore_bindings re-reads them through OMSetRenderTargets at submit. D3D12 permits immediate reuse of RTV/DSV descriptor memory after recording that call. A title can bind handle h as RTV A, record a deferred indirect draw, then overwrite h with RTV B before submit; replay binds B, whereas the original in-place list recorded A. The heap could also have been freed. A focused test could overwrite the slot between recording and submit and assert the draw still lands in A. Exact-head source review at 0d2517f05ff600ab24419633b4f069243bac33d7; no GPU reproduction. AI-assisted review with Codex.
|
Thanks @luckyteagirl, you're right. A deferred graphics call keeps only the RTV/DSV CPU handles from I'll snapshot the descriptors when a draw is put off: copy them into a small XCL-owned CPU heap and replay from the copy. I'll add the test you describe: overwrite the slot between recording and submit, and check that the draw still lands in A. I'll post here when it is pushed. AI use: Claude Code (Claude Opus 5.5) checked this against the head and wrote this reply. |
|
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
Thanks! — Devin |
Copy RTV and DSV descriptors into owned CPU heaps before splitting a deferred graphics call. Keep the copies with its binding state until replay. Cover source-slot overwrite and heap release with indirect-draw pixel readback tests. Assisted-by: Codex (GPT-6.1-Sol)
…+ xcl-dev#2548 + xcl-dev#2579 + xcl-dev#2581 + xcl-dev#2598 + xcl-dev#2611 + xcl-dev#2615 + xcl-dev#2622) (cherry picked from commit 57e5c216e924452b59cd64862d2941006e24c28c)
|
@luckyteagirl fixed in
One boundary is written in the code: a rewrite between AI use: Codex (GPT-6.1-Sol) wrote the fix and tests. Claude Code (Claude Opus 5.5) ran the validation and wrote this reply. |
|
One A/B pair on an RTX 5070 Ti, from identical cache copies. With this PR the title keeps presenting for 69 s after world entry, against 0 frames on Setup
Results
What this does and does not show
AI use: Claude Code (Claude Opus 5.5) ran the builds and runs on my machine, read the logs and wrote this comment. Logs stay local. |
|
The DSV snapshot now has a native RTX 4080 readback comparison. I recorded a deferred indirect draw with depth target A, then overwrote only its CPU DSV slot to point to B before submission. The color target stayed fixed. A admits the triangle and reads back red (
Both revisions matched both depth controls. No capability skips. The fixture used one RGBA8 pixel, D32_FLOAT depth clears of 0.75 and 0.25, a triangle at 0.5 with
|
|
Follow-up to my A/B above. With this PR, the next wall on my machine is the huge-build gate, not the title thread. Builds a submit will wait for are still gated as unwanted, so on a machine with little free commit they build one at a time. A one-line local change doubles the rate. Setup as above (RTX 5070 Ti, 31 GB RAM, commit limit 41.7 GB, What holds the frames with #2611 + #2613 (one 600 s run, thread dump at 450 s):
Local experiment: if !std::mem::replace(&mut p.demand.lock().unwrap().by_submit, true) {
p.want(); // a submit will wait for it
NEEDED.lock().unwrap().push_back(p);
...The same run with it on, starting from the same cache copy (NVIDIA's own cache was not cleared, so I count only builds that took more than 0.5 s):
What I'd suggest checking: whether a put-off call's pipeline should count as wanted for the gate. A submit is going to wait for it anyway, and the wanted cap (2 by default) still bounds the driver's memory. I am not opening a PR for this. It touches your code path, and the removal needs a second look first. Not tested: more runs, a run without #2613, AMD. AI use: Claude Code (Claude Opus 5.5) ran the builds and runs on my machine, read the logs and wrote this comment. Logs stay local. |
|
Thanks @NWProgramming00, that is a useful next step: with this PR the title thread no longer builds, and the gate then serializes the put-off builds because only the one a submit waits on is AI use: Claude Code (Claude Opus 5.5) wrote this. |
Part of #2088 (C12, the graphics half of #2118). It also helps with the world-start stalls discussed in #505, a step on the #1833 roadmap.
A lazy graphics pipeline is sent to the workers by
SetPipelineState, but theExecuteIndirectrecorded right after it calls
pso_async::resolve_wait. That call takes the build before a workerhas started it and runs it on the title's thread. A title that records *bind A, ExecuteIndirect A,
bind B, ExecuteIndirect B…* therefore builds its graphics pipelines one after another on that
thread, and the thread can't bind B until A is built. With cold graphics blobs, a retail title's world
start stopped presenting for minutes this way: one unnamed title thread was inside the driver's
compiler, with 2–4 s builds about every 7 s, while the
xcl-pso-*workers sat idle (thread dumps inmy #2088 comment of 20:40Z; rafelis1997 measured 162 s on 17 ExecuteIndirect + 2 DispatchMesh calls).
#2118 already puts a dispatch whose pipeline is still being built off to a list segment recorded at
ExecuteCommandLists. This PR does the same for anExecuteIndirectthat draws. The title's threadgoes on to its next binds, the builds run on the workers together, and the submit waits for each one
as a bind did. The segment is recorded with the real pipeline before the GPU runs it, so no draw is
left out.
What is in it
Review fix
445129ba(luckyteagirl's descriptor-lifetime review): a put-off graphics call copies the bound RTV/DSV descriptors into small XCL-owned CPU heaps before the list is split, and the replay binds the copies. If that allocation fails, the call takes the ordinary path before any list is closed. Boundary: a descriptor rewritten betweenOMSetRenderTargetsand the draw is still read at defer time (native D3D12 copies atOMSetRenderTargets); capturing there is a separate follow-up.crates/xcl/src/hle/d3d12x/bind.rs:execute_indirectalso puts off a drawing call whosepipeline is still being built. Signatures that change root arguments are excluded, because a
translated pipeline skips them anyway.
tracked_psois no longer test-only.crates/xcl/src/hle/d3d12x/list_x.rs:splitkeeps the list's whole graphics state on the put-off segment: bindings, depth bias,index buffer, depth bounds.
record_deferredrestores that state after the segment's Reset (restore_bindingsand the newrestore_direct). For a drawing call it Resets the segment with its pipeline, waited for as abind did, so a call whose build failed goes to the PC with its stand-in bound, as it would have
in its list.
restore_directissplit's existing depth-bias / index-buffer / depth-bounds block, moved intoa helper both use. It is not changed.
A call is not put off while any query but a timestamp is open on the list, so Begin and End
stay in one PC list (an occlusion query would also not count a put-off draw). The count
carries across a mid-list Wait split.
The put-off segment keeps the title's pipeline as its
bound_pso, so binding the real onethere does not re-key it (depth bias).
crates/xcl/src/hle/d3d12x/device_x.rs,bind.rs: a command signature whose arguments only draw(Draw, DrawIndexed, DispatchMesh) is noted at its creation; only those calls are put off.
Vertex / index buffer views and root arguments an ExecuteIndirect sets stay on the list after it.
a_graphics_execute_indirect_with_a_pipeline_still_building_waits_at_the_submit.Side effects on #2118's compute path:
A put-off dispatch on a direct list now also gets the list's graphics state restored on its
segment. Dispatches don't read it.
A dispatch inside an open query (any type but timestamps) is no longer put off. Before, the split
ended an occlusion query early, and other query types had their Begin and End in different PC lists.
The log line is now
a call with a pipeline still being built put off to the submit.Tested
Review fix
445129ba, RTX 5090, debug,XCL_NETWORK=0. New testdeferred_graphics_keeps_render_targets_after_descriptor_overwriteagainst the old runtime (0d2517f0): 0 passed, 1 failed. The readback showed the draw in B ([255,0,0,255]) and A clear: it followed the overwritten descriptor. With the fix, it and…_after_descriptor_heap_releasepass (2 passed, 0 failed) on the RTX 5090 and on the Ryzen 7 9800X3D's AMD iGPU (RDNA2); each prints its adapter.list_x: 43 passed, 0 failed on each adapter (the iGPU with theXCL_ADAPTERfixture from D3D12.X: a put-off call's segment that does not close is not submitted #2622's review). Whole suite aftercargo build --workspace: 1,422 passed, 4 failed (the knownfuzz_validate_and_gpu_0..3, DXIL GPU fuzz tests reproducibly fail with E_OUTOFMEMORY on RTX 5060 #1905), 46 ignored, 26 SKIPPED.Smoke on
445129ba, run twice (200 s, same recipe, fresh exe name each): 1,643 and 2,034 frames, no removals. In the lower run the world load started 28 s later (the put-off burst at 157.5 s vs 129.3 s), and both runs put off 128-255 calls. The block below is the second run; the first is available on request.RTX 5090 32 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 Pro 26200, Rust 1.99.1, debug tests,
release build.
Trees: unit tests on
maine1d84b7 with and without this change. The in-title A/B ran on 496dc74(= e1d84b7 + D3D12.X: an ExecuteIndirect of a split program runs its pieces #2404 @ 809da30, a local merge), with and without this change. D3D12.X: an ExecuteIndirect of a split program runs its pieces #2404 is in both arms,
and this PR is not stacked on it.
The new test fails on
main(ExecuteIndirect 0 waited for the build (10.0050257s), the titlethread ran the build) and passes with the change. Two held graphics builds run on the workers at
once, the submit waits for both, and an ExecuteIndirect inside an occlusion query stays in its list.
cargo test -p xcl --lib hle::d3d12x -- --test-threads=4: 254 passed, 0 failed, 2 ignored, noSKIPPED.
cargo test -p xcl --lib -- --test-threads=4on0d2517f: 1295 passed, 4 failed, 26 ignored.The 4 failures are
gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3(CreateComputePipelineState0x8007000E). They fail the same way onmaine1d84b7 (same seeds 70/545/1019/1507, GPU idle):pre-existing, DXIL GPU fuzz tests reproducibly fail with E_OUTOFMEMORY on RTX 5060 #1905. SKIPPED: the wave64 GPU tests (no wave64 on this card), three f16/f32 forms the
per-lane lowering refuses, and the driver-cache measurement (needs Developer Mode).
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4on0d2517f(
--no-fail-fastbecause the lib binary's 4 pre-existing failures otherwise stop cargo before theintegration tests;
XCL_NETWORK=0): 1420 passed, 4 failed, 46 ignored over all 37 testbinaries. The 4 failures are the fuzz tests above (pre-existing, DXIL GPU fuzz tests reproducibly fail with E_OUTOFMEMORY on RTX 5060 #1905).
SKIPPED (26 lines): 21 GPU tests or forms that need wave64 (no wave64 on this card); 3 f16/f32 forms
the per-lane lowering refuses (
V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32, gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426);heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows); andpso_measurement_compiles_an_exact_synthetic_record(disabling the driver cache needs Developer Mode).In-title A/B on 496dc74 with and without this change. Retail title, graphics driver blobs removed and
NVIDIA's cache cold (a new exe name), compute precompiled, `XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1
XCL_PSO_TRACE=1`, 200 s with the change (600 s without):
| | without | with |
|---|---|---|
| cold graphics builds on title threads after the world load starts (130 s) | 65 builds, 93 s in the driver, one at a time | 2 builds, 17 s |
| cold graphics builds at once (peak) | 6 | 18 |
| calls put off to the submit | 6 (dispatches, D3D12.X: a dispatch waits for its pipeline at the submit, not in the bind #2118) | ≥ 128 |
| draws skipped, GPU-wait timeouts, device removals in 0–200 s | 0 / 0 / 0 | 0 / 0 / 0 |
Measured with the first version of this change; the smoke run of
0d2517f(below) shows the same:≥ 128 calls put off and 2 title-thread graphics builds (17 s).
The time to the first world frame does not improve on this title yet. Both arms stop presenting
at 130 s. The next wall is cold whole forms of split compute programs (D3D12.X: an ExecuteIndirect of a split program runs its pieces #2404): a title thread builds
them one after another (
Chain::whole, 15–24 s each), and the workers one at a time under thebig-compile gate. Raising
XCL_HUGE_PSO_WANTED_CONCURRENCYto 4 changed nothing. Measuring thatwall together with Shaders: --precompile --pipelines also builds a split program's whole form #2551 is separate work and not claimed here.
Tested by others (thank you):
RTX 4080, CryingLaughing: a DSV readback test (depth target A, CPU DSV slot overwritten to B before submit). It failed on
0d2517f0(the draw followed B) and passed on445129ba(A). D3D12.X: a graphics ExecuteIndirect waits for its pipeline at the submit, not in the call #2611 (comment)RTX 5070 Ti 16 GB, NWProgramming00,
mainb49be18vs this PR (445129b) merged, from identical cache copies, 600 s in the title: 980 presents after world entry with this PR, against 0 onmain; 3 graphics builds on a title thread vs 12; no removals. D3D12.X: a graphics ExecuteIndirect waits for its pipeline at the submit, not in the call #2611 (comment)AMD RX 9070 XT (RDNA4), DarkPanda69: the new test passes with no skip;
d3d12x::255 passed, 0 failed. D3D12.X: a graphics ExecuteIndirect waits for its pipeline at the submit, not in the call #2611 (comment)RTX 3090 Ti (Ampere), GodlyBDS, A/B with this change backported (warm native cache, 1 GiB shader-heap profile): Present Implement XSystemGetDeviceType/PLS thunks and Opus audio carrier parsing #1,689 at 278.8 s against 534.7 s, longest frame gap 21.7 s against 252.0 s; one run per arm, both later stopped on memory pressure. D3D12.X: a graphics ExecuteIndirect waits for its pipeline at the submit, not in the call #2611 (comment)
RTX 3060 Ti, DavidM1911:
cargo test -p xcl --liball passed. D3D12.X: a graphics ExecuteIndirect waits for its pipeline at the submit, not in the call #2611 (comment)AMD RX 7900 XT (RDNA3), SlopTart, Linux + Wine/vkd3d-proton (RADV), head merged on current
main: the new test passes;gpu_suite 165 passed / 3 failed (the lane's known baseline, not this PR). D3D12.X: a graphics ExecuteIndirect waits for its pipeline at the submit, not in the call #2611 (comment)Regression run
main:This PR (
0d2517f):Both: the retail title,
-Seconds 200,XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1, the same scripted input to the world load, each on a copy of the same cache (compute precompiled, graphics driver blobs removed) under a never-used exe name. Both stop presenting at ~130 s, at the start of the world load (cold whole forms of split compute programs; see #2088).Not tested
The review fix's cost in the title: each put-off indirect graphics call creates up to two small CPU descriptor heaps (RTV and/or DSV). Not measured; the log does not count them.
Descriptor rewrites between
OMSetRenderTargetsand the draw remain outside this fix. (DSV copying is now covered by CryingLaughing's readback test, above.)AMD and Intel GPUs, other NVIDIA cards and drivers, Wine / vkd3d-proton.
Direct draws (
DrawInstanced/DrawIndexedInstanced) andDispatchMeshstill wait in the call.The measured pattern is ExecuteIndirect, and they are left for a follow-up.
State that
Bindingsdoes not carry is lost on a put-off segment, as on a mid-list Wait splittoday: shading rate and combiners, the shading-rate image, sample positions, the view-instance
mask, stream-output targets, and state an
ExecuteBundleset. Not checked whether the titleuses them on these passes.
The put-off path ignores the native
Closeresult of a segment (both when the empty segment is madeand after the call is recorded at the submit), so a segment whose recording failed would still be
submitted. This is pre-existing in D3D12.X: a dispatch waits for its pipeline at the submit, not in the bind #2118's code and was found by KOLESNiii on [OFFICIAL] Swarm: cold PSO compilation to first playable frame #2088; this PR sends more
calls through it. A separate fix with a failure-injection test is to follow.
A list predicated with plain
SetPredication(notSetPredicationBufferX) is not seen by thesplit, so a draw put off from it runs unpredicated (the same gap D3D12.X: a dispatch waits for its pipeline at the submit, not in the bind #2118 has for dispatches).
With defaults, the huge-compile gate lets at most
XCL_HUGE_PSO_WANTED_CONCURRENCY(2) wantedbuilds of ≥ 256 KB run at once. The gain with a higher cap is not measured here.
AMD test wanted: this has not run on AMD. A run on RDNA2/3/4 would help:
cargo test -p xcl --lib list_x -- --test-threads=4(the new test isa_graphics_execute_indirect_with_a_pipeline_still_building_waits_at_the_submit), and if you can,scripts/smoke.ps1on this head againstmain. Look for skipped draws or a device removal thatmaindoesn't have.AI use
Review fix: Codex (GPT-6.1-Sol) wrote the descriptor copy and the two GPU tests and ran the red/green checks; Claude Code (Claude Opus 5.5) ran the broader validation and the smoke runs and updated this description.
Claude Code (Claude Opus 5.5) found the cause from the code and logs, wrote the change, the test
and this description, and ran the tests listed above.
🤖 Generated with Claude Code