Repository navigation
Description
Context
- On the console, CPU and GPU share one memory: the application writes GPU data and GPU addresses into its own memory and reads GPU results back from it.
- On a PC with a discrete GPU, video memory is separate, so every path either shares the application's pages with the GPU or copies them.
- design: runtime model for the console's unified CPU/GPU memory (copies vs direct use of title memory) #1914 decided a hybrid model: share when the allocation, the adapter and the synchronization contract allow it, copy only when the copy keeps the same visibility and lifetime (it captures bytes at submission), otherwise a diagnosable refusal.
This issue does not reopen that decision. It lists the paths that exist on main today, what a start-up run shows about them, and small work items that can be claimed separately.
Inventory
Read from main at d5970858. Bare :N is src/startup_stubs/d3d12_xs_device.cpp; draw is d3d12_draw.inl, cdisp is d3d12_compute_dispatch.inl, both in src/startup_stubs/. "Desktop copy" means a separate D3D12 resource.
| # | Mechanism | GPU reads | Synchronized | Where | Known limit |
|---|---|---|---|---|---|
| 1 | Slot 133 buffer on an existing heap | application memory | no copy, both directions | :6688-6720 |
private allocation, committed from its base, offset a multiple of 64 KiB; the heap wraps and pins the whole allocation (#1942); no D3D12_FEATURE_EXISTING_HEAPS query on this path |
| 2 | Slot 133 buffer, fallback | desktop copy (committed, zeros) | never | :6724-6732 |
correct only for consumers that resolve the address themselves; at least 64 KiB each, kept for the process (#3474) |
| 3 | Slot 133 texture | desktop copy | uploaded on bind, re-hashed up to 32 MiB (R8/A8 each frame, others every 15 frames) | :6564-6608, draw:2002-2005 |
never shared: console layouts need detiling |
| 4 | Per-draw copy frame_copy |
upload ring | at draw record | draw:1940, call draw:4003 |
misses later writes; cut at 16 MiB (draw:3919-3921); 256 MiB ring |
| 5 | Root SRV upload_from_title |
upload ring | at bind, 64 KiB window | :3216-3221, :5238-5239 |
same; #1942 showed bind and record copies read the old bytes |
| 6 | Translated compute input snapshot (X2W_TRANSLATED_TITLE_INPUT_SNAPSHOT) |
snapshot pool | at Dispatch record, once | draw:2890-2902, cdisp:1514-1519 |
stale if the application writes before execution; 128 MiB pool |
| 7 | Copy-source snapshot (X2W_D3D12_TITLE_COPY_SNAPSHOT) |
snapshot pool | at record, up to 64 KiB | list_copy.inl:214-226 |
GPU writes into the source are not seen |
| 8 | Linear buffers (X2W_D3D12_LINEAR_BUFFERS, #2218) |
application memory if shared, else desktop copy | at ExecuteCommandLists |
linear_buffer_backing.h:3-30, linear_buffer_backing.h:473; hooks :5462, :5553 |
COMMON state only; no copy for GPU-written buffers (linear_buffer_backing.h:106-107); a write after submission is not seen (#1914) |
| 9 | XMem section lease (X2W_MESH86_XMEM_SRV, X2W_MESH_INDIRECT_XMEM; #2280, #2303) |
XMem pages | GPU copy, ordered by fence | mesh_xmem_handoff.inl:6-12, mesh_xmem_handoff.inl:204 |
one writer, one reader, a known range |
| 10 | Memory SRV, slot 70, unplaced | application memory if private, else a committed UPLOAD buffer | at view creation, recopied on reuse | d3d12_memory_srv.inl:358-372, d3d12_memory_srv.inl:399-449, d3d12_memory_srv.inl:336-343 |
entries are erased only when the device is cleared (d3d12_memory_srv.inl:279-297) |
| 11 | List upload memory, slot 148 | D3D12 upload memory handed to the application | no copy | list_upload_pages.h:24-37 |
only for memory D3D12 allocates |
| 12 | Page alias on demand (X2W_TRANSLATED_INDIRECT_ADDRESS_ALIAS) |
application memory | no copy | :6465-6500 |
private page outside any placement, heap already open, 64 entries |
Two rules sit above the table. Map and GetGPUVirtualAddress return the application's own memory and address when the resource has them (:5710-5725, :5737-5746). The desktop objects stay alive for the process unless X2W_D3D12_RELEASE_RETIRED=1 (:1239-1241, #2379), and buffers are outside that class (:1068).
Not wired into the stand-in: src/era_gpu_alias.h (one buffer over a whole allocation), src/era_title_va.h, src/era_title_gpu.h, src/title_va_lookup.hlsli.
Observed gaps
One start-up run of 900 s on one adapter, aggregate counts only.
Measured
- Stale compute input. With row 6 on, the device was removed with
0x887A0006. The same run was stable for 900 s with that one compute program excluded. - Placements. 7,790 buffer placements, 57 shared. About 7,600 of the others sit at an offset that is not a multiple of 64 KiB, all inside two allocations, most of them 4 KiB or smaller. Their committed fallbacks add up to about 475 MiB at 64 KiB each, for about 134 MiB of requested bytes. That is a size from counts, not measured residency; startup-runtime: every non-aliased placed buffer keeps its own committed buffer for the process, and re-placing the same address adds another #3474 found that releasing such buffers did not move DXGI local usage. The remaining 135 are GPU-written buffers at offset 0, about 750 MiB in total; the 174 MiB view of supply coherent backing for large placed Mesh86 buffer SRVs #3640 is one of them.
- Video memory. Local usage was above the DXGI budget for most of the run. About 16,000 live UPLOAD-heap objects held about 1.3 GiB at the end.
Read from the code
- No path copies desktop bytes back to application memory. A GPU write reaches the CPU only through rows 1, 8 (shared), 9 and 12. A query resolve into a resource with application memory is refused (
:3937-3939). QueryVideoMemoryInfois only logged (:8371);MakeResidentandEvictare forwarded (:1576-1585). Nothing bounds video memory (startup-runtime: guest-released committed textures are never freed, so local video memory exceeds the DXGI budget until the device is removed #2379).
Inferred, not confirmed
- The removal comes from input bytes that changed between record and execution. The two byte states were not logged.
- The 7,600 unaligned buffers are in private, fully committed memory and miss sharing only because of the 64 KiB rule: the region-information proof counter (
:6618) matches their number, but the default log line prints neither the memory type nor the reason. design: runtime model for the console's unified CPU/GPU memory (copies vs direct use of title memory) #1914 says "mostly mapped sections" and its field report says "the rest fail the 64 KiB offset rule"; both classes exist, the second by count and the first by bytes. - The 135 large buffers are XMem views.
- Row 10's UPLOAD fallback is a candidate for the UPLOAD count: about 85 KiB per object on average. The budget line has one
uploadcategory (resource_budget.h:9,resource_budget.h:156), so it cannot say.
Proposed work items
Each is one small PR with a source-built test. Comment here to claim one.
Already taken, do not duplicate
- Dirty signal for the submit-time walk and the gated write-after-submit fixture: MasterDomino, on design: runtime model for the console's unified CPU/GPU memory (copies vs direct use of title memory) #1914.
- supply coherent backing for large placed Mesh86 buffer SRVs #3640 trace and backing: Not-Saii. resolve the 128-byte mesh root SRV for slot 86 #3639 root SRV: claimed.
- Retained textures: the slices on startup-runtime: guest-released committed textures are never freed, so local video memory exceeds the DXGI budget until the device is removed #2379.
a. Snapshot at submission (row 6). A PR is in preparation. Reserve at record, copy in queue_execute before ExecuteCommandLists (:5486-5493), under the draw_lock already held there.
// record (cdisp:1514): reserve only
auto* mapped = reserve_upload_ring(self, bytes, &view.offset, &view.resource, true);
pass_of(self).pending_snapshots.push_back({view.snapshot_address, mapped, bytes});
// queue_execute, each submitted list, each submission
for (const auto& s : pass_of(w).pending_snapshots)
if (!x2w_local::guarded_memcpy(s.mapped, reinterpret_cast<const void*>(s.address), s.bytes, false))
skip_list(w); // a closed list resubmitted later copies again- Test: write A, record, write B, submit; the GPU reads B. A mutant that copies at record fails.
- Success: no device removal in the run above with the program included.
b. Placement and read-path census. Add range.type and the refusal reason to the default slot 133 line (:6733-6735), as the linear line already does (:6646-6650). Add a five-second line next to :8679:
x2w-d3d12 placed buffers by backing: shared N/bytes, unaligned N/bytes, mapped N/bytes, uncovered N/bytes, create-failed N/bytes (gpu-written N/bytes of each)
- Test: a fixture that places one buffer of each class and checks the counters.
- Success: the "Use by allocation" measurement asked in design: runtime model for the console's unified CPU/GPU memory (copies vs direct use of title memory) #1914 can be read from any run.
c. Split the upload budget category by creator (follow-up to #3491). Creators on main: ring and snapshot pool (:3153), slot 27/127 committed (:1161, :8167), slot 70 fallback (d3d12_memory_srv.inl:449), slot 148 pages (list_upload_pages.h:37), linear staging (linear_buffer_backing.h:1158), Mesh86 cache (mesh86_cache.inl:490).
- Test: the budget fixture creates one of each and checks its column.
- Success: the 16,000 objects are attributed.
d. One adapter-facts line at start-up. src/, tools/ and tests/ have no D3D12_FEATURE_ARCHITECTURE query.
D3D12_FEATURE_DATA_ARCHITECTURE1 arch{};
D3D12_FEATURE_DATA_EXISTING_HEAPS heaps{};
device->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE1, &arch, sizeof(arch));
device->CheckFeatureSupport(D3D12_FEATURE_EXISTING_HEAPS, &heaps, sizeof(heaps));
log("x2w-d3d12 adapter facts: uma=%d cache_coherent_uma=%d existing_heaps=%d local=%llu nonlocal=%llu", ...);- GPU upload heap support can be added where the SDK headers expose it.
- Test: the line appears once on WARP with
existing_heaps=1. - Success: reports state per adapter whether sharing is possible, and row 1 can refuse before any open.
e. Design proposal, for the maintainer to accept or reject: one desktop buffer per existing heap. For a buffer below 64 KiB at an unaligned offset in an allocation whose heap is open, stop creating a fallback. Keep one buffer over the heap, as era_gpu_alias does, and give the placement an offset.
struct HeapBuffer { ID3D12Heap* heap; ComPtr<ID3D12Resource> whole; }; // one per existing_heaps entry
// slot 133: (offset & 0xFFFF) != 0, range covered, MEM_PRIVATE, Width < 64 KiB
w->own().real = heap_buffer.whole.Get();
w->own().real_offset = offset; // every user of `real` adds it- Open points: each wrapper is one desktop resource today (states, views,
GetDesc); state tracking becomes per heap; GPU reads go to system memory. - First PR is the fixture only: two placements in one heap buffer, CPU write and GPU write visible both ways, overlapping ranges, on WARP and hardware.
- Success: rows 4 to 6 no longer copy these ranges, and the fallback count in (b) drops.
f. Measure before coding.
- supply coherent backing for large placed Mesh86 buffer SRVs #3640: for the ten largest GPU-written buffers, memory type, whether the pages are contiguous in one section, who writes, who reads and on which queue. This belongs to the supply coherent backing for large placed Mesh86 buffer SRVs #3640 trace; post counts there.
- GPU to CPU: count
Mapcalls on READBACK-heap resources, copies and resolves whose destination has application memory, and the refusals logged for copy destinations backed by application memory. Open an issue with the counts only if they are not zero.
Hardware
Recommendations, not measured.
- GPU: DirectX 12 Ultimate class, because mesh shader paths forward
DispatchMesh. - Video memory: startup-runtime: guest-released committed textures are never freed, so local video memory exceeds the DXGI budget until the device is removed #2379 reports about 7 GiB of live textures. 12 GiB is a reasonable floor, and 8 GiB will run over its budget until retention is fixed.
- Resizable BAR and GPU upload heaps: they can help hot buffers later. The design must not depend on them: sharing through an existing heap does not.
- Integrated GPU or APU: closest to the console, since shared memory has no bus cost. Textures are still copied, and design: runtime model for the console's unified CPU/GPU memory (copies vs direct use of title memory) #1914 reports an adapter where
D3D12_FEATURE_EXISTING_HEAPSis 0, which leaves only the copy path.
Activity
Not-Saii commentedon Dec 1, 2026
Claiming (b) placement and read-path census.
Environment: Windows 11 build 26300, NVIDIA GeForce RTX 4090 (driver 32.0.16.1088), Windows SDK 10.0.26100, plus WARP.
Scope: add
range.typeand the refusal reason to the default slot 133 placement line, and a five-secondx2w-d3d12 placed buffers by backingline (shared / unaligned / mapped / uncovered / create-failed, count and bytes, with the GPU-written share of each). Test: a source-built fixture that places one buffer of each class on WARP and checks the counters, with a negative control that misclassifies one class. Logging and counters only; no change to which path a placement takes. Leaves (a), (c), (d) and (e) alone. PR will targetmain.legacy-code-archaeologist commentedon Dec 1, 2026
Claiming (d) one adapter-facts line at start-up.
Environment: Windows 11 Pro 10.0.26100, in-box WARP (the hardware adapters here are an NVIDIA Quadro M1000M at D3D12 FL 11_0 and an Intel HD 530), VS 2026 BuildTools, Windows SDK 10.0.26100.
Scope: query
D3D12_FEATURE_ARCHITECTURE1andD3D12_FEATURE_EXISTING_HEAPSonce where the runtime creates its desktop device. Log onex2w-d3d12 adapter facts:line with uma, cache_coherent_uma, existing_heaps, and the local and non-local video memory from the adapter. A fixture will check that the line appears exactly once on WARP withexisting_heaps=1. Rows 1–2 are not changed in this PR.AI-assisted.
d3d12: label the census's ALLOW_UNORDERED_ACCESS counts uav-capable
runtime: log one adapter-facts line per adapter at device creation
d3d12: count slot 133 placements by backing
docs: describe the slot 133 backing census
RomainROCH commentedon Dec 1, 2026
For item (e), an independent MIT-licensed D3D12 fixture provides a preliminary check of the proposed single-buffer geometry (not a claim or a runtime integration).
On Windows 11 build 26100, system WARP 10.0.26100.9818, one placed buffer over an existing 64 KiB heap exposes two overlapping logical byte ranges. CPU-to-GPU visibility passes, and after an explicit fence both GPU readback and direct CPU observation return
10111213a0a1a2a3a4a5a6a7. The one-byte shifted-write negative control fails both post-fence checks (exit 2). On this particular shared cross-adapter heap, omitting the resource cross-adapter flag also returns E_INVALIDARG despite existing-heaps support.Reproduction commands and scope · Raw log
This covers one queue and logical subranges, not two runtime placement wrappers, resource-state integration, physical adapters or Windows 10. It may be useful as an independent control for the proposed fixture.
Physical adapter follow-up for (e). On Windows 11 build 26100 and in-box D3D12 10.0.26100.9818, a GTX 970M (driver 32.0.15.8253) reproduced the WARP bytes in the original 64 KiB fixture. An Intel HD Graphics 530 (31.0.101.2115) reported feature level 12.1 and
EXISTING_HEAPS=0, so the test skipped it before allocation or queue submission.WARP and the GTX both passed a DIRECT → COPY → DIRECT handoff with explicit fences and
COMMONat each handoff. After the final fence and release, recommitting the same virtual address returned zeroed backing. The second generation read50515253e0e1e2e3e4e5e6e7through both paths. Shifting that write by one byte failed both checks while the first generation stayed clean. The scope is two logical ranges inside one buffer.Reproduction and capability matrix · Raw output
lukaslw-lab commentedon Dec 1, 2026
Data point for row 12 / the
uncoveredclass, from one native Mesh86 run (main1c634037,X2W_REFUSE_FIXED_MESH=1,X2W_NATIVE_MESH86=1, 600 s, row 12 alias off):Two Mesh86 pipelines are refused at binding for a mesh
t0read through a descriptor table, root 1 at table offset0x40, 8 bytes needed:The descriptor's address is in application memory that no placement covers. This is not the #3640 shape (root 0,
0xAC0, a 174 MiB placed buffer). The same run's census line ends atuncovered 50/1094444, so these may be among those 50. Log lines are capped, so the counts are samples.I haven't tried
X2W_TRANSLATED_INDIRECT_ADDRESS_ALIASon it yet. Counts only.AI-assisted.
SimSalabimse commentedon Dec 1, 2026
I'll take (c): split the
uploadbudget category by creator (upload ring / snapshot pool, slot 27/127, slot 70 fallback, slot 148 pages, linear staging, Mesh86 cache, plus an explicit other bucket so totals don't change). Each creator gets its own column in the budget log and instartup_resource_budget, with a sum check against the old total. I'll keep it clear of #3491's report line. Fork first, then a PR, plus a test-PC game run so we can see who owns the ~16,000 UPLOAD objects.AI-Assisted
SimSalabimse commentedon Dec 1, 2026
I'll take the GPU-to-CPU half of (f): counters for Map calls on READBACK-heap resources, copies and resolves whose destination has application memory, and the refusals of those destinations (ResolveQueryData already refuses "destination has title memory"; Copy* currently forwards them). Logging and counters only; the #3640 top-10 GPU-written buffers stay with that trace. A source-built fixture will exercise each class, and a test-PC game run will show whether any count is non-zero (a follow-up issue only if so).
AI-Assisted
timbot103 commentedon Dec 1, 2026
Claiming item (e) first PR (standalone fixture only): one desktop placed buffer over an existing 64 KiB+
MEM_PRIVATEheap exposing two unaligned overlapping logical buffer ranges, verifying bidirectional CPU->GPU and GPU->CPU visibility plus negative controls on both WARP and hardware (no runtime integration yet, per the design proposal above).Environment: Windows 11 (26200), MSVC 19.44, Ninja, Windows SDK 10.0.26100, NVIDIA GeForce RTX 5080 (driver 621.40) + WARP.
AI-assisted.
timbot103 commentedon Dec 1, 2026
The standalone D3D12 fixture for item
(e)(no runtime integration) is up in #3723.Verified in both Debug and Release on WARP (
10.0.26100.9818) and NVIDIA GeForce RTX 5080 (32.0.16.2140, Windows 11 26200,D3D12_FEATURE_EXISTING_HEAPS=1; D3D12 debug layer unavailable on this host,0x887a002d): CPU→GPU, GPU→CPU, GPU→GPU UAV-barrier echo, and displaced-offset negative control (--offset-control/--corrupt-offsetexit code 3) all pass on both adapters.AI-assisted.
gpu: test overlapping placements in one existing heap (Part of #3676)
Merge pull request #3723 from timbot103/tests/existing-heap-shared-bu…