Skip to content

D3D12.X: a closed standby is recorded empty before it can be submitted - #3167

Open
KOLESNiii wants to merge 1 commit into
xcl-dev:mainfrom
KOLESNiii:d3d12x-closed-standby-submit
Open

KOLESNiii wants to merge 1 commit into
xcl-dev:mainfrom
KOLESNiii:d3d12x-closed-standby-submit

Conversation

@KOLESNiii

@KOLESNiii KOLESNiii commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3166.

When a mid-list split's Close fails, title_list::fail_closed routes the wrapper to a closed standby from reserve_closed_segment, and push_segments submits it. That standby came straight from CreateCommandList1: closed, but never recorded. Submitting such a list removes the device with 0x887a0001. A list that is Reset on an allocator and Closed empty does not.

What is in it

  • list_x.rs reserve_closed_segment / new record_empty_closed:
    • The new list is Reset on a private allocator and Closed with nothing recorded before it is handed out.
    • XCL's vtable is restored after the native Reset, as everywhere else, so the Close goes to the right method.
    • If this fails, the list is released and the existing CreateCommandList path is used.
  • list_x.rs STANDBY_ALLOCS:
    • The private allocator is kept while the list may be submitted with that recording, and dropped when the list is Reset onto the title's allocator or released. If it is still in flight at release, it is leaked rather than released, as own_alloc is.
    • It is not kept in LISTS: an allocator's last Release takes LISTS (on_allocator_release), so it is always dropped with no lock held. A first version kept it in the list state and deadlocked the suite.

#2925 (open) also records its stand-in empty and can rebase onto this.

Tested

  • NVIDIA RTX 2070 SUPER (driver 32.0.16.2140), AMD Ryzen 5 3600XT, Windows 11 build 26300, Rust 1.100.0 MSVC; tests in debug
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on f67ed2b: 2130 passed, 11 failed, 48 ignored. SKIPPED: 15 (14 no wave64, 1 no heap windows).
    • The 11 failures also fail on main e13d625 (2128 passed, 12 failed, 48 ignored, same 15 SKIPPED; the twelfth is the alloc_pool test completion_queries_run_outside_allocator_state):
      • 4 e2e title tests
      • split dispatch-chain ×3
      • msaa_tests::direct_msaa_loads_precede_get_dimensions
      • heap_window_tests::gpu_heap_flat_reads_match_guarded_and_root_output
      • gpu_compute_mode_dispatch_abi
      • gpu_float_cas_uses_ieee_equality
  • New test list_x::tests::a_reserved_closed_standby_can_be_submitted: ok. It submits the standby reserve_closed_segment gives and checks the device. With the fix disabled (an allocator made but nothing recorded), the device is removed and the test fails.

Regression run
RTX 2070 SUPER, the retail game, 60 s, XCL_PRESS_AT=25:A, XCL_PREPARE=0 (no startup shader preparation), release builds, one queue job (main, then #3167) with the same starting DXIL cache for every run.

main:

xcl-smoke v1
commit: 309c3ec5a25ea231ddbe01f76748ab8ed3d9d953
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1297 (PresentX 1298)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 14701 MB

This PR's head (based on main e13d6250):

xcl-smoke v1
commit: f67ed2bd17a9c881544ea4bbb1fecc4342f7fc2a
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1232 (PresentX 1232)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15542 MB

Not tested

  • A real title whose split Close fails. The retail game does not reach this path, so the smoke run is a regression check only.
  • The regression runs skip startup shader preparation (XCL_PREPARE=0), on main and on this PR alike.
  • AMD GPUs.

AI use

  • Claude Code, Claude Opus 5.5 (earlier steps of this session ran on Claude Sonnet 5.5): wrote the code, the test, the issue and this description; ran the tests.
  • Claude Code (Claude Opus 5.5) ran the regression runs and added them here.

🤖 Generated with Claude Code

@Aniseto

Aniseto commented Nov 28, 2026

Copy link
Copy Markdown

Ran the closed-standby submission test at f67ed2bd on an NVIDIA Blackwell desktop part:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_reserved_closed_standby_can_be_submitted -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 2034 filtered out      (exit 0)

The new test passes here: the standby list reserved after a failed mid-list Close can be submitted without removing the device. The thread has no comments yet, so this is the first datapoint in it and the first from an RTX 5070 Ti. It is a synthetic device test, not a title run.

Not tested: a retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@KOLESNiii
KOLESNiii force-pushed the d3d12x-closed-standby-submit branch from f67ed2b to 86ecaa6 Compare November 28, 2026 19:57
@KOLESNiii
KOLESNiii force-pushed the d3d12x-closed-standby-submit branch from 86ecaa6 to 95ca62c Compare November 29, 2026 20:55
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
@KOLESNiii
KOLESNiii marked this pull request as ready for review November 29, 2026 21:00
@andrewDoing

Copy link
Copy Markdown
Contributor

The existing fenced DIRECT standby test passed on RTX 5070 at 95ca62c5. A second check found a gap in the allocator tracking for DIRECT, COMPUTE, and COPY standbys. When the normal submission code reserved each list, the pool marked the list in flight. It had no recording association for the private allocator, and its allocator check still reported idle. The fixture cancelled the reservation before native execution and then released the idle list.

I tried the existing alloc_pool::reset_list path for the private Reset in record_empty_closed. All three queues then reported the private allocator as the recording backing and pinned it during the reservation. Cancelling the reservation returned each allocator to idle. The original fenced DIRECT test still passed. Companion commit

RTX 5070 12 GB (616.92), Ryzen 7 5700X3D, Windows 11 26300.10075, Rust 1.100.0 MSVC. XCL_ADAPTER=5070 cargo test --release --offline --locked -p xcl --lib -- a_reserved_closed_standby_can_be_submitted private_standby_recording_reaches_allocator_tracking --test-threads=1 --nocapture. PR head plus the fixture gave 1 pass and 1 failure. The source in the companion commit gave 2 passes and 0 failures. Both had 0 ignored and 0 explicit skips. This is a synthetic submission and bookkeeping check. Retail behavior remains unmeasured.

OpenAI Codex with GPT-6.2 Sol wrote and ran the fixture and companion change.

When a mid-list split's Close fails, title_list::fail_closed routes the
wrapper to a closed standby from reserve_closed_segment, and push_segments
submits it at the next ExecuteCommandLists. That standby came straight
from CreateCommandList1 (closed, never Reset or recorded). Submitting such
a list is invalid: on an RTX 2070 SUPER the device was removed with
0x887a0001 DXGI_ERROR_INVALID_CALL. A plain D3D12 repro (no XCL code)
removed the device the same way, and the same list after a Reset on an
allocator and an empty Close did not.

reserve_closed_segment now Resets the new list on a private allocator and
Closes it empty before handing it out; if that fails, it releases it and
falls back to the existing CreateCommandList path.

The private Reset goes through alloc_pool::reset_list, as the reserved
segment's later Reset does, so a submission of the standby pins its
private allocator; a direct PC Reset left the allocator untracked and
idle while the list was in flight (andrewDoing's review, with the test).

Co-Authored-By: andrew-ai <adoing@zirrusone.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KOLESNiii
KOLESNiii force-pushed the d3d12x-closed-standby-submit branch from 95ca62c to 57e0e5c Compare November 29, 2026 21:35
@KOLESNiii

Copy link
Copy Markdown
Contributor Author

Thanks @andrewDoing, you are right. record_empty_closed reset the standby on its private allocator with a direct PC Reset, so alloc_pool never recorded that the list records on that allocator. begin_submit then pinned the list but not the allocator. The reserved segment's later Reset (reset_reserved_segment) already goes through alloc_pool::reset_list, and the private Reset now does the same.

I took your change and your private_standby_recording_reaches_allocator_tracking test unchanged and squashed them into the PR's commit, crediting you as co-author: head is now 57e0e5c3. It builds here. The whole suite and the regression smoke on this head are queued on my RTX 2070 SUPER, and I'll update Tested with the counts when they finish.

— Claude Code (Claude Opus 5.5), on behalf of the PR author

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 57e0e5c

Fixes #3166. No other open or merged PR fixes it; the merged #2925 added the failed-split route this fixes, and main's reserve_closed_segment (list_x.rs) still returns the never-recorded CreateCommandList1 list as is.
No problems found in the diff. record_empty_closed resets the list on a private allocator and closes it, and STANDBY_ALLOCS keeps that allocator alive until reset_reserved_segment / on_release. One small point: drop_standby_alloc leaks the allocator for good (mem::forget) when it is still in flight instead of retiring it later; that path is rare.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head 57e0e5c, diff read, not a merge-check; PR description red: its smoke block and counts are from f67ed2b):

  • The spare path is still open. After a successful Close, the unused standby goes back to the spares (list_x.rs ~4701). title_list::put_spare calls alloc_pool::retire_recording, which drops the link from list to private allocator that this fix relies on. pop_spare (~4809) can then hand it out as the standby. On submit the list is pinned but its allocator isn't, so drop_standby_alloc (~1439-1443) can release an allocator the GPU is still using. The new test covers fresh lists only (unverified at runtime).
  • Default-path cost. Every fresh standby now costs an allocator plus a Reset and a Close, two per split (plus KickoffX and deferred segments), though only the rare failure route submits one. Making the empty recording lazily, when fail_closed actually routes to a standby, would keep the common path as it was. The PR's smoke pair is on different bases (+841 MB, -5 % frames), so it can't say.
  • Error path. If Reset succeeds and Close fails (~4863-4870, ~4830), alloc_pool keeps a link to temp, which is then dropped (rare, unverified).
  • mem::forget (~1443) leaks an in-flight allocator for good (rare).
  • The test (~7919) creates its device with D3D12CreateDevice(None), ignoring XCL_ADAPTER, on the device the other GPU tests share, so a regression removes it for all of them. It never releases the standby either (an entry stays in STANDBY_ALLOCS).
  • The description calls D3D12.X: a split whose Close fails leaves that list out and goes on #2925 open; it's merged.

Fine: the lock is released before the allocator's Release (no LISTS deadlock), the vtable is restored before Close, alloc_pool::reset_list is used, and the fallback stays. The root cause (a fresh standby from CreateCommandList1 submitted unrecorded, 0x887a0001) is right.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

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

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D3D12.X: a failed mid-list split submits a never-recorded standby list and removes the device

4 participants