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

Open
github-bot wants to merge 1 commit from github-bot/gh-1071 into main AGit
Owner

@⁠ChalanaGimhanaX on GitHub · 2026-11-24 11:16 UTC · original
ChalanaGimhanaX:d3d12x/alloc-pool-split-and-create → main · +429 −21 · 4 files · 1 commits · open

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 (#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.
**@⁠ChalanaGimhanaX** on GitHub · 2026-11-24 11:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/1071) `ChalanaGimhanaX:d3d12x/alloc-pool-split-and-create` → `main` · +429 −21 · 4 files · 1 commits · open 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` (#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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:42:30 +00:00
Author
Owner

@⁠dcastell1 on GitHub · 2026-11-24 11:21 UTC · original

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.

**@⁠dcastell1** on GitHub · 2026-11-24 11:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/1071#issuecomment-7129986250) 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.
Author
Owner

@⁠Toons29 on GitHub · 2026-11-25 03:11 UTC · original

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.

**@⁠Toons29** on GitHub · 2026-11-25 03:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/1071#issuecomment-7151671864) 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 08:51 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 08:51 UTC · [original](https://github.com/xcl-dev/xcl/pull/1071#issuecomment-7157559048) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠ChalanaGimhanaX on GitHub · 2026-11-25 21:58 UTC · original

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

**@⁠ChalanaGimhanaX** on GitHub · 2026-11-25 21:58 UTC · [original](https://github.com/xcl-dev/xcl/pull/1071#issuecomment-7175775353) @⁠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).
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 03:40 UTC · original

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

**@⁠DavidM1911** on GitHub · 2026-11-26 03:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/1071#issuecomment-7181931145) 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
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1071/head:github-bot/gh-1071'
git switch 'github-bot/gh-1071'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1071'
git switch 'github-bot/gh-1071'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1071'
git switch 'github-bot/gh-1071'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1071'
git switch 'main'
git merge --squash 'github-bot/gh-1071'
git switch 'main'
git merge --ff-only 'github-bot/gh-1071'
git switch 'main'
git merge 'github-bot/gh-1071'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.