D3D12.X Memory, Sync & GDK Drift: overlapping VRAM arenas, cross-queue texture upload state mismatch, SetPredicationBufferX state, and pre-Signal QUEUE_SHIFTED slot #18 overflow #104
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#104
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?
@raylitebull on GitHub · 2026-11-23 11:15 UTC · original
Summary
Verified 4 structural D3D12.X memory, synchronization, and GDK-version-drift bugs during an audit of
crates/xcl/src/hle/d3d12x/(onmain60599a9):1.
vram::arena_forcreates overlappingID3D12Heaparenas — breaks texture aliasing & leaks 128 MiB+ VRAM (crates/xcl/src/hle/d3d12x/vram.rs)arena_foronly checks whether an existing arena fully contains[va, va + bytes).baseor straddles itsbase + sizeboundary (e.g.,[0x1_0400_0000, +16 MiB)then[0x1_0200_0000, +48 MiB)),arena_forallocates a new, separateID3D12Heapoverlapping the existing arena in title VA space.ARENAShas no eviction/budget cap so each miss leaks >= 128 MiB ofDEFAULTVRAM.2.
title_textures::refreshre-uploads on a separate queue without GPU sync and uses stale creation state (crates/xcl/src/hle/d3d12x/title_textures.rs,crates/xcl/src/gpu/texture.rs)upload_allexecutes on XCL's ownupload_queuewithout GPU-waiting for in-flight work on the title's queue that may still be sampling the texture.upload_batchtransitions each texturee.state -> COPY_DEST -> e.stateusing its initial creation state recorded atCreatePlacedResourceX. Once the title transitions a texture (e.g.,COMMON -> PIXEL_SHADER_RESOURCE, orCOPY_DEST -> ALL_SHADER_RESOURCE) and CPU-writes to it (or a neighbor sharing the same 4 KiB write-watched page),record_uploademits an invalidBEFORE_AFTERtransition (or zero barriers ife.state == COPY_DEST).3.
SetPredicationBufferXimmediately transitions predication buffer back toCOMMON(crates/xcl/src/hle/d3d12x/list_x.rs)set_predication_buffer_xemits:COMMON -> PREDICATIONSetPredication(b, off, op)PREDICATION -> COMMONSetPredication(NULL, ...); transitioningbback toCOMMONimmediately invalidates its state before any predicated command executes, and conflicts if a subsequent UMA shader/copy uses the same window buffer asUNORDERED_ACCESS/COPY_DEST.4. Lazy
QUEUE_SHIFTEDdetection on newer GDK layouts overflows 8-byte out-param on slot#18and collides on list slots#83/#84(crates/xcl/src/hle/d3d12x/real.rs)QUEUE_SHIFTEDstartsfalseand only flips on the first call to queue slot#16or#17with a fence.GetTimestampFrequency(UINT64 *pFreq)(newer slot#18) before its firstSignal/Wait,queue_dispatchroutes it to older slot#18(GetDesc), writing a 16-byteD3D12_COMMAND_QUEUE_DESCinto an 8-byteUINT64out-parameter (8-byte stack/heap buffer overflow).QUEUE_SHIFTEDflipstrue,NEWER_LIST_SLOTSleaves list slots#83and#84bound to older#83(copy_texture_region_flags_x) /#84(copy_resource_flags_x), colliding with shiftedDrawIndexedX(81 + 2 = 83) on newer layouts.#18pre-Signaloverflow and#83/#84collision are directly visible inreal.rs.)github-bot referenced this issue2026-11-26 04:52:28 +00:00
@ivall on GitHub · 2026-11-23 11:42 UTC · original
Thanks. Triage against current
main:vramarenas – confirmed (arena_foronly reuses an arena that fully contains the range; a straddling placement gets a new heap over the same title addresses). A fix needs a non-overlapping arena layout (e.g. extend by allocating the remainder, or reserve larger aligned ranges) – PR welcome, with a test that places the straddling sequence you describe.SetPredicationBufferXback to COMMON – the window buffers are buffers in COMMON, which D3D12 promotes implicitly to read states; we have not seen a debug-layer complaint or a wrong result from it. Happy to take a change if you have one that shows a problem.QUEUE_SHIFTEDbefore the first Signal – the#18ambiguity is real on the newer layout; the only title we run on it (Unicorn Overlord) signals first. A safer route for#18until the layout is known (e.g. treating the out-param as 8 bytes) would be a good small PR.@ivall on GitHub · 2026-11-23 21:14 UTC · original
Progress: the overlapping VRAM arenas are gone for GPU-owned textures - they are tiled resources on 64 KiB pages of video memory now, one per page of the title's address (
38b05b7); arenas remain only for what the driver will not tile (D32S8, MSAA). The cross-queue texture upload state is #135 (merged).