Repository navigation
Route D3D12 buffer heaps, XMem graphics memory, and descriptor heaps to sparse VRAM - #40
Conversation
|
Thanks, merged! I tested it on retail titles before merging (RX 9070): Minecraft, Unicorn Overlord and Fortnite were fine straight away, but XDefiant rendered nothing but black frames, while Cause: XDefiant's very first allocation is a graphics reservation of The game kept drawing (no skipped draws, nothing else in the log), just without descriptors. Fix on top of the merge in acbbc55:
After the fix all four titles work. Two things I noticed that may be worth a look:
|
… in system memory The texture archive viewer is gone (the workspace exclude, the README tools row and two code comments pointed at it). The README's "performance work (GPU buffers live in system memory)" item is out of date since the title's graphics memory lives in video memory (PR #40).
|
Follow-up on the two notes above, in bb9f0b5:
|
…and coherent headroom Follow-up to PR #40 addressing the two remaining issues noted after merge: 1. Sparse window upload & write-watch overhead (XDefiant ~10 GB in 55 s): - Replace per-submit synchronous staging + wait_idle() in d3d12x::sparse with an asynchronous 64 MiB ring staging buffer, 16 upload command allocators/lists, a reusable Win32 fence event, and a dedicated 1 MiB pre-zeroed tile-clear buffer (zero CPU stall on uploads; title queues GPU-wait on the upload fence as before). - Unify mapped tile tracking into per-tile TileEntry (pool tile + u16 hole bitmask + lazy per-page sent hashes) backed by FxHashMap, replace the serial chunk hash with a 4-way parallel hash + compile-time ZERO_HASHES, and scan directly into a reusable dirty-run scratch buffer without per-page Vec/Box allocations on zero pages. - Batch UpdateTileMappings by pool heap with contiguous run merging in map_tiles/unmap_tiles, and eliminate per-run COM AddRef/Release clones in upload loops. - Cache watch_ranges in title_textures keyed by atomic generation counters (sparse mapped tiles, textures, graphics reservations), reuse thread-local GetWriteWatch/dirty buffers, merge contiguous sparse windows in Uma::watch_regions(), and skip refresh on empty ExecuteCommandLists(0, null). 2. Coherent Window 3 headroom (complementing bb9f0b5's COHERENT_KEPT for textures): - Stop blanket-routing D3D12_HEAP_TYPE_CUSTOM + D3D12_CPU_PAGE_PROPERTY_WRITE_BACK heaps and non-COPY_DEST buffers to coherent Window 3 (on Xbox UMA, CUSTOM+WRITE_BACK is general CPU-cached graphics memory); route them to sparse VRAM and spill oversized/excess readback allocations to sparse VRAM once coherent headroom reaches COHERENT_KEPT, while tracking SPARSE_READBACK so Map(0, NULL, ...) still syncs GPU writes back automatically. - Pack small AllocateUploadMemory (#148) calls into the command list Arena and route large ones to sparse VRAM instead of burning 64 KiB coherent grains per call.
Summary
Extends the sparse-window VRAM path (d3d12x::sparse + gpu::uma) to the three remaining system-RAM pools — D3D12 buffer heaps/buffers, XMem graphics memory, and console descriptor heaps — while preserving CPU Map() pointer coherence, 32-bit descriptor table addressing, GPU→CPU readback, and Arena pool headroom.
Runtime UMA Layout (crates/xcl/src/gpu/uma.rs)
eserve_pool) for per-draw io/
es/64-bit s[0:1] argument tables as well as READBACK / CUSTOM(WRITE_BACK) heaps and buffers.
Sparse VRAM Pool & Readback (crates/xcl/src/hle/d3d12x/sparse.rs, itle_textures.rs)
eadback_after_execute,
eadback_now) backed by a lazy D3D12_HEAP_TYPE_READBACK staging buffer +
b_fence, refreshing 64-byte sent hashes so readback copies do not trigger redundant re-uploads.
eadback_ranges at window boundaries, sanitizes reserved buffer flags in place_buffer, and wraps internal sparse CreateHeap/ExecuteCommandLists calls in itle_textures::own_work.
Phase 1 — D3D12 Buffer Heaps (crates/xcl/src/hle/d3d12x/real.rs)
es_map returns the write-watched console address and calls sparse::readback_now for non-empty read ranges) and releases sparse-owned resources via sparse::free.
Phase 2 — XMem Graphics Memory (crates/xcl/src/hle/kernelx.rs, list_x.rs,
eal.rs)
Phase 3 — Descriptor Heaps (crates/xcl/src/hle/d3d12x/console_heap.rs)
Testing
Verified on Windows 11 with an AMD Radeon RX 9070 XT (D3D12 SM 6.6 + DXC):
untime_layout_places_sparse_in_0_to_2_and_committed_in_3 (crates/xcl/src/gpu/uma.rs).
pf_e2e).