Skip to content

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

Open
Saksukella wants to merge 3 commits into
xcl-dev:amd-devfrom
Saksukella:fix/bind-rebind-scratch-pool-and-create-list
Open

Saksukella wants to merge 3 commits into
xcl-dev:amd-devfrom
Saksukella:fix/bind-rebind-scratch-pool-and-create-list

Conversation

@Saksukella

@Saksukella Saksukella commented Nov 26, 2026 •

Copy link
Copy Markdown

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.

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

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.

@emirduran707

Copy link
Copy Markdown
Contributor

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.

@Saksukella

Copy link
Copy Markdown
Author

Thanks @luckyteagirl — ed6c682 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 20b0ad3 (passes cleanly).

@relativespace2K

Copy link
Copy Markdown

Tested - retail title on native Windows AMD RDNA2, PR head 20b0ad31 on amd-dev b5c0275f

Tool: OpenCode with DeepSeek V4.1 Flash 1017

  • AMD Radeon RX 6800 XT (16338 MiB), driver 32.0.21045.29003; Ryzen 5 5600, 31.9 GB;
    Windows 11 IoT Enterprise LTSC 26100; release build; DXC 1.9.2602.17.
  • cargo test --release -p xcl --lib -- freed_two_pass_buffers_kept_for_reuse_are_capped:
    1 passed, 0 failed, 0 ignored, 0 skipped.
  • cargo test --release -p xcl --lib -- rebind_allocator_clears_per_recording_state_even_on_same_backing:
    1 passed, 0 failed, 0 ignored, 0 skipped.
  • Game: retail title 1.0.2.1, 180 s runs, XCL_INLINE_GUARD_BATCH=0 on both sides,
    one A press at 20 s, XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_FRAME_DUMP=1 XCL_RUN_SECONDS=180.
run draws last present peak commit local VRAM result
b5c0275f 25.2k 121.5 s 27,112 MB 12,445 MB device removed
PR run 1 17.2k 124.2 s 28,601 MB 11,096 MB no crash
PR run 2 8.7k 82.2 s 18,313 MB 7,487 MB no crash

The baseline lost the device at 122.1 s with 0x887a0006, right after a two-pass DispatchMesh /
ExecuteIndirect(DispatchMesh) burst (442 MB committed in 138 resources at 119.5 s), a +3.2 GB
local-VRAM jump in the last 2 s, and then an unhandled 0x80000003 in the title with
0x887a0005 in the registers. The PR ran 2/2 without a device removal, but neither run reached
that content: 17.2k and 8.7k draws against 25.2k, and the second run stalled on the loading screen
with no MS compiles, so I do not claim this PR fixes the device removal.

The PR is also DIRTY against the current amd-dev c32c91a3: git merge-tree reports one
conflict in crates/xcl/src/hle/d3d12x/bind.rs, so it needs a rebase.

Not tested: world/FPS (not reached), NVIDIA/Intel GPUs, full workspace, debug build.

AI use: OpenCode with DeepSeek V4.1 Flash 1017 ran the tests and the game runs, read the logs and wrote this comment; the counts and crash lines were checked against the logs.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants