Skip to content

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

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

Saksukella wants to merge 204 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
Contributor

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.

isaacwingate and others added 30 commits November 25, 2026 07:22
pso_async means a graphics pipeline still being built to go on with its
stand-in, which draws nothing, while a worker builds it; only compute
pipelines are waited for (a skipped dispatch would leave its outputs
unwritten). But graphics_bound and ExecuteIndirect called resolve_wait,
which waits for the build - and builds it on the title's thread when no
worker has started it. With lazy pipelines that is every graphics
pipeline's first draw.

On an NVIDIA GPU the retail title of xcl-dev#505 had its threads held 1 - 5 s
per draw in the driver's compiler as its world loaded: 25 graphics binds,
33.2 s in all within 25 s (counted with xcl-dev#899's log), and its hang
watchdog ended the run. A test report on xcl-dev#889 (RTX 4080) found a title
thread held in bind::execute_indirect -> resolve_wait at the abort.

Draws and ExecuteIndirect now take their pipeline with resolve_for_bind:
a graphics one still being built goes to the workers and the draw uses
its stand-in (ExecuteIndirect skips, as it already did for a pending
one); a compute one is waited for as before. With this, the same world
load logged no graphics wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…addresses

On the console a physical page mapped at several addresses is one page. XCL
keeps a page at one address at a time and copies it when the title maps it
elsewhere (`move_away`), so the other addresses go stale; a retail title maps
its streamed pages into a pool, into the CPU view of a 24 GB reservation and
into that reservation's GPU view (xcl-dev#1031).

`kernelx::sections` is the base for real aliasing: a block of physical pages
is one pagefile-backed SEC_RESERVE section, and a page is mapped as a view of
its 64 KiB slice into a placeholder (MapViewOfFile3 with
MEM_REPLACE_PLACEHOLDER). Every view of a slice is the same memory and a page
takes commit once, when it is committed through any view. Unmapping leaves a
placeholder for the next view. Ordinary reserved memory (write-watched if
asked) can replace part of a placeholder and go back to one.

Nothing calls it yet. Measured in a standalone program on Windows 11 26200
over 200 000 pages: map 2.2 us, unmap 2.75 us, commit 0.9 us a page.
GetWriteWatch refuses a range that holds a view (error 87), and one call
cannot span two neighbouring reservations either.
The upload of title memory to video memory (`d3d12x::sparse`) and the
textures kept in step with title memory learn what the CPU wrote from the
write watch, and a view of a section (`kernelx::sections`) cannot be
write-watched: GetWriteWatch refuses any range that holds one.

`kernelx::guards` keeps the views of a physical page read-only. The first
write through any of them faults; a vectored handler makes that view
writable, notes the page and lets the write go on. `take_dirty` hands over
the pages of every view of each page written – a write through one view is
a write to all of them – and guards those views again before their bytes are
read, so a later write is caught again and an earlier one is in what is read.

Kernel calls do not fault into the handler, they fail: `lazy::ensure`, which
XCL already calls before a kernel call or its own code writes title memory,
opens the guards there first and counts the write. A view committed by the
lazy handler is writable and counts as written. Both take no lock until a
view has been watched.

Nothing watches a view yet.
… fault

A guarded view of a physical page (`kernelx::guards`) is read-only until it
is written. Code of XCL's own that writes there faults into the guard and
goes on, but a kernel call does not fault: ReadFile into such a view fails.
`lazy::ensure` opened the views first, yet the submit thread's `take_dirty`
could guard them again before the write – between DirectStorage's check of
its destination and the copy, or before the kernel wrote a ReadFile buffer.

`guards::open` now returns `Opened`, which keeps its views writable until it
is dropped; `take_dirty` uploads a pinned view but does not guard it again,
and the end of the write counts as a write. `lazy::ensure` returns it and its
callers hold it across their write: the routed ReadFile for a synchronous
read, and the destination checks of DirectStorage and the CPU-side
bottom-of-pipe writes. An overlapped ReadFile writes after the call returns:
its views stay open until its OVERLAPPED is no longer STATUS_PENDING, which
`take_dirty` reads without faulting (the title may free it once done). A
retail title reads 271 MB that way into the CPU view of its 24 GB
reservation 8.5 s after start.

`guards::written` counts a page as written through all its views when XCL
writes it by page number.

Nothing watches a view yet, so nothing changes without views.
…s mapped at

Without it XCL keeps a physical page at one address at a time and copies it
when the title maps it elsewhere; the console shows the page at every
address it is mapped at. A retail title maps its streamed pages into a pool,
into the CPU view of a 24 GB reservation and into that reservation's GPU
view (xcl-dev#1031).

With `XCL_PAGE_ALIAS=1` (`kernelx::alias`):
- a block of physical pages is a section (`kernelx::sections`) with a view
  of its own, through which XCL reads and writes pages by number
  (DirectStorage); the title never maps a page there;
- the title's reservations of 64 KiB pages with no commit (its CPU view, GPU
  view and pool) are placeholders, and a page mapped there is a view of its
  slice, guarded (`kernelx::guards`) so that a write through one view is
  uploaded at all of them; `title_textures` adds those pages to what the
  write watch found;
- a page mapped anywhere else (a placeholder region the title made in a
  sparse window) is moved there and back with its bytes, as before.

Pages are committed on first use as before (`kernelx::lazy`); whether a page
is committed is a bit per page: asking Windows walked the rest of a fresh
block, and a title mapping 100 000 new pages one at a time took 20 s longer
to its first frame.

Measured in a traced run of a retail title: 3 blocks (11 360, 2 960 and
99 776 pages), 131 072 map calls in 150 s, nearly all single pages into its
plain reservations, none at a page's home, no commit inside them.
…GPU-view page shows

Queue method xcl-dev#31 (xcl-dev#29 of the older layout) maps pages of the title's
memory into GPU views; it was a stub. Its batches are now decoded and
checked against the batch count and the pool, and each 64 KiB page of
a GPU view records the pool page it was given and the physical page the
title had mapped there (kernelx::mirrors). A bad call records nothing;
releasing a view drops its pages.

XCL keeps a physical page's data where it was mapped last, and the
title maps most streamed pages into the CPU view behind the GPU view
too, so `mapped_source` answers where that page is now (`page_now`),
else the pool page itself. Each title mapping is remembered per address
(Away::title), written once the page is in place and forgotten when the
reservation goes; a page freed while its allocation lives is no longer
looked for (Away::freed).

Nothing reads the record yet: textures are unchanged; the queue logs its
counts. (xcl-dev#1031)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`mirrors::decode_batches` checks and decodes one call of the queue's
CopyPageMappingsBatchX into (GPU-view page, pool page or unmapped) pairs;
`apply_batches` records them as before. No change in behaviour: the next
commit maps the decoded pages for real when physical pages alias.
The queue's CopyPageMappingsBatchX maps pool pages into GPU views; on the
console a GPU-view page then shows the physical page mapped at its pool page
at the time of the call. xcl-dev#1055 decodes the calls and keeps a record of them;
with physical pages aliasing (`kernelx::alias`) the GPU view is a reservation
of views, so the decoded mappings are made for real: each GPU-view page
becomes a view of the physical page mapped at its pool page now, or is
unmapped (kind 2, or nothing mapped at the pool page). Textures in the GPU
view then read the page at their own address (`title_textures` prefers an
address with a physical page mapped), and a write through any view of the
page is uploaded at all of them.

Without the switch nothing changes: the call is recorded as in xcl-dev#1055.
Each chained dispatch made a scratch buffer for all its groups and kept it until the allocator's reset. A retail title's 176 split programs need 187 KB a group (median), 3 GB for 960x540 pixels in groups of 8x4. At most XCL_SPLIT_SCRATCH_MB (256) of groups now run at once, each piece adding the slab's origin to the group ids, and the chains recorded on one list share the buffer.
In a pixel shader EXEC holds helper lanes (s_wqm), and on a primitive's
edge the first lane of EXEC is often one. v_readfirstlane read that lane.
An RDNA2 driver (RX 6700 XT, 32.0.21045) gives 0 for everything a helper
lane holds once a WaveReadLaneAt ran inside a loop, quad reads included.
A loop whose state the console's compiler carries in a vector register
(v_mov v, s ... v_readfirstlane s, v) then read 0 back on each pass and
ran to the loop budget: a retail title's volumetric light pass took
seconds per draw at its world start and Windows reset the GPU (xcl-dev#675).

v_readfirstlane now reads the first lane of EXEC that is live
(ballot(true), per half in the wave32-in-64 form) when EXEC has one, and
the first lane of EXEC as before when it has none. The value is the same:
the console's compiler reads the first lane of a value equal in every
lane, or of a lane it then removes from EXEC (a waterfall loop).

The new GPU test draws that title's list-loop shape on two triangles
sharing a diagonal. Without the change, on the RX 6700 XT, 69 of 1024
pixels run the loop 65 536 times (the budget) with wrong results; with
it, none, and at most 16 passes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
raylitebull and others added 14 commits November 26, 2026 01:03
Complete Win11 scheduling hardening in kernelx/host/real:
- Export guest SetThreadPriority in kernelx.rs and floor guest priorities
  below THREAD_PRIORITY_BELOW_NORMAL (IDLE / LOWEST) to BELOW_NORMAL
  unless XCL_PRIORITY=0, preventing Windows 11 hybrid E-core starvation
  of title streaming/background threads while leaving internal XCL
  pso_async workers (calling win32 directly) untouched.
- Add winmm timeBeginPeriod(1) alongside NtSetTimerResolution(finest, 1)
  in kernelx::fine_timer(), and add idempotent restore_fine_timer() called
  on normal exit (host.rs) and forced/timed exit (real::end_title) so both
  timer-resolution requests are cleanly released on shutdown.
- Add unit tests covering priority flooring (pure + live guest hook) and
  idempotent timer-resolution restoration.

Assisted-by: Antigravity (Gemini 4 Neon High)
…ze deferred submits

Give graphics and compute pipelines independent 12 s per-frame wait windows (XCL_PSO_FRAME_BUDGET_MS, default 12000 ms; 0 = skip immediately, off = disabled). Builds run on prioritized wanted xcl-pso-* workers so title threads always wake when a frame's window expires; once spent, remaining unready draws or dispatches for that kind return the stand-in for the current frame and retry with a fresh window on the next frame instead of stalling PresentX into title render watchdogs or dropping fast cold graphics draws permanently. Also mark deferred submits wanted immediately in need_by_submit so DXC/big-compile gates and preload workers prioritize them right away.

Assisted-by: Antigravity (Gemini 4 Neon High)
…ed texture caches (xcl-dev#2578)

Adapt two cache-safe stability fixes cleanly onto origin/amd-dev (bf02341):
- xcl-dev#2577 (real.rs, shaders.rs): record the chosen adapter's PCI vendor ID
  in driver_cache::note_vendor() and disable on-disk .pso driver blobs on
  AMD (0x1002) unless XCL_PSO_DISK_CACHE=1, avoiding device removals from
  stale 954-byte driver cache stubs written before a crash/kill (xcl-dev#2512).
  Adds driver_cache::tests::blobs_are_kept_on_disk_unless_they_are_references.
- xcl-dev#2578 (title_textures.rs): return all retired resource pointers from
  Table::retire_range() so retire_overlapping() evicts LAST_CONTENT and
  STREAM_RECHECK for every retired texture (not only placed unmap targets).

Assisted-by: Antigravity (Gemini 4 Neon High)
…access (xcl-dev#2582)

Fix xcl-dev#2582 (0xc0000005 CPU write AV inside sparse UMA windows on buffers
backed by OutsideBufferTable / sparse::alloc_vram_only):
- place_at_title_address stored alloc_vram_only's uncommitted sparse VA
  (holes = 0xFFFF, MEM_RESERVE only) in UMA_BUFFERS, so GetGPUVirtualAddress
  and Map handed that uncommitted VA back to the title. When the title later
  CPU-wrote through it (e.g. clearing a 128x0x5c0 table), Windows raised
  0xc0000005.
- Mark alloc_vram_only 64 KiB pages with kernelx::lazy::mark (0 upfront CPU
  commit, GPU-only buffers keep holes = 0xFFFF and never clobber UAV writes)
  and unmark + MEM_DECOMMIT them cleanly in free_vram_only.
- When the title first CPU-touches a page, kernelx::lazy::commit commits it
  and queues it via sparse::note_lazy_commit (without locking sparse::STATE
  inside the VEH); before_execute, readback_now, readback_after_execute, and
  decommit_range drain LAZY_COMMITS to clear entry.holes without touching
  to_zero so only CPU-written 4 KiB pages upload to VRAM.
- In real::res_map, call kernelx::lazy::ensure(p, bytes) before readback_now
  so Map() on a lazy sparse buffer commits pages before VRAM->CPU copy.
- Add regression test lazy_commit_clears_vram_only_holes_without_clobbering_to_zero.

Assisted-by: Antigravity (Gemini 4 Neon High)
…ts, and keep split whole builds async

Eliminate the remaining multi-second stalls observed past the 12 s per-frame pipeline wait window on cold/warm world frames:
- Track in-flight wall-clock waits (`active_waiters` / `active_since`) in `pso_async::FrameWaitBudget` so staggered concurrent title threads share one hard wall-clock ceiling per kind per frame instead of each getting a fresh 12 s window (applied to both `FRAME_BUDGET_GFX`/`FRAME_BUDGET_CS` and `FRAME_WAIT`).
- Skip deferring pending compute dispatches to submit in `list_x::defer` when `XCL_PSO_WAIT_MS` is set (xcl-dev#2581), when the current frame's compute wait window is already spent, or once 16 deferred segments have already been allocated on the current frame (prevents 512+ deferred segments and command-allocator/RAM churn).
- Never compile `Chain::whole()` synchronously on a title/submit thread inside `dispatch_chain::dispatch` when scratch allocation fails under memory pressure or missing backing allocator: kick off `start_whole_async()` and return an error so the dispatch is skipped cleanly until the background whole build finishes, matching `whole_nonblocking`.

Assisted-by: Antigravity (Gemini 4 Neon High)
…#505/xcl-dev#1833)

Track recycled (previously returned/cooled) 64 KiB tiles in vram::TilePool
via a per-heap bitmap (freshly allocated D3D12 heaps remain clean with zero
extra GPU work) and asynchronously zero recycled tiles in one coalesced
CopyBufferRegion batch on Pages::queue before flushing Pages::fence in
before_execute (default ON, XCL_ZERO_TARGET_PAGES=0 disables):
- PoolHeaps caches a 0-extra-VRAM aliased 64 MiB placed BUFFER per pool heap
  (D3D12_HEAP_FLAG_NONE Tier 2) and ZeroRing reuses a 4-slot DIRECT command
  ring + 1 MiB pre-zeroed UPLOAD source with D3D12_RESOURCE_BARRIER_TYPE_ALIASING
  so stale render-target/depth/UAV bytes never bleed into newly mapped targets
  (e.g., 2560x1440 R9G9B9E5 lighting blocks/white-outs).
- Add unit tests tile_pool_tracks_dirty_bits_only_for_recycled_tiles and
  coalesce_tile_runs_merges_adjacent_tiles_per_heap.

Assisted-by: Antigravity (Gemini 4 Neon High)
Agility SDK 1.620+ allocates some D3D12 COM vtables on the heap rather than inside a loaded module. If a COM object is freed and a different object reuses the same heap address for its vtable, caching Class solely by (orig, kind) can dispatch through stale methods from the previous object.

Snapshot the copied runtime method pointers on Class when module_of(orig) == 0, compare them against the live vtable before reusing a cached Class, and double-check under CLASSES.write() before leaking a new extended vtable. DLL-resident vtables keep copied = None with zero extra overhead.

Verified with cargo check -p xcl --lib and class_for_rebuilds_when_heap_vtable_reused_with_different_methods (1 passed, 0 failed).

Assisted-by: Antigravity (Gemini 4 Neon High)
placed_srv_resource and placed_uav_resource returned uncounted raw ID3D12Resource pointers after dropping TABLE.lock(), and on a concurrent cache-miss race entry(key).or_insert(res) dropped the losing resource inside TABLE.lock() (risking res_release -> format_alias::forget deadlock) while still returning the dropped loser pointer. Furthermore, concurrent eviction via evict_stale_internal_at -> defer_drop_resources -> late_release::hold could synchronously run drain_known(true) and release the PC COM object while dev_create_srv_x was mid-call before r.GetDesc() (crashing inside amdxc64.dll).

Fix all three lifetime bugs:

- Return owned Option<ID3D12Resource> cloned inside TABLE.lock() from placed_srv_resource and placed_uav_resource (via cache_insert_or_clone), dropping any race loser outside TABLE.lock(), and hold the owned reference across dev_create_srv_x / dev_create_uav_x.

- Pin internal PlacedUav/PlacedSrv resources across sync_pair in on_uav_barrier and sync_title_writers.

- Drop adopted evicted resources normally in defer_drop_resources (outside TABLE.lock()) so real::res_release cleans up title_textures/vram/format_alias maps on the final ref before deferring the PC Release via late_release::hold.

- Reuse a single r.GetDesc() call across dev_create_srv_x.

Verified with cargo check -p xcl --lib and cargo test -p xcl --lib -- hle::d3d12x::format_alias::tests --test-threads=1 (5 passed, 0 failed).

Assisted-by: Antigravity (Gemini 4 Neon High)
…patch

In live world runs ambient.rs tracked TemporalResolve / ReflectionHistory PSOs and captured the 128x128 sky dome, yet ambient_fill_cs and reflect_clamp_cs never dispatched because find_dispatch_views missed the output UAV:

- SM 6.6 directly-indexed bindless heaps bind the view heap via SetDescriptorHeaps (s.heaps[0]) rather than Param::Table, leaving tables empty.

- ExecuteIndirect compute dispatches (both chained split and direct) never called ambient::after_compute_dispatch, and matches_dispatch_target rejected indirect/1D dispatches.

- matches_dispatch_target checked the resource format (often R16G16B16A16_TYPELESS) instead of the concrete UAV view format (R16G16B16A16_FLOAT / R11G11B10_FLOAT / R32G32B32A32_FLOAT).

- VIEW_SLOTS was keyed only by slot.index, colliding across CPU-only view heaps before CopyDescriptors copied them to the >1.24M-slot shader-visible heap, while the 1<<20 index cap and 256-byte CBV scan truncated high slots and larger pass CBVs.

Pass s.heaps[0] into find_dispatch_views, hook ExecuteIndirect compute dispatches, index ViewSlots by both unique slot.at and hosted GLOBAL index, raise the slot cap to 2_000_000 and CBV scan to 2048 B, match by concrete UAV view format with DepthOrArraySize == 1 guard, rank candidates by dispatch grid match, and log first-4 diagnostic misses.

Verified with cargo check -p xcl --lib and hle::d3d12x::ambient::tests (5 passed, 0 failed).

Assisted-by: Antigravity (Gemini 4 Neon High)
…adbacks

Two defensive memory/resource-lifetime fixes:

- kernelx.rs / uma.rs: clean up AWAY physical-page mappings, mirrors, and
  title mapping records on coherent UMA VirtualFree (MEM_DECOMMIT and
  MEM_RELEASE), matching sparse and plain VirtualFree so freed/reused
  coherent blocks never retain dangling AWAY entries. Add Uma::allocation_at
  and extend virtual_free_unmaps_away_pages_in_plain_and_sparse_reservations
  to cover coherent UMA MEM_DECOMMIT and MEM_RELEASE.
- real.rs: call cpu_writes::unregister_water_readback in res_release so
  released or recycled placed textures never retain stale water-readback
  entries.

Assisted-by: Antigravity (Gemini 4 Neon High)
…raphics once, and guard unbuilt ExecuteIndirect

- Keep non-spared memory-writing producer compute pipelines (`!spared && !bvh_traversal`)
  exempt from the per-frame `XCL_PSO_FRAME_BUDGET_MS` skip cutoff so world-entry dispatches
  never leave title memory/tables uninitialized; prioritize wanted producer compute ahead of
  wanted graphics in `PsoQueue::pop`, and run non-deprioritized producer compute inline when
  no worker has started it yet.
- Restrict `XCL_PSO_FRAME_BUDGET_MS` skipping to graphics pipelines and stamp `waited_frame`
  on `Pending` so an unready slow graphics PSO stalls at most one frame while workers finish
  compiling it in the background.
- Skip `list_x::defer` for `spared`/`bvh_traversal` compute PSOs and make `FrameDeferCap`
  slot reservation atomic (`try_reserve`/`release`) so concurrent threads cannot overshoot
  the per-frame deferred segment cap (producer dispatches past the cap fall through to
  `resolve_wait` instead of being dropped).
- Add `pso_async::bound_unbuilt(raw_pso, pso)` for `execute_indirect` and `dispatch_mesh`
  so a pipeline that finishes building right after `resolve_for_bind` returned the stand-in
  cannot slip into the raw PC call with a mismatched root signature.

Assisted-by: Antigravity (Gemini 4 Neon High)
…8x4 grids in ambient

Wave 16e diagnostics showed both TemporalResolve ([320, 360, 1]) and ReflectionHistory ([0, 0, 0]) reached ambient::after_compute_dispatch with tables=3, view_heap=0x4c610000, indices=16 (meaning zero root constants/CBVs and all bindings inside the two Param::Table descriptor tables).

Fix all four remaining lookup gaps:

- Decode CBV V# buffer descriptors (w3 >> 28 < 8, dst_sel 0xFAC) in slots 0..32 of every bound Param::Table and scan their readable constant-buffer bytes (up to 2048 B) for bindless view-heap indices.

- Probe direct image T# descriptors across slots 0..64 of every bound Param::Table (previously capped at 0..16).

- Resolve DXGI_FORMAT_UNKNOWN (0) in dev_create_uav_x and dev_create_srv_x to rd.Format.0 before calling ambient::note_descriptor so views that inherit the resource format are never dropped.

- Score Wave32 [8, 4, 1] and [4, 2, 1] dispatch grids alongside [8, 8, 1] and lower min_w/min_h to (groups/2).max(64) so [320, 360, 1] matches 2560x1440, 1280x720, and half-res probe targets.

Verified with cargo check -p xcl --lib and hle::d3d12x::ambient::tests (5 passed, 0 failed).

Assisted-by: Antigravity (Gemini 4 Neon High)
… for DRED, and bind active backing on CreateCommandList

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

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 20b0ad3

Main and amd-dev already create lists on the active backing (680ea61). device_x::create_list passes alloc_pool::current(alloc) to on_create_with_backing and keeps the title allocator in ListState. amd-dev's default_uav_buffer already names each buffer (SetName("xcl {what}")), and the 16-entry pool_keeps cap was replaced by a byte-capped FreePool.
rebind_allocator and the inherit_for_split res_buf change touch code that exists only in this branch's base, b5c0275 (about 217 commits not in amd-dev or main), so they cannot apply to the target. That is also why the PR shows +35098 lines. If the same-backing state reset is still needed, it would have to be redone against current amd-dev.
Recommendation: close (superseded by main/amd-dev commit 680ea61).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@throny

throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Closing as superseded: this change is already on amd-dev (680ea61). From Foniass's rechecked close list on #1607, checked again by script just now. If something here is still missing, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5).

@throny throny added the duplicate This issue or pull request already exists label Dec 1, 2026
@throny throny closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.