Skip to content

D3D12.X: an ExecuteIndirect of a split program runs its pieces - #2404

Open
Kalmarv wants to merge 15 commits into
xcl-dev:mainfrom
Kalmarv:chain-indirect
Open

Kalmarv wants to merge 15 commits into
xcl-dev:mainfrom
Kalmarv:chain-indirect

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2088.

On NVIDIA with XCL_DIRECT_DXIL=1, a retail title's world load stalls on whole-program compiles. Each per-material ray-tracing resolve program is split into 9–14 pieces, and those build fast. The title then dispatches the program through ExecuteIndirect, and bind.rs falls back to the program's whole form (690–950 KB of DXIL), compiled synchronously on the title's thread. In a 600 s run on main 0829441 (RTX 5070 Ti), 11 of these compiles took 16–40 s each, one after another, from 326 s to past the end of the run.

This makes such an ExecuteIndirect run the program's pieces. The title's group counts are written on the GPU, so the CPU cannot cut them into slabs when recording. A one-thread compute pass (the slicer) reads the title's arguments and count on the GPU. For a fixed number of rounds it writes, for each slab of dispatch_slabs, one command per piece: the root constants record_dispatch_chain sets, then the slab's group counts. Each piece then runs one ExecuteIndirect per round with a command signature on the chain's root signature, with UAV barriers between them, in the bounded scratch split dispatches already use. Unused rounds dispatch nothing.

All of the title's ExecuteIndirects of split programs (150 in a 360 s run) used one command signature: one Dispatch, stride 12, MaxCommandCount 1, no count buffer. Their group counts were 0 when recorded during load.

What is in it

Rebased onto main b49be18. The hashes in this list are the rebased commits. Under Tested, 77cfec2, d76f773 and 809da30 are the same commits before the rebase (now 9125edb, f0cef78 and 3ca9071).

  • D3D12.X: an ExecuteIndirect of a split program runs its pieces (4aadaab):

    • gpu/recomp/pso.rs: the slicer (HLSL compiled once per device), the chain's command signature, a one-Dispatch command signature for the whole form, record_slicer, record_dispatch_chain_indirect and slab_count, with a test that slab_count matches dispatch_slabs.
    • hle/d3d12x/real/dispatch_chain.rs: execute_indirect. The number of rounds comes from the arguments the CPU sees when recording and the most slabs an earlier ExecuteIndirect of the program needed, plus a quarter (2 to XCL_SPLIT_INDIRECT_ROUNDS).
      • The slicer first counts the slabs. When there are more than the rounds and the whole form is built already, it leaves the rounds empty and writes the title's Dispatch arguments after its own words. The whole form then runs on them through ExecuteIndirect. Otherwise it leaves those arguments empty, so exactly one of the two has groups. The whole form's ExecuteIndirect is recorded first, and the rounds follow after a UAV barrier. Nothing is predicated: on NVIDIA Ampere cards, the predicated form of this ran the first piece in some skipped rounds and never ran the whole form. On an RTX 3080 Ti the whole form ran right after the slicer alone, but not after the pieces' ExecuteIndirects (review of this PR).
      • If the whole form is not built, the rounds still run. The slabs past them are lost, counted, and warned about once per program. The whole form is then built on another thread, and later ExecuteIndirects of the program get more rounds.
      • The slicer's words are read back when the allocator is reset.
      • The title's own predication also holds for the slicer, so the same choice is made under it.
      • Once the slicer is recorded, nothing returns early. If binding fails, the recording still keeps the commands buffer until the allocator is reset, with a test.
      • Bundles, lists without scratch and other command signatures keep the whole form.
      • The compute split line counts chained, whole and lost ExecuteIndirects.
    • hle/d3d12x/bind.rs, device_x.rs: the call site, and which command signatures are a single Dispatch.
  • Tests: a split program's ExecuteIndirect matches the whole program (dbc793d): runner::dispatch_split_indirect records it the way the runtime does. dispatch_chain_divergent_forward_edges_3d compares the memory with the whole program's output and checks the slicer's slab count for:

    • one command;
    • several commands, with empty ones and a count buffer that leaves the last one out;
    • a 20-byte stride;
    • slabs of 1–12 groups and 1–16 rounds;
    • each without and with a whole form built (its arguments then empty).

    With more slabs than rounds, it checks the slicer's flag and that the output matches with a whole form. That output would not match if the rounds also ran, because the whole form would then read words the pieces had already changed. Without a whole form, it checks that only the rounds' groups run.

  • D3D12.X: a chained ExecuteIndirect drops slabs only past 32 before its whole form (9125edb), in dispatch_chain.rs, after review:

    • An ExecuteIndirect of a program with none read back yet gets the most rounds: the arguments the CPU sees when recording read 0 while a title loads.
    • XCL_SPLIT_INDIRECT_ROUNDS defaults to 32, not 16.
    • The whole form is asked for at the program's first chained ExecuteIndirect. It is built on an xcl-pso thread, so a huge one waits for the huge-build gate. It is bound only on an overflow.
    • Tests for the first ExecuteIndirect's rounds and for the gate.

    In ten title runs of the earlier head 5ca9c23, six lost slabs: 158 over 73,714 chained ExecuteIndirects. All of them came from one program with 17 slabs per run: 15 at its first ExecuteIndirect (2 rounds), then 1 at each later one (16 rounds) until its whole form was built. With this commit none of them would have been lost. More than 32 slabs before the whole form is built are still lost, counted and warned about. Waiting for the whole form when recording would make it exact, but the precompile does not build the whole forms of split programs, so that is a cold 16–40 s compile on the title's thread. A follow-up records which programs a title runs as chained ExecuteIndirects, so that the precompile builds their whole forms; the runtime can then wait.

  • D3D12.X: a chained ExecuteIndirect under the title's predication is not read back (f0cef78), in dispatch_chain.rs, bind.rs and list_x.rs, after review. Under the title's predication the slicer may be skipped, and its zeroed words were then taken as a count: the program counted as measured with 0 slabs, so its next ExecuteIndirect whose arguments read 0 got 2 rounds instead of 32. Such an ExecuteIndirect is no longer read back. Tests: the device test also records one predicated and one plain ExecuteIndirect, and the list_x predication test checks the state the call reads. Reported by @thehollowedone.

  • Tests: the predicated ExecuteIndirect test binds the chain's root signature (70f687a): the device test of f0cef78 bound no root signature for the two ExecuteIndirects it records, which gave 258 messages under the debug layer with GPU-based validation (953, 744, 712). It still passed.

  • D3D12.X: once a split program's whole form is built, its last ExecuteIndirect sizes the rounds (3ca9071), in dispatch_chain.rs, with a unit test. Each round of a chained ExecuteIndirect is one barrier and one ExecuteIndirect per piece, also when empty, and on the RTX 5070 Ti such a step takes 14.4 µs of GPU time (144 µs a round for 10 pieces; measured with timestamps, review of this PR). The rounds followed the most slabs any ExecuteIndirect of the program had. Once the whole form is built, an overflow runs it, so the rounds now follow the last one read back. The cost per step comes from the barrier before an ExecuteIndirect whose signature sets root constants (0.41 µs with a Dispatch-only signature). A follow-up PR removes the root constants from the pieces' ExecuteIndirects.

  • Tests: the chained ExecuteIndirect device test binds descriptor heaps (0755bd7): under GPU-based validation the device test gave 4 errors (1419) at 809da30. Its bind set the chain's root signature, which indexes the descriptor heaps directly, on a list without heaps. It now sets two shader-visible heaps first, as a title's list has them.

  • D3D12.X: a chained ExecuteIndirect takes on a list the pool does not track (50205bc), in alloc_pool.rs and dispatch_chain.rs, with a unit test.

  • D3D12.X: a list made or released at an address drops the chain scratch (073f8ea), in dispatch_chain.rs and list_x.rs, with a unit test. The chains of one recording share one scratch, found by the list's address. Addresses are reused (D3D12.X: a direct list at a released compute list's heap vtable address gets the compute list's methods #2588): a list created where a released one was could share the old list's scratch with work the GPU may still be running. list_x now forgets the entry when a list is created and when it is released.

  • D3D12.X: a PC allocator put aside lets go of its chain recordings once free (551a75e), in alloc_pool.rs, with three unit tests.

    • When the title resets an allocator whose recordings are still held or on the GPU, the pool puts the PC allocator aside and gives the title another. The one put aside was reset, and its chain recordings released, only when the same title allocator reused it, which may never happen.
    • Every title Reset now also releases the recordings of each PC allocator put aside that nothing holds any more: no list records on it and its submits are done.
    • Found by @dhillonjagdeep650-boop. On an RTX 3080 Ti, recordings went from 1 at 80 s to 1,887 under 48 allocators at 110 s, and local and non-local video memory grew about 150 MB/s each until a removal. The pool's line said 119 made, 119 put aside.
    • @Royalflamejlh traced the same leak independently (7181244718): a put-aside allocator keeps its recordings until a later Reset of the same title allocator takes it back. D3D12.X: reclaim idle put-aside allocators and retire orphaned batches #2138's reclaim_idle_in resets idle put-aside allocators, except a title's own allocator once put aside, and in their run that case held 2,258 of 11,061 recordings at 170 s. Their candidate, Royalflamejlh/xcl@f4608d7, differs from this commit:
  • D3D12.X: a title thread does not wait behind a background whole build's turn (97a70a7), in pso_async.rs and dispatch_chain.rs, with a unit test, after review (@pvfreis, review). want_whole builds the whole form on an xcl-pso* thread, so a huge one waits in big_compile_turn for a background slot and 3 GB of free commit, holding Chain::build_whole, and nothing told it a title thread waited. A title thread that needed the same form (bind.rs, or dispatch without scratch) waited behind that turn, without the wanted cap or the commit skip. Now such a thread counts itself in Chain::waiting while it waits, and the background build runs in pso_async::build_waited_on, so build_is_wanted is true on its thread while one does: the build goes as one the title waits for.

  • D3D12.X: the split-program counter line says what holds chain recordings (99ca688), in alloc_pool.rs and dispatch_chain.rs, with a unit test. Logging only. Every 10 s, with the compute split line, a second line splits the recordings held by the PC allocator they are under: compute split: N of M recordings held, under K PC allocators: put aside with a list on it …, put aside with submits on the GPU …, put aside and free …; in use and busy …, in use and free …; not the pool's … (M: all recordings made). In @pvfreis's and @Royalflamejlh's runs of 97a70a7 the recordings held kept rising (583 of 771 at 190 s, review; 7,410 under 115 allocators at 270 s, only 2,297 of them under ones put aside, review). This line says what holds them; the runs here do not reach that part of the title.

  • D3D12.X: whole forms of split programs are built in turn, not a thread each (c9904d7), in dispatch_chain.rs, with a unit test, after review (@Royalflamejlh). want_whole started an OS thread for each whole form, and each waited for its turn in big_compile_turn: at 280 s, 199 of 200 such threads were waiting. The whole forms now queue in three lanes, one for each slot set of driver_compile (under 256 KiB, huge, giant). A lane has at most one thread, which builds its forms one after another and ends when its queue is empty. A form whose program was released before its turn is not built. A title thread that needs a whole form still builds it itself.

  • D3D12.X: a chained ExecuteIndirect keeps the most rounds until the whole form is built (5b9d4ff), in dispatch_chain.rs, with its unit test changed, after review (@Royalflamejlh). 9125edb's 32 rounds held only until a program's first read-back. After it, the most slabs read back set the rounds, so a program whose earlier ExecuteIndirects had 1 slab got 2 rounds, and its next one, of 22 slabs, lost 20 (2 of 3 runs in that review). Until the whole form is built, a chained ExecuteIndirect now records XCL_SPLIT_INDIRECT_ROUNDS (32) rounds whatever was read back. Once it is built, the last one read back sizes them, as with 3ca9071. The cost is the empty rounds until the whole form is built (14.4 µs per piece step on the RTX 5070 Ti, as under 3ca9071; D3D12.X: the pieces of a split program read their slab from a root CBV #2633 makes that step 0.41 µs).

  • D3D12.X: a free_aside sweep keeps recordings made after the allocator's reuse (9620331), in alloc_pool.rs and dispatch_chain.rs, with a unit test, after review. title_reset decided which put-aside PC allocators were free under the pool lock, released it, and only then dropped their chain recordings; another title Reset could reuse such an allocator in between and record on it, and the sweep then released the new recording's commands buffer while the slicer was still to write it (the page fault in @Raul-Paiva's report). The recordings are now detached under the lock and dropped after it. The interleaving, this change and its test a_free_spare_reused_after_a_sweep_keeps_its_new_chain_recording are @thehollowedone's (review), applied as posted; @KDenKC posted an equivalent patch and found the same race (7196846147, 7197560233); in-title runs without the fault by @Raul-Paiva, @b3IKK and @Royalflamejlh (below).

1211 changed lines (1194 added), over the ~400 target: 121 are the GPU test and its runner, about 390 are unit tests, and 52 are the slicer's HLSL. The runtime part cannot be split further without leaving a commit whose ExecuteIndirect path runs nothing or is not called. The last seven commits fix how this PR's own recordings are kept, how its own background builds of the whole form wait and are run, and how many rounds it records before one is built, or count what holds its recordings, so they go with it.

Tested

  • Ryzen 9 9950X, RTX 5070 Ti (NVIDIA 610.74), Windows 11 build 26200, rustc 1.99.0, DXC 1.9.2609.
  • On 9620331 (this head), on the GPU (debug):
    • cargo test --workspace --no-fail-fast -- --test-threads=4: 1446 passed, 2 failed, 47 ignored (the new test among them). The two failed are link_tests::gpu_linked_memory_accessors and link_tests::linked_programs_keep_their_declarations (DXC: "attribute WaveSize only valid on entry point function"); they fail the same way on main b49be18 (cargo test -p xcl --lib link_tests: 0 passed, 2 failed). This machine's tests now take a different DXC than in the runs below: 144 SKIPPED (119 validator 1.7 < 1.8, validation step only; 21 no wave64; 3 refused f16 forms; 1 no heap windows).
    • cargo test -p xcl --lib -- alloc_pool dispatch_chain: 26 passed, 0 failed, 0 ignored.
    • In the title, others ran 5b9d4ff with this fix applied by hand (the same change, or @KDenKC's equivalent): @Raul-Paiva, RTX 3070 Laptop 8 GB, 0 page-fault dumps in 3 runs of 900 s against 8 of 10 without it (7199386758); @b3IKK, RTX 5080, 0 device removals in two 600 s runs (7198145884, 7199036830); @Royalflamejlh, RTX 4060 Ti on Linux, 0 of 2 runs lost the device against 2 of 2 without it (7200335602).
  • On 5b9d4ff (the previous head), on the GPU (debug):
    • cargo test --workspace --no-fail-fast -- --test-threads=4: 1447 passed, 0 failed, 47 ignored (the two new tests among them). 25 SKIPPED notices, as on 551a75e below.
    • The dispatch_chain and alloc_pool unit tests, --test-threads=1: 21 passed.
    • The dispatch_chain, split, execute_indirect and slab filters with the debug layer and GPU-based validation, --nocapture, on the local build described below, --test-threads=1: 50 passed, 0 failed, 1 ignored. 1 SKIPPED: dispatch_chain_native_wave64_builds_whole (no wave64). During the tests: 1 error, 884, from main's split_compute_program_prebuilds_and_caches_chain_pieces (a deliberately invalid blob); 275 warnings, 195 of 1328 and 80 of 926, as on 551a75e.
    • Without the GPU, each against the code before it (--test-threads=1): the_recordings_held_are_split_by_what_holds_their_allocator, whole_forms_wanted_together_are_built_one_after_another_on_one_thread and once_the_whole_form_is_built_the_last_execute_indirect_sizes_the_rounds: 1 passed each. With InTurn::push starting a thread for each item, as want_whole did: failed, 5 threads for 5 whole forms. With 97a70a7's rounds: failed, 2 rounds, not 32, after a read-back of 1 slab.
  • On 97a70a7, on the GPU (debug):
    • cargo test --workspace --no-fail-fast -- --test-threads=4: 1445 passed, 0 failed, 47 ignored (the new test among them). 25 SKIPPED notices, as on 551a75e below.
    • The new a_title_thread_does_not_wait_behind_a_background_whole_build_waiting_for_its_turn, three runs: 1 passed each. With the count left out (Chain::waiting not raised, as on 551a75e): failed, "the title thread waited for the background build's turn" (still waiting after 5 s).
    • The dispatch_chain unit tests, --test-threads=1: 7 passed. The dispatch_chain, split, execute_indirect and slab filters, --test-threads=1: 48 passed, 0 failed, 1 ignored, 1 SKIPPED (dispatch_chain_native_wave64_builds_whole, no wave64). pso_async and big_compile: 25 passed.
  • On 551a75e (rebased onto main b49be18), on the GPU (debug):
    • cargo test --workspace --no-fail-fast -- --test-threads=4: 1444 passed, 0 failed, 47 ignored. 25 SKIPPED notices: 21 for no native wave64 on this card, three per-lane FP16 forms the per-lane lowering refuses, and no heap windows. a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, which failed on 68a284a and d76f773, passes on this base.
    • The dispatch_chain unit tests, --test-threads=1: 6 passed, 0 failed.
    • The dispatch_chain, split, execute_indirect and slab filters, --test-threads=1: 47 passed, 0 failed, 1 ignored. 1 SKIPPED: dispatch_chain_native_wave64_builds_whole (no wave64).
    • list_x: 41 passed. alloc_pool: 8 passed (the four new tests among them).
    • The same filters with the debug layer and GPU-based validation, --nocapture, on the local build described below: 47 passed, 0 failed, 1 ignored. During the tests: 1 error, 884, from main's split_compute_program_prebuilds_and_caches_chain_pieces, which feeds the driver a deliberately invalid blob; and 275 warnings, 1328 and 926 as below. The device test's 4 errors (1419) at 809da30 are gone.
    • Without the GPU: cargo check -p xcl --lib --tests builds each of 50205bc, 073f8ea and 551a75e. The first of 551a75e's tests failed with the release taken out ("a free allocator put aside still held its chain recordings"; run on an earlier version of the same commit, with the same test and release), and passes with it.
  • On 551a75e, on an RTX 2060 (NVIDIA 595.91) under Wine (wine-staging 11.21) + vkd3d-proton 30b0eb9, a release windows-gnu test build, --test-threads=1, no XCL_D3D12_DEBUG or GPU-based validation set; correctness only: the dispatch_chain unit tests 6 passed; the dispatch_chain, split, execute_indirect and slab filters 47 passed, 0 failed, 1 ignored, SKIPPED dispatch_chain_native_wave64_builds_whole (no wave64); list_x 41 passed; alloc_pool 8 passed.
  • Tested by others, on this PR's head 97a70a7: @LocranKing, RTX 3060 Ti 8 GB (NVIDIA 621.40), Ryzen 5 5500, Windows 11 build 26300, rustc 1.100.0, debug (review). cargo test --workspace --no-fail-fast -- --test-threads=4: 1445 passed, 0 failed, 47 ignored, 27 SKIPPED: 21 no wave64, 3 per-lane FP16/FP32 forms, no heap windows, and two 0x887A002D (texture_states's uploads_start_from_each_subresources_state, no D3D12 debug layer; shaders's pso_measurement_compiles_an_exact_synthetic_record, no Developer Mode). Those two are main's tests of files this PR does not change. A 60 s smoke on their own title, from release builds: main b49be18 1409 frames, peak commit 14,032 MB; 97a70a7 1567 frames, 14,026 MB; no device removal or crash. It covers boot, intro and menus, not the world.
  • Tested by others, on 97a70a7: @pvfreis, RTX 3060 12 GB, 31.9 GB RAM, one release run each of 97a70a7 and main b49be18 from an empty cache, both with one local logging line (review). With this PR: 177 chained ExecuteIndirects, 0 whole, 0 slabs lost, no whole forms compiled, presenting again after a stall of about 33 s; recordings held rose from 54 at 140 s to 583 of 771 at 190 s, and their 37 GiB guard stopped the run at 192 s, with commit +322 MB/s and non-local video memory +214 MB/s over 170–190 s. On main, title threads compiled whole forms from 126.5 s to the 210 s limit and presenting stopped at 112 s. What holds the recordings is open; 99ca688's line is for that.
  • Tested by others, on 97a70a7: @Royalflamejlh, Linux + NVIDIA, 300 s runs from the same caches (review). With this PR: presenting after the title's burst in 3 of 3 runs, 15,299–35,755 chained ExecuteIndirects, 0 whole; 20 slabs lost in 2 runs (5b9d4ff above); non-local video memory 4.1 → 12.3–13.9 GB, their memory guard stopped 2 of 3. Without it: no presents after 76 s in 2 of 2, a title thread compiling a whole form in all four dumps.
  • Tested by others, on 97a70a7 + Shaders: --precompile --pipelines also builds a split program's whole form #2551: @KDenKC, RTX 5090 32 GB (NVIDIA 621.24), Windows 11, release (review): 0 slabs lost and 0 whole in 4 runs; the pool's PC allocators made kept growing with the resets (to 549 by 183 s, 710 by 440 s). Their runs ended in NVIDIA: the device is removed when the pipelines in use need more than 512 MB of shader code (0x887a0005) #2403's removals and one device hang they are still looking into.
  • Tested by others, on this PR's head 5b9d4ff: @thehollowedone, RTX 3080 Ti (NVIDIA 621.35), Ryzen 7 9800X3D, Windows 11 build 26300, rustc 1.99.1 (review). cargo test --workspace --no-fail-fast -- --test-threads=4: 1447 passed, 0 failed, 47 ignored, 25 SKIPPED. dispatch_chain_divergent_forward_edges_3d, --test-threads=1: 1 passed, no SKIPPED notice, the 32- and 64-thread cases on the card. Synthetic tests only, no title run.
  • Tested by others, on 97a70a7 (this PR's previous head): @jennydeth, RTX 3060 12 GB (NVIDIA 32.0.16.2101), Ryzen 5 5600X, Windows 11, rustc 1.100.0, release (review). cargo test --workspace --release --no-fail-fast -- --test-threads=4: 1445 passed, 0 failed, 47 ignored, 29 SKIPPED (21 no wave64, 3 per-lane FP16/FP32 forms, 3 no D3D12 debug layer, no heap windows, and pso_measurement_compiles_an_exact_synthetic_record). A 600 s smoke pair with default settings: main b49be18 2171 frames, peak commit 35,030 MB; 97a70a7 2211 frames, 36,162 MB; no device removal or crash. No program is split with default settings, so this pair does not reach this PR's code. With XCL_DIRECT_DXIL=1 (900 s, warm driver cache), one run of 97a70a7 logged 397 chained ExecuteIndirects, 0 whole, 0 slabs lost. Every direct run ended in a 0x887a0005 removal (DRED: page fault at VA 0x0) between 99 and 115 s, main's run too, as in NVIDIA: the device is removed when the pipelines in use need more than 512 MB of shader code (0x887a0005) #2403, so the removal is not from this PR.
  • Tested by others, on this PR's head 5b9d4ff: @jennydeth, RTX 3060 12 GB (NVIDIA 32.0.16.2101), XCL_DIRECT_DXIL=1, 900 s, warm caches, one run at the default shader heap and one with xcl run: xcl nvprofile puts xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) #2590's 1 GiB profile (review). Both: 2,474 pieces built, 0 whole, 0 slabs lost; 3,020 and 4,582 chained ExecuteIndirects by 160 s. Both lost the device (0x887a0005, DRED: page fault at VA 0x0), at 166.0 s and 163.6 s. At the default heap that is the removal main b49be18 has with these switches (114.8–216.0 s in their three runs). With the 1 GiB profile, two runs of b49be18 kept the device and this one run lost it; why is open.
  • Tested by others, on 5b9d4ff + D3D12.X: detach retired segments and reclaim idle aside allocators #2707 (dff6edc7, D3D12.X: detach retired segments and reclaim idle aside allocators #2707's side of the alloc_pool.rs conflict) + Shaders: --precompile --pipelines also builds a split program's whole form #2551: @KDenKC, RTX 5090, one run to NVIDIA: the device is removed when the pipelines in use need more than 512 MB of shader code (0x887a0005) #2403's removal at 161.4 s (review). At 160 s, against 5b9d4ff alone: 32 PC allocators (47), 848 recordings under busy allocators in use (1,719), 530 put aside with a list on it (559). So D3D12.X: detach retired segments and reclaim idle aside allocators #2707 lowers the allocators but not those held by lists: a list stays on its allocator until the title resets it elsewhere or releases it.
  • Tested by others, on main b49be18 + Direct DXIL: compute programs over 1.5 MB of plain DXIL are retried in the compact form #2301 with this PR's 5b9d4ff merged on top: @Natakout, RTX 3060 12 GB (NVIDIA 621.14), i9-13900K, Windows 11 build 26200, release, XCL_DIRECT_DXIL=1, 480 s runs from warm caches (review). Without this PR, presents stopped 3 to 31 s after the title's #101 in 5 of 5 runs; a symbolized dump showed one title thread compiling a whole form in Chain::whole and another waiting on build_whole. With it, no stall there in 2 of 2, and both lost the device 2 and 11 s after #101 (NVIDIA: the device is removed when the pipelines in use need more than 512 MB of shader code (0x887a0005) #2403's code heap). With xcl run: xcl nvprofile puts xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) #2590's 1 GiB profile, 5 runs: the world rendered at about one present every 2 s for 70 to 240 s, then the GPU hung (0x887a0006) in all 5. With TdrDelay/TdrDdiDelay at 60 s, no removal in 4 runs of 480 s, with world frames of about 0.5–2 s of GPU each (report); so these read as timeouts of long frames, not shown to come from the split. They list this PR among the five things their 3060 needs to get past #101. With splitting off (XCL_DIRECT_SPLIT_INSTRUCTIONS=0) their world ran about 4× faster.
  • Tested by others, on this PR's head 5b9d4ff: @ClosetPie107, RX 9070 16 GB (RADV, Mesa 26.3.1), Ryzen 5 9600X, Linux, Proton Experimental with a patched vkd3d-proton (ec207194), release windows-gnu (review). dispatch_chain: 16 passed; module::split: 8 passed; 0 failed, 0 SKIPPED. A 300 s run of the retail title with XCL_DIRECT_DXIL=1: exit 0, 1,800 presents, no crash or device removal; at 290 s 221 programs split, 2,355 pieces built, 24,395 chained ExecuteIndirects, 0 whole, 0 slabs lost, scratch 1,648 MiB (most 1,655). Not the full suite, Windows or NVIDIA.
  • Tested by others, of their own change, not of this PR's head: @Royalflamejlh's Royalflamejlh/xcl@f4608d7 (put-aside allocators reset at the title's Reset once their GPU work is done), on this PR at 77cfec2 with D3D12.X: keep caller allocator for untracked lists and retain whole PSOs in dispatch_chain #2333 (RTX 4060 Ti 16 GB, Linux, Wine + vkd3d-proton, 1 run each; review). Recordings held went from 11,061 under 156 allocators at 170 s to 3,316–5,563 under 59–82 allocators between 120 and 200 s, and non-local video memory from 8.7 GB at 169 s to 7.1 GB at 166 s. Their memory guard still stopped that run at 204.5 s for low system RAM.
  • On 77cfec2, d76f773 and 809da30, without the GPU:
    • cargo build --release -p xcl: builds on each. Its 2 warnings are deprecations in files this PR does not change (real.rs:3797, xgameruntime/mod.rs:547).
    • cargo clippy -p xcl --lib --tests: no warning on a line this PR changes, on each. It stops at 3 approx_constant errors (6.283_185_3 for TAU) in lower_valu.rs, lower_wide.rs and recomp/lower.rs, which this PR does not touch.
    • cargo test -p xcl --lib on the unit tests of the chain that need no GPU: 4 passed, 0 failed on each (slab_count against dispatch_slabs, the bounded scratch, the first ExecuteIndirect's rounds, the gate). On d76f773 and 809da30 also set_predication_buffer_state_transitions_and_lifecycle, and on 809da30 once_the_whole_form_is_built_the_last_execute_indirect_sizes_the_rounds: 1 passed each.
    • Not cargo fmt: the tree is not rustfmt-clean. The changed lines follow the code around them.
  • On d76f773, on the GPU (debug):
    • dispatch_chain_divergent_forward_edges_3d --test-threads=1, three runs: 1 passed, 0 failed each.
    • The dispatch_chain unit tests, --test-threads=1: 4 passed, 0 failed (the device test included).
    • The dispatch_chain, split, execute_indirect and slab filters with XCL_D3D12_DEBUG=1, --test-threads=4: 42 passed, 0 failed, 1 ignored. 1 SKIPPED: dispatch_chain_native_wave64_builds_whole (no wave64).
    • cargo test --workspace --no-fail-fast -- --test-threads=4: 1292 passed, 1 failed, 46 ignored. Failed: gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, as on 5ca9c23 and main 68a284a (below). 25 SKIPPED notices, as below.
    • The same filters with the debug layer and GPU-based validation, --nocapture, on a local build of the test runner that switches GPU-based validation on and prints every layer message (neither is an XCL option): 42 passed, 0 failed, 1 ignored. The messages printed during the tests showed 258 errors (953, 744, 712), all from the device test added in d76f773; 54a936a fixes that test. Also 266 warnings: 1328 (a buffer's initial state ignored) and 926 (a root view's address in a heap).
  • On 809da30, on the GPU (debug):
    • dispatch_chain_divergent_forward_edges_3d --test-threads=1, three runs: 1 passed, 0 failed each.
    • The dispatch_chain unit tests, --test-threads=1: 5 passed, 0 failed.
    • The dispatch_chain, split, execute_indirect and slab filters with XCL_D3D12_DEBUG=1, --test-threads=4: 43 passed, 0 failed, 1 ignored. 1 SKIPPED: dispatch_chain_native_wave64_builds_whole (no wave64).
    • The same filters with the debug layer and GPU-based validation, --nocapture, on the same local build (GPU-based validation and the messages are switched on there, not by an XCL option): 43 passed, 0 failed, 1 ignored. During the tests: 273 warnings, 1328 and 926 as above, and 4 errors, all 1419 and all from the device test: its bind sets the chain's root signature on a list without descriptor heaps (a title's list has them). No other test gave an error.
  • On the earlier, predicated head 5ca9c23 (on main 68a284a): cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 1289 passed, 1 failed, 46 ignored. Failed: gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, which fails on main 68a284a too, with the same assertion and output (lower_dxil.rs:1155); main's CI fails since Recompiler: a bridged mask write in the split form meets no barrier #2074. 25 SKIPPED notices: no native wave64 on this card, three per-lane FP16 forms the per-lane lowering refuses, and no heap windows. An earlier version of this description gave the filters with XCL_D3D12_DEBUG=1 as a debug-layer pass. The runner registers no message callback, so such a run shows no layer messages; it showed nothing.
  • The two title runs below are of 5ca9c23. In them no ExecuteIndirect needed more slabs than its rounds.
  • The title, 600 s, XCL_DIRECT_DXIL=all: this branch, against a 300 s run of main 68a284a with the same environment.
    • Whole compiles on the title's threads: 1 cdb sample of 132 between 90 and 600 s (one program under 256 KB, at 508 s, about 6 thread-seconds). The main run (300 s) did not get that far: from 168 s to its end, a title thread was in the call for an unsplit 1.39 MB compute build.
    • Counter at 595 s: 235 programs split, 2007 pieces built, 439 chained dispatches issued in 3326 slabs; scratch 654 MiB (most 654, largest dispatch 2109 in one slab); ExecuteIndirect: 1303 chained (0 of them whole, 0 slabs lost), 28 whole.
    • No slab lost or warned about, and the whole form in place of the rounds was never needed. The 28 whole ExecuteIndirects (from 499 s on) took one of the paths that keep the whole form; which one is not logged.
    • No device removal and no crash.
    • The world was not reached in 600 s on either build. What holds it now is two unsplit shadow-cascade compute programs that the driver builds one after the other on worker threads (1.39 MB and 1.58 MB of DXIL, 216 s and 211 s). This PR does not change them; Recompiler: split wave64 compute groups of several waves across dispatches #2097 splits them.
  • The title, 300 s, main 68a284a with this PR and Recompiler: split wave64 compute groups of several waves across dispatches #2097: past the loading screen into the intro cutscene, the first such run here on NVIDIA. The device was removed at 154 s (0x887a0005, local video memory full); the cause is open (#505 comment).
  • Native code size: the whole form of one ray-tracing resolve program (707,256 B DXIL) has an 894,574 B driver blob (GetCachedBlob).

Regression run

scripts/smoke.ps1 -Seconds 60, the same retail title, XCL_DIRECT_DXIL=1, a private XCL cache started from the same used-pipelines.txt. Both ran back to back in one queue job on the machine under Tested, from release builds of clean trees. That job ran in the queue's title lane, beside 2 other jobs (builds, suites or precompiles; no other title run or timing job runs at the same time there).

main b49be18 (this PR's base):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1228 (PresentX 1228)
presents per 2 s (last 3): 4 19 9
device removals: 0
crashes: 0
peak commit: 26156 MB

this PR, 9620331, the same recipe, in a title-lane job of its own after the push (the main side above is unchanged, the same base):

xcl-smoke v1
commit: 96203314ba8e266328c14292532a5d255edeee09
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1305 (PresentX 1305)
presents per 2 s (last 3): 27 15 7
device removals: 0
crashes: 0
peak commit: 23433 MB

compute split counter at the end of each run:

  • main: compute split: 171 programs split, 1811 pieces built, 0 chained dispatches issued in 0 slabs; scratch 0 MiB (most 0, largest dispatch 0 in one slab)
  • this PR (9620331): compute split: 6 programs split, 41 pieces built, 0 chained dispatches issued in 0 slabs; scratch 0 MiB (most 0, largest dispatch 0 in one slab); ExecuteIndirect: 0 chained (0 of them whole, 0 slabs lost), 0 whole. This run split 6 programs where both sides of the earlier pair split 171; I have not looked into why.

Neither run reaches a chained ExecuteIndirect. 551a75e alone, 120 s, same setup, in an earlier title-lane job beside other jobs (no main side: our harness failed it), reaches 6: 1324 frames, peak commit 30,050 MB, 0 device removals, 0 crashes, and the counter compute split: 92 programs split, 935 pieces built, 51 chained dispatches issued in 51 slabs; scratch 390 MiB (most 390, largest dispatch 9 in one slab); ExecuteIndirect: 6 chained (0 of them whole, 0 slabs lost), 0 whole.

Its scratch is 390 MiB because a chained ExecuteIndirect takes the whole scratch budget (XCL_SPLIT_SCRATCH_MB, 256 MiB) for its list: its group counts are not known when it is recorded.

Not tested

AI use

  • Claude Code with Claude Opus 5.5 wrote the code, the tests and this description (except 9620331, @thehollowedone's change and test applied as posted; their AI use is in their review), and ran the tests, the title runs and the regression run on the hardware above.

🤖 Generated with Claude Code

@GreemSC

GreemSC commented Nov 25, 2026

Copy link
Copy Markdown

Test report on AMD / Linux (RDNA3, RADV): with #2404 + #2097 no title thread builds a whole form any more, and with XCL_PSO_WAIT_MS=50 on top the title kept presenting to the end of both 180 s runs (+85 / +88 s after the first #101, against +4 / +7 s without the PRs).

Setup: RX 7900 XT 20 GB (Mesa 26.2.5 RADV), Linux 7.2, Proton-CachyOS Wine 11, a local vkd3d-proton build; 24 GB RAM, the game capped at 16 GB. Retail 1.0.2.1, XCL_DIRECT_DXIL=1, A pressed every 4 s from 22 s, 180 s runs, caches as left by earlier runs. Release build of main 68a284a + #1732 (2fb4601, has #871 and #877) + #684 (e56dbc3) + #1860 (bcc71b6) + the sparse.rs part of #203 + local logging, then this PR (5ca9c23f) and #2097 (d5c2781d).

tree (2 runs each) first #101 last present after #101 title threads at the thread dumps
without #2404/#2097 96.1 / 90.8 s 100.1 / 98.3 s +4 / +7 s one in bind::execute_indirect → dispatch_chain::whole → driver_pso (whole forms, median 5.3–5.7 s each on RADV); in one run a second in pso_async::resolve_for_bind
same + XCL_PSO_WAIT_MS=50 92.5 / 90.5 s 94.4 / 92.1 s +2 / +2 s still one (then two) in dispatch_chain::whole
+ #2097 + #2404 90.9 / 68.6 s 94.3 / 96.2 s +3 / +28 s none in whole; one or two in pso_async::resolve_for_bind → build_compute
+ #2097 + #2404 + XCL_PSO_WAIT_MS=50 91.7 / 94.6 s 179.9 / 179.4 s +88 / +85 s (the runs end at 180 s) none held by XCL's compiles
  • Split counters with both PRs at 180 s: 157 programs split, 1,664 pieces; ExecuteIndirect 150 chained, 0 whole. With XCL_PSO_WAIT_MS=50 as well: 13,249 / 17,508 chained, 0 whole, 0 slabs lost.
  • No crash, no device removal in any of the 8 runs. Past #101 the last tree presents 0.5–0.6 frames per second. Peak RAM + swap 15.7 GB, right under our 16 GB cap.
  • How the stop was read: the stalled runs' thread dumps (28 frames deep) and the SYNC_GRAPH cells: two Wait64 cells (0x42437fe00/fe08) had their value recorded (0x620) but never submitted while the title thread that recorded it was in Chain::whole, so the bridged prod=qNone waits of the same runs were not the block.

Not tested: what is on screen (no screenshots of these runs; longer runs with captures are going now), Windows, NVIDIA, this PR without the other carried PRs, a cold cache.

AI use: Claude Code (Claude Opus 5.5) ran the builds and runs on this machine, read the logs and thread dumps, and wrote this report.

@pvfreis

pvfreis commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Added for 97a70a7 (2026-11-26)

On an RTX 3060 12 GB, the PR run recorded 177 chained ExecuteIndirect calls, with zero whole-form executions or lost slabs. It compiled no whole forms and resumed presenting after a roughly 33 s stall. On main, title threads compiled whole forms from 126.5 s until the stop. Non-local video memory rose by about 1 GB after the early put-off bursts in both runs.

Tested

  • One release xcl run per build on an RTX 3060 12 GB with 31.9 GB RAM. main b49be183 + PR head 97a70a73 was built as b4bd408fe. The b49be183 baseline was built as 2f421655c. Each has one local logging line. Both runs started with an empty XCL cache and used the same scripted input and XCL_DIRECT_DXIL=1 XCL_COHERENT_HEAPS=0 XCL_COHERENT_MB=512 XCL_PSO_WAIT_MS=50 XCL_PSO_TRACE=1 XCL_NETWORK=0 XCL_ACTIVITY=1.
  • With this PR. The 37 GiB private-memory guard stopped the run at 192 s. The first chained dispatches and ExecuteIndirect calls appeared in the 140 s split line. At 190 s, 17 programs had been split and 594 dispatches chained. The log read ExecuteIndirect: 177 chained (0 of them whole, 0 slabs lost), 0 whole. The largest compute compile was 509 KB of DXIL.
  • The log counted 54, 111, 112, 138, 328 and 583 recordings held at 140, 150, 160, 170, 180 and 190 s. The count at 170 s matched all 117 chained dispatches and 21 chained ExecuteIndirect calls. At 190 s it was 583 of 771, with 40 PC allocator entries, including empty ones. Of the held recordings, 158 were ExecuteIndirect calls with 2 MiB of command buffers total. The pool logged 84 allocators made and 84 put aside at 170 s, then 409 made and 408 put aside at 190 s.
  • From about 135 to 168 s there were no presents and 0–5 submits per 2 s. Afterwards there were 0–2 presents and 5–56 submits per 2 s. By 188 s, 17,328 dispatches had followed the first chained ExecuteIndirect. Put-off dispatches #4096 and #8192 appeared at 173.8 and 183.5 s.
  • At 168, 170, 180 and 190 s, process commit was 30,550, 31,023, 33,858 and 37,459 MB, local video memory was 14,889, 14,977, 15,427 and 15,654 MB, and non-local video memory was 2,243, 2,398, 4,044 and 6,668 MB. From 170 to 190 s, non-local video memory rose by 214 MB/s and commit by 322 MB/s. The logged scratch (480 MiB at 190 s, 486 MiB peak) and 2 MiB of command buffers are far smaller than the late increase.
  • Without this PR. The 210 s time limit stopped the run. Put-off bursts #64–#1024 appeared at 111.7–112.2 s and #2048 at 116.2 s. Non-local video memory was 1,129 MB at 110 s, 1,378 at 112 s, 1,661 at 114 s, 1,880 at 118 s and 2,061 at 130 s. Commit rose from 27,691 to 30,000 MB. After 130 s, non-local video memory stayed within 2,063–2,073 MB and commit within 30,150–31,297 MB. With the PR, those bursts appeared at 133.5–134.9 s and 148.8 s, with non-local video memory rising from 1,142 to 2,184 MB and commit from 27,794 to 30,196 MB between 134 and 150 s.
  • On main, presenting stopped at 112 s and submits stayed at 0–2 per 2 s from 114 s. At the stop there were 956 dispatches after the first chained dispatch, with 106 chained dispatches and 106 recordings held since 130 s. Title threads started whole forms of three split programs (859, 899 and 943 KB of DXIL). Two compiled at 126.5–149.6 s and 149.6–182.4 s on a thread that issued ExecuteIndirect calls. The third started at 182.5 s on the PresentX thread and was still building at the stop.
  • The writes after the GPU … (fence at 5, wanted 6; 1 writes) warning appeared once on main, at 136.2 s. With the PR, the first warning was at 158.5 s, and the counter reached 64 by 187.2 s. The older 5ca9c23 run logged none.

The single run per build leaves open what drove the late 4.3 GB rise in non-local video memory, why the PR run stalled from 135 to 168 s, and whether main would show a similar rise if it resumed presenting.

Not tested

Rendered picture, the suite at 97a70a7, debug builds or AMD.

AI use

Claude Code (Claude Opus 5.5) ran the tests and drafted the report. Claude Fable 5.2 rechecked it. OpenAI Codex (GPT-6, exact serving variant unavailable) checked the live PR and applied the edits.


Added for 77cfec2 (2026-11-25): RTX 3060 12 GB (Ampere), dispatch_chain lib tests, one process per run: 5ca9c23 failed 3 of 3, 77cfec2 passed 10 of 10. Not run at d76f773, which leaves split.rs, pso.rs and runner.rs unchanged but changes one of the 12 tests (bind failure).

  • NVIDIA 617.14, Rust 1.100.0; non-interactive session, Low integrity, debug, --test-threads=1 (suite: 4), 32-lane waves only. Both unrebased; our hook in lib.rs repeats the runs, crates/xcl/tests left out.
  • 5ca9c23: 8 passed, 1 failed each: dispatch_chain_divergent_forward_edges_3d, split.rs:1101, 352, 384, 384 of 400 words differ. 77cfec2: 12 passed each. Both: dispatch_chain_native_wave64_builds_whole SKIPPED every run.
  • Suite: 77cfec2 merged onto e1d84b7 1425/1/46 (passed/failed/ignored), main e1d84b7 1422/1/46; same failure (e2e.rs:249, presents) and 25 SKIPPED.

Not tested: title, debug layer, wave64, AMD.

AI use: Claude Code; Claude Opus 5.5 ran and wrote this, a second Claude Opus 5.5 checked it against the logs, Claude Fable 5.2 reviewed the text.


RTX 3060 12 GB, 32 GB RAM, main 3ceb5507 + 5ca9c23 (no #2097): the whole-form stall did not occur before the title crashed at 527.7 s. One run.

Tested

  • Windows 11 26300, NVIDIA 617.14, Ryzen 9 5900XT, release; XCL_DIRECT_DXIL=1 XCL_PSO_WAIT_MS=50 XCL_COHERENT_HEAPS=0 XCL_COHERENT_MB=512 XCL_NETWORK=0. XCL cache empty, driver cache from earlier runs.
  • At 520 s: ExecuteIndirect: 8418 chained (0 of them whole, 0 slabs lost), 0 whole. From the first counted (150 s): 504,780 dispatches, 277 presents, one 2 s window without submits (470 s, two queue.Wait timeouts). Compute compiles >= 256 KB: 47, none on a title thread. Skipped console dispatches: 114,560 (524,288 ran).
  • Two earlier runs stopped in a title thread's 851 KB whole-form compile, at 213,267 dispatches (main 68a284a + a log patch) and 132,798 (0829441 + DirectStorage: read a physical-page list again when its request runs #1405 + D3D12.X: title texture reads outside the coherent window use the safe copy #751). Here its 11 pieces built on workers. Mains and caches differ: not a controlled pair.
  • Crash: 0x80000003 on 7 title threads at one address; cause unknown, not attributed to this PR. The process then did not exit (39 GiB private 88 s later) and the PC froze. Commit at equal dispatch counts was within 0.6 GB of the 68a284a run (to 213,267).
  • Free RAM under 1 GiB in 60 of 75 samples from 150 s (earlier runs: 8 and 29 of 32). Scratch peak 658 MiB (total 384; yours 654).

By reading (neither exercised here)

  1. xcl-chain-whole threads, one per program, skip the huge-build gate (xcl-pso* only). The whole is wanted even when slabs <= most_rounds(), which the next call in equal scratch fits.
  2. If bind()? fails, buffer is released with the slicer's dispatch recorded.

Not tested: picture, same caches without this PR, the suite, AMD. Unknown: exit code, whether our low-commit stop script ended it.

AI use: Claude Code. Claude Opus 5.5 ran it and wrote this; a second Claude Opus 5.5 checked the numbers; Claude Fable 5.2 reviewed the text; a person checked it.

@thiagocalile

Copy link
Copy Markdown

Independent test and smoke report for head 5ca9c23ffd858e487b7611211492afc456fadbad on an AMD Radeon RX 6600 (8 GB VRAM, RDNA2, native wave64).

Tested

  • Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64 + mesh shaders, driver 32.0.21045.29003, XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.8.2502.11.
  • XCL_ADAPTER=radeon cargo test --no-fail-fast -p xcl --lib -- split --test-threads=4: 32 passed, 0 failed, 1 ignored (0 skipped).

Regression run (scripts/smoke.ps1, release builds, XCL_ADAPTER=radeon)

main (2898511):

xcl-smoke v1
commit: 2898511af1c038a2ef809719e9b6f89e5675c422
gpu: AMD Radeon RX 6600
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1488 (PresentX 1489)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 11934 MB

PR #2404 (5ca9c23):

xcl-smoke v1
commit: 5ca9c23ffd858e487b7611211492afc456fadbad
gpu: AMD Radeon RX 6600
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1565 (PresentX 1565)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15400 MB

Not tested: NVIDIA/Intel GPUs, Linux/Wine, or world load past the 60 s smoke window.

AI use: Antigravity (Gemini 4 Neon) ran the builds, tests, and smoke runs and drafted this report; the account owner reviewed and approved posting.

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head 5ca9c23ffd858e487b7611211492afc456fadbad (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1287 passed, 3 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests and dispatch_chain tests ran and passed.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: 5ca9c23ffd858e487b7611211492afc456fadbad
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1607 (PresentX 1607)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13956 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

@thehollowedone

Copy link
Copy Markdown

Independent Windows/NVIDIA result on clean 5ca9c23. RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC, DXC/DXIL 1.8.2502.11. XCL_ADAPTER=RTX 3080 Ti, XCL_D3D12_DEBUG=1, XCL_NETWORK=0; offline Cargo, no sample data.

cargo test --offline --locked -p xcl --lib dispatch_chain_divergent_forward_edges_3d --jobs 6 -- --test-threads=1 --nocapture failed reproducibly on the untouched head: 0 passed, 1 failed, 0 ignored, 0 skipped. The earlier whole, split, slabbed, and non-overflow indirect cases in that fixture pass. At the first overflow fallback (threads=32, most=1, rounds=11), the slicer result matches the expected [partial=1, 0, slabs=12, 0], but the whole-form output does not appear: output word 0 remains 17 instead of 100000. This also reproduces with the D3D12 debug layer enabled. I have not established whether this is a fixture-only problem or affects runtime fallback.

Adjacent controls on the same head: cargo test --offline --locked -p xcl --lib execute_indirect --jobs 6 -- --test-threads=1 --nocapture 4 passed, 0 failed, 0 ignored, 0 skipped; cargo test --offline --locked -p xcl --lib slabs_cover_a_dispatch_once_within_their_size --jobs 6 -- --test-threads=1 --nocapture 1 passed, 0 failed, 0 ignored, 0 skipped.

Not tested: full workspace, retail title, other GPUs. AI-assisted. Codex (GPT-6, exact variant unavailable) ran the checks and drafted this report.

@b3IKK

b3IKK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Independent retail check on an RTX 5080 (retail 1.0.2.1, 600 s, XCL_DIRECT_DXIL=1, default wait): on a clean tree 68a284a + this PR's 2b19fec/5ca9c23 + #2097's 8524858/d5c2781, the run reports

compute split: 152 programs split, 1,413 pieces built, 159 chained dispatches issued in 1,318 slabs; ... ExecuteIndirect: 51 chained (0 of them whole, 0 slabs lost), 0 ...

at 600 s. Without the stack, the same title's direct runs fell back to ~900 KB whole forms built on title threads at 93, 135, 176, 224, 265, 303, 357, 398, 437, 474, 505 and 580 s — exactly the wall this PR describes. So the ExecuteIndirect whole-form fallback is gone here (0 whole, 0 slabs lost).

Caveat on presentation: this first stack run presented to 116 s (14 two-second intervals after 96 s), but it ran on a new base with a cold direct cache (8 cold compiles). A second run is warming it; I will report the number when it finishes. The 0 whole ExecuteIndirect count is the PR working as intended.

AI use: OpenCode, Claude Fable 5.2 built the stack, ran the retail title on this machine and wrote this.

@SlopTart

Copy link
Copy Markdown

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: 160 passed / 4 failed. Three are the known baseline trio on this lane; the fourth is the new gpu_promoted_uav_clear_values_pass_create_committed_resource failure that current main carries (reported here), not caused by this PR. Everything else is green.
Split-program ExecuteIndirect is in the area that produced the d3d12core.dll + 0x1AB118 crashes on #2338/#2344/#2349; no crash reproduces at this head on this lane.

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@b3IKK

b3IKK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Follow-up after a second (warm) run of the same stack: the ExecuteIndirect whole forms are still 0 of them whole, 0 slabs lost (392 chained), and the split counter grew to 294 programs, 2,778 pieces. Presentation did not improve: 92 s, with 31 cold split pieces of 291–372 KB starting every 5–10 s from 6 s to 185 s. So this PR does exactly what it says — the ExecuteIndirect fallback is gone — but on this title the remaining cost is the split pieces themselves, not the whole forms. The next lever is a warm/offline precompile of those pieces (#2338's path), not the ExecuteIndirect path.

AI use: OpenCode, Claude Fable 5.2 ran the second stack run on this machine and wrote this.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…#2404, xcl-dev#2405

Integrates VRAM top-mip pressure shedding (xcl-dev#2385), DXC wanted-compile
prioritization & worker headroom (xcl-dev#2423), inline split pipeline foreground
path (xcl-dev#2424), ExecuteIndirect split program dispatch (xcl-dev#2404), and hosted
view heap exhaustion null-pair fallback (xcl-dev#2405).

Assisted-by: Antigravity (Gemini 4 Neon)
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
, xcl-dev#2333, and UnadoptGuard test submits

Assisted-by: Antigravity (Gemini 4 Neon)
@ivall

ivall commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Read in full (body, thread, diff). The approach is the one I want for #2088: it removes the whole-form compiles from the title's threads, and the retail reports above agree on that (0 whole). Before it can be merged:

  1. The overflow fallback on the RTX 3080 Ti. @thehollowedone's report above: dispatch_chain_divergent_forward_edges_3d fails every time at the first case with more slabs than rounds. The slicer's words are right (partial 1, 12 slabs), but output word 0 stays 17, so the whole form's result is missing. It passes here on AMD RDNA4 and on your RTX 5070 Ti, so it looks driver- or card-dependent. Merging it would make that test red on such cards, and in a title the slabs past the rounds would be lost while read_back counts them as run whole. Does the predicate reach the pieces and the whole form with the same value there (did the pieces run in that case)? @thehollowedone, could you say how many words differ from the expected output, and whether it also fails with the two SetPredication calls taken out around the whole form?
  2. The command buffer on the error paths (@pvfreis's second point; I agree by reading, not reproduced). In dispatch_chain::execute_indirect, buffer is already referenced by the recorded slicer dispatch and transition when bind()? or the first compute piece lookup returns Err. It is then released while the list still uses it. It should be kept in RECORDINGS (or an equivalent) before the first call that can fail.
  3. Rebase. It conflicts with D3D12.X: keep caller allocator for untracked lists and retain whole PSOs in dispatch_chain #2333 in dispatch_chain.rs; D3D12.X: keep caller allocator for untracked lists and retain whole PSOs in dispatch_chain #2333 goes first (one test fix is pending there). The CI failure is the old a_bridged_mask_write… check, fixed on main by Tests: check divergent block barriers in a_bridged_mask_write #2420, so a rebase clears it too. #2372 would come after this one, for the cases that still need the whole form.

@pvfreis's first point (the xcl-chain-whole threads skip the huge-build gate) can be a follow-up; with #2372 the whole form would go through the PSO workers anyway.

Tested on AMD RDNA4 (native wave64), Windows, DXC 1.8.2502.11, debug, main 06055a7 with #2097 and this PR (5ca9c23) merged locally: whole suite 1413 passed, 2 failed, 46 ignored, 7 SKIPPED; with XCL_DIRECT_DXIL=1, gpu:: hle::d3d12x 943 passed, 2 failed, 24 ignored. The two failures are fuzz_validate_and_gpu_1 and _3, the same on main here. dispatch_chain list_x::tests --test-threads=8: 10 of 10 runs pass.

Not tested: a title run with this PR, NVIDIA.

AI use: Claude Code (Claude Opus 5.5) read the thread and the diff, ran the tests and wrote this on the maintainer's behalf.

@upipibi

upipibi commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Update: this report covers 5ca9c23 only. On 809da30 the same card passes: #2404 (comment) (13 passed, 0 failed, 3 processes); razormontana's RTX 3070 also passes there, including a run with the D3D12 debug layer: #2404 (comment).

@ivall On point 1, a second NVIDIA card: the same failure on an RTX 3070 8 GB (Ampere, driver 616.56; thehollowedone's 3080 Ti is on 621.35), Windows 11, debug, without the D3D12 debug layer. cargo test -p xcl --lib dispatch_chain -- --test-threads=1 at 5ca9c23 as is, 3 runs: 8 passed and 1 failed each time, dispatch_chain_divergent_forward_edges_3d at split.rs:1101, "whole form for 1 groups, 11 rounds". That is the first of the overflow cases this PR adds to the test.

How many words differ, from the assertion's left / right (384 output words plus 16 guard words): in runs 1 and 2, 16 output words hold the expected 100000+i (indices 32-60 and 224-252, every 4th), and in run 3, 24 do (also 256-284). All the other output words still hold their initial value (index + 17), and the 16 guard words are intact. Word 0 stays 17.

Added 20:13Z, corrected 20:50Z. Run alone (--exact) on this card, the output words that got their expected value: 0, 0 and 0 in three runs without the debug layer; 0, 8, 0, 56, 0, 0 and 8 in seven runs with XCL_D3D12_DEBUG=1. All other output words kept their initial value and the 16 guard words were intact every time. In those runs the device was not removed (GetDeviceRemovedReason S_OK, every fence completed), and the debug layer, with its messages captured through an info-queue callback, logged no errors, only a CreateCommittedResource initial-state warning.

With the two SetPredication calls taken out, the read-back buffer is all zero. Withdrawn: as @thehollowedone found, the pieces' own predicate (pso.rs:1387) stays set through the read-back copy, so that result shows the copy being skipped, not what the shaders wrote.

(Edited 20:20Z: corrected the counts above. I had first counted the 16 guard words as matching output words, and the time of the addition was a placeholder.)

AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only.

@treybertram06

Copy link
Copy Markdown
Contributor

Test report: #2372 and #2404 on an RTX 3080, retail title 7952987A

Summary: both PRs remove the world-load freeze on this card. With either one applied, every run then hits the silent 0x887a0005 device removal (#1452) at about 85–122 s.

Setup

Conflicts with current main

Base, 6 runs

  • Freeze: in 5 of 6 runs everything stops: presents, submits, dispatches and DirectStorage. Four froze at about 90 s and one at about 270 s. Audio keeps going until the end of the run.
  • Where it waits: thread dumps at 120, 240 and 400 s show a title thread in bind::execute_indirect → dispatch_chain::whole → Chain::whole. In 2 of the 3 dumps it is waiting; in the other it is in nvgpucomp64.dll. One dump also shows a second title thread in Chain::whole, presumably behind the build lock.
  • Device removal: 2 of 6 runs (90 s and 387 s).

#2404, 3 runs

  • Freeze: none. Log: ExecuteIndirect: 3455 chained (0 of them whole, 0 slabs lost), 37 whole, and no title thread builds a whole form.
  • Device removal: 0x887a0005 in 3 of 3 runs, at 90, 90 and 122 s. Each comes about 2 s after the first chained ExecuteIndirects, after a burst of 1-tile sparse maps.
  • Skips: the no buffer for the commands of a chained ExecuteIndirect skips come 2 ms after the removal, so they are a consequence of it.

#2372, 3 runs

  • Freeze: none. Log: whole form: 146 asked for, 146 built, 0 dispatches skipped while it was being built.
  • Device removal: 0x887a0005 in 3 of 3 runs, at 85, 90 and 94 s.

What this says
On this card the freeze has been hiding the removal: while the title waits on a whole build, it submits nothing. Once it keeps submitting, the removal comes at the next step every time. These runs can't tell whether either PR's GPU work contributes to the removal. One base run was also removed at 89.8 s, before the freeze took hold.

Not tested: AMD, other titles, and runs without XCL_UMA_SHADOW.

(Runs and report by Claude Code with Claude Opus 5.5. The commands and counts above come from these runs.)

@thehollowedone

thehollowedone commented Nov 25, 2026 •

Copy link
Copy Markdown

For the requested RTX 3080 Ti overflow check on #2404 head 5ca9c23: the unmodified dispatch_chain_divergent_forward_edges_3d failed in four single-threaded runs at the first overflow case (split 32, 1 group per slab, 11 rounds). Of 400 compared words, 376, 368, 360, and 328 differed. The 16 guard words stayed intact. The slicer tail assertion passed ([1, 0, 12, 0]). In those runs 8, 16, 24, and 56 output words changed from their initial values to the expected values, all at indices divisible by four; the other output words remained at their initial values. That shows some compute output, but the readback alone cannot establish which dispatch wrote it or whether the pieces and whole form observed the same predicate.

I then removed only the two SetPredication calls around the whole-form ExecuteIndirect in the test runner (runner.rs, lines 1707 and 1710), leaving the chain call, the whole-form ExecuteIndirect, and its command arguments in place. It still failed in three of three runs: all 400 readback words were zero, including the guards. This matches the separate RTX 3070 observation above. The edit was diagnostic only and is not proposed as a fix.

Windows 11 build 26300, NVIDIA RTX 3080 Ti / 621.35, Rust 1.99.1; cargo test --offline --locked -p xcl --lib dispatch_chain_divergent_forward_edges_3d --jobs 6 -- --test-threads=1 --nocapture. Each run: 0 passed, 1 failed, 0 ignored. Synthetic fixture only; no retail run for this check. AI-assisted: Codex (GPT-6, exact variant unavailable) made the local diagnostic edit, ran the tests, and drafted this report.

Update after predicate-isolation controls (same head and GPU): The two-call deletion above left the chain's earlier SetPredication active through the final CopyBufferRegion. Since D3D12 also predicates copies, the all-zero readback cannot establish what the shaders wrote. That experiment still fails, but its output should not be read as zero shader output.

  • Replacing only the first whole-form SetPredication with SetPredication(NULL) (keeping the final clear, the piece chain, and whole ExecuteIndirect) still failed in four runs: 344, 352, 384, and 336 of 400 words differed; the guard words stayed intact. Clearing the predicate before the fallback alone does not make this fixture pass.
  • Keeping the slicer, chain predicate setup, scratch binding, whole-form ExecuteIndirect and readback, but omitting the piece ExecuteIndirect loop only when a whole form is available, made the complete dispatch_chain_divergent_forward_edges_3d test pass (1/1, both 32- and 64-thread fixtures). This is a diagnostic control, not a proposed runtime behavior: it skips work that normal calls need.
  • The unmodified test still failed with XCL_D3D12_DEBUG=1. I queried the D3D12 InfoQueue after each synthetic dispatch: it recorded routine buffer initial-state warnings, but no error or corruption messages. This was the standard debug layer, not GPU-based validation.

These controls narrow the failing path to the piece indirect-command sequence before the fallback. They do not establish whether the cause is command recording, synchronization, or a driver interaction. All edits stayed in the scratch test worktree; no retail run or PR patch was made.

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: valid ExecuteIndirect work is knowingly truncated when slab count exceeds rounds and no whole form is ready. dispatch_chain.rs:337-355 leaves full=None unless chain.whole already exists, but still records only rounds chain commands. The new test at split.rs:1102-1107 explicitly accepts partial output for that first call. A later background-built whole form does not make the initial valid dispatch correct. Under title predication, full is forced None even when built and feedback is disabled, so over-limit predicated calls are permanently truncated. Please fall back to the original whole ExecuteIndirect whenever complete chain coverage cannot be guaranteed, including predicated cases.

@Kalmarv

Kalmarv commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Natakout for the write-up on #505 (7193547117). Two things from it for this PR:

  • You list this PR among the five things your 3060 needs to get past #101. Without it, a title thread builds Chain::whole inside execute_indirect for about 50 s. That is now in your entry under Tested by others, with the 4× world rate you saw with splitting off.
  • With TdrDelay/TdrDdiDelay at 60 s you had no removal in 4 runs of 480 s. At the default 2 s, world frames of 0.5–2 s of GPU time end in 0x887a0006 with a WATCHDOG dump. So we read your 5 of 5 hangs with the 1 GiB profile as timeouts from long frames. They have not been shown to come from the split. That answers what the DRED branch was for, so there is no need for the run I asked for in 7191552589. Thanks for that too.

AI use: Claude Code with Claude Opus 5.5 read the report and wrote this reply.

@afpruivo

afpruivo commented Nov 26, 2026 •

Copy link
Copy Markdown

RTX 3090 24 GB (621.40), retail 1.0.2.1 on main b49be18: with this PR at 5b9d4ff6 the device was removed in 3 of 3 runs, 22–47 s into the world. Without it, 0 of 2 in 480 s. Windows logged two of the three as shader MMU faults, not as timeouts; an Aftermath dump of a fourth (below) shows a shader writing into a freed buffer the size of this PR's chained-ExecuteIndirect commands buffer. The PR itself works as described here: thousands of chained ExecuteIndirects with 0 whole and 0 slabs lost, and about 92 % fewer Chain::whole demands. One machine and five runs, so read it as a direction, not a rate.

Setup

Tests at the merged tree: cargo test --release -p xcl --lib -- hle::d3d12x::real::dispatch_chain:: hle::d3d12x::real::chain_whole_capture:: gpu::dxil::module::split: 28 passed, 0 failed. --test gpu_compute_e2e: 7 passed, 0 failed, 1 SKIPPED (no heap windows).

run tree world start end chained ExecuteIndirects (whole, lost) Chain::whole demands peak commit
1 A 74.3 s no removal, 480 s – 224 40.6 GB
2 B 85.9 s 0x887a0006 at 132.6 s 6,673 (0, 0) 19 42.6 GB
3 B 84.2 s 0x887a0006 at 106.4 s 2,402 (0, 0) 16 39.4 GB
4 A 89.7 s no removal, 480 s – 222 40.5 GB
5 this PR alone 84.9 s 0x887a0006 at 131.9 s 7,168 (0, 0) – 42.5 GB

What Windows logged (System log, nvlddmkm):

  • Runs 2 and 5: 16 and 9 pairs of Graphics SM Warp Exception on (GPC …): MMU Fault with Multiple Warp Errors, on different SMs, plus event 153, at the time of the removal.
  • Run 3: only event 153.
  • Runs 1 and 4: nothing.
  • So at least two of the three look like shader memory faults rather than the 2 s watchdog. @Natakout's hangs were WATCHDOG timeouts and @Royalflamejlh's an Xid 109, both reported above.

DRED (all three: page fault at GPU VA 0x0, no allocation there or recently freed):

  • Run 2: a compute list on the title's queue stopped at 53 of 647 operations, 15 0 0 >6 15 0, with cs a2dd01b69d355516 bound.
  • Run 3: a list stopped at 3,279 of 20,307, 0 15 6 >15 0 0, on "a stand-in, or not translated" pipeline.
  • I have not mapped these to the slicer or to chain pieces. The chain-indirect-dred diagnostic branch would be the way to do that.

Update: an Nsight Aftermath dump of the fault. Run 6: this PR alone again, same setup, with the Nsight Aftermath Monitor 2026.4 in Global mode (resource tracking and additional shader error reporting on, shader debug info and call stacks off). Removed at 145.4 s (0x887a0006, DRED VA 0x0, 58 s into the world); the Monitor wrote a dump. From nv-aftermath-format --json:

  • Device state Error_DMA_PageFault, engine reset. Page fault: Write, "Failed to translate the virtual address", by the Graphics Processing Cluster, at GPU VA 0x1245348000.
  • Faulted warp: "A shader instruction caused an MMU fault when accessing memory", in a 9,216-byte compute shader (compute_01 @ 0x000017d0).
  • The resource at that address had been destroyed: a committed buffer, 19,740 bytes wide, no format, created at Aftermath tick 111000828 and destroyed at 111001984. The dump was at 111005109 (ms), so about 3.1 s after it was freed. Before it, an 18,332-byte buffer at the same address, also destroyed.
  • Both widths are chain_commands_bytes(rounds, pieces, 1) with 32 rounds: 32 × 14 × 44 + 28 = 19,740 and 32 × 13 × 44 + 28 = 18,332. The type matches chain_commands_buffer (committed, UAV, DXGI_FORMAT_UNKNOWN). As far as I can see, the slicer is the only shader that writes that buffer, and the fault is a write. So a chained ExecuteIndirect's commands buffer was released while its slicer had not run yet. I have not confirmed the shader is the slicer: the dump gives no name for it.
  • At the removal, dozens of lists on the title's queue had not started (DRED "0 of N operations done"), while the 140 s pool line said put aside with submits on the GPU 0. The buffer goes with its PC allocator's recordings (dispatch_chain::allocator_reset, from alloc_pool and the allocator reset and release hooks). So the place to look may be whatever lets those recordings go while the list that holds them is still queued. That could be the same thing as @KDenKC's spare-pool last_submit point on D3D12.X: unpin retired split segments from alloc_pool and guard title_list::release ABA #1453.

Not tested: TdrDelay raised; the chain-indirect-dred branch; which release path freed the buffer; more runs; the LiveKernelReports folder (it needs an elevated prompt here); other cards; nvidia-dev.

AI use: Claude Code (Claude Opus 5.5) merged the trees, ran the tests and the runs on my machine, read the logs, DRED, the event log and the Aftermath dump, and drafted this. Checked by me before posting.

@Raul-Paiva

Raul-Paiva commented Nov 26, 2026 •

Copy link
Copy Markdown

On 5b9d4ff, an RTX 3070 Laptop 8 GB gets a GPU page fault in the world: the slicer writes to a chain_commands_buffer that free_aside released 3 ms – 1.1 s after it was recorded. Seen in 8 of 10 runs with Aftermath; the other two ended first, in a 0x887a0005 at 407 s and a 0x887a0007 at 222 s. With TdrDelay at 10 s it ends as an ordinary 0x887a0006. This could also explain removals reported here as hangs with no cause.

This may be what @afpruivo's MMU faults above are (comment): same DRED signature (page fault at GPU VA 0x0, a compute list stopped around 15 0 0 >6 15 0), and it goes away without this PR there. Below is which buffer it is and what releases it.

Setup:

1. What faults. 8 Aftermath dumps. 7 of them are the same:

  • Error_DMA_PageFault, engine reset.
  • The faulting shader is the 8 960-byte compute program (the slicer from record_slicer). It writes to a 540-byte committed buffer that Aftermath lists as destroyed.
  • Aftermath shows earlier 540-byte buffers created and destroyed at the same address.
  • The 8th, the first one, was a read from a destroyed 315 KiB buffer instead. I have not traced that one.
  • XCL's DRED line shows page fault at GPU VA 0x0 for them, so DRED does not catch it on this card.

2. Which buffer. The address matches a buffer made by pso::chain_commands_buffer ← dispatch_chain::execute_indirect ← bind::chained_indirect ← bind::execute_indirect. That is one per chained ExecuteIndirect: 4 849 of them in one 265 s run.

3. Who releases it, and when. In each traced fault, the buffer was dropped by alloc_pool::title_reset → free_aside → dispatch_chain::allocator_reset, holding the only reference:

run recorded dropped by free_aside after the PC allocator's backing at that moment fault
A 219.654 s 219.691 s 37 ms – (that log came later) 236.8 s
B 350.936 s 351.009 s 73 ms – 368.0 s
C 296.408 s 296.411 s 3 ms users 0, marks [q: wants 0x1da1, done 0x1df9] 312.3 s
D 242.732 s 243.879 s 1.1 s users 0, marks [q: wants 0x1bd6, done 0x1d9c] 260.1 s
  • So free() was true: no list counted as recording on the allocator, and its last marked submit was long done.
  • Yet the chain had just recorded there, and that recording does run on the GPU later: the fault comes 15 – 17 s after it, while the GPU is far behind in the world (about one present every 6 – 8 s).
  • So the list that recorded the chain left the backing's users without a submit of it being marked on that backing.
  • In run C the same allocator was freed by free_aside 280 times in 326 s. free_aside ran about 393 000 times in that run, on every title allocator reset, over every allocator put aside.

4. What I ruled out:

5. Not found: the exact path by which the list leaves the backing's users between recording the chain and a marked submit. My guesses, untested:

A simple guard would make free_aside, or allocator_reset from it, keep recordings made after the backing's last mark. I have not tried it.

Side note: with XCL_GPU_WAIT_TIMEOUT_MS=60000 (no CPU-released GPU waits), one run got noticeably further into the title's opening than any run with the default 5 s, before this fault ended it. That is a single run.

Not tested: other GPUs; this PR alone on main; the 315 KiB read fault; a fix.

AI use: Claude Code (Claude Opus 5.5) wrote the local diagnostics, ran the runs, decoded the Aftermath dumps, matched them to the logs, and wrote this.

Edit, added after this comment was first posted (15:25 UTC): one run with free_aside turned off, same tree and settings. Everything above is unchanged.

  • The change: a local switch makes title_reset skip free_aside, so a put-aside allocator's recordings go only at its own Reset. With XCL_GPU_WAIT_TIMEOUT_MS=60000 and Aftermath on, as in the last runs above.

  • No page fault: no Aftermath dump in the whole run. Before, 8 of 10 runs had one, at 185 – 593 s.

  • The title ran longer:

    • last present at 596 s, removed at 603 s with 0x887a0007;
    • no Display 4101 event, so not a TDR, and no dump; I have not looked into that one yet;
    • 8 – 12 presents per minute in the world all the way, as before.
  • The cost:

    120 s 240 s 362 s 485 s 609 s
    PC allocators 35 101 111 137 160
    • Committed memory went from 32.6 GB at 211 s to 35.9 GB at 606 s.
    • Local video memory went from 13.2 to 14.8 GB.
    • So the growth free_aside is there for comes back, about 1 GB of commit every 2 minutes.
  • This is one run, but it fits the trace above: the fault needs free_aside to drop recordings made after the allocator's last marked submit. So the fix is probably in what free_aside counts as free, not in removing it.

@KDenKC

KDenKC commented Nov 26, 2026 •

Copy link
Copy Markdown

@Raul-Paiva @Kalmarv: our two unexplained hangs on an RTX 5090 match this signature. Both were on builds with 551a75e's free_aside, both ended 0x887a0006 with nvlddmkm 153 events, and DRED showed only page fault at GPU VA 0x0. We had no Aftermath, so this is a match of signature and timing, not proof.

run build hang allocator churn before it chained ExecuteIndirect
dt-A 97a70a7 + #2551 + our tail release 228.4 s (TDRs at 222.5 / 224.3 s) 2,048 allocator resets, 549 made / 549 put aside by 182.8 s running; +290 in the last 10 s
#2633 run 1 db34184 (on 5b9d4ff) + #2551 133.45 s (TDRs ~2-3 s before) holder line at 130 s: 1,778 of 3,623 held, so 1,845 already let go 2,768 by 130 s

For contrast, the base 5b9d4ff run on the same recipe had 1,030 of 1,030 held (none let go) at 130 s, and ended in the plain #2403 removal at 134.7 s. But the second db34184 run had let go of a similar number (1,680 of 3,584 held at 130 s) and did not hang. So letting go under heavy chained use was present in both hangs, but it did not cause a hang every time, which fits a timing-dependent fault.

So the hang I mentioned in 7184267294 and on #2633 is probably this, not the tail release or #2633 itself.

AI use: Gemini (Antigravity) lined up the logs. Claude Code (Claude Opus 5.5) checked that both builds contain 551a75e and wrote this.

Osanchez pushed a commit to Osanchez/xcl that referenced this pull request Nov 26, 2026
…l is put off

need_by_submit marked a put-off call's pipeline by_submit and moved it
ahead of the workers' queue, but not wanted, and the big-compile gate
reads only wanted: until record_deferred reached the call and marked the
next four, those builds went through the gate one at a time, behind the
background slot. In a retail title's world start on Linux (RTX 4060 Ti,
with xcl-dev#2404 and xcl-dev#2333) the put-off builds spent 3,153 s waiting at the
gate against 320 s in the driver.

Since ae00ec7 wanted builds have a hard cap of their own
(XCL_HUGE_PSO_WANTED_CONCURRENCY), so marking them all at once no longer
lets an unbounded number skip the commit headroom; the look-ahead window
of four in record_deferred, and want/want_bound behind it, go.

Found by reading the gate waits of Bench E's runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KDenKC

KDenKC commented Nov 26, 2026 •

Copy link
Copy Markdown

Edit: @thehollowedone found the same interleaving independently and posted it a minute later (7196877276), with a test setup. Two separate reads of the same race.

@Raul-Paiva @Kalmarv: a candidate for why free_aside drops a buffer that was recorded just before, from reading 5b9d4ff (no run yet).

alloc_pool::title_reset (alloc_pool.rs:~316-327) computes let free = free_aside(s) under STATE, then drop(g), and only afterwards calls dispatch_chain::allocator_reset(b) for each b. That removes RECORDINGS[b] unconditionally (dispatch_chain.rs:~343). Between the two, another thread's title_reset can pick the same b: title_reset_in's reuse takes a put-aside allocator that is free() (alloc_pool.rs:~353), the same set free_aside returns. It resets b, and a list then records a chained ExecuteIndirect on it, filing a new RECORDINGS[b] entry with its chain_commands_buffer. When the first thread's loop then reaches b, it drops that new entry while the slicer may still write the buffer.

That fits the trace in 7195594188:

  • dropped by title_reset → free_aside → allocator_reset;
  • 3 ms to 1.1 s after it was recorded;
  • users 0 and done marks at that moment, because the backing was free when the snapshot was taken.

The interleaving itself is inferred; nothing in our logs records it. A fix in the shape the code already uses: take the free backings' RECORDINGS entries out while STATE is held (or under a lock that the reuse path also takes), and drop the detached objects after unlocking, so a backing that is reused meanwhile keeps its new recordings.

AI use: Codex (GPT-6.2-Sol) traced the interleaving. Claude Code (Claude Opus 5.5) checked both paths in the source at 5b9d4ff and wrote this.

@thehollowedone

Copy link
Copy Markdown

At #2404 head 5b9d4ff6, I found a separate allocator-reuse interleaving in the free_aside cleanup. It is a possible way to release a newly recorded chain commands buffer; I have not established that this is the interleaving behind the retail GPU page-fault report.

Test machine: RTX 3080 Ti (NVIDIA 621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC; debug build.

  1. One thread finds PC allocator B free in title_reset, collects B for cleanup, then releases the pool lock.
  2. Another title reset reuses B and records a chained ExecuteIndirect, adding its commands buffer to RECORDINGS[B].
  3. The first thread calls dispatch_chain::allocator_reset(B), which removes the current bucket, including the new recording.

The attached candidate detaches the old bucket while the pool lock still protects the free decision, then drops it after unlocking; a recording destructor can map its commands buffer. The deterministic CPU regression pauses at that boundary, reuses B through the production allocator selection with a mock native reset, and checks that the new marker survives. It failed before the change (0 passed, 1 failed: new marker removed) and passed after (1 passed, 0 failed), using cargo test --offline --locked -p xcl --lib a_free_spare_reused_after_a_sweep_keeps_its_new_chain_recording -- --test-threads=1. The surrounding alloc_pool::tests and dispatch_chain::tests passed 10/0/0 and 8/0/0.

cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 on this uncommitted candidate: 1,447 passed, 1 failed, 47 ignored across 37 targets; 25 GPU SKIPPED notices are included in the passing count. The sole failure was console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk (DXIL not compiled yet); I reproduced the same failure with the focused test on this PR's exact parent b49be18. git diff --check passed.

Not tested: a retail title, an Aftermath run, AMD/Intel, or paired clean-tree smoke. This candidate establishes the code race, not that it resolves the reported device removals.

Local candidate diff and regression (uncommitted)
diff --git a/crates/xcl/src/hle/d3d12x/alloc_pool.rs b/crates/xcl/src/hle/d3d12x/alloc_pool.rs
index d08a3ca2..6fd7f570 100644
--- a/crates/xcl/src/hle/d3d12x/alloc_pool.rs
+++ b/crates/xcl/src/hle/d3d12x/alloc_pool.rs
@@ -312,16 +312,24 @@ pub unsafe fn forget(alloc: usize) {
 /// recording on it, or this is off). `Some(hr)`: done here – the PC allocator in use was put
 /// aside with its recordings and another one took its place.
 pub unsafe fn title_reset(alloc: *mut c_void) -> Option<HRESULT> {
+    title_reset_with_after_unlock(alloc, || {})
+}
+
+unsafe fn title_reset_with_after_unlock(alloc: *mut c_void, after_unlock: impl FnOnce()) -> Option<HRESULT> {
     if !enabled() {
         return None;
     }
     let mut g = STATE.lock().unwrap();
     let s = g.get_or_insert_with(State::default);
     let hr = title_reset_in(s, alloc, |raw| super::real::reset_pc_allocator(raw));
-    let free = free_aside(s);
+    // Detach while the pool lock still protects the free decision: another title Reset may
+    // reuse this backing as soon as the lock is released and record new commands on it.
+    let free: Vec<_> = free_aside(s).into_iter()
+        .filter_map(super::real::dispatch_chain::detach_recordings).collect();
     drop(g);
-    for b in free {
-        super::real::dispatch_chain::allocator_reset(b);
+    after_unlock();
+    for recordings in free {
+        recordings.release();
     }
     hr
 }
@@ -396,6 +404,49 @@ unsafe fn title_reset_in(s: &mut State, alloc: *mut c_void, mut reset: impl FnMu
 mod tests {
     use super::*;
 
+    #[test]
+    fn a_free_spare_reused_after_a_sweep_keeps_its_new_chain_recording() {
+        use super::super::real::dispatch_chain::{holds_recordings_for_test as holds, note_recordings_for_test as note};
+        let mut ids = Box::new([0u8; 5]);
+        let base = ids.as_mut_ptr() as usize;
+        let (title, spare, busy, list, trigger) = (base, base + 1, base + 2, base + 3, base + 4);
+        {
+            let mut g = STATE.lock().unwrap();
+            let s = g.get_or_insert_with(State::default);
+            s.aside.insert(title, vec![spare]);
+            s.cur.insert(title, busy);
+            s.types.insert(title, D3D12_COMMAND_LIST_TYPE_DIRECT.0);
+            s.backings.entry(spare).or_default();
+            s.backings.entry(busy).or_default().users.insert(list);
+        }
+        note(spare);
+        unsafe {
+            title_reset_with_after_unlock(trigger as *mut c_void, || {
+                let mut g = STATE.lock().unwrap();
+                let s = g.as_mut().unwrap();
+                let hr = title_reset_in(s, title as *mut c_void, |raw| {
+                    assert_eq!(raw as usize, spare);
+                    super::super::real::dispatch_chain::allocator_reset(spare);
+                    0
+                });
+                assert_eq!(hr, Some(0));
+                note(spare);
+            });
+        }
+        let kept = holds(spare);
+        {
+            let mut g = STATE.lock().unwrap();
+            let s = g.as_mut().unwrap();
+            s.aside.remove(&title);
+            s.cur.remove(&title);
+            s.types.remove(&title);
+            s.backings.remove(&spare);
+            s.backings.remove(&busy);
+        }
+        super::super::real::dispatch_chain::allocator_reset(spare);
+        assert!(kept, "a sweep removed the chain recording made after the spare was reused");
+    }
+
     #[test]
     fn a_spare_whose_reset_fails_stays_available_for_retry() {
         let (alloc, spare, list) = (0x1000usize, 0x2000usize, 0x3000usize);
diff --git a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
index d37feb40..feee1b8d 100644
--- a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
+++ b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
@@ -274,6 +274,19 @@ impl Drop for Recording {
 }
 
 static RECORDINGS: LazyLock<Mutex<HashMap<usize, Vec<Arc<Recording>>>>> = LazyLock::new(Default::default);
+
+pub(in crate::hle::d3d12x) struct DetachedRecordings(Vec<Arc<Recording>>);
+
+impl DetachedRecordings {
+    pub(in crate::hle::d3d12x) fn release(self) {
+        drop(self.0);
+    }
+}
+
+pub(in crate::hle::d3d12x) fn detach_recordings(allocator: usize) -> Option<DetachedRecordings> {
+    RECORDINGS.lock().unwrap().remove(&allocator).map(DetachedRecordings)
+}
+
 /// list → the allocator it records on and the scratch its chains share: they are dispatched one
 /// after another, with a barrier between them (the recordings keep it alive)
 static SHARED: LazyLock<Mutex<HashMap<usize, (usize, std::sync::Weak<Scratch>)>>> = LazyLock::new(Default::default);
@@ -341,8 +354,9 @@ unsafe fn scratch_for(dev: &ID3D12Device, list: usize, allocator: usize, needed:
 }
 
 pub(in crate::hle::d3d12x) fn allocator_reset(allocator: usize) {
-    let recordings = RECORDINGS.lock().unwrap().remove(&allocator);
-    drop(recordings);
+    if let Some(recordings) = detach_recordings(allocator) {
+        recordings.release();
+    }
 }
 
 #[cfg(test)]

AI use: Codex (GPT-6.2 Sol) traced the interleaving, wrote and ran the local patch and tests, and drafted this report; Codex (GPT-6.2 Astra) reviewed the lifetime and lock ordering.

@Raul-Paiva

Raul-Paiva commented Nov 26, 2026 •

Copy link
Copy Markdown

@KDenKC @thehollowedone, thanks. That interleaving fits what I logged: the buffer was dropped 3 ms – 1.1 s after it was recorded, by free_aside → allocator_reset, with the backing at users 0 and done marks. That is the state at the moment free_aside took its snapshot, before the other thread reused the allocator. My logs do not show the reuse itself, so this is consistent with it, not a proof.

Two more runs since my comment above, same RTX 3070 Laptop 8 GB, same tree, XCL_GPU_WAIT_TIMEOUT_MS=60000, Aftermath on, 900 s each:

free_aside on (10 runs above) free_aside skipped splitting off (XCL_DIRECT_SPLIT_INSTRUCTIONS=0)
page-fault dumps 8 of 10 0 0
device removed in every run, 222 – 653 s 603 s, 0x887a0007, no 4101 event none
last present 179 – 588 s 596 s 878 s
presents per minute in the world 5 – 12 8 – 12 7 – 12
committed memory 32 – 36 GB 32.6 → 35.9 GB 27.5 → 33.2 GB, growing more slowly
PC allocators – 35 → 160 none (no chains)
  • The free_aside-skipped run is the edit in my comment above.
  • The run with splitting off used a fresh --precompile --only cs --pipelines with the same value (the cache key changes). It had no chained ExecuteIndirect and no allocators put aside. That run is the most stable on this card so far.
  • It ended at 883 s on a CPU-side 0x80000003 in the title's own code, the same instruction each time. It is not from the GPU. I have not looked further.
  • It was not faster: 7 – 12 presents per minute in the world, as with splitting. So on this card the slow world frames are not from the split.

If it helps, I can run @thehollowedone's candidate on this machine with Aftermath, free_aside on and splitting on: the setup that faulted in 8 of 10 runs. With it applied, 2 – 3 runs without a fault would say more than any single run.

AI use: Claude Code (Claude Opus 5.5) ran the runs, read the logs and the dumps, and wrote this.

@KDenKC

KDenKC commented Nov 26, 2026

Copy link
Copy Markdown

@Kalmarv a tested patch for the free_aside race (7196846147, and @thehollowedone's 7196877276), in case it saves you time. Take it or rewrite it as you like.

  • title_reset now takes the free backings' RECORDINGS entries out while STATE is held (dispatch_chain::take_recordings), and drops them after unlocking, so Readback/COM releases still happen outside the lock. A backing reused in between keeps the recordings made after its reuse. The lock order is the existing one: STATE, then RECORDINGS.
  • New test aside_sweep_keeps_recordings_made_after_backing_reuse. It pauses the sweep right after the unlock, reuses the backing and records on it, then lets the sweep finish. On 5b9d4ff it fails (the earlier sweep erased the reused backing's new recording). With the patch it passes, and the existing alloc_pool tests pass too (8/8, no GPU needed).
  • About 76 changed lines, on 5b9d4ff6.

Not tested: a title run with the patch (it should remove the fault class in 7195594188 if this interleaving is the cause); AMD.

patch on 5b9d4ff
diff --git a/crates/xcl/src/hle/d3d12x/alloc_pool.rs b/crates/xcl/src/hle/d3d12x/alloc_pool.rs
index d08a3ca2..359dbe59 100644
--- a/crates/xcl/src/hle/d3d12x/alloc_pool.rs
+++ b/crates/xcl/src/hle/d3d12x/alloc_pool.rs
@@ -312,17 +312,22 @@ pub unsafe fn forget(alloc: usize) {
 /// recording on it, or this is off). `Some(hr)`: done here – the PC allocator in use was put
 /// aside with its recordings and another one took its place.
 pub unsafe fn title_reset(alloc: *mut c_void) -> Option<HRESULT> {
+    title_reset_with(alloc, || {})
+}
+
+unsafe fn title_reset_with(alloc: *mut c_void, after_unlock: impl FnOnce()) -> Option<HRESULT> {
     if !enabled() {
         return None;
     }
     let mut g = STATE.lock().unwrap();
     let s = g.get_or_insert_with(State::default);
     let hr = title_reset_in(s, alloc, |raw| super::real::reset_pc_allocator(raw));
-    let free = free_aside(s);
+    // A backing can be reused as soon as STATE is unlocked. Detach its old recordings
+    // now so the sweep cannot remove recordings made by its next user.
+    let retired: Vec<_> = free_aside(s).filter_map(super::real::dispatch_chain::take_recordings).collect();
     drop(g);
-    for b in free {
-        super::real::dispatch_chain::allocator_reset(b);
-    }
+    after_unlock();
+    drop(retired);
     hr
 }
 
@@ -331,8 +336,8 @@ pub unsafe fn title_reset(alloc: *mut c_void) -> Option<HRESULT> {
 /// for takes one of them again, which may not come, so the scratch and commands that chained
 /// ExecuteIndirects kept with their recordings (`dispatch_chain::allocator_reset`) go now. Without
 /// this a title held 1,887 recordings under 48 allocators 110 s in, and memory grew until removal.
-unsafe fn free_aside(s: &State) -> Vec<usize> {
-    s.aside.values().flatten().copied().filter(|b| s.backings.get(b).is_none_or(|x| x.free())).collect()
+unsafe fn free_aside(s: &State) -> impl Iterator<Item = usize> + '_ {
+    s.aside.values().flatten().copied().filter(move |b| s.backings.get(b).is_none_or(|x| x.free()))
 }
 
 /// The allocator transition, with the PC Reset supplied so failure/retry needs no GPU in tests.
@@ -396,6 +401,55 @@ unsafe fn title_reset_in(s: &mut State, alloc: *mut c_void, mut reset: impl FnMu
 mod tests {
     use super::*;
 
+    #[test]
+    fn aside_sweep_keeps_recordings_made_after_backing_reuse() {
+        use super::super::real::dispatch_chain::{allocator_reset, holds_recordings_for_test as holds, note_recordings_for_test as note};
+
+        let ids = Box::new([0u8; 6]);
+        let title = ids.as_ptr() as usize;
+        let (current, spare, old_list, new_list, trigger) = (title + 1, title + 2, title + 3, title + 4, title + 5);
+        let ty = D3D12_COMMAND_LIST_TYPE_DIRECT.0;
+        {
+            let mut g = STATE.lock().unwrap();
+            let s = g.get_or_insert_with(State::default);
+            s.cur.insert(title, current);
+            s.aside.insert(title, vec![spare]);
+            s.types.insert(title, ty);
+            move_list(s, old_list, current);
+        }
+        note(spare);
+
+        // Pause the sweep after it unlocks and run reuse before it can finish retirement.
+        let hr = unsafe { title_reset_with(trigger as *mut c_void, || {
+            let mut g = STATE.lock().unwrap();
+            let s = g.as_mut().unwrap();
+            let reused = title_reset_in(s, title as *mut c_void, |raw| {
+                assert_eq!(raw as usize, spare);
+                allocator_reset(spare); // what native allocator Reset does after success
+                0
+            });
+            assert_eq!(reused, Some(0));
+            move_list(s, new_list, spare);
+            note(spare);
+        }) };
+        let kept = holds(spare);
+
+        forget_list(old_list);
+        forget_list(new_list);
+        {
+            let mut g = STATE.lock().unwrap();
+            let s = g.as_mut().unwrap();
+            s.cur.remove(&title);
+            s.aside.remove(&title);
+            s.types.remove(&title);
+            s.backings.remove(&current);
+            s.backings.remove(&spare);
+        }
+        allocator_reset(spare);
+        assert_eq!(hr, None);
+        assert!(kept, "the earlier sweep erased the reused backing's new recording");
+    }
+
     #[test]
     fn a_spare_whose_reset_fails_stays_available_for_retry() {
         let (alloc, spare, list) = (0x1000usize, 0x2000usize, 0x3000usize);
diff --git a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
index d37feb40..87ee632d 100644
--- a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
+++ b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
@@ -222,7 +222,7 @@ impl Drop for Scratch {
     }
 }
 
-struct Recording {
+pub(in crate::hle::d3d12x) struct Recording {
     scratch: Arc<Scratch>,
     first: ID3D12PipelineState,
     chain: Arc<Chain>,
@@ -340,9 +340,13 @@ unsafe fn scratch_for(dev: &ID3D12Device, list: usize, allocator: usize, needed:
     Some((s, false))
 }
 
+/// Take ownership without running recording readback or releasing COM objects under the lock.
+pub(in crate::hle::d3d12x) fn take_recordings(allocator: usize) -> Option<Vec<Arc<Recording>>> {
+    RECORDINGS.lock().unwrap().remove(&allocator)
+}
+
 pub(in crate::hle::d3d12x) fn allocator_reset(allocator: usize) {
-    let recordings = RECORDINGS.lock().unwrap().remove(&allocator);
-    drop(recordings);
+    drop(take_recordings(allocator));
 }
 
 #[cfg(test)]

AI use: Codex (GPT-6.2-Sol) wrote the patch and test and ran them. Claude Code (Claude Opus 5.5) reviewed it and wrote this.

@b3IKK

b3IKK commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

I applied the free_aside patch from @KDenKC's comment on top of 5b9d4ff + #2519's scratch; the new aside_sweep_keeps_recordings_made_after_backing_reuse test passes (it fails on 5b9d4ff).

A 600 s retail run with it (2 GiB shader heap, heap windows, precompiled compute cache) had 0 device removals: 1,954 frames, the world reached. At the end: 48,348 chain recordings, 3,555 held (2,126 put aside with a list, 808 busy, 615 in use and free), 0 whole forms. The last 180 s are cold compute/graphics pipeline compiles (18.8 s / 3.2 s), not a recording fault.

So the patch holds on a real session; the remaining wall there is the pipelines the used-only precompile skipped and the VRAM overcommit (#2688).

AI use: OpenCode, Claude Fable 5.2 applied the patch, ran the tests and the 600 s title, and wrote this.

@KDenKC

KDenKC commented Nov 26, 2026

Copy link
Copy Markdown

@b3IKK thank you for running it in the title. Two runs removed at 520 s without the patch against none in 600 s with it (2 GiB heap, RTX 5080) is the in-title result we did not have, and it fits @Raul-Paiva's trace. It is now up to @Kalmarv whether to take it into this PR.

AI use: Claude Code (Claude Opus 5.5) wrote this.

@b3IKK

b3IKK commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Second profile result with the patch: 1 GiB heap + full compute precompile, 600 s retail run = 0 device removals, 0 crashes, 2,014 frames, world reached. At the end 76,155 chain recordings, 4,334 held (3,078 put aside with a list, 909 busy, 347 in use and free), 20.9 GB local video memory.

The 2 GiB profile on the same stack gave a host VCRUNTIME 0xc0000005 at 543 s; 1 GiB has no such crash. The patch holds across both profiles. The remaining stalls are cold graphics PSOs in the later areas, not the recording fault.

AI use: OpenCode, Claude Fable 5.2 ran the 1 GiB run and wrote this.

@Raul-Paiva

Copy link
Copy Markdown

In-title result for the free_aside race fix on the RTX 3070 Laptop 8 GB from my comments above. It agrees with @b3IKK's RTX 5080 runs. I applied @thehollowedone's version (detach_recordings, 7196877276); @KDenKC's take_recordings does the same thing.

Setup as in 7195594188: main b49be18 + this PR 5b9d4ff and the others listed there, with #2725 reverted. free_aside on, splitting on, 1 GiB shader heap, XCL_GPU_WAIT_TIMEOUT_MS=60000, Aftermath, 900 s each. With #2633 in the tree, allocator_reset also returns constant blocks. I kept that and only replaced its two lines that remove the recordings with the patch's detach_recordings(..).release().

without the fix (10 runs above) with the fix (3 runs)
programs split, chained ExecuteIndirects 313, 10 000 – 13 500 324, 7 984 – 15 348
page-fault dumps (the slicer writing a freed chain_commands_buffer) 8 of 10 0 of 3
PC allocators at the end up to 59 40 – 58
committed memory 32 – 36 GB 32 – 33 GB

The three runs then ended on other things:

run last present end Display 4101
1 354 s 383 s: the title's own 0xc0000005 write at 0 at +0x23cf683 (#675 / #846) none
2 313 s 324 s: 0x887a0005, the #2403 pattern none
3 234 s 241 s: 0x887a0007; a mid-list split's CreateCommandList1 failed just before none

None of them is the page fault in this PR's chain path. Three runs, one machine.

A trap for anyone A/B-testing splitting: my first three runs with the fix showed 0 programs split. An earlier --precompile --pipelines with XCL_DIRECT_SPLIT_INSTRUCTIONS=0 had left a whole-form driver blob for every split program, and #2371 reuses an offline whole pipeline before splitting. So splitting stays off on later runs, whatever the setting. I moved those 826 blobs aside and reran. If you test both ways, check the compute split: N programs split line.

AI use: Claude Code (Claude Opus 5.5) applied the patch, ran the runs, decoded the dumps and wrote this.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

On Linux + NVIDIA, with KDenKC's patch for the free_aside race (7197560233), this PR 5b9d4ff + #2633 lost the device in 0 of 2 runs, against 2 of 2 without it on the same tree. That fits b3IKK's Windows runs without a removal and Raul-Paiva's without a page fault (7198145884, 7199386758). Turning free_aside off at 97a70a7 went the same way (our 7199843186 on #2615).

Setup: RTX 4060 Ti 16 GB, NVIDIA 615.71.09, Wine 11.21 Staging; vkd3d-proton v3.1-90-g30b0eb9b with its allocator Reset releasing the command pool's memory (our 7189698499); main b49be18 + #684, #751, #1599, #1860, #2082 + the trees below; XCL_DIRECT_DXIL=1 XCL_HUGE_PSO_WANTED_CONCURRENCY=6 XCL_DXC_THREADS=4 XCL_PSO_DISK_CACHE=0, no wait budget; first-run screens completed once, no story progress; 300 s; each run on a fresh copy of one NVIDIA cache per pair. The 5b9d4ff runs went in turn, control first, 0 draws or dispatches skipped; the 97a70a7 pairs ran 6–7 h apart, as 7199843186 says.

tree runs lost the device
this PR 5b9d4ff + #2633 db34184 + a logging-only line of ours 2 2: Xid 109, removed at 232.7 and 183.8 s (153 and 97 s after the world load, the first #101)
the same + KDenKC's patch, applied by hand: with #2633, allocator_reset also returns constant blocks, so ours takes them out under STATE with the recordings 2 0: one presented to 257 s (168 s after the world load); one was still presenting 180 s after it when our memory guard ended it at 248.6 s (under 5 GB of RAM free)
this PR 97a70a7 + #2615 + #2598 2 2: Xid 109, 37 and 63 s after the world load
the same, free_aside returning nothing 2 0, to the 300 s limit (210 and 234 s after the world load)
  • Each loss began with Xid 109, a context-switch timeout. One 97a70a7 loss also logged an MMU fault (Xid 31) 6 s later, at the removal; the other three logged none. So the tie to Raul-Paiva's page faults (7195594188) is the A/B, not a matching fault.
  • The margin is small: the first patched run presented 15 s further into the world than the longer control run (168 against 153 s), then submitted nothing from 259 s to the limit (0–4 draws every 2 s), with no removal. Whether that is another stop is not shown.

Not tested: Windows; the patch on 5b9d4ff without #2633, or on #2633's head now (19be659); its unit test (left out of ours).

AI use: Claude Code (Claude Opus 5.5) merged the trees, adapted the patch, made and read the runs, and wrote this.

Posted without review by a person: the account owner was away and reads replies later.

…'s reuse

title_reset decided which put-aside PC allocators were free under the
pool lock, released the lock, and only then dropped each allocator's
chain recordings. Another title Reset could reuse such an allocator in
between and record a chained ExecuteIndirect on it; the sweep then
removed that new recording, and its commands buffer was released while
the slicer was still to write it. That is the GPU page fault and device
removal reported on this PR (the slicer writing a chain_commands_buffer
released 3 ms - 1.1 s after it was recorded).

The recordings are now detached while the lock still protects the free
decision and dropped after it is released, so destructors that map a
buffer still run outside the lock. The lock order stays STATE, then
RECORDINGS.

Found and fixed in review: the interleaving and this change with its
test by thehollowedone
(a_free_spare_reused_after_a_sweep_keeps_its_new_chain_recording, which
fails without the change), an equivalent patch by KDenKC; in-title runs
without the fault by Raul-Paiva, b3IKK and Royalflamejlh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kalmarv

Kalmarv commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks all: the free_aside race fix is in this PR now, as its own commit 9620331 (D3D12.X: a free_aside sweep keeps recordings made after the allocator's reuse). It is @thehollowedone's detach_recordings version as posted (7196877276), with their test a_free_spare_reused_after_a_sweep_keeps_its_new_chain_recording; @KDenKC's take_recordings patch (7197560233) does the same thing. The commit message credits @KDenKC and @thehollowedone for the interleaving and the fix, and @Raul-Paiva, @b3IKK and @Royalflamejlh for the in-title runs without the fault.

Tested on 9620331, RTX 5070 Ti, Windows 11, Rust stable MSVC:

  • cargo test -p xcl --lib -- alloc_pool dispatch_chain: 26 passed, 0 failed, 0 ignored
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1446 passed, 2 failed, 47 ignored. The two failed are the link_tests pair that fails the same way on main b49be18 on this machine (details in the description).
  • scripts/smoke.ps1 -Seconds 60 on 9620331: 1,305 frames, 0 device removals, 0 crashes (block in the description). That run reaches no chained ExecuteIndirect, so it is a regression check only.

Not tested: a title run of mine that reaches a chained ExecuteIndirect on this head; the in-title evidence for the fix is the runs above, made by others on 5b9d4ff plus the patch.

AI use: Claude Code, Claude Opus 5.5 applied the posted patch, ran the tests and wrote this reply.

@thehollowedone

Copy link
Copy Markdown

Independent NVIDIA recheck of #2404 at 9620331, including its new free_aside recording-lifetime change.

Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti 12 GiB / driver 621.35, Rust 1.99.1 MSVC, DXC 1.8.2502.11:

  • cargo test --offline --locked -p xcl --lib alloc_pool -- --test-threads=1: 10 passed, 0 failed, 0 ignored. The new a_free_spare_reused_after_a_sweep_keeps_its_new_chain_recording regression passed.
  • cargo test --offline --locked -p xcl --lib dispatch_chain -- --test-threads=1: 16 passed, 0 failed, 0 ignored; one native-wave64 case printed SKIPPED on this wave32 card.
  • cargo test --offline --locked -p xcl --lib gpu::dxil::module::split::tests::dispatch_chain_divergent_forward_edges_3d -- --exact --test-threads=1 --nocapture: 1 passed, 0 failed, 0 ignored, 0 skipped. The test identified the RTX 3080 Ti and checked both 32- and 64-thread split-chain cases, including synthetic GPU ExecuteIndirect argument/count, slab and whole-form paths.
  • cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1,448 passed, 0 failed, 47 ignored across 37 test targets. Its log contains 25 GPU SKIPPED notices (21 no native wave64, 3 refused per-lane f16 forms, 1 no heap windows); they are not coverage. XCL_DXIL_CACHE pointed to writable scratch under target.

I checked that the new sweep detaches the old recordings while holding the allocator-pool lock, then drops them after unlocking; the regression covers reuse in that interval. This is a synthetic regression and GPU-output check on the current head. I did not run a retail title, paired smoke, AMD/Intel, or a title case that reaches chained ExecuteIndirect on this revision.

AI use: Codex (GPT-6.2 Sol) inspected the current change, ran the tests, and drafted this report; I checked the source and outputs before posting.

@b3IKK

b3IKK commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

The stack with KDenKC's free_aside patch reached a stable 600 s world on the RTX 5080: 0 device removals, 0 crashes, 2,138 frames, last present at 599.2 s, exit 0x0. Also in the stack: 5b9d4ff + #2519's scratch + #684 + #2877 (#2841) + the 2 GiB shader heap + heap windows and the full compute precompile. At the end 118,628 chain recordings (5,065 held; 3,819 put aside with a list), 0 whole forms, 30 of 85,635 ExecuteIndirect chains whole, 0 slabs lost. The world is ~0.3 fps (#2688), but it no longer removes the device.

AI use: OpenCode, Claude Fable 5.2 ran the 600 s stack and wrote this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.