Skip to content

D3D12.X: a mid-list split gets its next segment before it closes the list - #2717

Open
Kalmarv wants to merge 2 commits into
xcl-dev:mainfrom
Kalmarv:split-close-order
Open

Kalmarv wants to merge 2 commits into
xcl-dev:mainfrom
Kalmarv:split-close-order

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

A mid-list split (a Wait64BitValueX after a Write64BitValue* in the same list) closed the title's list before it had the next segment. When the next segment could not be made (CreateCommandList failed), the split gave up with the list already closed: the title went on recording into a closed list. All of it was lost, Write64 cell writes included, and the title's own Close then failed. Now the split gets the next segment first: a spare, or a new list made closed with CreateCommandList1. It is opened on the allocator only after the Close, because an allocator backs one recording at a time. When none can be had, the list stays open and the wait stays in it, as when the split is turned off (XCL_SPLIT_MIDLIST_WAIT=0).

Part of #1452. This may not be what stops the reporter's run (#1452 (comment)), where a Write64 cell is recorded and never submitted. That log shows a successful split (#1) and, in what was posted, no mid-list split … CreateCommandList failed warning. This is one path that gives that state; #2691 (a list forgotten after the runtime frees it, so a new list at its address loses its Write64s) is another. The dump line that tells them apart is in #2718 (stacked on #2244). @xpatfussy69x, if you can: one run of your route with that PR and nvidia-smi dmon -s pucm -o T beside it, plus any mid-list split lines from the log.

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: split takes the next segment (next_segment_list) before it closes the list. A failed Close puts the segment back as a spare. A failed Reset of it releases that list (title_list::release_segment) and falls back to CreateCommandList on the allocator, as before.
  • crates/xcl/src/hle/d3d12x/real.rs: create_closed_pc_command_list (CreateCommandList1, closed, no allocator), next to create_raw_pc_command_list.
  • 23d3131 (luckyteagirl's review): before, a next segment whose Reset failed was dropped without a Release, and now a fresh CreateCommandList1 list could take that path. It is released before the fallback is made. Test a_split_whose_next_segment_fails_its_reset_releases_that_list_once: the Reset fails (a test-only switch), once with the fallback made and once with it failing too. Each time the list's reference must be released exactly once.
  • Test a_split_without_a_next_segment_leaves_the_list_recording: a split with no next segment to be had (a test-only switch), then one that makes its segment with CreateCommandList1. A GPU write recorded after each wait must land, and both Write64s must count as submitted.

Tested

  • NVIDIA GeForce RTX 5070 Ti, driver 610.74; AMD Ryzen 9 9950X; Windows 11 (10.0.26200.9711); Rust 1.99.0, debug
  • cargo test --workspace --no-fail-fast -- --test-threads=4 at 23d31316 (on main b49be183): 1435 passed, 2 failed, 47 ignored. The 2 are gpu::recomp::link_tests::gpu_linked_memory_accessors and linked_programs_keep_their_declarations: this machine's DXC (Windows SDK, 1.7.2308) rejects [WaveSize] on a function that is not an entry point. They fail the same way on main's code.
  • SKIPPED (144): 119 validator 1.7 < 1.8 (validation step only), 21 no wave64, 3 wave32 per-lane form refused (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32), heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
  • a_split_without_a_next_segment_leaves_the_list_recording fails with main's split and the same switch (the list is closed after the failed split, so the next split's Close fails and no segment is made: 1 segment, expected 2), and passes with this change.
  • a_split_whose_next_segment_fails_its_reset_releases_that_list_once fails with the release_segment call taken out (the list's reference is still held: the split released the list whose Reset failed, once), and passes with it.
  • DarkPanda69 ran 7fce129 (D3D12.X: a mid-list split gets its next segment before it closes the list #2717 (comment)): a_split_without_a_next_segment_leaves_the_list_recording passes on an AMD Radeon RX 9070 XT (driver 32.0.32029.2010). cargo test -p xcl --lib -- d3d12x:: gave 255 passed, 0 failed, 2 ignored on it and on an RTX 3060 (driver 32.0.16.1088). The test uses the default adapter, so it did not run on the RTX 3060.
  • Royalflamejlh ran the title with 7fce129 under Wine 11.21 + vkd3d-proton on an RTX 4070 (D3D12.X: a mid-list split gets its next segment before it closes the list #2717 (comment)): 2 runs with and 2 without, each with one successful mid-list split and no difference between the two. a_split_without_a_next_segment_leaves_the_list_recording passed under Wine. The failure path this PR changes (a split whose next segment cannot be made, or whose Reset fails) was not reached in those runs.
  • Tested by others, Decodere (D3D12.X: a mid-list split gets its next segment before it closes the list #2717 (comment)): 23d3131 on an RTX 4060 8 GB (driver 621.14), release. Both split tests passed, including a_split_whose_next_segment_fails_its_reset_releases_that_list_once; title_list:: 3, list_x:: 42 and real:: 60 passed, with no skips. A paired 60 s smoke of another title, main b49be18 against 23d3131: 1518 against 1547 frames, no device removal, no crash. The full suite, AMD, Intel and Wine were not run there.

Regression run
main (b49be18):

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

this PR (23d3131):

xcl-smoke v1
commit: 23d313161e3a3a09bbd9353f9a183865373c31bf
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1386 (PresentX 1387)
presents per 2 s (last 3): 56 22 1
device removals: 0
crashes: 0
peak commit: 20244 MB

Not tested

  • The reporter's card (RTX 3060) and route; whether this is the cause there (see above)
  • Intel GPUs; 23d3131's test on AMD
  • A real CreateCommandList or Reset failure: the tests switch them off
  • The split in a title run: neither 60 s smoke run makes a mid-list split (no split command list line in either log), so they check the rest of the runtime only

AI use

  • Claude Code, Claude Opus 5.5: found the path, wrote the change, the test and this description.

🤖 Generated with Claude Code

…list

split() closed the title's list and only then reset a spare or made a
new list for the next segment. When CreateCommandList failed there, it
returned with the list already closed and the wrapper still on it: what
the title recorded after the Wait went into a closed list and was lost,
Write64 cell writes included (a cell then stays recorded and never
submitted, as in xcl-dev#1452), and the title's own Close failed.

The next segment is now had first: a spare, or a list made closed on no
allocator with CreateCommandList1 (create_closed_pc_command_list). It is
reset onto the allocator only after the Close, since an allocator backs
one recording at a time. With no segment to be had, the list stays open
and the wait stays in it, as with XCL_SPLIT_MIDLIST_WAIT=0. A failed
Close puts the segment back as a spare; a failed Reset of it falls back
to CreateCommandList on the allocator, as before.

Part of xcl-dev#1452.

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

DarkPanda69 commented Nov 26, 2026 •

Copy link
Copy Markdown

Update for head 23d3131: rerun on main b49be18, same cards and --nocapture. The filter a_split_ gives 2 passed, no SKIPPED, on the RX 9070 XT (the default adapter these tests use): a_split_without_a_next_segment_leaves_the_list_recording and the new fault-injected a_split_whose_next_segment_fails_its_reset_releases_that_list_once. d3d12x:: gives 256 passed, 0 failed, 2 ignored, no SKIPPED, on both the RX 9070 XT and the RTX 3060.

AMD run (listed as untested): the new test passes on an RX 9070 XT, and the d3d12x:: tests pass on it and on an RTX 3060.

Head 7fce129 applied on main b49be18, debug, Windows 11 Pro 26200, card chosen with XCL_ADAPTER, run with --nocapture:

  • a_split_without_a_next_segment_leaves_the_list_recording: ok, no SKIPPED. The test makes its device on the default adapter, which is the RX 9070 XT (RDNA4, driver 32.0.32029.2010) on this machine.
  • cargo test -p xcl --lib -- d3d12x::: 255 passed, 0 failed, 2 ignored, no SKIPPED, on both the RX 9070 XT and the RTX 3060 (12 GB, driver 32.0.16.1088).

Not tested: the reporter's route on the RTX 3060. There is no title here, and the new test always uses the default adapter, so it did not run on the RTX 3060. Also not tested: Intel, a real CreateCommandList failure.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

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

At exact head 7fce129 on current main b49be18, a failed Reset abandons an owned command-list reference. This is a source-derived review; I did not inject a D3D12 Reset failure.

The no-spare path now gets next from create_closed_pc_command_list, whose normal-device branch transfers ownership with into_raw() and adopts it. After the current list closes, split tries reset_list(next, …). If that Reset fails, the branch at list_x.rs:2834–2845 replaces next with a separately created fallback list or returns None; neither outcome releases or pools the failed next. The earlier code had a similar hole for a popped spare, but this PR makes a fresh list reachable through the failure path too, including when resource pressure is already causing Reset/creation failures.

Could the failed next be released through the adopted-list cleanup path before trying the fallback (rather than reusing a list whose Reset failed)? A fault-injected Reset failure with both successful and failed fallback creation could assert that the abandoned list's COM reference is released exactly once.

AI assistance: three GPT-6.2 Sol agents independently identified the ownership path; GPT-6.2 Astra checked the exact-head source and wording.

When the Reset that opens a split's next segment failed, split() made a
list in its place (or gave up) and dropped the failed one without a
Release: with the next segment now made by CreateCommandList1 when there
is no spare, that leaked a fresh list. It is released now
(title_list::release_segment, as the recording's segments are at its
Release), before the fallback is made.

The test fails the Reset and, in its second half, the fallback too
(test-only switches), and checks that the list's reference was released
once in both.

Part of xcl-dev#1452.

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

Copy link
Copy Markdown
Contributor

The title ran the same with this pull request as without it, in 2 runs of each under Wine + vkd3d-proton on an RTX 4070. Each run split one list around a mid-list Wait, 0.6 to 2.5 s after the title's first call to the stub ID3D12GraphicsCommandList10::#101, logged no mid-list split warning, and had stopped presenting by 2.0 to 3.3 s after that #101. The split was the same in both trees, with the same log line and no failure, so the new order changed nothing the runs could see. The case it fixes, a split whose next segment cannot be made, did not happen in these runs. a_split_without_a_next_segment_leaves_the_list_recording passed under Wine (-- split --test-threads=4: 35 passed, 1 ignored).

Setup: main b49be18 + #684 (e56dbc3, which our runs need to get this far; merged as 4044c646), against the same + this pull request (7fce1295), release, Wine 11.21 Staging + vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, VKD3D_CONFIG=ignore_shared_fence, RTX 4070 12 GB, driver 615.71.09. 120 s each, A pressed once the title presented steadily, XCL_PSO_PRELOAD=0, the first-run screens completed once, no story progress.

Run Tree A pressed First #101 Split Last 2 s with presents ends Frames
1 main + #684 18.4 s 83.4 s 85.9 s 86.7 s 1,480
2 main + #684 16.2 s 73.4 s 75.0 s 76.1 s 1,346
3 + #2717 16.5 s 74.0 s 74.6 s 76.1 s 1,321
4 + #2717 16.4 s 76.2 s 77.4 s 78.3 s 1,362
  • The split line, the same in all four (XCL prints every split up to Olympus compatibility layer #4, so each run split once): D3D12.X: split command list (type 2) around mid-list Wait after Write64 (#1).

Read: the split now takes its next segment (a spare, else CreateCommandList1) at list_x.rs:2772, before the Close at 2813, and the early returns at 2780 and 2818 put it back as a spare. The runs never reached the failed-Reset branch at 2834–2845, where luckyteagirl's review asks for that segment to be released.

Not tested: Windows; a split whose next segment cannot be made, in the title; the whole test suite.

AI use: Claude Code (Claude Opus 5.5) ran the title and the tests and wrote this comment.

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

bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
The transactional split already reserves a closed continuation before closing the producer, but a cache miss made a private allocator, opened a list on it, and closed the list only to Reset it later onto the title allocator. CreateCommandList1 directly makes the required closed allocator-free object.

Use that path when ID3D12Device4 is available and retain the existing allocator-backed path for older devices and Close-failure injection tests. This preserves the integrated preflight/commit/rollback model and allocator generation tracking.

The Windows GNU library/test cross-check passed with existing warnings. Windows MSVC, GPU tests, and title smoke were not available here.

Adapted from the CreateCommandList1 reservation concept in xcl-dev#2717 by Kalmarv with Claude Code (Claude Opus 5.5); its core close-before-create fix was already superseded by the integrated transactional split.

Assisted-by: Codex (GPT-5.6-sol)
@Decodere

Copy link
Copy Markdown
Contributor

Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2717 at 23d313161e3a3a09bbd9353f9a183865373c31bf (parent 7fce1295e919607e3db30c3bc4a31755cf3209d2; merge-base origin/main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). Measurements and targeted test results only; not a full source review.

Setup

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200
  • Toolchain / caches: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)
  • Workload: Retail workload title: 29640639 via scripts/smoke.ps1 -Seconds 60 (XCL_NETWORK=0 XCL_ACTIVITY=1, default flags, no input)

Targeted RTX 4060 release unit tests (23d31316)

  • cargo test --release -p xcl --lib a_split_without_a_next_segment_leaves_the_list_recording -- --nocapture: 1 passed, 0 failed, 0 ignored (0.25 s, exit 0).
  • cargo test --release -p xcl --lib a_split_whose_next_segment_fails_its_reset_releases_that_list_once -- --nocapture: 1 passed, 0 failed, 0 ignored (0.20 s, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::title_list:: -- --test-threads=4: 3 passed, 0 failed, 0 ignored (0.02 s, 0 skipped, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::list_x:: -- --test-threads=4: 42 passed, 0 failed, 0 ignored (0.70 s, 0 skipped, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::real:: -- --test-threads=4: 60 passed, 0 failed, 0 ignored (0.65 s, 0 skipped, exit 0).

Observations

  • Both mid-list split tests (a_split_without_a_next_segment_leaves_the_list_recording and the updated failed-Reset cleanup regression test a_split_whose_next_segment_fails_its_reset_releases_that_list_once) plus all 105 targeted title_list::, list_x::, and real:: tests passed cleanly in --release on native Windows 11 / RTX 4060 with 0 skips.
  • Quiet 60 s retail smoke ran cleanly (exit: 0x0, 1547 frames shown, 60 60 60 steady-state presents per 2 s, 0 device removals, 0 crashes, 13977 MB peak commit vs origin/main b49be183's 14018 MB / 1518 frames).

Paired 60 s RTX 4060 smoke (b49be183 vs 23d31316)

Merge-base origin/main (b49be183):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB

PR #2717 head (23d31316):

xcl-smoke v1
commit: 23d313161e3a3a09bbd9353f9a183865373c31bf
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1547 (PresentX 1547)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13977 MB

Limits of coverage

  • Full workspace test suite was not re-run on 23d31316 (only targeted title_list::, list_x::, and real:: release tests plus paired quiet 60 s smoke).
  • The quiet 60 s retail smoke verifies no runtime regression on normal command-list recording; mid-list split allocation failure and failed-Reset release paths are covered by the two targeted unit tests above.
  • Native Windows 11 (26200) / discrete RTX 4060 only; no AMD, Intel, or Wine/Linux run on this host.

AI use

Ran the targeted release unit tests and paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts and smoke blocks were taken directly from cargo test and scripts/smoke.ps1 outputs.

@Kalmarv

Kalmarv commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@luckyteagirl Thanks, confirmed and fixed in 23d3131, a commit on top of 7fce129, so that commit is the whole change since your review. When the next segment's Reset fails, split now releases that list through title_list::release_segment (the same Release and bind::forget the wrapper's own Release does for its segments), then makes the fallback. The new a_split_whose_next_segment_fails_its_reset_releases_that_list_once fails the Reset with a test-only switch, once with the fallback made and once with it failing too. It holds an extra reference on the list and checks that its own Release afterwards is the last one. That fails with the release_segment call taken out and passes with it. Suite at 23d3131 on an RTX 5070 Ti: 1435 passed, 2 failed (the two DXC 1.7 link_tests, as on main), 47 ignored. Our new smoke pair at 23d3131 is in the description.

Thanks @DarkPanda69 for the RX 9070 XT and RTX 3060 runs of 7fce129, and @Royalflamejlh for the four Wine + vkd3d-proton title runs on an RTX 4070. In Royalflamejlh's runs each split succeeded, so they did not reach the failure path this PR changes. Neither of those runs covers 23d3131. Thanks too @Decodere for the RTX 4060 run of 23d3131: both split tests passed, the fault-injected one included, and so did the paired smoke (1518 against 1547 frames, no removal). All three are in Tested.

AI use: Claude Code, Claude Opus 5.5 wrote the fix, the test and this reply.

@Prime1997 Prime1997 mentioned this pull request Nov 26, 2026
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
The transactional split already reserves a closed continuation before closing the producer, but a cache miss made a private allocator, opened a list on it, and closed the list only to Reset it later onto the title allocator. CreateCommandList1 directly makes the required closed allocator-free object.

Use that path when ID3D12Device4 is available and retain the existing allocator-backed path for older devices and Close-failure injection tests. This preserves the integrated preflight/commit/rollback model and allocator generation tracking.

The Windows GNU library/test cross-check passed with existing warnings. Windows MSVC, GPU tests, and title smoke were not available here.

Adapted from the CreateCommandList1 reservation concept in xcl-dev#2717 by Kalmarv with Claude Code (Claude Opus 5.5); its core close-before-create fix was already superseded by the integrated transactional split.

Assisted-by: Codex (GPT-5.6-sol)
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