Skip to content

D3D12.X: track split and created lists on alloc_pool's active backing - #1071

Open
ChalanaGimhanaX wants to merge 1 commit into
xcl-dev:mainfrom
ChalanaGimhanaX:d3d12x/alloc-pool-split-and-create
Open

ChalanaGimhanaX wants to merge 1 commit into
xcl-dev:mainfrom
ChalanaGimhanaX:d3d12x/alloc-pool-split-and-create

Conversation

@ChalanaGimhanaX

@ChalanaGimhanaX ChalanaGimhanaX commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

When a command allocator is swapped out by alloc_pool while an earlier command list still holds an active recording (or has not finished on the GPU), follow-on list/allocator paths could still touch the stale backing or lose track of live recordings on spares:

  1. Mid-list split and deferred segments (list_x::split, list_x::deferred_segment): creating a new PC command list segment resolved alloc_pool::current(...) for the native CreateCommandList call, but never registered the newly created PC segment with alloc_pool (created_on_backing), leaving the active backing unpinned for that segment.
  2. Retiring split/stand-in segments into spares (list_x::clear_segment_state): resetting a wrapper moves extra split segments and retired stand-in lists into title_list's spare pool without dropping their backing pin in alloc_pool, holding allocator spares pinned until process shutdown. At the same time, retiring a segment into spares must preserve last_submit / recordings so alloc_pool::in_flight (Retail game (retail title, Series X build): GPU device removal after Wait64BitValueX waits with no producer; also watchdog stalls on slow compute pipeline builds #1452) still blocks pop_spare from reusing a list whose GPU work has not finished yet.
  3. Device list creation and stand-in creation on an already-swapped allocator (device_x::create_list, list_x::reset_stand_in): create_list passed the raw title alloc instead of resolving pc_alloc = alloc_pool::current(alloc), creating new lists onto a retired busy allocator; reset_stand_in passed pc_alloc as both title allocator and backing to on_create, inserting the substitute backing into s.types instead of keying s.types on alloc.
  4. Adopted PC command list resets (real::cl_reset): ID3D12GraphicsCommandList::Reset bypassed alloc_pool::reset_list, both failing to redirect the title allocator to current(allocator) and failing to move this onto the resolved PC backing in alloc_pool.

What is in it

  • crates/xcl/src/hle/d3d12x/alloc_pool.rs: add created_on_backing(list, title_alloc, pc_alloc, ty) (keeping the recordings increment and gating created_on under #[cfg(test)]); add release_recording(list) to unpin of_list/users on retired spare segments while preserving last_submit and recordings for in_flight; add tests cl_reset_and_new_list_after_swap_use_active_backing, created_list_after_swap_tracks_active_backing, release_recording_unpins_backing_while_preserving_in_flight, and concurrent_allocator_reset_and_list_reset_keep_backing_invariants (deterministic barrier-synchronized interleaving + 4-thread concurrent stress test).
  • crates/xcl/src/hle/d3d12x/list_x.rs: add on_create_with_backing(list, alloc, pc_alloc, pso, ty) delegating from on_create; use on_create_with_backing in reset_stand_in; call alloc_pool::release_recording(list) in clear_segment_state; register newly created split and deferred PC segments in split and deferred_segment via alloc_pool::created_on_backing(...); add test mid_list_split_tracks_new_segment_in_alloc_pool_and_releases_spare_on_reset.
  • crates/xcl/src/hle/d3d12x/device_x.rs: resolve pc_alloc = alloc_pool::current(alloc) in create_list and pass both alloc and pc_alloc to list_x::on_create_with_backing.
  • crates/xcl/src/hle/d3d12x/real.rs: wrap ID3D12GraphicsCommandList::Reset in cl_reset with alloc_pool::reset_list(this as usize, allocator as usize, -1, ...).

Tested

  • Rebased head ffc3f6c on origin/main e1d84b7:
    • Hardware / toolchain: NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.1714), Intel Core i5-10400F (12 threads), 16 GB RAM, Windows 11 Pro Build 26200, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.8.2502.11 (Windows SDK 10.0.26100.0), release profile.
    • Focused tests (cargo test --release -p xcl --lib -- alloc_pool::tests mid_list_split_tracks_new_segment_in_alloc_pool_and_releases_spare_on_reset title_list::tests --test-threads=1): 12 passed, 0 failed, 0 ignored.
    • Full workspace suite (cargo build --release --workspace + cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture): 1,428 passed, 0 failed, 46 ignored across 37 test binaries (26 SKIPPED lines: 21 no wave64 on 32-lane RTX 3060, 3 per-lane refused f16/f32 forms #1426, 1 no heap windows, 1 pso_measurement_compiles_an_exact_synthetic_record requiring Windows Developer Mode).
    • cargo test --release -p xcl --test e2e -- --test-threads=1: 4 passed, 0 failed.

Regression run
Paired 60 s retail smoke runs (.\scripts\smoke.ps1 -Game <retail> -Seconds 60, release build, same title):

main (6d051da):

xcl-smoke v1
commit: 6d051da51ba3fe7ba7d4ef542da71f544646e3ba
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 1473 (PresentX 1473)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14348 MB

PR head (ffc3f6c):

xcl-smoke v1
commit: ffc3f6c3d6a4a9ce8ed876e81b01494d4e2ba4b9
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 1514 (PresentX 1514)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 10036 MB

Not tested

  • The 60 s retail smoke runs above stay in menus and act as a regression check only (they do not prove how often the title triggers mid-list splits or allocator swaps during those 60 s; the fixed paths are exercised by the five unit/concurrency tests above).
  • AMD / Intel GPUs and Linux/Wine on this rebased head ffc3f6c.
  • Retail sample test suites (XCL_SAMPLE_* unset).

AI use

  • Google Antigravity (Gemini 4 Neon) wrote the original fix, resolved the rebase onto origin/main e1d84b7 (including deferred_segment active-backing registration and the concurrent allocator-reset vs. command-list-reset stress test), ran the full workspace test suite, e2e suite, and 60 s retail smoke run, and updated this description under author review.

@dcastell1

Copy link
Copy Markdown

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@47efa2e (baseline 741 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
744 passed; 0 failed; 41 ignored   (exit 0)

Three more passing tests than the baseline; tracking split and created lists on the allocator pool ships its coverage and it runs green here.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of 522a3b73 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 522a3b730b6c2db566406496c0b62546fe99202f
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1633 (PresentX 1633)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14812 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

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

No concrete lifetime/synchronization defect found. Current-backing tracking, retired segment pin removal with last_submit retention, and split-created-list tracking look coherent; current CI/smoke evidence is green. GitHub merge state is dirty, so rebase before merge. Nonblocking gap: no explicit concurrent allocator-reset vs command-list-reset stress case.

@ChalanaGimhanaX
ChalanaGimhanaX force-pushed the d3d12x/alloc-pool-split-and-create branch from 6c21c1f to ffc3f6c Compare November 25, 2026 21:58
@ChalanaGimhanaX

Copy link
Copy Markdown
Contributor Author

@bmjask Thanks for the review! Rebased onto current \main\ (\e1d84b7, new head \ fc3f6c), extended \created_on_backing\ to the newly merged \deferred_segment\ path in \list_x.rs, and added \concurrent_allocator_reset_and_list_reset_keep_backing_invariants\ in \�lloc_pool.rs\ (covering both a barrier-synchronized
eset_list\ vs. \ itle_reset_in\ swap interleaving and a 4-thread concurrent stress loop). Re-verified full release workspace tests (1,428 passed, 0 failed), \e2e\ (4/4), and a 60 s retail smoke run (1,514 frames, 0 crashes/removals).

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that #1453 #2707 #2936 solves the same problem in a different way: #1607, group D147. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

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.

6 participants