Skip to content

D3D12.X: switch KickoffX onto an idle spare PC list when the submitted list is in flight - #2320

Open
Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-2163-kickoff-in-flight-spare
Open

Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-2163-kickoff-in-flight-spare

Conversation

@Decodere

Copy link
Copy Markdown
Contributor

What is in it

Follow-up to #2163 (Part of #1452).

list_x::kickoff_x() previously closed and submitted the active PC command list (this) — plus any earlier split segments — and immediately called Reset on that same PC list (or on primary after a mid-list split), even when its submission was still in flight on the GPU. When a title issues back-to-back KickoffX calls or follows KickoffX with Close + ExecuteCommandLists before the previous kickoff retires, PC D3D12 rejects resubmitting an in-flight command list (debug layer ID 553, EXECUTECOMMANDLISTS_COMMANDLIST_STILL_IN_FLIGHT) and strict drivers can trigger device removal.

  • crates/xcl/src/hle/d3d12x/title_list.rs:
    • Added primary_of(wrapper) and switch_active_for_kickoff(wrapper, old_active, new_active) to update F_BACKING, WRAPPER_OF, book.first, and book.spares only after Reset succeeds, while keeping F_PRIMARY out of book.first and book.spares.
    • Added pure-CPU unit test switch_active_for_kickoff_keeps_primary_out_of_spares covering primary -> spare1 -> spare2 -> primary, WRAPPER_OF updates, spare-pool invariants, and clean release.
  • crates/xcl/src/hle/d3d12x/list_x.rs:
    • Extracted shared create_closed_spare(template, ty, alloc) (used by both reset_stand_in and kickoff_x) so a newly created spare whose initial Close fails is forgotten and released rather than returned to the spare pool.
    • Updated kickoff_x to capture wrapper before reclaim_for_kickoff, prefer returning to primary once idle when standing in on a spare, otherwise pop an idle spare or create a fresh closed spare whenever current_target is still in flight, reset the candidate before committing switch_active_for_kickoff (returning a failed non-primary spare to put_spare and falling back to current_target), transfer bind + ListState + DRED pipeline labels onto target, clear retired segment state, and guard init_pso and predication restore for COPY command lists.
    • Added WARP-fallback gated-queue tests kickoff_x_while_in_flight_switches_to_idle_spare_and_preserves_state and kickoff_x_after_midlist_split_switches_to_idle_spare.

Tested

Hardware / toolchain: Windows 11 Home 26200, Intel Core i5-11400F, 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (driver 621.14, wave32-only), Rust 1.100.0, DXC 1.9.2609.5.

  • Pre-fix failing-first (new tests against unmodified kickoff_x on RTX 4060, --test-threads=1):
    • cargo test -p xcl --lib kickoff_x_ -- --test-threads=1 --nocapture: 0 passed; 2 failed (kickoff_x_while_in_flight_switches_to_idle_spare_and_preserves_state and kickoff_x_after_midlist_split_switches_to_idle_spare both reproduced live D3D12 ID 553 in-flight command-list resubmission warnings #1..#3 and failed assertions).
  • Post-fix targeted tests (4db9383a on origin/main 06c9f550):
    • cargo build --release --workspace: passed.
    • cargo test --release -p xcl --lib -- hle::d3d12x::title_list::tests hle::d3d12x::list_x::tests --test-threads=1 --nocapture: 40 passed; 0 failed; 0 ignored (0.94 s, zero ID 553 resubmission warnings).
    • 10x repeated stress of all 3 new tests (switch_active_for_kickoff_keeps_primary_out_of_spares, kickoff_x_while_in_flight_switches_to_idle_spare_and_preserves_state, kickoff_x_after_midlist_split_switches_to_idle_spare) under --test-threads=4: 10/10 passed.

Regression run

  • Full release workspace suite (cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture on 4db9383a):
    • 1268 passed; 0 failed; 46 ignored across 23 test binaries (xcl lib 1199 passed; 0 failed; 26 ignored; integration/bin/doc binaries 69 passed; 0 failed; 20 ignored).
    • 28 tests printed SKIPPED due to host hardware/environment capabilities:
      • 21 no wave64 (RTX 4060 is wave32-only: 1 in gpu::dxil::kernel, 4 in gpu::recomp::lower, 14 in gpu::recomp::lower_dxil, 2 in gpu::recomp::tests)
      • 3 wave32, per-lane form: refused (f16_programs_on_the_gpu arithmetic & packed, f32_programs_on_the_gpu conversions)
      • 2 missing D3D12 debug layer (test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll; uploads_start_from_each_subresources_state: no D3D12 debug layer)
      • 1 no heap windows (heap_window_out_of_memory_falls_back_to_the_switch_form)
      • 1 cannot disable the driver cache (shaders::tests::pso_measurement_compiles_an_exact_synthetic_record)
  • Paired 60 s retail smoke on RTX 4060 (scripts/smoke.ps1 -Seconds 60):

Baseline (origin/main 06c9f5505f63f10c5ec49ef932d75b2c28177324):

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

PR head (4db9383acea69d0c355ce5d2cb339a9f6ad1d2bb):

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

Not tested

  • AMD, Intel, and wave64 GPUs, and live D3D12 debug layer validation (d3d12SDKLayers.dll is not installed on this host; in-flight resubmission avoidance is verified via alloc_pool::note_resubmits and GetDeviceRemovedReason().is_ok()).
  • A retail title that triggers back-to-back in-flight KickoffX on a COPY command list (the COPY list init_pso / predication guard was verified by code inspection).
  • Pre-existing concurrent D3D12 test-harness contention observed in list_x::tests under --test-threads=4 on NVIDIA driver 621.14 (also reproduced 3/15 times on unmodified origin/main afc5ee86 with DXGI_ERROR_DEVICE_HUNG / E_OUTOFMEMORY across cross_queue_wait64_before_signal, mid_list_write64_wait64_split, and rotating_queue_self_deadlock; out of scope for this PR, while the two new gated-queue KickoffX tests serialize against each other via a test-only mutex).

AI use

Assisted by Google Antigravity (Gemini 4 Neon) for code analysis, implementation, test authoring, and verification.

…d list is in flight

Follow-up to xcl-dev#2163 (Part of xcl-dev#1452).

`list_x::kickoff_x()` previously reset and resumed recording on the same PC command list it had just submitted (or on `primary` after a mid-list split), even when that list's submission was still executing on the GPU. A subsequent `KickoffX` or final `Close` + `ExecuteCommandLists` then resubmitted an in-flight PC command list, triggering D3D12 debug layer ID 553 (`EXECUTECOMMANDLISTS_COMMANDLIST_STILL_IN_FLIGHT`) and device removal on strict drivers.

- Add `title_list::primary_of` and `title_list::switch_active_for_kickoff` to switch `F_BACKING` / `WRAPPER_OF` / `book.first` / `book.spares` after `Reset` succeeds while keeping `F_PRIMARY` out of `book.first` and `book.spares`.
- Extract shared `list_x::create_closed_spare` (used by both `reset_stand_in` and `kickoff_x`) so a spare whose initial `Close` fails is released instead of pooled.
- Update `list_x::kickoff_x` to prefer an idle `primary` when standing in on a spare, otherwise switch to an idle or freshly created spare when the submitted target is still in flight, preserve `bind` / `ListState` / DRED pipeline state onto the new active list, clear retired segment state, and guard `init_pso` and predication restore for `COPY` command lists.
- Add unit tests covering `switch_active_for_kickoff` invariants, back-to-back in-flight `KickoffX` + return to `primary` after drain, and `KickoffX` after a mid-list `Write64 -> Wait64` split.

Assisted-by: Google Antigravity (Gemini 4 Neon)
@nnonno91

Copy link
Copy Markdown

Independent focused check of 4db9383acea69d0c355ce5d2cb339a9f6ad1d2bb.

Tested

  • Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC, unoptimized profiles. AMD Radeon(TM) Graphics driver 32.0.21042.62 and GeForce RTX 5090 driver 32.0.16.1742. The fixture uses D3D12's default adapter with a WARP fallback. It does not print the adapter chosen.
  • cargo test --locked -p xcl --lib kickoff -- --nocapture --test-threads=1 gave 4 passed, 0 failed, 0 ignored and no skips. Both new in-flight queue scenarios completed, including after a mid-list split. The spare bookkeeping and existing render-target binding tests also passed.

Not tested

Explicit per-adapter or WARP runs, before/after reproduction, the full workspace suite and retail smoke.

AI use

OpenAI Codex (GPT-6.2 Sol) ran the checks, verified the logs and wrote this report.

@thehollowedone

Copy link
Copy Markdown

Independent check of 4db9383. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, DXC 1.8.2502.11.

  • The clean head built with cargo build --offline --locked --workspace -j 6. cargo test --offline --locked --workspace --no-fail-fast -j 6 -- --test-threads=4 --nocapture finished with 1,268 passed, 0 failed, 46 ignored, including 26 runtime skips in the pass count. All four stock KickoffX and spare-list bookkeeping tests passed.
  • I ran cargo test --offline --locked -p xcl --lib -j 6 kickoff_x_ -- --test-threads=1 --nocapture in separate processes with test-only changes that selected the RTX 3080 Ti and Microsoft WARP explicitly and read the D3D12 debug queue. Both runs passed 3/3 with zero skips. Each adapter completed the two gated-queue cases (back-to-back kickoff and mid-list split) with zero ID 553 messages, zero D3D12 warnings or errors, and a healthy device. Runtime code was unchanged.

Synthetic input only. No retail smoke on this machine.

AI-assisted. Codex (GPT-6, exact variant unavailable) added the temporary test instrumentation, ran the tests and drafted this report.

@luckyteagirl

Copy link
Copy Markdown
Contributor

Independent RX 6800M verification of exact PR head 4db9383acea69d0c355ce5d2cb339a9f6ad1d2bb.

Environment: Windows 11 build 26200; Ryzen 9 5980HX; discrete AMD Radeon RX 6800M driver 30.0.13002.13003 alongside integrated Radeon graphics; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Isolated debug Cargo target.

On the unchanged head, cargo test --locked -p xcl --lib kickoff_x_ -- --test-threads=1 --show-output passed 3 passed, 0 failed, 0 ignored, with no skips. Its test_device_or_warp helper does not print or select the adapter, so that run alone is not attributable to the RX 6800M.

For an attributable GPU check, I changed only that test helper locally to use gpu::adapter::Selector::from_env_or("auto") plus candidates, then ran the same filter with XCL_ADAPTER=6800M. It again passed 3/0/0, no skips. Both new in-flight tests printed KickoffX test adapter: AMD Radeon RX 6800M: back-to-back gated KickoffX switched to distinct idle spares and returned to primary after draining; the mid-list Write64/Wait64 split resumed on an idle spare. Their built-in checks reported no in-flight resubmits and a healthy device. The third passing test is the existing render-target binding check. I removed the test-only selector edit and verified the worktree is clean.

Limits: Focused synthetic tests only. I did not run the full workspace suite, a paired title smoke, or a live D3D12 debug-layer check on this head. A separate title smoke attempt for another PR had stopped under the available-commit memory guard. This does not cover an actual title's back-to-back KickoffX sequence.

AI use: OpenAI Codex (GPT-6; exact variant unavailable in this session) ran the Windows checks, made and restored the test-only selector, and drafted this report. No game data was used.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Independent AMD report for 4db9383acea69d0c355ce5d2cb339a9f6ad1d2bb.

Tested

  • AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 build 26200, rustc 1.100.0, debug profile for tests, release for smoke. Tested at the exact PR head (not a local merge onto main).
  • cargo test -p xcl --lib kickoff: 4 passed, 0 failed. switch_active_for_kickoff: 1 passed. Both new in-flight scenarios ran on the RX 7800 XT (no SKIPPED line).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1267 passed, 1 failed, 46 ignored. The one failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] = 0x1, CPU 0x7fffffff). It fails identically on main 06c9f550 on this adapter (cargo test -p xcl --lib fuzz_validate_and_gpu_1), so it is not caused by this PR.
  • SKIPPED lines in the log: 7 (6 of them f16_programs_on_the_gpu / f32_programs_on_the_gpu per-lane cases refused for V_MUL_F16, V_PK_MUL_F16 or V_CVT_F16_F32, plus heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • scripts/smoke.ps1 -Seconds 60 on a real title (same title, same time), release build. main 06c9f550: 1531 frames, last presents per 2 s 60 36 38, peak commit 17752 MB, no device removal, no crash. PR head 4db9383a: 1571 frames, last presents per 2 s 59 61 59, peak commit 15155 MB, no device removal, no crash. Both exit 0x0.

Not tested

Retail title with a before/after reproduction of the #1452 debug-layer error, other adapters, NVIDIA.

AI use

Claude Code (Claude Sonnet 5.5) ran the tests and the smoke runs and wrote this report. No game files, dumps or shader names are included.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…#2296, xcl-dev#2297, xcl-dev#2320, xcl-dev#2323, xcl-dev#2329, xcl-dev#2333

Integrates shader heap-base addresses (xcl-dev#1803), fenced superseded texture unmaps (xcl-dev#2270), cross-queue VRAM heap reclamation fencing (xcl-dev#2275, using create_raw_fence under Wine), PcCall frame clamping and orphan PSO drop (xcl-dev#2296), PSO pointer guards (xcl-dev#2297), KickoffX idle spare list switching (xcl-dev#2320, preserving UnadoptGuard), console-list descriptor heap binding (xcl-dev#2323), ClearUnorderedAccessView PC handles (xcl-dev#2329), and dispatch_chain PSO retention (xcl-dev#2333).
@thiagocalile

Copy link
Copy Markdown

Independent test and 60 s smoke report for head 4db9383acea69d0c355ce5d2cb339a9f6ad1d2bb on an AMD Radeon RX 6600 (8 GB VRAM, RDNA2, native wave64).

Tested

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

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

main (06c9f55):

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

PR #2320 (4db9383):

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

Not tested: full workspace test suite on this head, NVIDIA/Intel GPUs, Linux/Wine, or world load past the 60 s smoke window.

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

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants