D3D12.X: a graphics ExecuteIndirect waits for its pipeline at the submit, not in the call #2611

Open
github-bot wants to merge 2 commits from github-bot/gh-2611 into main AGit
Owner

@⁠KDenKC on GitHub · 2026-11-26 01:52 UTC · original
KDenKC:c12-gfx-ei → main · +466 −49 · 4 files · 2 commits · open

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 the ExecuteIndirect

recorded right after it calls pso_async::resolve_wait. That call takes the build before a worker

has 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 in

my #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 an ExecuteIndirect that draws. The title's thread

goes 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 between OMSetRenderTargets and the draw is still read at defer time (native D3D12 copies at OMSetRenderTargets); capturing there is a separate follow-up.

  • crates/xcl/src/hle/d3d12x/bind.rs: execute_indirect also puts off a drawing call whose

    pipeline is still being built. Signatures that change root arguments are excluded, because a

    translated pipeline skips them anyway. tracked_pso is no longer test-only.

  • crates/xcl/src/hle/d3d12x/list_x.rs:

    • split keeps the list's whole graphics state on the put-off segment: bindings, depth bias,

      index buffer, depth bounds.

    • record_deferred restores that state after the segment's Reset (restore_bindings and the new

      restore_direct). For a drawing call it Resets the segment with its pipeline, waited for as a

      bind did, so a call whose build failed goes to the PC with its stand-in bound, as it would have

      in its list.

    • restore_direct is split's existing depth-bias / index-buffer / depth-bounds block, moved into

      a 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 one

      there 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.

    • Test 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 test deferred_graphics_keeps_render_targets_after_descriptor_overwrite against 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_release pass (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 the XCL_ADAPTER fixture from #2622's review). Whole suite after cargo build --workspace: 1,422 passed, 4 failed (the known fuzz_validate_and_gpu_0..3, #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 main e1d84b7 with and without this change. The in-title A/B ran on 496dc74

    (= e1d84b7 + #2404 @ 809da30, a local merge), with and without this change. #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 title

    thread 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, no

    SKIPPED.

  • cargo test -p xcl --lib -- --test-threads=4 on 0d2517f: 1295 passed, 4 failed, 26 ignored.

    The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (CreateComputePipelineState

    0x8007000E). They fail the same way on main e1d84b7 (same seeds 70/545/1019/1507, GPU idle):

    pre-existing, #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, then cargo test --workspace --no-fail-fast -- --test-threads=4 on 0d2517f

    (--no-fail-fast because the lib binary's 4 pre-existing failures otherwise stop cargo before the

    integration tests; XCL_NETWORK=0): 1420 passed, 4 failed, 46 ignored over all 37 test

    binaries. The 4 failures are the fuzz tests above (pre-existing, #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, #1426);

    heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows); and

    pso_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, #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 (#2404): a title thread builds

    them one after another (Chain::whole, 15–24 s each), and the workers one at a time under the

    big-compile gate. Raising XCL_HUGE_PSO_WANTED_CONCURRENCY to 4 changed nothing. Measuring that

    wall together with #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 on 445129ba (A). #2611

  • RTX 5070 Ti 16 GB, NWProgramming00, main b49be18 vs this PR (445129b) merged, from identical cache copies, 600 s in the title: 980 presents after world entry with this PR, against 0 on main; 3 graphics builds on a title thread vs 12; no removals. #2611

  • AMD RX 9070 XT (RDNA4), DarkPanda69: the new test passes with no skip; d3d12x:: 255 passed, 0 failed. #2611

  • RTX 3090 Ti (Ampere), GodlyBDS, A/B with this change backported (warm native cache, 1 GiB shader-heap profile): Present #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. #2611

  • RTX 3060 Ti, DavidM1911: cargo test -p xcl --lib all passed. #2611

  • 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). #2611

Regression run

main:



xcl-smoke v1


commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea


gpu: NVIDIA GeForce RTX 5090


title: 9cc6a39e


seconds: 200


exit: 0x0


frames shown: 1471 (PresentX 1471)


presents per 2 s (last 3): 0 0 0


device removals: 0


crashes: 0


peak commit: 31165 MB


This PR (0d2517f):



xcl-smoke v1
commit: 445129ba178eebd7b168e7469080d067b40f0e95
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 200
exit: 0x0
frames shown: 2034 (PresentX 2034)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 32071 MB

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 OMSetRenderTargets and 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) and DispatchMesh still wait in the call.

    The measured pattern is ExecuteIndirect, and they are left for a follow-up.

  • State that Bindings does not carry is lost on a put-off segment, as on a mid-list Wait split

    today: shading rate and combiners, the shading-rate image, sample positions, the view-instance

    mask, stream-output targets, and state an ExecuteBundle set. Not checked whether the title

    uses them on these passes.

  • The put-off path ignores the native Close result of a segment (both when the empty segment is made

    and after the call is recorded at the submit), so a segment whose recording failed would still be

    submitted. This is pre-existing in #2118's code and was found by KOLESNiii on #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 (not SetPredicationBufferX) is not seen by the

    split, so a draw put off from it runs unpredicated (the same gap #2118 has for dispatches).

  • With defaults, the huge-compile gate lets at most XCL_HUGE_PSO_WANTED_CONCURRENCY (2) wanted

    builds 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 is a_graphics_execute_indirect_with_a_pipeline_still_building_waits_at_the_submit), and if you can, scripts/smoke.ps1 on this head against main. Look for skipped draws or a device removal that main doesn'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

**@⁠KDenKC** on GitHub · 2026-11-26 01:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/2611) `KDenKC:c12-gfx-ei` → `main` · +466 −49 · 4 files · 2 commits · open 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 the `ExecuteIndirect` recorded right after it calls `pso_async::resolve_wait`. That call takes the build before a worker has 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 in my #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 an `ExecuteIndirect` that draws. The title's thread goes 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](https://git.gtahub.st/github/xcl-dev--xcl/pulls/2611)): 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 between `OMSetRenderTargets` and the draw is still read at defer time (native D3D12 copies at `OMSetRenderTargets`); capturing there is a separate follow-up. - `crates/xcl/src/hle/d3d12x/bind.rs`: `execute_indirect` also puts off a drawing call whose pipeline is still being built. Signatures that change root arguments are excluded, because a translated pipeline skips them anyway. `tracked_pso` is no longer test-only. - `crates/xcl/src/hle/d3d12x/list_x.rs`: - `split` keeps the list's whole graphics state on the put-off segment: bindings, depth bias, index buffer, depth bounds. - `record_deferred` restores that state after the segment's Reset (`restore_bindings` and the new `restore_direct`). For a drawing call it Resets the segment with its pipeline, waited for as a bind did, so a call whose build failed goes to the PC with its stand-in bound, as it would have in its list. - `restore_direct` is `split`'s existing depth-bias / index-buffer / depth-bounds block, moved into a 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 one there 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. - Test `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 test `deferred_graphics_keeps_render_targets_after_descriptor_overwrite` against 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_release` pass (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 the `XCL_ADAPTER` fixture from #2622's review). Whole suite after `cargo build --workspace`: 1,422 passed, 4 failed (the known `fuzz_validate_and_gpu_0..3`, #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 `main` e1d84b7 with and without this change. The in-title A/B ran on 496dc74 (= e1d84b7 + #2404 @ 809da30, a local merge), with and without this change. #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 title thread 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, no SKIPPED. - `cargo test -p xcl --lib -- --test-threads=4` on `0d2517f`: 1295 passed, 4 failed, 26 ignored. The 4 failures are `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3` (`CreateComputePipelineState` `0x8007000E`). They fail the same way on `main` e1d84b7 (same seeds 70/545/1019/1507, GPU idle): pre-existing, #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`, then `cargo test --workspace --no-fail-fast -- --test-threads=4` on `0d2517f` (`--no-fail-fast` because the lib binary's 4 pre-existing failures otherwise stop cargo before the integration tests; `XCL_NETWORK=0`): **1420 passed, 4 failed, 46 ignored** over all 37 test binaries. The 4 failures are the fuzz tests above (pre-existing, #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`, #1426); `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows); and `pso_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, #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 (#2404): a title thread builds them one after another (`Chain::whole`, 15–24 s each), and the workers one at a time under the big-compile gate. Raising `XCL_HUGE_PSO_WANTED_CONCURRENCY` to 4 changed nothing. Measuring that wall together with #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 on `445129ba` (A). https://git.gtahub.st/github/xcl-dev--xcl/pulls/2611 - RTX 5070 Ti 16 GB, NWProgramming00, `main` `b49be18` vs this PR (`445129b`) merged, from identical cache copies, 600 s in the title: 980 presents after world entry with this PR, against 0 on `main`; 3 graphics builds on a title thread vs 12; no removals. https://git.gtahub.st/github/xcl-dev--xcl/pulls/2611 - AMD RX 9070 XT (RDNA4), DarkPanda69: the new test passes with no skip; `d3d12x::` 255 passed, 0 failed. https://git.gtahub.st/github/xcl-dev--xcl/pulls/2611 - RTX 3090 Ti (Ampere), GodlyBDS, A/B with this change backported (warm native cache, 1 GiB shader-heap profile): Present #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. https://git.gtahub.st/github/xcl-dev--xcl/pulls/2611 - RTX 3060 Ti, DavidM1911: `cargo test -p xcl --lib` all passed. https://git.gtahub.st/github/xcl-dev--xcl/pulls/2611 - 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). https://git.gtahub.st/github/xcl-dev--xcl/pulls/2611 **Regression run** `main`: ``` xcl-smoke v1 commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea gpu: NVIDIA GeForce RTX 5090 title: 9cc6a39e seconds: 200 exit: 0x0 frames shown: 1471 (PresentX 1471) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 31165 MB ``` This PR (`0d2517f`): ``` xcl-smoke v1 commit: 445129ba178eebd7b168e7469080d067b40f0e95 gpu: NVIDIA GeForce RTX 5090 title: 9cc6a39e seconds: 200 exit: 0x0 frames shown: 2034 (PresentX 2034) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 32071 MB ``` 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 `OMSetRenderTargets` and 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`) and `DispatchMesh` still wait in the call. The measured pattern is ExecuteIndirect, and they are left for a follow-up. - State that `Bindings` does not carry is lost on a put-off segment, as on a mid-list Wait split today: shading rate and combiners, the shading-rate image, sample positions, the view-instance mask, stream-output targets, and state an `ExecuteBundle` set. Not checked whether the title uses them on these passes. - The put-off path ignores the native `Close` result of a segment (both when the empty segment is made and after the call is recorded at the submit), so a segment whose recording failed would still be submitted. This is pre-existing in #2118's code and was found by KOLESNiii on #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` (not `SetPredicationBufferX`) is not seen by the split, so a draw put off from it runs unpredicated (the same gap #2118 has for dispatches). - With defaults, the huge-compile gate lets at most `XCL_HUGE_PSO_WANTED_CONCURRENCY` (2) wanted builds 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 is `a_graphics_execute_indirect_with_a_pipeline_still_building_waits_at_the_submit`), and if you can, `scripts/smoke.ps1` on this head against `main`. Look for skipped draws or a device removal that `main` doesn'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](https://claude.com/claude-code)
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 #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 #2088.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:34:49 +00:00
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-26 02:28 UTC · original · edited 2026-11-26 09:10 UTC

Update for head 445129b: rerun on main b49be18, same cards and --nocapture. On the RX 9070 XT, the default adapter here, a_graphics_execute_indirect_with_a_pipeline_still_building_waits_at_the_submit is ok and the deferred_ filter (the new render-target tests among them) gives 5 passed, with no SKIPPED. d3d12x:: gives 257 passed, 0 failed, 2 ignored, no SKIPPED, on both the RX 9070 XT and the RTX 3060.

AMD run (listed as untested): the new test passes on an RX 9070 XT, with no skip.

Head 0d2517f applied on main b49be18, debug, Windows 11 Pro 26200, RX 9070 XT (RDNA4, driver 32.0.32029.2010):

  • cargo test -p xcl --lib -- a_graphics_execute_indirect_with_a_pipeline_still_building --nocapture: a_graphics_execute_indirect_with_a_pipeline_still_building_waits_at_the_submit ok, no SKIPPED. The test makes its device on the default adapter, which is the RX 9070 XT here.
  • cargo test -p xcl --lib -- d3d12x:: --test-threads=4: 255 passed, 0 failed, 2 ignored.

Not tested: this test on the machine's RTX 3060 (it always uses the default adapter), a title, Intel, Wine / vkd3d-proton.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

**@⁠DarkPanda69** on GitHub · 2026-11-26 02:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/2611#issuecomment-7180831722) · edited 2026-11-26 09:10 UTC **Update for head `445129b`:** rerun on `main` `b49be18`, same cards and `--nocapture`. On the RX 9070 XT, the default adapter here, `a_graphics_execute_indirect_with_a_pipeline_still_building_waits_at_the_submit` is ok and the `deferred_` filter (the new render-target tests among them) gives 5 passed, with no SKIPPED. `d3d12x::` gives 257 passed, 0 failed, 2 ignored, no SKIPPED, on both the RX 9070 XT and the RTX 3060. AMD run (listed as untested): the new test passes on an RX 9070 XT, with no skip. Head `0d2517f` applied on `main` `b49be18`, debug, Windows 11 Pro 26200, RX 9070 XT (RDNA4, driver 32.0.32029.2010): - `cargo test -p xcl --lib -- a_graphics_execute_indirect_with_a_pipeline_still_building --nocapture`: `a_graphics_execute_indirect_with_a_pipeline_still_building_waits_at_the_submit` ok, no SKIPPED. The test makes its device on the default adapter, which is the RX 9070 XT here. - `cargo test -p xcl --lib -- d3d12x:: --test-threads=4`: 255 passed, 0 failed, 2 ignored. Not tested: this test on the machine's RTX 3060 (it always uses the default adapter), a title, Intel, Wine / vkd3d-proton. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 02:31 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 02:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/2611#issuecomment-7180889956) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 26 ignored. Thanks! — Devin
Author
Owner

@⁠GodlyBDS on GitHub · 2026-11-26 02:34 UTC · original · edited 2026-11-26 02:58 UTC

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 08294413, a warm but incomplete native PSO cache (6,234 entries at launch), a per-executable 1 GiB shader heap reserve, and no fixed run timer. The PR itself was not applied in this measurement.

  • The largest gap between successful Presents was 376.217 s, from 474.656 s through 850.873 s. One recording thread recorded 64 graphics ExecuteIndirect PSO waits on 64 distinct scheduler IDs in that interval. Median wait was 5.465 s, maximum 11.340 s, and their sum was 373.302 s.
  • Matching scheduler IDs to native-driver compile event IDs found 64 graphics completions, totaling 103.402 s inside the driver and 0 s of measured driver-gate wait for those events. The wider PSO wait includes other stages. This trace does not attribute the difference to any specific one of them.
  • Presents resumed without a device reset at the end of the gap. Rendering reached opening overlays; visible 3D geometry was not verified. I did not classify the command signatures in this run, so 64 is a baseline count of observed waits, not a count of calls eligible for this PR's deferral.

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 0d2517f0 onto the same local 08294413-based texture-remap control, preserving the existing scheduler trace and adding separate timing for the submit-side wait. The two arms used the same verified 6,569 native cache entries, four DXC/PSO workers, and the same 1 GiB per-executable NVIDIA reserve. No fixed run timer. The PR's graphics ExecuteIndirect regression passed on the RTX 3090 Ti (1 passed, no skip), including its GPU pixel readback.

One run per arm Control #2611 backport
Present #1,689 534.704 s 278.814 s
Longest Present gap before #1,689 251.969 s 21.689 s
Traced graphics-only deferred calls 0 104 calls, 24 distinct pipeline IDs
Traced graphics submit-side waits N/A 7 distinct IDs, 28.997 s total, 12.469 s max

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 XCL_PSO_PRELOAD reduced process-private memory by about 2.2 GiB at Presents #1,200 and #1,500 with similar texture-page usage. Later the run logged 685 graphics deferrals, 564 of them DispatchMesh calls. Process private bytes grew from approximately 33.3 to 43.2 GiB across consecutive five-second samples. The first failure in this sequence was E_OUTOFMEMORY allocating a 32 MiB two-pass record buffer, followed by more allocation failures, DXGI_ERROR_DEVICE_REMOVED from native PSO creation, and process exit 0xC0000409. There was no matching Windows display reset in the run interval. The final captured frame did not contain 3D geometry.

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.

**@⁠GodlyBDS** on GitHub · 2026-11-26 02:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/2611#issuecomment-7180933331) · edited 2026-11-26 02:58 UTC 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 `08294413`, a warm but incomplete native PSO cache (6,234 entries at launch), a per-executable 1 GiB shader heap reserve, and no fixed run timer. **The PR itself was not applied in this measurement.** - The largest gap between successful Presents was **376.217 s**, from 474.656 s through 850.873 s. One recording thread recorded **64 graphics `ExecuteIndirect` PSO waits on 64 distinct scheduler IDs** in that interval. Median wait was 5.465 s, maximum 11.340 s, and their sum was 373.302 s. - Matching scheduler IDs to native-driver compile event IDs found 64 graphics completions, totaling **103.402 s inside the driver** and 0 s of measured driver-gate wait for those events. The wider PSO wait includes other stages. This trace does not attribute the difference to any specific one of them. - Presents resumed without a device reset at the end of the gap. Rendering reached opening overlays; visible 3D geometry was not verified. I did not classify the command signatures in this run, so 64 is a baseline count of observed waits, not a count of calls eligible for this PR's deferral. 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 `0d2517f0` onto the same local `08294413`-based texture-remap control, preserving the existing scheduler trace and adding separate timing for the submit-side wait. The two arms used the same verified 6,569 native cache entries, four DXC/PSO workers, and the same 1 GiB per-executable NVIDIA reserve. No fixed run timer. The PR's graphics `ExecuteIndirect` regression passed on the RTX 3090 Ti (1 passed, no skip), including its GPU pixel readback. | One run per arm | Control | #2611 backport | | --- | ---: | ---: | | Present #1,689 | 534.704 s | 278.814 s | | Longest Present gap before #1,689 | 251.969 s | 21.689 s | | Traced graphics-only deferred calls | 0 | 104 calls, 24 distinct pipeline IDs | | Traced graphics submit-side waits | N/A | 7 distinct IDs, 28.997 s total, 12.469 s max | 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 `XCL_PSO_PRELOAD` reduced process-private memory by about 2.2 GiB at Presents #1,200 and #1,500 with similar texture-page usage. Later the run logged 685 graphics deferrals, 564 of them `DispatchMesh` calls. Process private bytes grew from approximately 33.3 to 43.2 GiB across consecutive five-second samples. The first failure in this sequence was `E_OUTOFMEMORY` allocating a 32 MiB two-pass record buffer, followed by more allocation failures, `DXGI_ERROR_DEVICE_REMOVED` from native PSO creation, and process exit `0xC0000409`. There was no matching Windows display reset in the run interval. The final captured frame did not contain 3D geometry. 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.
Author
Owner

@⁠KDenKC on GitHub · 2026-11-26 04:02 UTC · original

AMD RDNA2 run of the new test, with the adapter shown. Head 0d2517f, debug, Windows 11 Pro 26200, on the integrated AMD Radeon(TM) Graphics of a Ryzen 7 9800X3D (RDNA2; driver version not recorded). The list_x fixture was temporarily changed (local, test-only, not part of this PR) to select the adapter with XCL_ADAPTER and print it:

  • list_x fixture adapter: AMD Radeon(TM) Graphics; WARP=false
  • cargo test -p xcl --lib a_graphics_execute_indirect_with_a_pipeline_still_building -- --test-threads=4: a_graphics_execute_indirect_with_a_pipeline_still_building_waits_at_the_submit ok, 1 passed, 0 failed, no SKIPPED.

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.

**@⁠KDenKC** on GitHub · 2026-11-26 04:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/2611#issuecomment-7182248049) **AMD RDNA2 run of the new test, with the adapter shown.** Head `0d2517f`, debug, Windows 11 Pro 26200, on the integrated AMD Radeon(TM) Graphics of a Ryzen 7 9800X3D (RDNA2; driver version not recorded). The `list_x` fixture was temporarily changed (local, test-only, not part of this PR) to select the adapter with `XCL_ADAPTER` and print it: - `list_x fixture adapter: AMD Radeon(TM) Graphics; WARP=false` - `cargo test -p xcl --lib a_graphics_execute_indirect_with_a_pipeline_still_building -- --test-threads=4`: `a_graphics_execute_indirect_with_a_pipeline_still_building_waits_at_the_submit` **ok**, 1 passed, 0 failed, no SKIPPED. 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.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-26 05:29 UTC · original

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. This PR does not change the mad/mac red on RADV.
Targeted run of a_graphics_execute_indirect_with_a_pipeline_still_building_waits_at_the_submit: passed.

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.

**@⁠SlopTart** on GitHub · 2026-11-26 05:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2611#issuecomment-7183538719) **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). `gpu_` suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. This PR does not change the mad/mac red on RADV. Targeted run of `a_graphics_execute_indirect_with_a_pipeline_still_building_waits_at_the_submit`: passed. **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.
Author
Owner

@⁠KDenKC on GitHub · 2026-11-26 06:14 UTC · original

Thanks @⁠luckyteagirl, you're right. A deferred graphics call keeps only the RTV/DSV CPU handles from OMSetRenderTargets (note_render_targets), and restore_bindings binds them again at submit. If the title rewrites or frees that descriptor between recording and submit, the replay binds whatever the slot holds by then. The mid-list split reads the same handles at record time, so there is no gap there; the gap is specific to the put-off draws this PR adds.

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.

**@⁠KDenKC** on GitHub · 2026-11-26 06:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/2611#issuecomment-7184224779) Thanks @⁠luckyteagirl, you're right. A deferred graphics call keeps only the RTV/DSV CPU handles from `OMSetRenderTargets` (`note_render_targets`), and `restore_bindings` binds them again at submit. If the title rewrites or frees that descriptor between recording and submit, the replay binds whatever the slot holds by then. The mid-list split reads the same handles at record time, so there is no gap there; the gap is specific to the put-off draws this PR adds. 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.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 05:56 UTC · original · reviewed

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.

**@⁠luckyteagirl** on GitHub · 2026-11-26 05:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/2611#pullrequestreview-6069212926) · **reviewed** 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](https://learn.microsoft.com/en-us/windows/win32/direct3d12/non-shader-visible-descriptor-heaps#non-visible-views). 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 08:29 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 08:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2611#issuecomment-7186652323) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. 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)
Author
Owner

@⁠KDenKC on GitHub · 2026-11-26 09:09 UTC · original

@⁠luckyteagirl fixed in 445129ba, as promised in 7184224779. A put-off graphics call now copies the bound RTV/DSV descriptors into small XCL-owned CPU heaps before the split, and the replay binds the copies.

  • The new overwrite test failed on the old code: the draw landed in B, not A.
  • With the fix, it and the heap-release test pass on an RTX 5090 and on an AMD RDNA2 iGPU.
  • list_x passes 43/43 on each, and the whole suite shows only the known fuzz failures.

One boundary is written in the code: a rewrite between OMSetRenderTargets and the draw is still read at defer time, where native D3D12 copies at OMSetRenderTargets. Capturing there needs per-binding copies, so it is a separate follow-up to keep this PR small.

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.

**@⁠KDenKC** on GitHub · 2026-11-26 09:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/2611#issuecomment-7187511852) @⁠luckyteagirl fixed in `445129ba`, as promised in 7184224779. A put-off graphics call now copies the bound RTV/DSV descriptors into small XCL-owned CPU heaps before the split, and the replay binds the copies. - The new overwrite test failed on the old code: the draw landed in B, not A. - With the fix, it and the heap-release test pass on an RTX 5090 and on an AMD RDNA2 iGPU. - `list_x` passes 43/43 on each, and the whole suite shows only the known fuzz failures. One boundary is written in the code: a rewrite between `OMSetRenderTargets` and the draw is still read at defer time, where native D3D12 copies at `OMSetRenderTargets`. Capturing there needs per-binding copies, so it is a separate follow-up to keep this PR small. 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.
Author
Owner

@⁠NWProgramming00 on GitHub · 2026-11-26 11:53 UTC · original

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 main after the same point. Most graphics builds after world entry run on the workers. Neither run reached world rendering, and the later stop with this PR coincides with cold compute builds, not graphics ones.

Setup

  • RTX 5070 Ti 16 GB (driver 32.0.16.2124), Ryzen 7 9700X, Windows 11 26300, Rust 1.100 MSVC, release. XCL_NETWORK=0 XCL_ACTIVITY=1, A pressed by XCL_PRESS_A_AT (15–150 s, every 5 s), XCL_THREAD_DUMP_AT=300, 600 s per run. Retail title of #505.
  • Trees: main b49be18, and b49be18 with this PR (445129b) merged locally (no conflicts).
  • Caches: one xcl shaders <pack> --precompile --only cs --used-only --pipelines on b49be18 (811 compute pipelines, 0 refused). I then copied the XCL cache folder twice (5.5 GB each) and gave each run its own copy through XCL_DXIL_CACHE, so both started from the same XCL and driver blobs. Graphics driver blobs for this tree were cold in both.
  • Order: this PR first, then main. NVIDIA's own shader cache was not cleared between the runs, so any advantage from it went to main.

Results

main b49be18 with #2611
first #101 (world entry) 252.4 s 299.3 s
last 2 s window with a present 254.1 s 368.1 s
presents after #101 0 980
graphics driver builds finished after #101 29 (80.5 s in the driver) 14 (38.8 s)
… of them on a title thread (ungated here) 12 3
… on an xcl-pso worker (gated) 17 11
"put off to the submit" lines 7 13
frames in 600 s, exit 3,319, exit 0 5,485, exit 0
  • On main, presents stop within 2 s of world entry and do not come back. Graphics builds go on to the end of the run, 12 of them on a title thread.
  • With this PR, the title presents about 30 frames per 2 s for 69 s after world entry, then 0 from 370 s to the end.
  • What the stop with this PR coincides with:
    • Three cold compute builds (blob absent; they were not in --used-only's list) started only at 369.7 s, 388.2 s and 417.1 s, after waiting 343, 375 and 401 s for the huge-build slot.
    • They took 18.5, 28.8 and 6.5 s in the driver.
    • A 1.29 MB cold compute build that started at 529.8 s had not finished at 600 s.
    • I have no thread dump from that stretch (mine was at 300 s), so I do not claim that this is what holds the frames.
  • Device removals: none in either run.

What this does and does not show

  • One run each, so run-to-run variance is not known. The world-entry times differ by 47 s between the two runs.
  • It fits what the PR describes: the title thread no longer builds most graphics pipelines itself, and frames go on after world entry while builds run on the workers.
  • Not tested: AMD, XCL_DIRECT_DXIL=1, more runs, a smoke pair.

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.

**@⁠NWProgramming00** on GitHub · 2026-11-26 11:53 UTC · [original](https://github.com/xcl-dev/xcl/pull/2611#issuecomment-7191296845) 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 `main` after the same point. Most graphics builds after world entry run on the workers. Neither run reached world rendering, and the later stop with this PR coincides with cold compute builds, not graphics ones. **Setup** - RTX 5070 Ti 16 GB (driver 32.0.16.2124), Ryzen 7 9700X, Windows 11 26300, Rust 1.100 MSVC, release. `XCL_NETWORK=0 XCL_ACTIVITY=1`, A pressed by `XCL_PRESS_A_AT` (15–150 s, every 5 s), `XCL_THREAD_DUMP_AT=300`, 600 s per run. Retail title of #505. - Trees: `main` `b49be18`, and `b49be18` with this PR (`445129b`) merged locally (no conflicts). - Caches: one `xcl shaders <pack> --precompile --only cs --used-only --pipelines` on `b49be18` (811 compute pipelines, 0 refused). I then copied the XCL cache folder twice (5.5 GB each) and gave each run its own copy through `XCL_DXIL_CACHE`, so both started from the same XCL and driver blobs. Graphics driver blobs for this tree were cold in both. - Order: this PR first, then `main`. NVIDIA's own shader cache was not cleared between the runs, so any advantage from it went to `main`. **Results** | | `main` `b49be18` | with #2611 | |---|---|---| | first `#101` (world entry) | 252.4 s | 299.3 s | | last 2 s window with a present | 254.1 s | 368.1 s | | presents after `#101` | 0 | 980 | | graphics driver builds finished after `#101` | 29 (80.5 s in the driver) | 14 (38.8 s) | | … of them on a title thread (`ungated here`) | 12 | 3 | | … on an `xcl-pso` worker (`gated`) | 17 | 11 | | "put off to the submit" lines | 7 | 13 | | frames in 600 s, exit | 3,319, exit 0 | 5,485, exit 0 | - On `main`, presents stop within 2 s of world entry and do not come back. Graphics builds go on to the end of the run, 12 of them on a title thread. - With this PR, the title presents about 30 frames per 2 s for 69 s after world entry, then 0 from 370 s to the end. - What the stop with this PR coincides with: - Three cold compute builds (blob absent; they were not in `--used-only`'s list) started only at 369.7 s, 388.2 s and 417.1 s, after waiting 343, 375 and 401 s for the huge-build slot. - They took 18.5, 28.8 and 6.5 s in the driver. - A 1.29 MB cold compute build that started at 529.8 s had not finished at 600 s. - I have no thread dump from that stretch (mine was at 300 s), so I do not claim that this is what holds the frames. - Device removals: none in either run. **What this does and does not show** - One run each, so run-to-run variance is not known. The world-entry times differ by 47 s between the two runs. - It fits what the PR describes: the title thread no longer builds most graphics pipelines itself, and frames go on after world entry while builds run on the workers. - Not tested: AMD, `XCL_DIRECT_DXIL=1`, more runs, a smoke pair. 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.
Author
Owner

@⁠CryingLaughing on GitHub · 2026-11-26 12:33 UTC · original

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 (ff0000ff). B rejects it and keeps the blue clear (0000ffff).

Revision with the same test-only overlay After descriptor overwrite Focused result
Immediate parent 0d2517f05ff600ab24419633b4f069243bac33d7 Blue, matching B 0 passed, 1 failed at the expected assertion, 0 ignored
PR head 445129ba178eebd7b168e7469080d067b40f0e95 Red, matching A 1 passed, 0 failed, 0 ignored

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 LESS, and a fence before color readback. The device was verified as RTX 4080, driver 621.01, on an i5-13600K with Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC and DXC 1.8.2502.11. Overlay source SHA-256 f121b8e633ded12e2799804c6d7014fe3050f4333d1964c929160c186c267e80.

cargo test -p xcl --lib --locked -j 4 --no-run --message-format=json then hle::d3d12x::list_x::dsv_replay_tests::deferred_graphics_keeps_depth_after_descriptor_overwrite --exact --ignored --test-threads=1 --nocapture on each built test executable. This covers overwrite after deferral. The interval from OMSetRenderTargets to draw recording and retail behavior remain untested.

**@⁠CryingLaughing** on GitHub · 2026-11-26 12:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/2611#issuecomment-7192146356) 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 (`ff0000ff`). B rejects it and keeps the blue clear (`0000ffff`). | Revision with the same test-only overlay | After descriptor overwrite | Focused result | | --- | --- | --- | | Immediate parent `0d2517f05ff600ab24419633b4f069243bac33d7` | Blue, matching B | 0 passed, 1 failed at the expected assertion, 0 ignored | | PR head `445129ba178eebd7b168e7469080d067b40f0e95` | Red, matching A | 1 passed, 0 failed, 0 ignored | 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 `LESS`, and a fence before color readback. The device was verified as RTX 4080, driver 621.01, on an i5-13600K with Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC and DXC 1.8.2502.11. Overlay source SHA-256 `f121b8e633ded12e2799804c6d7014fe3050f4333d1964c929160c186c267e80`. `cargo test -p xcl --lib --locked -j 4 --no-run --message-format=json` then `hle::d3d12x::list_x::dsv_replay_tests::deferred_graphics_keeps_depth_after_descriptor_overwrite --exact --ignored --test-threads=1 --nocapture` on each built test executable. This covers overwrite after deferral. The interval from `OMSetRenderTargets` to draw recording and retail behavior remain untested.
Author
Owner

@⁠NWProgramming00 on GitHub · 2026-11-26 13:39 UTC · original

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, main b49be18). This time I used this PR together with #2613 (2d229b9), and a --used-only precompile with #2613's graphics warming: 23,215 compiled, 0 errors, 62 min. The cache copy came from the same state as before.

What holds the frames with #2611 + #2613 (one 600 s run, thread dump at 450 s):

  • The title's submit thread waits in q_execute_command_lists → list_x::record_deferred → bind::execute_indirect → pso_async::resolve_wait.
  • 13 of the 15 xcl-pso-* workers and the three xcl-pso-pre-* workers wait in big_compile_turn. One worker is in nvgpucomp64.dll.
  • After world entry, 78 graphics driver builds finished, with 260.9 s spent in the driver over 263 s of wall time, i.e. one at a time. Their gate waits add up to 3,731 s (at most 233 s).
  • Presents stop 1 s after world entry and do not come back.
  • The process commit is about 30 GB of the machine's 41.7 GB limit, so big_compile_commit_free (3 GB of free page file) stays false. A build is let through only once it is wanted.
  • record_deferred wants WANTED_AT_ONCE segments ahead, but each submit here had one put-off call, so only one build at a time was wanted. The other put-off calls (need_by_submit) stay unwanted until their own submit waits for them.

Local experiment: need_by_submit also calls p.want() the first time, behind a switch:

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):

  • 97 such graphics builds after world entry, 426.5 s spent in the driver over the 212 s from world entry to the end of the run. That is about 2 at a time instead of 1, which is the existing XCL_HUGE_PSO_WANTED_CONCURRENCY default.
  • Presents did not come back in the run either. It ended at 427 s in D3D12 device removed: 0x887a0005, with process commit at 30.2 GB.
  • I have no DRED or shader-code count from that run, so I cannot say whether this is #2403's shader-code heap, reached sooner because pipelines are made faster. I measured that wall at 429–448 MB on this card. It is not shown to be caused by the change.

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.

**@⁠NWProgramming00** on GitHub · 2026-11-26 13:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/2611#issuecomment-7193653105) 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, `main` `b49be18`). This time I used this PR together with #2613 (`2d229b9`), and a `--used-only` precompile with #2613's graphics warming: 23,215 compiled, 0 errors, 62 min. The cache copy came from the same state as before. **What holds the frames with #2611 + #2613** (one 600 s run, thread dump at 450 s): - The title's submit thread waits in `q_execute_command_lists → list_x::record_deferred → bind::execute_indirect → pso_async::resolve_wait`. - 13 of the 15 `xcl-pso-*` workers and the three `xcl-pso-pre-*` workers wait in `big_compile_turn`. One worker is in `nvgpucomp64.dll`. - After world entry, 78 graphics driver builds finished, with 260.9 s spent in the driver over 263 s of wall time, i.e. one at a time. Their gate waits add up to 3,731 s (at most 233 s). - Presents stop 1 s after world entry and do not come back. - The process commit is about 30 GB of the machine's 41.7 GB limit, so `big_compile_commit_free` (3 GB of free page file) stays false. A build is let through only once it is `wanted`. - `record_deferred` wants `WANTED_AT_ONCE` segments ahead, but each submit here had one put-off call, so only one build at a time was wanted. The other put-off calls (`need_by_submit`) stay unwanted until their own submit waits for them. **Local experiment:** `need_by_submit` also calls `p.want()` the first time, behind a switch: ```rust 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): - 97 such graphics builds after world entry, 426.5 s spent in the driver over the 212 s from world entry to the end of the run. That is **about 2 at a time instead of 1**, which is the existing `XCL_HUGE_PSO_WANTED_CONCURRENCY` default. - Presents did not come back in the run either. It ended at 427 s in `D3D12 device removed: 0x887a0005`, with process commit at 30.2 GB. - I have no DRED or shader-code count from that run, so I cannot say whether this is #2403's shader-code heap, reached sooner because pipelines are made faster. I measured that wall at 429–448 MB on this card. It is not shown to be caused by the change. **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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2611/head:github-bot/gh-2611'
git switch 'github-bot/gh-2611'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2611'
git switch 'github-bot/gh-2611'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2611'
git switch 'github-bot/gh-2611'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2611'
git switch 'main'
git merge --squash 'github-bot/gh-2611'
git switch 'main'
git merge --ff-only 'github-bot/gh-2611'
git switch 'main'
git merge 'github-bot/gh-2611'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.