Skip to content

D3D12.X: the pieces of a split program read their slab from a root CBV - #2633

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

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

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #2404; only the top commit (db34184) belongs here.

A chained ExecuteIndirect (#2404) records, for each round and piece, a UAV barrier, the piece's pipeline and an ExecuteIndirect whose command signature sets the slab's eight root constants. On the RTX 5070 Ti such an ExecuteIndirect after the barrier takes 15.3 µs of GPU time, empty or not, so 32 rounds of 10 pieces cost 4.9 ms every time. With a Dispatch-only signature it takes 0.41 µs. The pieces read only the slab's size and origin, the same for every piece of a round, so the chain's root signature now gives them as a root CBV (b0, space2, the register the pieces already read) instead of root constants. The pieces' code does not change.

What is in it

  • D3D12.X: the pieces of a split program read their slab from a root CBV (db34184), in pso.rs, runner.rs, dispatch_chain.rs and real.rs, with unit tests:
    • ExecuteIndirect: the slicer writes one 256-byte command a round (the slab's constants, its Dispatch 32 bytes in) instead of one 44-byte command per piece. The CPU points the CBV at the round's command, and the pieces' ExecuteIndirects use the Dispatch-only signature. The commands buffer for 32 rounds is 8 KiB, whatever the number of pieces.
    • Dispatch: the CPU writes the slabs' constants into 64 KiB upload-heap blocks of the list's allocator, used again once it is reset. A list with no allocator runs the whole form, as without scratch. Only blocks of 64 KiB are kept for use again, up to 8 MiB of them; bigger blocks and those past it are released at the reset (keep_free_constants; review by @luckyteagirl).
    • The driver blob of a piece kept on disk: the pieces' DXIL is the same as under D3D12.X: an ExecuteIndirect of a split program runs its pieces #2404, so its file now also names the chain's root signature, as a hash of it serialized (pso::abi_signature_id, in driver_cache::name_for). A blob built for D3D12.X: an ExecuteIndirect of a split program runs its pieces #2404's root constants is then not read and refused, and D3D12.X: an ExecuteIndirect of a split program runs its pieces #2404's and this PR's files sit side by side in one cache (review by @KDenKC).

Tested

  • Ryzen 9 9950X, RTX 5070 Ti (NVIDIA 610.74), Windows 11 build 26200, rustc 1.99.0, DXC 1.9.2609; tests in debug, the smoke runs from release builds.

  • On db34184 (on D3D12.X: an ExecuteIndirect of a split program runs its pieces #2404's head 5b9d4ff), on the GPU (debug):

    • cargo test --workspace --no-fail-fast -- --test-threads=4: 1449 passed, 0 failed, 47 ignored, the new a_piece_is_named_after_the_root_signature_it_was_built_with among them. 25 SKIPPED, as below.
    • direct_dispatches_write_their_constants_in_blocks_used_again_after_the_allocator_reset, with the new assertions that no block bigger than 64 KiB is kept and the kept ones stay within 8 MiB: 1 passed. With acba153's reset (every block kept): failed, "a block bigger than 65536 kept for use again".
    • The dispatch_chain, alloc_pool and driver_cache unit tests, --test-threads=1: 23 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: 51 passed, 0 failed, 1 ignored. 1 SKIPPED: dispatch_chain_native_wave64_builds_whole (no wave64). During the tests: 1 error, 884, and 275 warnings (195 of 1328, 80 of 926), as on 1202ac1 below.
    • Without the GPU: a_piece_is_named_after_the_root_signature_it_was_built_with and a_file_is_named_after_its_dxil_and_flags failed with the piece's file named as before (no signature), and pass with it.
  • On acba153, this change before the two review fixes (on D3D12.X: an ExecuteIndirect of a split program runs its pieces #2404's then head 97a70a7): cargo test --workspace --no-fail-fast -- --test-threads=4: 1446 passed, 0 failed, 47 ignored, the new direct_dispatches_write_their_constants_in_blocks_used_again_after_the_allocator_reset among them. 25 SKIPPED: 21 for no native wave64 on this card, three per-lane FP16 forms the per-lane lowering refuses, and no heap windows.

  • The runs below on 1202ac1 are of the same change before its rebase onto 97a70a7 (on 551a75e).

  • On 1202ac1, the dispatch_chain, split, execute_indirect and slab filters with XCL_D3D12_DEBUG=1, --test-threads=4: 48 passed, 0 failed, 1 ignored. 1 SKIPPED: dispatch_chain_native_wave64_builds_whole (no wave64). The dispatch_chain unit tests, --test-threads=1: 7 passed. dispatch_chain_divergent_forward_edges_3d, three runs: 1 passed each.

  • 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): 48 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: 195 of 1328 (a buffer's initial state ignored) and 80 of 926 (a root view's address in a heap), as on D3D12.X: an ExecuteIndirect of a split program runs its pieces #2404's head.

  • On 1202ac1, 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 7 passed; the dispatch_chain, split, execute_indirect and slab filters 48 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: @luckyteagirl, on acba153, AMD Radeon RX 6800M (driver 30.0.13002.13003), Windows 11 build 26200, debug (review): dispatch_chain_divergent_forward_edges_3d with XCL_REQUIRE_GPU=wave64, --test-threads=1: 1 passed, 0 failed, no SKIPPED notice, both the 32- and 64-thread chains (3 pieces each). Not the whole suite.

  • Tested by others, on acba153: @pickles976, RTX 4060 Laptop GPU 8 GB (NVIDIA 590.48.1) under Wine 11.0 + vkd3d-proton 3.2.0, a local diagnostic build of it with relaxed checks (-Db_ndebug=true and two local from_iface relaxations), x86_64-pc-windows-msvc, one test thread (review): direct_dispatches_write_their_constants_in_blocks_used_again_after_the_allocator_reset: 1 passed, on the NVIDIA device. Correctness only, with no timing or title run.

  • GPU timestamps, 16 rounds × 10 pieces, median per piece step, in a local-only test not in this PR, on the same change before its rebase (f29910f, on 809da30):

    empty one group
    ExecuteIndirect, root constants (before) 15.3 µs 15.6 µs
    ExecuteIndirect, root CBV, Dispatch-only signature 0.41 µs 1.01 µs
    Dispatch, root constants (before) 0.25 µs 0.61 µs
    Dispatch, root CBV in the upload heap 0.25 µs 0.61 µs

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

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, db34184:

xcl-smoke v1
commit: db34184fe8c017347303433e714d2f6dd7fc5ee9
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1540 (PresentX 1540)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17783 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: compute split: 49 programs split, 465 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

Not tested

  • This 60 s run reaches no chained Dispatch or ExecuteIndirect on either side, so it checks for regressions only; this PR's paths did not run in the title.
  • The GPU time saved in a title: only the local test above measured it.
  • AMD beyond that one test on an RX 6800M; other NVIDIA generations than Blackwell.

Other branches

AI use

  • Claude Code with Claude Opus 5.5 wrote the code, the tests and this description, and ran the tests and the regression run on the hardware above.

🤖 Generated with Claude Code

Kalmarv and others added 11 commits November 25, 2026 19:49
An ExecuteIndirect of a compute program that the recompiler split into
pieces fell back to the program's whole form, and that form was compiled
on the recording thread when first needed. On an RTX 5070 Ti with
XCL_DIRECT_DXIL=1 a retail title stalls its world load on it: 11
per-material programs, 9-14 pieces each, each dispatched through
ExecuteIndirect, each whole form 690-950 KB of DXIL taking 16-40 s to
compile, one after another from 326 s to past 600 s.

The title's ExecuteIndirects of split programs all have one command
signature: one Dispatch, stride 12, MaxCommandCount 1, no count buffer
(150 of them in 360 s). Their group counts are written on the GPU, so
the CPU cannot slice them when recording.

The ExecuteIndirect now runs the chain on the GPU. A small compute pass
(pso::record_slicer) reads the title's arguments (and count) and writes,
for a fixed number of rounds, one command per piece of each slab of
dispatch_slabs (the root constants of record_dispatch_chain, then the
slab's group counts); unused rounds get empty dispatches. Each piece then
runs one ExecuteIndirect per round with the chain's command signature,
with UAV barriers between them, in the bounded scratch.

The rounds come from the arguments the CPU sees now and the most slabs an
earlier ExecuteIndirect of the program had, plus a quarter (2 to
XCL_SPLIT_INDIRECT_ROUNDS, 16). When the arguments need more slabs and
the whole form is built already, the slicer leaves the rounds empty and
writes the title's Dispatch arguments after them, and the whole form runs
on those through a command signature of one Dispatch; otherwise it leaves
those empty. So one of the two runs, without predication: under one
predicate, two NVIDIA Ampere cards (RTX 3080 Ti, RTX 3070) ran some of
the rounds and not the whole form (xcl-dev#2404). The whole form's
ExecuteIndirect is recorded first, and the rounds' UAV barriers follow
it: on the RTX 3080 Ti it ran right after the slicer alone but not
after the pieces' ExecuteIndirects. If the whole form is not
built, the rounds run, the lost slabs are counted and warned about once
per program, the whole form is built on another thread for the next
ones, and the next rounds are sized from the count. The title's own
predication holds for the slicer too, so the same choice is made under
it. Bundles, lists without scratch and
other command signatures keep the whole form. The 'compute split' line
counts chained, whole and lost ExecuteIndirects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
runner::dispatch_split_indirect records a chain's ExecuteIndirect the way
the runtime does: the slicer, the whole form on the slicer's arguments
when there is one, then the rounds' ExecuteIndirects.
dispatch_chain_divergent_forward_edges_3d runs it with one command,
several with empty commands and a count buffer that leaves the last out,
and a stride of 20 bytes, in slabs of 1 to 12 groups and 1 to 16 rounds,
each without and with a whole form. It checks the memory against the
whole program and the slicer's slab count. With more slabs than rounds
it checks that the slicer says so and that the whole form runs instead
(the memory would not match if the rounds had run too). Without a whole
form it checks that only the rounds' groups run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s whole form

A chained ExecuteIndirect whose arguments have more slabs than its
rounds runs the program's whole form instead, but only when that form is
built already. Until then the slabs past the rounds are lost, counted and
warned about. Across ten title runs of the earlier version, 158 slabs were
lost in six, in 73,714 chained ExecuteIndirects. In each run it was one
program with 17 slabs: 15 at its first ExecuteIndirect, whose arguments
read 0 when it was recorded and which so got 2 rounds, then 1 at each
later one (at most 16 rounds) until its whole form was built.

- An ExecuteIndirect of a program none of whose ExecuteIndirects has been
  read back yet gets the most rounds. After that, the most slabs any of
  them had (not only those that lost some) size the rounds. This costs
  the empty rounds of a program's first ExecuteIndirects: one
  ExecuteIndirect and one UAV barrier per piece and round. The scratch
  does not grow with the rounds; the command buffer does, by 44 bytes a
  piece and round.
- XCL_SPLIT_INDIRECT_ROUNDS defaults to 32, not 16. Rounds are sized from
  the slabs read back, so the cap matters only for programs that need
  more. With both, none of those runs would have lost a slab.
- The whole form is asked for at the program's first chained
  ExecuteIndirect, not after a loss is read back. It is built on an
  xcl-pso-chain-whole thread, so a huge whole form waits for its turn
  (driver_compile) as the workers' builds do. Before, it was built on a
  thread named xcl-chain-whole, which the huge-build gate did not hold
  (pvfreis, xcl-dev#2404). It is bound only when an ExecuteIndirect has more
  slabs than its rounds.

More than 32 slabs before the whole form is built are still lost, counted
and warned about. Waiting for the whole form when the ExecuteIndirect is
recorded would make it exact. But the precompile does not build the whole
forms of split programs, so that wait is a cold compile on the title's
thread: the 16-40 s stalls this chain removes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ot read back

The slicer's words after the rounds size the next ExecuteIndirects of
the program: the most slabs one had, and whether any had been measured
at all. Under the title's predication (SetPredicationBufferX) the slicer's
Dispatch may be skipped, and its words then stay as the buffer was
created, all 0. read_back still took them as a count: the program counted
as measured with 0 slabs, so its next ExecuteIndirect whose arguments read
0 on the CPU got 2 rounds instead of the 32 of one never measured.

A chained ExecuteIndirect recorded while the title's predication is set
is no longer read back, as one whose binding failed. Its slicer still
runs the same choice under the predicate.

Reported by @thehollowedone (xcl-dev#2404).

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

a_chained_execute_indirect_keeps_its_commands_when_binding_fails records
two chained ExecuteIndirects whose binding succeeds, but its bind closure
did not set the chain's root signature, as bind_abi does. The pieces'
ExecuteIndirects then ran under the slicer's root signature: with the D3D12
debug layer and GPU-based validation, 258 messages (953, 744 and 712). The
test still passed; the runtime's path sets the root signature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Indirect sizes the rounds

A chained ExecuteIndirect records rounds x pieces ExecuteIndirects, each
after a UAV barrier, also when the slicer leaves them empty. On an RTX
5070 Ti (NVIDIA 610.74) such a step takes 14.4 us of GPU time with the
chain's command signature (eight root constants and a Dispatch): 144 us a
round for 10 pieces, 2.3 ms for 16 rounds, 4.6 ms for 32, empty or not.
Without the barrier it is 0.17 us, and with a Dispatch-only signature
0.41 us; a count buffer of 0 makes it 11.5 us. The rounds came from the
most slabs any ExecuteIndirect of the program had, so one large one kept
every later one at that size.

Until the whole form is built that is needed, since the slabs past the
rounds are lost. Once it is built, an ExecuteIndirect with more slabs than
its rounds runs the whole form, so the rounds now follow the last one
read back (and the arguments seen when recording), not the most.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The chain's root signature indexes the descriptor heaps directly, so setting it on a list
without heaps is a debug-layer error (1419, four of them under GPU-based validation at
809da30). A title's list has its heaps set when XCL binds the ABI; the test's `bind` now sets
two shader-visible heaps before the root signature, as that list has.

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

With the allocator pool on, `execute_indirect` kept the recording with the
PC allocator the list records on (`alloc_pool::recording_backing`). For a
list the pool does not track it got 0, so it returned Ok(false) and the
ExecuteIndirect ran its whole form. XCL makes such lists itself: a mid-list
split's next list is created on `alloc_pool::current(alloc)` with no
`created_on`. Under Wine + vkd3d-proton on an RTX 4060 Ti, this branch
chained 2 ExecuteIndirects and ran 26-30 whole in three runs of a title,
and the title presented nothing after its loading burst. In a fourth run
with a log line, all 32 that declined did so for this reason.

Such a list is now taken on by the pool, on the PC allocator the title's
allocator stands for, which is the one the list was made on
(`alloc_pool::recording_backing_or_take_on`), and the recording is kept
there. xcl-dev#2333 keeps these recordings with the title's allocator instead
(its `resolve_allocator`). The pool then knows nothing of the list, so it
can take that allocator for free and release the recordings (scratch and
commands buffer) while the list still records or runs on the GPU. Taken
on, the list keeps its backing busy until it is reset elsewhere or
released, and its submits mark the backing like any other list's.

The title's allocator also gets the list's type, so that a Reset while
the list holds its backing swaps it like the title's own lists.

Reported by @Royalflamejlh (xcl-dev#2404). With xcl-dev#2333 merged under this branch
and its fallback in `execute_indirect`, every ExecuteIndirect chained in
four runs (22 to 70,341 of them, 0 whole).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The chains of one recording share one scratch, which `dispatch_chain`
finds by the list's address (`SHARED`). Only a list's Reset forgot it.
Addresses are reused (xcl-dev#2588). A list created at the address of a
released one, on the same allocator while the old recordings were still
held, found the old list's scratch and shared it with work the GPU may
still be running. A chained ExecuteIndirect takes its scratch the same
way. `list_x` now forgets the entry when a list is created and when it
is released, with a unit test that fails without the change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e free

A chained ExecuteIndirect keeps its slicer scratch and commands buffer
with the recording of its PC allocator until that allocator is reset
(dispatch_chain::allocator_reset, from reset_pc_allocator) or released.
When the title resets an allocator whose recording is still held or on
the GPU, alloc_pool puts the PC allocator aside and gives the title
another. The one put aside is reset only when the same title allocator
is reset again and reuses it, which may never happen. Until then its
recordings, and the memory they keep, stay.

dhillonjagdeep650-boop found it on an RTX 3080 Ti (xcl-dev#2404): 1,887
recordings under 48 allocators at 110 s, local and non-local memory
growing about 150 MB/s, then a device removal at 110.8 s. The allocator
log said 119 made and 119 put aside.

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. This happens outside the pool's lock.
allocator_reset of an allocator without recordings does nothing, and
the allocator is reset as before when it is reused.

This relies on every chained recording being filed with the PC
allocator its list records on, and on that list being known to the pool
(an earlier commit here takes on the lists it had not seen). A recording
filed with a title's allocator, as xcl-dev#2333's lines file one, would go when
that allocator is free, while its list still records or runs on the GPU
elsewhere.

The first test fails without the sweep: the free allocator put aside still
holds its recordings after another title allocator's Reset. Two more
show that a taken-on list's recording stays while the list records on
its allocator put aside and while its submit runs, and goes after both;
and that a free title allocator put aside does not take a live list's
recording with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s turn

`want_whole` builds a split program's whole form on `xcl-pso-chain-whole`, an `xcl-pso*` thread,
so a huge one waits in `big_compile_turn` for a background slot and 3 GB of free commit, with no
timeout. It waits holding `Chain::build_whole`, and nothing on that thread says a title thread
waits for it (`pso_async::build_is_wanted` reads only a worker's build). So a title thread that
needs the same whole form meanwhile (`bind.rs` for an ExecuteIndirect it cannot chain,
`dispatch` without scratch) blocked on the mutex until the background turn came. It got neither
the wanted cap nor the commit skip of a build the title waits for, where before `want_whole` it
compiled at once (found by @pvfreis in the review of xcl-dev#2404).

A title thread now counts itself in `Chain::waiting` while it waits for the whole form, and
`want_whole`'s build runs in `pso_async::build_waited_on`, so `build_is_wanted` is true on that
thread while one does. The background build then goes as one the title waits for, and the title
thread gets the form when it is built. The test fills the background slots, starts the build and
asks for the form on another thread: without the count it waited until the slots were freed
("the title thread waited for the background build's turn").

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

Copy link
Copy Markdown
Contributor

Focused RX 6800M check on clean PR head acba153caf086ef0e0ebe4cda4e76b7216217fc3: Windows 11 Home build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver 30.0.13002.13003, Rust 1.99.0 MSVC, DXC 1.9.2609.5 (debug test build).

$env:XCL_ADAPTER = '6800M'
$env:XCL_REQUIRE_GPU = 'wave64'
cargo test --locked -p xcl --lib dispatch_chain_divergent_forward_edges_3d -- --test-threads=1 --show-output

Result: 1 passed, 0 failed, 0 ignored, 1,346 filtered, 0 SKIPPED notices. The guarded run exited 0 with no memory guard trigger. The test printed CHAIN_GPU=AMD Radeon RX 6800M and completed both split-chain forms:

Guest threads Pieces Scratch words per group Checked words Guard words
32 3 288 384 16
64 3 576 768 16

This is the focused synthetic split ExecuteIndirect fixture. I did not run the full workspace suite or reproduce a title-specific GPU fault on this PR head.

AI use: OpenAI Codex (GPT-6; exact serving variant unavailable) and a Luna subagent selected and ran the test, verified the live head and adapter, and prepared this report.

@pickles976

Copy link
Copy Markdown

Wine/NVIDIA cross-check of the new test — passes on the real adapter. Head acba153caf086ef0e0ebe4cda4e76b7216217fc3 (stacked on #2404's 97a70a73c, as described), RTX 4060 Laptop GPU 8 GiB, Wine 11.0, vkd3d-proton 3.2.0 diagnostic-relaxed build (same provenance commit as the stock DLL, -Db_ndebug=true + the two #175 from_iface relaxations, local-only; this test is not behind the vtable wall but the stack is uniform here), NVIDIA 590.48.1, --locked --target x86_64-pc-windows-msvc, one test thread, fresh Compiling xcl .../xcl-pr2633/... provenance.

direct_dispatches_write_their_constants_in_blocks_used_again_after_the_allocator_reset — 1/1 pass (0.65 s), with the real NVIDIA device opened (DXVK logs Found device: NVIDIA GeForce RTX 4060 Laptop GPU): the Dispatch-form slab constants go into 64 KiB upload-heap blocks of the list's allocator and the blocks are reused after reset, as the test's assertions check.

Scope: correctness fixture only — the 15.3 µs → 0.41 µs ExecuteIndirect claim remains the author's RTX 5070 Ti measurement; no perf numbers from this host, no title run. Log: .compat-xcl/logs/verify-pr2633-wine-cbv-slab-relaxed.log (local). AI-assisted verification and report (OpenAI Codex).

@Kalmarv

Kalmarv commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@pickles976 thank you for the Wine cross-check on acba153 (7183101906): the new test passing on the RTX 4060 Laptop's own device is the first run of it outside our machines. It is in the description under Tested, with your caveats: your local relaxed vkd3d-proton build, correctness only, no timing or title run.

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

Kalmarv added a commit to Kalmarv/xcl that referenced this pull request Nov 26, 2026
With the CPU-scaled default, huge_pso_concurrency is 4 on a 16-thread
machine while huge_pso_wanted_concurrency stayed base.max(2), also 4: with
four background huge compiles running, a build a title thread waits for
had no slot of its own and queued behind them. The wanted default is now
one more than the background concurrency, as it was when that was 1.

Found by xcl-dev#2633's a_title_thread_does_not_wait_behind_a_background_whole_
build_waiting_for_its_turn, which fails with this branch merged and passes
with XCL_HUGE_PSO_CONCURRENCY=1 or XCL_HUGE_PSO_WANTED_CONCURRENCY=5.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@luckyteagirl luckyteagirl 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.

Could the free constants pool have a byte budget, or release oversized blocks on allocator reset? Every block removed from CONSTANTS is retained in process-global FREE_CONSTANTS; reuse requires the same device and sufficient capacity, and I could not find a trim or device-cleanup path. A temporary burst of large slab constants can therefore leave its committed upload resources mapped for the rest of the process, even after the recording allocators retire. The reuse fixture could also assert that excess blocks are released. Exact-head source review at acba153caf086ef0e0ebe4cda4e76b7216217fc3; no measured memory footprint or title run. AI-assisted review with Codex.

Kalmarv and others added 3 commits November 26, 2026 01:06
A chained dispatch or ExecuteIndirect keeps its scratch and commands until
the PC allocator it recorded on is reset or, put aside, is free. Two runs on
other machines held thousands of them (7,410 under 115 allocators at 270 s,
2,297 of them under ones put aside) while memory grew, and neither log says
why the rest were not let go.

Every 10 s, with the counter line, a second line gives the recordings held
and made, and splits the held ones by their allocator: put aside with a list
still recording on it, with submits on the GPU, or free; in use for a
title's allocator, busy or free; or one the pool does not know.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d each

`want_whole` started a thread for each split program whose whole form it
asked for. A huge whole form on it waits for its turn (`driver_compile`),
so the threads piled up: a run on Linux + NVIDIA had 200 of them at 280 s,
199 waiting.

The whole forms now queue on one thread for each slot set of
`driver_compile` (small, huge, giant), which builds them one after another
and ends when its queue is empty. Small ones are never gated, and at the
default of one huge compile at a time (`XCL_HUGE_PSO_CONCURRENCY`) huge or
giant ones took their turns one by one already. A title thread that needs a
whole form still builds it itself. A program released before its turn is
not built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ole form is built

Until a split program's whole form is built, slabs past a chained
ExecuteIndirect's rounds are lost. The rounds were sized by the most slabs
one of its ExecuteIndirects had read back, so the 32 of 9125edb held only
until the first read-back: a program whose first ones had a slab got 2
rounds, and a later one with 22 slabs lost 20 (two runs on Linux + NVIDIA).

Before the whole form is built a chained ExecuteIndirect now records the most
rounds (`XCL_SPLIT_INDIRECT_ROUNDS`, 32) whatever was read back; once it is
built, the last one read back sizes them as before. The whole form is asked
for at the program's first chained ExecuteIndirect, so the empty rounds
last until it is built.

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

KDenKC commented Nov 26, 2026

Copy link
Copy Markdown

Source review of acba153c, no run yet. One thing for anyone A/B-ing this against #2404 on a warm cache:

The pieces' DXIL doesn't change here, only their root signature does (parameter 7 goes from 8 root constants to a root CBV in abi_signature). But driver_cache::name_for (real.rs:4506) keys a piece's blob only on the DXIL hash, its length and the flags. So a .chain.pso written by #2404 (or main) has the same file name under this head, and it was built against the old root signature. Expected effect: the driver refuses it ("a driver blob kept on disk was refused … compiled again"), so the first run after switching builds every piece cold. A comparison on a shared cache would then charge that to this PR. And if a driver ever did accept the mismatched blob, it would be running pieces against the wrong root signature. A different extension for the CBV layout (or a layout version folded into name_for) would keep the two apart.

When we run it, we'll give each side its own cache.

My 5090 and I await the root-CBV era.

AI use: Gemini (Antigravity) noticed the shared file name in a review; Claude Code (Claude Opus 5.5) checked name_for, the piece DXIL and the refusal path at acba153c and wrote this.

A chained ExecuteIndirect records, per round and piece, a UAV barrier, the piece's pipeline
and an ExecuteIndirect whose command signature sets the eight root constants of the slab. On
an RTX 5070 Ti (NVIDIA 610.74) such an ExecuteIndirect after the barrier takes 15.3 us of GPU
time, empty or not: 32 rounds of 10 pieces are 4.9 ms, every time (xcl-dev#2404). With a Dispatch-only
signature it takes 0.41 us; a barrier only to the scratch does not help (15.3 us).

The pieces read only the slab's size and origin (`split.rs`, `Slab::new`), the same for every
piece of a round. So the chain's root signature takes them as a root CBV (b0 space2, the
register the pieces already read) instead of root constants, and the pieces do not change:
- ExecuteIndirect: the slicer writes one 256-byte command a round (the slab's constants, its
  Dispatch 32 bytes in) instead of one 44-byte command per piece; the CPU points the CBV at the
  round's command, and the pieces' ExecuteIndirects take the Dispatch-only signature. The buffer
  for 32 rounds is 8 KiB, whatever the pieces.
- Dispatch: the CPU writes the slabs' constants into 64 KiB upload-heap blocks of the list's
  allocator, used again once it is reset; without one the whole form runs, as without scratch.
  Only blocks of 64 KiB are kept for use again, up to 8 MiB of them; bigger ones and those
  past it are released at the reset.

The pieces' DXIL is the same as before, so a piece's driver blob kept on disk now also names
the chain's root signature (a hash of it serialized): one built for the root constants is not
read and refused, and the pieces are not compiled again for that in every first run.

Measured on the RTX 5070 Ti, GPU timestamps, 16 rounds x 10 pieces, median per piece step:
  ExecuteIndirect, root constants (before)       15.3 us empty, 15.6 us with one group
  ExecuteIndirect, root CBV, Dispatch-only        0.41 us empty,  1.01 us with one group
  Dispatch, root constants (before)               0.25 us empty,  0.61 us with one group
  Dispatch, root CBV in the upload heap           0.25 us empty,  0.61 us with one group

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

Kalmarv commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@luckyteagirl thank you for the review (6069221831): right, nothing ever released a block once it was in FREE_CONSTANTS. In db34184 an allocator's reset keeps only blocks of the usual 64 KiB for use again, up to 8 MiB of them (keep_free_constants); bigger blocks and those past it are released there. The reuse fixture now also asserts that no block bigger than 64 KiB is kept and that the kept ones stay within the 8 MiB. With the old reset it fails ("a block bigger than 65536 kept for use again").

@KDenKC thank you (7184414003), that was a real gap: the pieces' DXIL is the same under this PR, so a .chain.pso built for #2404's root constants had the same name. In db34184 a piece's file also names the chain's root signature, as a hash of it serialized (pso::abi_signature_id), so -<sig>.chain.pso files of #2404/main and of this PR sit side by side instead of being read and refused. Test: a_piece_is_named_after_the_root_signature_it_was_built_with (one DXIL, two root signatures, two names); with the old name it fails. On a shared cache each side's first run still builds its own pieces once, but switching no longer makes the driver refuse and drop the other side's files, and no blob of the other layout can be accepted. Separate caches per side remain the cleaner A/B.

AI use: Claude Code with Claude Opus 5.5 wrote both changes, their assertions and this reply, and ran the tests.

@SzczepanGrela

Copy link
Copy Markdown

RX 9070 / RADV paired check of #2633 db34184fe8c017347303433e714d2f6dd7fc5ee9 against its stacked #2404 base 97a70a73c96ee39cadffe1baafbc6725091277f6.

Tested

Ryzen 7 7700, RX 9070, CachyOS Linux 7.3.0-5-cachyos, RADV Mesa 26.3.1-arch3.5, GE-Proton11-12 / Wine 11.0, vkd3d-proton 8293130ebe370b1+ (local build with assertions disabled), DXC 1.9.2602.17, Rust 1.97.1. Windows GNU release binaries under Wine.

Built both exact revisions with cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run. Ran wine <unit-test.exe> <filter> --skip retail_ --nocapture --test-threads=1, then the same filters with --test-threads=4.

The counts below were identical in both thread modes. Filters are under hle::d3d12x:::

Filter #2404 passed / failed #2633 passed / failed
real::dispatch_chain::tests:: 7 / 0 9 / 0
alloc_pool::tests:: 7 / 1 8 / 1
real::driver_cache::tests:: 4 / 0 5 / 0

Zero ignored tests and zero SKIPPED notices. The updated constants-reuse test, root-signature cache-name test and whole-build queue test passed. The shared failure is a_recording_outlives_the_reset_of_the_titles_allocator: CreateCommandList returns 0x80070057, with d3d12_command_list_Reset: Invalid command allocator on both revisions.

dispatch_chain_divergent_forward_edges_3d aborts on both revisions with 0xc0000005 at d3d12core.dll+0x2e7d48. Symbolized XCL frames lead to CreateComputePipelineState for a split piece in runner::dispatch_split_samples, before the fixture's indirect cases. This fixture did not pass; no cause is attributed to this PR.

Local GPU-timestamp diagnostic

Separate local copies add test-only repetition/timestamp instrumentation to runner::dispatch_split_indirect and a synthetic DXC fixture. Production recording functions are unchanged from their respective revisions. Ten cs_6_6 pieces use the chain ABI, pass values through scratch and add 55 per active word per repetition. The 20 shader blobs, for 32- and 64-thread groups, are byte-identical between versions. Every result word, 16 guard words and the indirect tail were checked.

Indirect samples cover the command-buffer transition back to UAV, the slicer and all 32 rounds of 10 pieces, with at most one group per slab. The direct control has 12 slabs of 10 pieces. PSO creation, allocation, initial uploads, final readback and CPU recording time are outside the timestamps. Five paired trials alternate A/B and B/A. Each case runs eight batches of 17 repetitions; discard two warmup batches and the first repetition of each remaining batch, keeping 96 samples per trial per case.

GPU microseconds per complete operation, median of the five trial medians; brackets give their min/max:

Threads Case #2404 us [min, max] #2633 us [min, max]
32 indirect, empty 1946.56 [1715.40, 2047.06] 533.24 [533.20, 536.72]
32 indirect, 1 group 1970.82 [1573.04, 2046.36] 544.52 [544.22, 547.80]
32 indirect, 12 groups 2010.48 [1563.16, 2092.08] 635.72 [635.40, 637.36]
32 direct, 12 groups 114.48 [96.48, 116.52] 137.18 [137.16, 137.26]
64 indirect, empty 2543.24 [1895.56, 2580.12] 625.44 [625.40, 625.44]
64 indirect, 1 group 1970.80 [1788.18, 2058.48] 637.12 [637.08, 637.12]
64 indirect, 12 groups 1801.40 [1704.22, 2086.68] 738.30 [736.44, 740.20]
64 direct, 12 groups 108.88 [104.88, 114.60] 169.12 [138.08, 169.12]

All ten diagnostic invocations passed: one test each, zero failed, ignored or skipped. Indirect operations take less GPU time in every paired trial. The 32-thread direct control takes 19.8% more at the reported medians, and more in every pair. The 64-thread direct result has larger variation. These are synthetic command-path results, not the author's per-step benchmark or a title-speed measurement; the direct-control difference has no established root cause.

Not tested

Native Windows, the full workspace suite, retail workloads or scripts/smoke.ps1, gameplay/FPS, persisted driver-blob acceptance across layouts, or translated guest wave64 correctness. The diagnostic uses DXC-built pieces and bypasses runtime allocator reuse and the title pipeline-cache path. XCL application caches were separate per version; the vkd3d shader disk cache was disabled. GPU clocks were not fixed.

AI use

OpenAI Codex (GPT-6; exact serving variant unavailable) audited the diffs, prepared and ran the comparisons and local diagnostic, checked the logs and drafted this report for user review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants