Skip to content

D3D12.X: split title_list command lists around mid-list Wait64 after Write64 - #797

Merged
theaustinayers merged 2 commits into
xcl-dev:mainfrom
gsucristo:d3d12x/wait64-midlist-split
Nov 24, 2026
Merged

theaustinayers merged 2 commits into
xcl-dev:mainfrom
gsucristo:d3d12x/wait64-midlist-split

Conversation

@gsucristo

Copy link
Copy Markdown
Contributor

Stacked on #795; only the top commit belongs here.

Split title_list-backed command lists around mid-list Wait64BitValueX / Wait32BitValueX calls that follow a Write64BitValueX in the same list, avoiding cross-queue cycles where a consumer queue waits on the prefix write before signaling the value the suffix waits on. Related to #505 (note: open #708 also splits lists at recorded waits; this approach extends title_list with F_PRIMARY/F_BACKING segment tracking, reuses closed spare PC lists on the same allocator across Reset/KickoffX, and integrates directly with #795's exact cycle graph).

What is in it

  • crates/xcl/src/hle/d3d12x/title_list.rs: separate F_PRIMARY (0x2FF0) and F_BACKING (0x2FF8) slots so QueryInterface/AddRef/Release stay pinned to the primary PC list while recording advances across split segments; expand all segments via push_segments; reclaim spare closed segments on Reset (calling list_x::reset_x directly) and KickoffX (reclaim_for_kickoff).
  • crates/xcl/src/hle/d3d12x/list_x.rs, bind.rs, real.rs: add try_split_for_wait (opt-out via XCL_SPLIT_MIDLIST_WAIT=0), carry active D3D12 and UMA bindings (bind::inherit_for_split) across split segments, expand wrapped lists in q_execute_command_lists, and add mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares verifying 2-frame splitting, spare reuse, and zero CPU cycle breaks.

Tested

  • NVIDIA GeForce RTX 4090 (driver 610.57.04), AMD Ryzen 9 7950X3D, Linux + Proton Experimental / vkd3d-proton (relaxed vtable check), rustc 1.98.1 (x86_64-pc-windows-msvc cross-compile), debug.
  • cargo test --workspace --no-fail-fast --target x86_64-pc-windows-msvc -- --test-threads=4 --skip a_freed_block_is_decommitted_before_its_address_is_reused: 706 passed, 4 failed (pre-existing Wine-only failures: hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime, test_title_runs_and_game_folder_is_untouched, disk_free_space_ex_reports_pls_quota, set_predication_buffer_state_and_kickoff), 41 ignored, 1 filtered (a_freed_block_is_decommitted_before_its_address_is_reused).
  • SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64).
  • New GPU test passed on RTX 4090: hle::d3d12x::list_x::tests::mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares (2 frames, 2 segments, spare reused, 0 CPU cycle breaks).

Regression run

  • Pending native Windows scripts/smoke.ps1 runs on a retail title (Linux/Proton environment only).

Not tested

  • Native Windows 10/11, AMD RDNA, Intel GPUs, scripts/smoke.ps1 retail regression run.

AI use

  • Antigravity (Google DeepMind; exact model version not exposed to the agent) — assisted with code, tests, and PR description; reviewed, built, and run on hardware by the author.

Bridge monotonic `Wait64BitValueX` / `Wait32BitValueX` and `Write64BitValueX`
sequences across queues via real `ID3D12Fence` `queue.Wait` / `queue.Signal`
instead of blocking the CPU submission thread until timeout (related to xcl-dev#505).

Track submitted and pending wait/signal dependencies as an exact `(queue, seq)`
directed graph (including same-cell write/wait edges and same-queue FIFO
ordering) so genuine cross-queue cycles are detected and broken deterministically
at Signal time without false positives on pipelined frames, backed by a GPU
completion watchdog and unit/GPU regression tests.
…Write64

When a single command list records `Write64BitValueX` followed later in the
same list by `Wait64BitValueX` / `Wait32BitValueX` on a value produced by
another queue that waits on the earlier write, executing the list as a single
atomic `ExecuteCommandLists` submission creates a cross-queue cycle.

Extend `title_list` with separate `F_PRIMARY` and `F_BACKING` slots so
`list_x` can transparently split `title_list`-backed command lists around
mid-list waits after writes (opt-out via `XCL_SPLIT_MIDLIST_WAIT=0`),
carrying active D3D12/UMA bindings across segments, expanding all segments on
`ExecuteCommandLists`, and reusing closed spare PC lists on the same command
allocator across `Reset` and `KickoffX`.
@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of 285560fae476d6501355d2f3fcfccadeb1558a20 on AMD RDNA4. I merged it onto current main e50836b locally (clean merge), so the tree tested includes the PR under it (#795).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200 (native Windows, not Wine), Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 711 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 670 passed, 0 failed, 21 ignored
  • 0 SKIPPED; the title_list / guard tests pass.

Review: Stacked on #795; I reviewed the top commit's structure only. It splits lists at mid-list waits, which #708 (open) also does, so the same choice applies as for #795.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

@theaustinayers
theaustinayers merged commit beaa245 into xcl-dev:main Nov 24, 2026
1 check failed
cmt8 added a commit to cmt8/xcl that referenced this pull request Nov 24, 2026
…able

vkd3d-proton takes a heap, fence, resource, descriptor or query heap, root signature, pipeline
state or command signature only with its own vtable - an assert() in each of its methods and
wherever one is passed in, which the release builds keep (the process ends with status 3) - and a
command allocator only by a run-time check (CreateCommandList / Reset: E_INVALIDARG). Adoption
replaced that vtable pointer, so on vkd3d-proton the real backend stopped at the first such
object (the test title at its first heap).

Under Wine (util::under_wine) the classes whose console slots all sit inside the PC interface -
heap, resource, descriptor / query heap, root signature, pipeline state, command signature,
command allocator - get XCL's PC slots written into the runtime's own table instead (VirtualProtect,
as XAudio2's patch), only up to the interface's method count, and only when the object answered
QueryInterface for that interface with itself; orig_fn finds the entries from before by the
table. The table is shared by every object of the class (swap-chain buffers too); the overrides
already take objects XCL did not create. Console calls past the PC interface on these classes no
longer reach a logging stub. Command lists keep their extended table (the console layout is
reordered and longer than the PC one): around the runtime's ExecuteCommandLists they carry the
runtime's table, which vkd3d-proton reads only during the call. Fences are not covered yet
(console xcl-dev#12 is past the end of the PC table). On Windows nothing changes: every new path is
behind under_wine(), and orig_fn's lookup has no table on Windows.

vkd3d-proton 3.1's tables have exactly the PC interfaces' method counts (heap 10, resource 17,
descriptor heap 11, root signature 8, pipeline state 9, query heap 8, command signature 8,
allocators 9; read from its source). Wine 11.22, vkd3d-proton 3.1 release DLLs, RX 7900 XTX
RADV: bind::create_list_reset_and_clear_state_track_initial_pso_on_d3d12 passes (aborted
before); the other seven tests that aborted and the e2e test title now stop at the fence
assertion. Not run on Windows.

On upstream 1ec4c98 KickoffX also submits the earlier segments of a list xcl-dev#797 split around a
mid-list Wait64: those go with the runtime's table as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmt8 added a commit to cmt8/xcl that referenced this pull request Nov 24, 2026
… behind

ff59ccd wrote XCL's PC slots into vkd3d-proton's own allocator table, which ends after the PC's
9 methods. A console title calls past them (upstream's log names allocator xcl-dev#9, a logging stub
answered 0 on Windows): found with a retail title under Wine, whose call landed on the zeros
after vkd3d-proton 3.1's table (its slots 9-11 are 0, another table follows) and executed
address 0 about 29 s in. The fence's way (07bccd7) instead: under Wine CreateCommandAllocator
does not adopt the runtime's allocator; it returns an object of XCL's (alloc_x::wrap) with the
console length - the PC methods call the runtime allocator's through its own table (bundle
allocators have another), QueryInterface gives the wrapper back for the allocator itself,
AddRef / Release are the runtime allocator's count, Release and Reset keep alloc_release /
alloc_reset's bookkeeping on the wrapper (list_x::on_allocator_release,
console_list::allocator_reset), and xcl-dev#9 on are the same "ID3D12CommandAllocator::#N (not on PC)"
stubs as on Windows. Every allocator XCL keeps (list_x, console_list, bind) is the pointer its
caller has, the wrapper; only where an allocator goes to the runtime is it unwrapped
(alloc_x::for_runtime): the device's CreateCommandList (also console CreateCommandList /
CreateCommandListX), a list's Reset on the PC path (cl_reset, also console_list's Reset) and
the console's (list_x::reset_x: xcl-dev#10, xcl-dev#139, the DMA list) and KickoffX's Reset. These are the
places vkd3d-proton 3.1 takes an allocator back (d3d12_command_list_Reset, d3d12_bundle_Reset,
and CreateCommandList through Reset). Allocators are no longer patched in place. The pair is
made before CreateCommandAllocator returns, so no caller ever has the runtime's allocator. On
Windows nothing changes: CreateCommandAllocator takes the new path only under
util::under_wine(), and for_runtime passes the allocator as it is there.

Test: alloc_x::tests::a_wrapped_allocator_forwards_to_the_runtime_allocator (no GPU). Wine 11.22,
vkd3d-proton 3.1 release DLLs, RX 7900 XTX RADV: it, bind's
create_list_reset_and_clear_state_track_initial_pso_on_d3d12, gpu_sparse_vram_descriptors_buffers_and_xmem,
title_textures' gpu_mirror_upload_... and placed_title_textures_..., both gpu_compute_e2e tests, list_x's
reset_commits_state_..., fence_x's and the in-place test pass, each in its own process, with no
"Invalid command allocator." in any log; the whole suite gives the same results as before the
change (no pass -> fail; the same four failures) and the e2e test title the same 49 checks passed
and one failed (its window is not cloaked under Wine). The retail title was not run again. Not run
on Windows.

On upstream 1ec4c98 the allocator also goes to the runtime as its own where xcl-dev#797's mid-list
split resets a spare list or makes a new one (`create_raw_pc_command_list`) and where
`title_list`'s Reset calls a list that is not adopted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wondercrash pushed a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
… split

xcl-dev#708 predates xcl-dev#795 (GPU-fence bridge) and xcl-dev#797 (mid-list split) and was
not rebased. Resolution keeps main's split machinery (xcl-dev#797 + xcl-dev#851) and
cpu_writes from xcl-dev#850 (the xcl-dev#708 per-queue workers with xcl-dev#873's
diagnostics), and ports xcl-dev#708's core change onto it:

- wait_gate.rs (from xcl-dev#708): a queue-side gate the CPU opens once it
  sees the progress value.
- PendingWait::gate: a Wait64 GE, full mask, on a non-sparse value the
  CPU can read, in a direct/compute title list, that starts its PC
  segment (split by xcl-dev#797/xcl-dev#851, or nothing recorded before it).
- execute_with_waits_on / KickoffX: gated waits arm a wait_gate instead
  of the xcl-dev#795 GPU-fence bridge; with sparse writes at or after the list
  in the batch they take the bounded CPU wait (xcl-dev#708's rule). Other waits
  keep the xcl-dev#795 bridge. Arming failure stops the title (xcl-dev#708).
- Dropped from xcl-dev#708: its own title_list piece/split machinery,
  split_recording, restore_after_reopen, open-query / split-barrier
  tracking and the Result-returning execute_with_waits.
- wait_tests.rs (from xcl-dev#708) adapted to push_segments /
  execute_with_waits_on.
cmt8 added a commit to cmt8/xcl that referenced this pull request Nov 24, 2026
…able

vkd3d-proton takes a heap, fence, resource, descriptor or query heap, root signature, pipeline
state or command signature only with its own vtable - an assert() in each of its methods and
wherever one is passed in, which the release builds keep (the process ends with status 3) - and a
command allocator only by a run-time check (CreateCommandList / Reset: E_INVALIDARG). Adoption
replaced that vtable pointer, so on vkd3d-proton the real backend stopped at the first such
object (the test title at its first heap).

Under Wine (util::under_wine) the classes whose console slots all sit inside the PC interface -
heap, resource, descriptor / query heap, root signature, pipeline state, command signature,
command allocator - get XCL's PC slots written into the runtime's own table instead (VirtualProtect,
as XAudio2's patch), only up to the interface's method count, and only when the object answered
QueryInterface for that interface with itself; orig_fn finds the entries from before by the
table. The table is shared by every object of the class (swap-chain buffers too); the overrides
already take objects XCL did not create. Console calls past the PC interface on these classes no
longer reach a logging stub. Command lists keep their extended table (the console layout is
reordered and longer than the PC one): around the runtime's ExecuteCommandLists they carry the
runtime's table, which vkd3d-proton reads only during the call. Fences are not covered yet
(console xcl-dev#12 is past the end of the PC table). On Windows nothing changes: every new path is
behind under_wine(), and orig_fn's lookup has no table on Windows.

vkd3d-proton 3.1's tables have exactly the PC interfaces' method counts (heap 10, resource 17,
descriptor heap 11, root signature 8, pipeline state 9, query heap 8, command signature 8,
allocators 9; read from its source). Wine 11.22, vkd3d-proton 3.1 release DLLs, RX 7900 XTX
RADV: bind::create_list_reset_and_clear_state_track_initial_pso_on_d3d12 passes (aborted
before); the other seven tests that aborted and the e2e test title now stop at the fence
assertion. Not run on Windows.

On upstream 1ec4c98 KickoffX also submits the earlier segments of a list xcl-dev#797 split around a
mid-list Wait64: those go with the runtime's table as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmt8 added a commit to cmt8/xcl that referenced this pull request Nov 24, 2026
… behind

ff59ccd wrote XCL's PC slots into vkd3d-proton's own allocator table, which ends after the PC's
9 methods. A console title calls past them (upstream's log names allocator xcl-dev#9, a logging stub
answered 0 on Windows): found with a retail title under Wine, whose call landed on the zeros
after vkd3d-proton 3.1's table (its slots 9-11 are 0, another table follows) and executed
address 0 about 29 s in. The fence's way (07bccd7) instead: under Wine CreateCommandAllocator
does not adopt the runtime's allocator; it returns an object of XCL's (alloc_x::wrap) with the
console length - the PC methods call the runtime allocator's through its own table (bundle
allocators have another), QueryInterface gives the wrapper back for the allocator itself,
AddRef / Release are the runtime allocator's count, Release and Reset keep alloc_release /
alloc_reset's bookkeeping on the wrapper (list_x::on_allocator_release,
console_list::allocator_reset), and xcl-dev#9 on are the same "ID3D12CommandAllocator::#N (not on PC)"
stubs as on Windows. Every allocator XCL keeps (list_x, console_list, bind) is the pointer its
caller has, the wrapper; only where an allocator goes to the runtime is it unwrapped
(alloc_x::for_runtime): the device's CreateCommandList (also console CreateCommandList /
CreateCommandListX), a list's Reset on the PC path (cl_reset, also console_list's Reset) and
the console's (list_x::reset_x: xcl-dev#10, xcl-dev#139, the DMA list) and KickoffX's Reset. These are the
places vkd3d-proton 3.1 takes an allocator back (d3d12_command_list_Reset, d3d12_bundle_Reset,
and CreateCommandList through Reset). Allocators are no longer patched in place. The pair is
made before CreateCommandAllocator returns, so no caller ever has the runtime's allocator. On
Windows nothing changes: CreateCommandAllocator takes the new path only under
util::under_wine(), and for_runtime passes the allocator as it is there.

Test: alloc_x::tests::a_wrapped_allocator_forwards_to_the_runtime_allocator (no GPU). Wine 11.22,
vkd3d-proton 3.1 release DLLs, RX 7900 XTX RADV: it, bind's
create_list_reset_and_clear_state_track_initial_pso_on_d3d12, gpu_sparse_vram_descriptors_buffers_and_xmem,
title_textures' gpu_mirror_upload_... and placed_title_textures_..., both gpu_compute_e2e tests, list_x's
reset_commits_state_..., fence_x's and the in-place test pass, each in its own process, with no
"Invalid command allocator." in any log; the whole suite gives the same results as before the
change (no pass -> fail; the same four failures) and the e2e test title the same 49 checks passed
and one failed (its window is not cloaked under Wine). The retail title was not run again. Not run
on Windows.

On upstream 1ec4c98 the allocator also goes to the runtime as its own where xcl-dev#797's mid-list
split resets a spare list or makes a new one (`create_raw_pc_command_list`) and where
`title_list`'s Reset calls a list that is not adopted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmt8 added a commit to cmt8/xcl that referenced this pull request Nov 24, 2026
…able

vkd3d-proton takes a heap, fence, resource, descriptor or query heap, root signature, pipeline
state or command signature only with its own vtable - an assert() in each of its methods and
wherever one is passed in, which the release builds keep (the process ends with status 3) - and a
command allocator only by a run-time check (CreateCommandList / Reset: E_INVALIDARG). Adoption
replaced that vtable pointer, so on vkd3d-proton the real backend stopped at the first such
object (the test title at its first heap).

Under Wine (util::under_wine) the classes whose console slots all sit inside the PC interface -
heap, resource, descriptor / query heap, root signature, pipeline state, command signature,
command allocator - get XCL's PC slots written into the runtime's own table instead (VirtualProtect,
as XAudio2's patch), only up to the interface's method count, and only when the object answered
QueryInterface for that interface with itself; orig_fn finds the entries from before by the
table. The table is shared by every object of the class (swap-chain buffers too); the overrides
already take objects XCL did not create. Console calls past the PC interface on these classes no
longer reach a logging stub. Command lists keep their extended table (the console layout is
reordered and longer than the PC one): around the runtime's ExecuteCommandLists they carry the
runtime's table, which vkd3d-proton reads only during the call. Fences are not covered yet
(console xcl-dev#12 is past the end of the PC table). On Windows nothing changes: every new path is
behind under_wine(), and orig_fn's lookup has no table on Windows.

vkd3d-proton 3.1's tables have exactly the PC interfaces' method counts (heap 10, resource 17,
descriptor heap 11, root signature 8, pipeline state 9, query heap 8, command signature 8,
allocators 9; read from its source). Wine 11.22, vkd3d-proton 3.1 release DLLs, RX 7900 XTX
RADV: bind::create_list_reset_and_clear_state_track_initial_pso_on_d3d12 passes (aborted
before); the other seven tests that aborted and the e2e test title now stop at the fence
assertion. Not run on Windows.

On upstream 1ec4c98 KickoffX also submits the earlier segments of a list xcl-dev#797 split around a
mid-list Wait64: those go with the runtime's table as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmt8 added a commit to cmt8/xcl that referenced this pull request Nov 24, 2026
… behind

ff59ccd wrote XCL's PC slots into vkd3d-proton's own allocator table, which ends after the PC's
9 methods. A console title calls past them (upstream's log names allocator xcl-dev#9, a logging stub
answered 0 on Windows): found with a retail title under Wine, whose call landed on the zeros
after vkd3d-proton 3.1's table (its slots 9-11 are 0, another table follows) and executed
address 0 about 29 s in. The fence's way (07bccd7) instead: under Wine CreateCommandAllocator
does not adopt the runtime's allocator; it returns an object of XCL's (alloc_x::wrap) with the
console length - the PC methods call the runtime allocator's through its own table (bundle
allocators have another), QueryInterface gives the wrapper back for the allocator itself,
AddRef / Release are the runtime allocator's count, Release and Reset keep alloc_release /
alloc_reset's bookkeeping on the wrapper (list_x::on_allocator_release,
console_list::allocator_reset), and xcl-dev#9 on are the same "ID3D12CommandAllocator::#N (not on PC)"
stubs as on Windows. Every allocator XCL keeps (list_x, console_list, bind) is the pointer its
caller has, the wrapper; only where an allocator goes to the runtime is it unwrapped
(alloc_x::for_runtime): the device's CreateCommandList (also console CreateCommandList /
CreateCommandListX), a list's Reset on the PC path (cl_reset, also console_list's Reset) and
the console's (list_x::reset_x: xcl-dev#10, xcl-dev#139, the DMA list) and KickoffX's Reset. These are the
places vkd3d-proton 3.1 takes an allocator back (d3d12_command_list_Reset, d3d12_bundle_Reset,
and CreateCommandList through Reset). Allocators are no longer patched in place. The pair is
made before CreateCommandAllocator returns, so no caller ever has the runtime's allocator. On
Windows nothing changes: CreateCommandAllocator takes the new path only under
util::under_wine(), and for_runtime passes the allocator as it is there.

Test: alloc_x::tests::a_wrapped_allocator_forwards_to_the_runtime_allocator (no GPU). Wine 11.22,
vkd3d-proton 3.1 release DLLs, RX 7900 XTX RADV: it, bind's
create_list_reset_and_clear_state_track_initial_pso_on_d3d12, gpu_sparse_vram_descriptors_buffers_and_xmem,
title_textures' gpu_mirror_upload_... and placed_title_textures_..., both gpu_compute_e2e tests, list_x's
reset_commits_state_..., fence_x's and the in-place test pass, each in its own process, with no
"Invalid command allocator." in any log; the whole suite gives the same results as before the
change (no pass -> fail; the same four failures) and the e2e test title the same 49 checks passed
and one failed (its window is not cloaked under Wine). The retail title was not run again. Not run
on Windows.

On upstream 1ec4c98 the allocator also goes to the runtime as its own where xcl-dev#797's mid-list
split resets a spare list or makes a new one (`create_raw_pc_command_list`) and where
`title_list`'s Reset calls a list that is not adopted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants