D3D12.X: vram::unmap_superseded unmaps tiles synchronously on pages.queue without waiting on title GPU queues and races with remap_if_unmapped #1897
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#1897
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@microwave805 on GitHub · 2026-11-24 22:37 UTC · original
Static audit on
main @ 689f2dbfound two synchronization / lifetime bugs in sparse tile unmapping for superseded placed textures (vram::unmap_supersededandtitle_textures.rs):Where
crates/xcl/src/hle/d3d12x/vram.rs:499-520(Pages::unmap)crates/xcl/src/hle/d3d12x/vram.rs:772-816(unmap_superseded,remap_if_unmapped)crates/xcl/src/hle/d3d12x/title_textures.rs:385-394, 479-515(track,retire_overlapping,forget)Root causes
Cross-queue synchronous
UpdateTileMappings(NULL)without waiting on title GPU queues (vram.rs:499-520, 772-789)When a title creates a new placed texture
Boverlapping an existing placed textureA(standard transient/aliased render-target or texture-pool reuse on console),title_textures::track()/retire_overlapping()immediately callsvram::unmap_superseded(A).Pages::unmap()callsself.queue.UpdateTileMappings(A, ..., D3D12_TILE_RANGE_FLAG_NULL, ...)onpages.queue— an independent internalID3D12CommandQueuethat never waits on the title's graphics, compute, or copy queues:A(which are still in-flight or queued behind a fence on the title's queue),pages.queueimmediately null-mapsA's tiles out from under the executing/pending GPU work, causingAto read zeros / drop writes or corrupt rendering.release_tiles(..., immediate_cool = true)(vram.rs:527-530) immediately drops unshared tiles into the wall-clock cooling pool with no GPU fence synchronization against the title's queues.Lock-gap TOCTOU race between
unmap_supersededandremap_if_unmapped(title_textures.rs:385-394, 483-493, 501-512)Both
track()/retire_overlapping()andforget()releaseTEXTURESbefore acquiringPAGESto callunmap_superseded()/remap_if_unmapped():BsupersedingA: underTEXTURES, movesAtoshadowed, returnsto_unmap = [A], and dropsTEXTURES.unmap_superseded(A), Thread 2 releasesB(forget(B)): underTEXTURES, restoresAback into activeby_res, returnsto_remap = [A], dropsTEXTURES, and callsremap_if_unmapped(A).remap_if_unmapped(A)(vram.rs:804-806) seest.mapped == trueand returns early as a no-op.unmap_superseded(A)(vram.rs:777-786), seest.mapped == true, and unmaps the now-active textureAtoNULL.title_texturesconsidersAactive and mapped inby_res, while its D3D12 reserved resource is permanentlyNULL-mapped until released — silently dropping all future reads/writes toA.Fix direction
Aonpages.queue(and before returning its tiles to the pool),pages.queuemustWaiton the title queues' current fence values (or defer theUpdateTileMappings(NULL)and tile cooling until after the queues that may referenceAreach their submitted fence values, analogous to#1040).unmap_superseded/remap_if_unmappedstate transitions per resource (e.g. monotonic generation/state check underTEXTURESbefore acting underPAGES, or an explicit desired-mapped state checked inside the lock) so a staleunmap_supersededcannot unmap a resource that was already restored toby_res.AI use
main @ 689f2dband issue drafting.@Anon64 on GitHub · 2026-11-24 23:58 UTC · original
Where the two points of this issue stand in open PRs: point 1 (unmapping on
pages.queuewithout waiting for the title's queues) is #594. Point 2 (the gap betweenunmap_supersededandforget'sremap_if_unmapped) is not covered by #594 or #799. It touches #799's call sites, so I described how #799's lock could cover it there: #799. Checked by readingmainfc14fab, not reproduced.Written with Claude Code (Claude Opus 5.5).
@JJAutoCompare on GitHub · 2026-11-25 00:41 UTC · original
I compared current
main@6567c5fwith #799 (c9633c6), #1733 (44089a2), and #594 (3bb3c2f). The stale-unmap path remains open. #799 serializes against refresh uploads but takesREFRESHafter the decision to unmap. In that gapforgetcan restore the predecessor and see it is still mapped, after which the delayed unmap drops the active predecessor's tiles. #1733 handles pending upload accounting. Placement and releaseA focused follow-up to #799 can revalidate shadowed state under
TEXTURESimmediately before unmapping and keep restoration and remap serialized with that check. Avoid acquiringREFRESHinforget, since refresh can drop references that re-enter the release path. A channel-gated test can restore the predecessor after the initial decision and assert the resumed unmap leaves it active and mapped.The submitted-GPU-work lifetime is separate. #594 adds cross-queue waits, but a mapping fence can also hold up a later title submission that would release an earlier queue. A regression should show that the old resource retains its tiles while the first queue is blocked and that the other queue can still submit the signal that unblocks it. Source review only. No local GPU reproduction for this issue. Assisted by Codex (
gpt-6.2-sol).@Mustafaiq1998x on GitHub · 2026-11-25 02:16 UTC · original
I would like to take point 2 of this issue: the stale unmap race between texture retirement and restoration.
I plan to add a deterministic GPU regression test on an RX 6800 (native wave64), followed by a focused synchronization fix without duplicating #594 or #799.
Is anyone currently implementing this specific fix?
AI-assisted investigation using ChatGPT (GPT-6.2).