Route D3D12 buffer heaps, XMem graphics memory, and descriptor heaps to sparse VRAM #40
No reviewers
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!40
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/40/head"
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-22 19:32 UTC · original
raylitebull:sparse-vram-pools→main· +1204 −173 · 10 files · 1 commits · merged 2026-11-22 20:01 UTCSummary
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).
@ivall on GitHub · 2026-11-22 20:02 UTC · original
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
mainwithout the PR showed its menu.Cause: XDefiant's very first allocation is a graphics reservation of
0x200410000bytes (8 GiB + 4 MiB). That is more than windows 1..2 hold, sosparse_reservefell back to the start of window 0 and the reservation took all of it,DESC_HEADROOMincluded (the headroom only kept XCL's ownsparse_allocout, not title reservations). 0.8 s later every console descriptor heap failed:The game kept drawing (no skipped draws, nothing else in the log), just without descriptors.
Fix on top of the merge in
acbbc55:Uma::desc_range). Those first 64 KiB stay unused, so no descriptor table sits at console address 0.sparse_reserve,sparse_allocand the fallbacks never hand that range to the title. Onlysparse_alloc_in(0)uses it, falling back to the rest of window 0 if it ever fills up.a_reservation_larger_than_windows_1_and_2_leaves_window_0_room_for_descriptor_heaps. Your layout test and the test title's XMem check no longer expect the first graphics allocation at the region's start.After the fix all four titles work. Two things I noticed that may be worth a look:
@ivall on GitHub · 2026-11-22 20:22 UTC · original
Follow-up on the two notes above, in
bb9f0b5:place_console_texture). Unicorn makes about 2.2 GB of them, and 37 of them already filled the 512 MB. They now take the window only while 128 MB stay free (COHERENT_KEPT), and beyond that they are plain PC textures, as most of them already were. The window stops at 384 MB and the picture is unchanged. I also tried putting them in the sparse windows instead: Unicorn was fine, but XDefiant rendered black again (warm shader cache, nothing in the log). I don't understand that one yet; it's noted in HANDOFF in case you want to dig.XCL_TRACE_MEM=1now also logs each coherent-window allocation of 1 MB or more, and each failed one, with the XCL call site.