D3D12.X: clear rebind state, raise scratch pool cap, name UAV scratch for DRED, and bind active backing on CreateCommandList #2738

Open
github-bot wants to merge 3 commits from github-bot/gh-2738 into amd-dev AGit
Owner

@⁠Saksukella on GitHub · 2026-11-26 09:22 UTC · original
Saksukella:fix/bind-rebind-scratch-pool-and-create-list → amd-dev · +194 −17 · 4 files · 3 commits · open

What is in it

  • crates/xcl/src/hle/d3d12x/bind.rs:
    • rebind_allocator: unconditionally clear per-recording state reset by native Reset() (heaps_ensured, pc_abi_gfx, pc_abi_cs, arg_order_clean, inline_guard, prelude_built, prelude scratch/job queues, and scratch slot states back to COMMON) and retire prelude_owned onto backing even when s.allocator == backing, preventing stale descriptor-heap/ABI caches, replayed prelude jobs, and premature prelude teardown after KickoffX or deferred-segment resets.
    • inherit_for_split: retire s.res_buf alongside s.res_retired (matching bind::reset).
    • pool_keeps: raise FREE_RES entry count cap from 16 to 256 (still bounded by FREE_RES_CAP = 256 MiB) to avoid heavy 1 MiB scratch buffer create/drop churn under multi-allocator frames.
    • default_uav_buffer: attach debug names via real::name_resource(res.as_raw(), what) when XCL_DRED=1 (real::dred_on()).
    • Update freed_two_pass_buffers_kept_for_reuse_are_capped and add rebind_allocator_clears_per_recording_state_even_on_same_backing.
  • crates/xcl/src/hle/d3d12x/device_x.rs & crates/xcl/src/hle/d3d12x/list_x.rs:
    • create_list: resolve let pc_alloc = super::alloc_pool::current(alloc); for real::dev_create_command_list and pass both (alloc, pc_alloc) via list_x::on_create_with_backing so alloc_pool::created_on tracks the active PC backing while ListState.allocator keeps the logical title allocator for future splits/KickoffX resets.
  • Target branch: amd-dev (where rebind_allocator, default_uav_buffer, and FREE_RES live).

Tested

  • Hardware: AMD Radeon RX 9070 XT (driver 32.0.32029.2010), 24-thread x86_64 CPU, 32 GB RAM, Windows; rustc 1.100.0 (0ef1bc386 2026-11-09); debug (tests) and release (xcl.exe).
  • cargo test -p xcl --lib hle::d3d12x::bind::tests::freed_two_pass_buffers_kept_for_reuse_are_capped: 1 passed, 0 failed (0.00s).
  • cargo test -p xcl --lib hle::d3d12x::bind::tests::rebind_allocator_clears_per_recording_state_even_on_same_backing: 1 passed, 0 failed (0.00s).

Regression run

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1624 (PresentX 1624)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19700 MB
xcl-smoke v1
commit: 20b0ad316b795e5490ad5a0e1457b660e0e3407d
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1662 (PresentX 1662)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15117 MB

Not tested

  • NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only).

AI use

  • Antigravity (Google Gemini): assisted with DRED page-fault analysis of prelude_guard_dispatch_args scratch buffers, authoring the bind.rs and device_x.rs fixes and unit tests, and running local tests and smoke verification. All diffs and measurements were verified locally on hardware.
**@⁠Saksukella** on GitHub · 2026-11-26 09:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/2738) `Saksukella:fix/bind-rebind-scratch-pool-and-create-list` → `amd-dev` · +194 −17 · 4 files · 3 commits · open **What is in it** - `crates/xcl/src/hle/d3d12x/bind.rs`: - `rebind_allocator`: unconditionally clear per-recording state reset by native `Reset()` (`heaps_ensured`, `pc_abi_gfx`, `pc_abi_cs`, `arg_order_clean`, `inline_guard`, `prelude_built`, prelude scratch/job queues, and scratch slot states back to `COMMON`) and retire `prelude_owned` onto `backing` even when `s.allocator == backing`, preventing stale descriptor-heap/ABI caches, replayed prelude jobs, and premature prelude teardown after `KickoffX` or deferred-segment resets. - `inherit_for_split`: retire `s.res_buf` alongside `s.res_retired` (matching `bind::reset`). - `pool_keeps`: raise `FREE_RES` entry count cap from `16` to `256` (still bounded by `FREE_RES_CAP = 256 MiB`) to avoid heavy 1 MiB scratch buffer create/drop churn under multi-allocator frames. - `default_uav_buffer`: attach debug names via `real::name_resource(res.as_raw(), what)` when `XCL_DRED=1` (`real::dred_on()`). - Update `freed_two_pass_buffers_kept_for_reuse_are_capped` and add `rebind_allocator_clears_per_recording_state_even_on_same_backing`. - `crates/xcl/src/hle/d3d12x/device_x.rs` & `crates/xcl/src/hle/d3d12x/list_x.rs`: - `create_list`: resolve `let pc_alloc = super::alloc_pool::current(alloc);` for `real::dev_create_command_list` and pass both `(alloc, pc_alloc)` via `list_x::on_create_with_backing` so `alloc_pool::created_on` tracks the active PC backing while `ListState.allocator` keeps the logical title allocator for future splits/`KickoffX` resets. - Target branch: `amd-dev` (where `rebind_allocator`, `default_uav_buffer`, and `FREE_RES` live). **Tested** - Hardware: AMD Radeon RX 9070 XT (driver `32.0.32029.2010`), 24-thread x86_64 CPU, 32 GB RAM, Windows; `rustc 1.100.0 (0ef1bc386 2026-11-09)`; debug (tests) and release (`xcl.exe`). - `cargo test -p xcl --lib hle::d3d12x::bind::tests::freed_two_pass_buffers_kept_for_reuse_are_capped`: 1 passed, 0 failed (`0.00s`). - `cargo test -p xcl --lib hle::d3d12x::bind::tests::rebind_allocator_clears_per_recording_state_even_on_same_backing`: 1 passed, 0 failed (`0.00s`). **Regression run** ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: AMD Radeon RX 9070 XT title: b8db18c2 seconds: 60 exit: 0x0 frames shown: 1624 (PresentX 1624) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19700 MB ``` ``` xcl-smoke v1 commit: 20b0ad316b795e5490ad5a0e1457b660e0e3407d gpu: AMD Radeon RX 9070 XT title: b8db18c2 seconds: 60 exit: 0x0 frames shown: 1662 (PresentX 1662) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15117 MB ``` **Not tested** - NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only). **AI use** - Antigravity (Google Gemini): assisted with DRED page-fault analysis of `prelude_guard_dispatch_args` scratch buffers, authoring the `bind.rs` and `device_x.rs` fixes and unit tests, and running local tests and smoke verification. All diffs and measurements were verified locally on hardware.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:14:30 +00:00
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 09:38 UTC · original · reviewed

On 223ed4d, create_list correctly resolves title allocator A to native backing B for CreateCommandList, but then passes B as the alloc argument to list_x::on_create. That stores B as ListState.allocator, which later continuation/Kickoff paths use as the logical allocator for alloc_pool::reset_list/current. If A rotates again to C while the initial recording still holds B, those paths look up B rather than A and can continue on the stale backing instead of C.

Could the list retain A as its title allocator while separately registering B as its native recording backing? Open PR #1071 already introduces on_create_with_backing(list, title_alloc, pc_alloc, ...) and created_on_backing, so this change may be easiest to coordinate with that branch. A two-rotation test (A→B at create, A→C before continuation) should verify the continuation selects C while the first recording remains pinned to B. This is exact-head source review; I did not run a title or GPU fixture.

**@⁠luckyteagirl** on GitHub · 2026-11-26 09:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/2738#pullrequestreview-6071686897) · **reviewed** On `223ed4d`, `create_list` correctly resolves title allocator A to native backing B for `CreateCommandList`, but then passes B as the `alloc` argument to `list_x::on_create`. That stores B as `ListState.allocator`, which later continuation/Kickoff paths use as the logical allocator for `alloc_pool::reset_list`/`current`. If A rotates again to C while the initial recording still holds B, those paths look up B rather than A and can continue on the stale backing instead of C. Could the list retain A as its title allocator while separately registering B as its native recording backing? Open PR #1071 already introduces `on_create_with_backing(list, title_alloc, pc_alloc, ...)` and `created_on_backing`, so this change may be easiest to coordinate with that branch. A two-rotation test (A→B at create, A→C before continuation) should verify the continuation selects C while the first recording remains pinned to B. This is exact-head source review; I did not run a title or GPU fixture.
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-26 09:47 UTC · original

Independent AMD RDNA4 (native wave64) verification of commit 223ed4dc80a067de057e3914e6d0704607ee46d8 (tested just before the push of ed6c6825) on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver 32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC 1.9.2602.17).

Tested

  • cargo build --workspace (debug): passed (0 errors).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1657 passed, 14 failed, 47 ignored (5 SKIPPED: 4 f16_programs_on_the_gpu per-lane forms refused by host adapter/driver, 1 pso_measurement_compiles_an_exact_synthetic_record Windows Developer Mode off).
    • The new test hle::d3d12x::bind::tests::rebind_allocator_clears_per_recording_state_even_on_same_backing passed.
    • The 14 failures are identical to the amd-dev base (#2726 on the same base reproduces the exact same 14 failures on this machine).
  • cargo build --release -p xcl + 60 s retail-title smoke test (scripts/smoke.ps1, offline):
xcl-smoke v1
commit: 223ed4dc80a067de057e3914e6d0704607ee46d8
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1534 (PresentX 1534)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14959 MB

Not tested

  • Latest pushed commit ed6c6825, NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.
**@⁠emirduran707** on GitHub · 2026-11-26 09:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/2738#issuecomment-7188467223) Independent AMD RDNA4 (native wave64) verification of commit `223ed4dc80a067de057e3914e6d0704607ee46d8` (tested just before the push of `ed6c6825`) on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver `32.0.31044.16`, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC `1.9.2602.17`). **Tested** - `cargo build --workspace` (debug): passed (`0` errors). - `cargo test --workspace --no-fail-fast -- --test-threads=4`: `1657 passed, 14 failed, 47 ignored` (`5 SKIPPED`: 4 `f16_programs_on_the_gpu` per-lane forms refused by host adapter/driver, 1 `pso_measurement_compiles_an_exact_synthetic_record` Windows Developer Mode off). - The new test `hle::d3d12x::bind::tests::rebind_allocator_clears_per_recording_state_even_on_same_backing` passed. - The 14 failures are identical to the `amd-dev` base (`#2726` on the same base reproduces the exact same 14 failures on this machine). - `cargo build --release -p xcl` + 60 s retail-title smoke test (`scripts/smoke.ps1`, offline): ``` xcl-smoke v1 commit: 223ed4dc80a067de057e3914e6d0704607ee46d8 gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1534 (PresentX 1534) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14959 MB ``` **Not tested** - Latest pushed commit `ed6c6825`, NVIDIA / Intel GPUs, Linux / Wine. **AI use** - Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.
Author
Owner

@⁠Saksukella on GitHub · 2026-11-26 10:14 UTC · original

Thanks @⁠luckyteagirl — ed6c6825 already introduced list_x::on_create_with_backing(list, title_alloc, pc_alloc, pso, ty) so ListState.allocator keeps the logical title allocator A while lloc_pool::created_on and ind::reset pin the first recording to B. Added the requested two-rotation unit test (created_on_rotated_backing_keeps_title_allocator_across_second_rotation, covering A -> B at create, A -> C before continuation, and verifying ListState.allocator == A, initial recording + ind pinned to B, and continuation selecting C) in 20b0ad31 (passes cleanly).

**@⁠Saksukella** on GitHub · 2026-11-26 10:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/2738#issuecomment-7189092136) Thanks @⁠luckyteagirl — ed6c6825 already introduced list_x::on_create_with_backing(list, title_alloc, pc_alloc, pso, ty) so ListState.allocator keeps the logical title allocator A while lloc_pool::created_on and ind::reset pin the first recording to B. Added the requested two-rotation unit test (created_on_rotated_backing_keeps_title_allocator_across_second_rotation, covering A -> B at create, A -> C before continuation, and verifying ListState.allocator == A, initial recording + ind pinned to B, and continuation selecting C) in 20b0ad31 (passes cleanly).
This pull request can be merged automatically.
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/2738/head:github-bot/gh-2738'
git switch 'github-bot/gh-2738'

Merge

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