Repository navigation
Description
Design decision needed. This changes how every GPU-visible title allocation is backed on desktop, so it cuts across xmem, the D3D12 stand-in, storage and the translators. Opened from the gap summary on #874, so the decision has its own record. No implementation is proposed here, and none should start before a direction is agreed.
Background
The console has one physical memory shared by CPU and GPU. A title uses the same addresses for both, within a 40-bit range:
- it keeps a CPU range A and a GPU range B and translates between them by offset;
- other addresses pass through unchanged (docs/experiments.md, "CPU/GPU range translation against a desktop D3D12 heap (gpu: establish the D3D12ConfigureVirtualMemoryX startup contract #874)").
A title therefore writes GPU-visible data and GPU addresses straight into its own memory: vertex and constant data, descriptors, acceleration-structure inputs and destinations, upload memory from the command list (slot 148, #1758). It expects the GPU to see them, and expects to see what the GPU writes back.
How the runtime handles it today (measured on main df40e4bc, RX 9070 XT, the first-run UI and the post-confirm load)
| Path | What happens | Evidence |
|---|---|---|
| Placed resources (device slot 133) | Aliased with title memory only when the title range is one private committed allocation (OpenExistingHeapFromAddress). Otherwise a separate committed desktop buffer is used. |
67 aliased, 3,508 not aliased of 3,575 placements in one run. Title pages are mostly mapped sections (MEM_MAPPED), which this path refuses. |
| Data reached by GPU address (root descriptors, fetch tables) | Copied per use into a 256 MiB desktop upload ring (upload_from_title) |
every translated draw |
| Textures | Uploaded and detiled into desktop textures | about 1,370 textures, about 5.4 GiB in the #870 runs |
| Title GPU view | X2W_XMEM_GPU_MIRROR maps each physical page section into both the CPU and GPU reservations |
docs/startup-runtime.md |
| Addresses the title hands to consumers | Title CPU addresses, used directly; only placement is constrained | #1860 (opt-in placement below 2^40) |
The building blocks for direct use exist and are tested in isolation:
vm_translation_*:OpenExistingHeapFromAddressover a committed range, GPU reads and writes visible on both sides.vm_page_provenance_*andvm_translation_*exerciseOpenExistingHeapFromFileMapping. The RX 590 report in gpu: establish the D3D12ConfigureVirtualMemoryX startup contract #874 passed Page Provenance and failed the separate reserved-buffer COPY-to-DIRECT tile remap. Source check and report distinction.d3d12_xs_range: a 32 GiB windowed GPU range with tile mapping.era_gpu_alias.
Why the copy model is reaching its limits (observed)
- Addresses. The title's own addresses reach consumers that check them: the package BVH builder's 40-bit check (startup-runtime: the package BVH builder throws an HRESULT during the post-confirm load #1758). Placement fixes the width (xmem: opt-in placement of 0x283 startup blocks below 2^40 #1860), but the consumer still gets a title CPU address, not a desktop GPU VA.
- Upload memory from the command list (slot 148). A pointer the title writes and the GPU reads; it needs a defined lifetime and a CPU/GPU address relation (gpu: establish the D3D12ConfigureVirtualMemoryX startup contract #874 task, startup: exercise upload arena allocation contract #1774 arena).
- Direct command writes (hypothesis from reading the builder, not yet reached in a run): the BVH builder appears to write command packets straight into the command-list object's buffer at fixed offsets.
- Coherence. A copy taken at bind or upload time misses CPU writes made later before execution, and GPU writes the title reads back. Not measured yet; it becomes visible once loading produces GPU-written data.
- Memory doubling. Peak commit is 14.6–16.2 GiB during the post-confirm load, against roughly 10–13 GiB attributable to the title (P0: main executable startup progress #870). Title pages and their desktop copies coexist, and the default
-MemoryGiB 14cap is not enough. - Silent failure paths. Refused storage requests leave destinations untouched while the title only polls
IsComplete(startup-runtime: loading-phase DirectStorage requests read past a file end and at non-zlib data #1198). A copy taken from such a destination can carry stale data into GPU work without any error.
Options to decide between
A. Keep copies, make them exact.
- Copy or translate per use; add the missing contracts one by one (slot 148, placement, coherence points).
- Pro: no change to memory backing; works on any adapter.
- Con: memory doubling stays; every new consumer of a title address needs its own translation. Coherence relies on choosing the right copy points.
B. Back GPU-visible title memory directly (heap from file mapping or address, placed desktop resources over it).
- Pro: one copy of the bytes; GPU writes land in title memory.
- Con:
- desktop GPU VAs still differ from title addresses, so every embedded address needs translation (descriptors, root and indirect arguments, AS instance and BLAS references);
- system memory over the bus is slower for GPU-heavy data;
- textures still need detiling copies (desktop layouts are opaque);
OpenExistingHeapFromFileMappingbehaviour differs by adapter (RX 590 failsvm_copy_queue);- sections and placeholder splitting constrain heap boundaries.
C. Hybrid.
- Direct backing for buffers the title addresses itself: upload memory, AS inputs and destinations, constant and structured data. Copies for textures and render targets.
- Translation for embedded addresses.
- Needs a per-allocation policy, based on attributes and observed use.
The choice also fixes who translates title addresses (the stand-in at bind time, the translators at lowering time, or both), and how the 40-bit address domain is kept on desktop.
Measurements that would inform the decision (proposed, aggregate only)
- Use by allocation: per title allocation shape (XMem attributes, page size), whether the GPU reads, writes or never touches it, and whether the CPU rewrites it after submission.
- Copied volume: how much is copied per frame and per load through each path above, and how much of it could be shared.
- Embedded addresses: how many embedded GPU addresses appear in title-written GPU data, by kind (descriptors, root and indirect arguments, AS references).
- Adapter matrix: heap from file mapping and from address, on the adapters reported in gpu: establish the D3D12ConfigureVirtualMemoryX startup contract #874.
Ask
@R0Y00, which direction should the runtime take, and which measurements do you want first? The concrete #874 rows (placement, slot 148) stay as scoped; this issue is only for the overall model.
AI-assisted.
Activity
R0Y00 commentedon Nov 24, 2026
We'll use a hybrid model, starting with one ordinary linear CPU-written, GPU-read buffer. Keep the current production backing as the default. Opt-in eligibility depends on the allocation's use, mapped extent, the adapter actually creating the shared backing, and whether the path can meet the synchronization contract. Acceleration structures, textures and render targets are outside this first slice. If sharing fails, use a copy only when it can preserve the same visibility and lifetime guarantees. Otherwise return a diagnosable failure.
XMem owns guest allocation identity, mappings, byte offsets and lifetime. D3D12 owns desktop backing, resource state, queues and fences. Resolve each known address field to a desktop GPU VA through the same range- and generation-checked mapping. Translators declare the types of address fields they know, and the runtime binds or relocates them. Refuse dynamic layouts with unrecognized address fields. Storage publishes the range it actually wrote on success and preserves the error on failure. The 40-bit constraint stays with the specified guest address domain.
This first comparison is available to claim here. Reuse the source-built heap and cross-queue controls in #874. Run the same buffer through real sharing, forced copying and forced sharing failure. Bind A, write B before submission, and verify the GPU reads B. In a separate GPU-write case, wait for the fence and verify the CPU alias sees the result. Hold one submission in flight and check that its backing isn't reused. Missing refresh and readback before fence completion should expose stale data or a defined refusal. Report the commit, commands, adapter/driver, bytes copied, backing usage and actual HRESULTs, with skips separate. Unsynchronized concurrent writes are outside the contract.
Once both paths agree on bytes and lifetime, the first buffer change can be reviewed independently. The existing scoped placement work in #1860 and slot 148 ownership are unchanged.
MasterDomino commentedon Nov 24, 2026
Thanks for the direction. Claiming the first comparison as scoped: one ordinary linear CPU-written, GPU-read buffer, run source-built through real sharing, forced copying and forced sharing failure, reusing the heap and cross-queue controls from #874 (
vm_translation,vm_copy_queue,era_gpu_alias).Cases (each on all three paths):
Reported: commit, commands, adapter and driver (WARP and RX 9070 XT), bytes copied, backing used, the actual HRESULTs, and skips separately.
No change to the production default. Unsynchronized concurrent writes stay out of scope, and so do acceleration structures, textures and render targets. #1860 and slot 148 are unchanged. I'll post the comparison here before proposing the first buffer change.
AI-assisted.
Leyukaka commentedon Nov 24, 2026
A static read of
mainatba0449cagainst the issue text and the claimed first comparison. Nothing was built or run for this. Bare:Nrefers tosrc/startup_stubs/d3d12_xs_device.cppatba0449c.One correction to the background table.
OpenExistingHeapFromFileMappingis exercised byvm_page_provenance_*(SectionPage,tests/vm_copy_queue_check.cpp:191-221, dispatched at:706of that file) and bytests/vm_translation_check.cpp:522. Thevm_copy_queue_*tests order a tile remap of a reserved buffer across a COPY and a DIRECT queue, and open no file-mapping heap. The RX 590 failure in #874 is that remap row, and the same report has Page Provenance passing on the RX 590. So it is not evidence that file-mapping heaps differ by adapter.src/has no call toOpenExistingHeapFromFileMappingatba0449c.Rows the four cases can pass without exercising, depending on how the fixture is built:
src/xmem_mapped_pages.cpp:74-157), and slot 133 only aliasesMEM_PRIVATEranges (:2972). A fixture over a privateVirtualAllocrange, or over a fresh one-page section, does not cover:src/xmem_mapped_pages.cpp:83-91).upload_from_title,:2245) and at draw record (frame_copy,d3d12_draw.inl:615, called at:1098), both beforeExecuteCommandLists. A harness that copies at submit passes "bind A, write B" by construction. Naming the copy point under test, and using a bind-time copy as the "missing refresh" negative, would make the forced-copy row match production.reserve_upload_ring,:1719-1754, wrap at:1750-1751). A forced-copy path that allocates a fresh buffer per submission never reuses, so the in-flight case passes unless reuse is forced: a ring wrap for the copy path, and a free and slot reuse in XMem for the shared path.Wait/Signal, asvm_copy_queuedoes (tests/vm_copy_queue_check.cpp:152-158), removes the timing assumption. On the sharing path, a defined refusal is the stable oracle.not aliasedand returns success (:2996-3026), and it does not copy the title's bytes into that buffer. The failure row could tell this apart from a copy that preserves visibility: the outcome to catch is a success whose backing holds neither the title's bytes nor a refusal.Also from the code:
OpenExistingHeapFromAddress(:2982) without queryingD3D12_FEATURE_EXISTING_HEAPS;src/era_gpu_alias.cpp:41-42does query it.existing_heapscaches heaps by raw allocation base and has no removal (:2902,:2976-2985). A later allocation at the same base would be placed on the heap opened for the earlier one. That is read from the code, not observed. The range- and generation-checked mapping in the direction above would replace it.AI-assisted.
MasterDomino commentedon Nov 24, 2026
The first comparison is up as #1942. It is test-only:
tests/unified_buffer_paths_check.cppchanges no production backing and changes no stand-in's default behaviour.Result (WARP 10.0.26100.9818 and RX 9070 XT, driver 32.0.31044.16, Windows 11 build 26300, debug layer off and on; identical on both, no skips): 40 cases pass on
share,copyandfallbackfor both pools.upload_from_title) or at draw record (frame_copy) hands the GPU the stale A, while sharing reads B. Today's copy points therefore can't stand in for sharing when the title writes between bind andExecuteCommandLists.S_OKwith zero-filled, non-aliased backing. The oracle catches it in both cases.How Leyukaka's review points are covered:
vm_page_provenance_*andvm_translation_range_*and makes no claim of an adapter difference.0x30000on a reused slot that must read zero first. The privateVirtualAllocpool runs alongside.bindandrecordare the missing-refresh negatives (d1b and d1r).0x887A000A. The shared path frees a slot and reallocates it while its submission is held.Waiton a CPU-signalled gate, with the0x887A000Arefusal as the oracle.Measured but not asserted:
OpenExistingHeapFromAddressaccepted aMEM_MAPPEDview of the section on both adapters, with CPU and GPU writes visible both ways. On the first view of a split run, it gives only a 64 KiB heap.VirtualFreeof that range fails with error 87 for both release and decommit. So with an unclearedexisting_heaps, the observed hazard is the title's free failing, not a stale read. The generation-checked mapping from the decision would remove it either way.The first buffer change will be proposed separately, against these rows.
AI-assisted.
legacy-code-archaeologist commentedon Nov 24, 2026
Adapter-matrix data point for the first comparison: #1942 at its head 0e81481, run on two GPU families that are not covered yet, plus WARP. Windows 11 Pro 26100.9168, MSVC 19.52,
devpreset,unified_buffer_paths_check <warp|hardware>. The adapter was selected withXBOX2WINDOWS_ADAPTER. The debug layer is not installed here (0x887a002d), so all runs are debug layer off.D3D12_FEATURE_EXISTING_HEAPSctest -R '^unified_buffer_paths_'passes 5/5 (hardware = the Quadro, the high-performance adapter). The three mutant controls fail as required.Quadro (Maxwell): it behaves like your WARP and RX 9070 XT runs.
OpenExistingHeapFromAddressaccepted the 128 KiBMEM_MAPPEDview of the 256 MiB section at +0x30000. The GPU read the CPU writes (1024/1024), and a GPU write was seen through the split run.0x80070057).VirtualFree(release and decommit) fails with error 87. After the heap is released, it succeeds.Intel HD 530 (Gen9) has no existing-heap support at all.
D3D12_FEATURE_EXISTING_HEAPSreports 0.sharerow, 6 for the section pool and 6 for the private pool, skips withopen=0x887a0004(DXGI_ERROR_UNSUPPORTED).OpenExistingHeapFromAddresson the section view returns0x80070057. The placement probes and the stale-heap probe do not run.copyandfallbackrows pass.The point for the model: the slot 133 stand-in falls back on this adapter even for private title memory. Both
private slot133rows are caught ascommitted default buffer, not aliased, no copy, withshare_hr=0x887a0004. On WARP, the Quadro and your adapters, slot 133 aliases private memory, and only the section rows are caught.So on a Gen9 Intel GPU, every slot 133 placement takes the silent-success path you described. The new backing holds zeros, not the title's bytes. This matches Leyukaka's note that slot 133 calls
OpenExistingHeapFromAddresswithout queryingD3D12_FEATURE_EXISTING_HEAPS.For the eligibility rule in the direction above, "the adapter actually creating the shared backing", this is a concrete adapter where the answer is always no. The copy path that preserves visibility, or a diagnosable failure, is then the only valid option. I have not run the production runtime here, so this is the fixture's model of slot 133, not a measured title run.
Full outputs per adapter are available if useful. I made no code change.
gpu: compare one linear buffer through sharing, copying and refused s…
MasterDomino commentedon Nov 24, 2026
Thanks for the matrix. The Gen9 row is the most useful data point so far.
MEM_MAPPEDview acceptance, the 64 KiB first-view heap and theVirtualFreeerror 87 while the heap lives. That makes three hardware families plus WARP agreeing on those probes.D3D12_FEATURE_EXISTING_HEAPS= 0): this is an adapter where sharing is never available. On it the slot 133 model takes the silent-success path even for private memory, which today's adapters avoid. So the eligibility rule has to be decided per adapter from the feature query before any open is attempted. On a "no", the only valid outcomes are the copy path that keeps visibility or a diagnosable refusal. Slot 133's missing feature query (Leyukaka's note) is then not cosmetic. I'll carry that into the first buffer-change proposal as a requirement, with your Gen9 row as the case it must handle.AI-assisted.
R0Y00 commentedon Nov 24, 2026
The test-only comparison in #1942 has merged at
cd5508e9. The Gen9 report gives the copy path a useful adapter without existing-heap support. The production slice is available for one contributor: wire the existing comparison to one ordinary linear CPU-written, GPU-read buffer, keeping the current backing as the default.Reuse #1942 for the A-to-B write before submit, GPU write and fence before alias readback, and backing reuse only after completion. Report real sharing, forced copying and host sharing refusal separately, with actual HRESULTs and bytes copied. If the copy path cannot meet the same visibility and lifetime guarantees on a case, report that refusal. Please claim the buffer here before changing the production path. Textures, acceleration structures and command-list slot 148 can continue in their existing threads.
MasterDomino commentedon Nov 25, 2026
I'll take the production slice: one ordinary linear CPU-written, GPU-read buffer, with the current backing kept as the default.
Plan:
D3D12_FEATURE_EXISTING_HEAPSbefore any open is attempted. The Gen9 row is the case where sharing must be refused. A copy that can't keep the same visibility and lifetime guarantees reports a refusal instead of returning success.Textures, acceleration structures and slot 148 stay out of scope. I'll post the PR here.
AI-assisted.
MasterDomino commentedon Nov 25, 2026
PR for the production slice: #2218. The switch is opt-in,
X2W_D3D12_LINEAR_BUFFERS=1; unset, slot 133 is unchanged. It covers slot 133 buffers inCOMMONstate with row-major or unknown layout.D3D12_FEATURE_EXISTING_HEAPSreports support.Why the last point: an earlier revision returned the refusal, and the title faulted at 1.76 s on its first GPU-written placement, because on the console
CreatePlacedResourceXdoesn't fail.On this revision, a matched title pair on the RX 9070 XT reached the same slot 148 stop: 294.1 s with the switch on, 290.1 s off. The frame rate was within 1% (29.6 against 29.8 fps). Placements: 3,094 copied at submit, 64 shared, 507 kept the default backing with the refusal recorded.
The fixture
linear_buffer_backing_*reuses #1942's cases over XMem pages and a private range. It covers six paths, the Gen9 refusal simulated with the feature forced to 0, and five mutants, on WARP and the RX 9070 XT with the debug layer off and on. 22/22 pass with the comparison tests.Not fixed by this slice: the 506 GPU-written XMem buffers (856 MiB in that run) still have the default backing, now recorded. They need a copy-back point or a releasable shared backing.
AI-assisted.
gpu: back slot 133 linear buffers by sharing or a submit-time copy (o…
gpu: keep slot 133's default backing where the linear path refuses
gpu: refresh linear buffers without holding their lock across waits
MasterDomino commentedon Nov 25, 2026
Heads-up for anyone running the #1942 fixture repeatedly:
unified_buffer_paths_checkleaves about 1.8 GiB of system commit per run until reboot. The cause isOpenExistingHeapFromFileMappingretaining its section after process exit, which I measured on Windows 11 build 26300 on WARP and the RX 9070 XT. The details and the fix are in #2234.AI-assisted.
gpu: note why concurrent linear-buffer publishes only cost a refresh
28 remaining items
gpu: stop refreshing a copied linear buffer that a list copy writes
docs: record linear-buffer budgets, list-copy holds and the lease def…
gpu: mark a copied linear buffer GPU-written when its copy is submitted
gpu: order linear-buffer refreshes behind earlier submissions
gpu: publish linear-buffer uploads in the order their copies execute
gpu: probe and guard title memory right before staging a linear buffer
tests: drive discarded copies, earlier reads and refresh races in lin…
docs: record the linear-buffer submit-time GPU write, producer wait a…
gpu: back slot 133 linear buffers by sharing or a submit-time copy (o…
lukaslw-lab commentedon Nov 26, 2026
Field result for #2218's
X2W_D3D12_LINEAR_BUFFERS=1in a main-executable run: on this host the submit-time copy halves translated draws, shows brief visual glitches that the default backing does not, and does not reduce held memory.Windows 10 22H2, RTX 3080 Ti (driver 32.0.16.1047), release build of
maina6967446plus #2611, warm shader cache, same recorded input. All runs:X2W_D3D12_BUDGET=1 X2W_D3D12_RELEASE_RETIRED=1 X2W_D3D12_RELEASE_RETIRED_VIEWS=1 X2W_D3D12_RETIRE_REASONS=1, 600 s. The only difference is the switch.share=E_INVALIDARG), so on this title the copy path is the normal path.0x887a000astale refreshes, but only after ~510 s.ExecuteCommandListsand before the GPU reaches the work is visible with the default backing but missed by the copy taken at submit.LinearBuffersunder one mutex. I have not profiled this.Aggregate counts only; no addresses or title data. AI-assisted (Claude); I ran the runs and noted the glitch times.
MasterDomino commentedon Nov 26, 2026
Thanks, @lukaslw-lab. This is the field result #2218 needed, and both readings fit how the opt-in works:
mutex_, about 21 k records per submission across about 72 k submissions, whatever was written. That's far more likely to be the cost than the 16 MiB copied. A per-buffer dirty signal, such as a write watch on the title pages or a generation counter set by the XMem write paths, would make the walk proportional to what changed. I haven't profiled it either, so that's a hypothesis until a trace shows it.ExecuteCommandLists, which is the visibility rule agreed in design: runtime model for the console's unified CPU/GPU memory (copies vs direct use of title memory) #1914. A title that writes a buffer after submitting and before the GPU reaches the work relies on unified memory, and the aliasing backing gives it that, but a submit-time copy can't. Your bursts lining up with the glitches fit that. A deterministic case would settle it: submit a read gated on a fence, write B from the CPU, then signal. The aliased backing reads B, while the copy reads A by design.The default backing is unchanged, so nothing regresses without the switch. I'll take the two follow-ups:
Each would come as its own PR. Before I start: @R0Y00, is a write-after-submit gap acceptable for the opt-in as long as it's documented, or should that pattern be refused or warned about in the copy path?
AI-assisted.
R0Y00 commentedon Nov 26, 2026
Keep the current opt-in contract for this slice: the copy captures bytes at submission. A workload that depends on writes after submission needs a backing path that can provide that visibility. Please take the gated fixture and the separate profiling work. For the fixture, hold GPU consumption behind a queue wait, write B on the CPU, then signal and read back after completion. Report the measured shared and forced-copy results separately, and keep the write-before-submit control where both should read B. Document the confirmed limit with the fixture. Leave the default backing and fallback behavior in place. A runtime warning or refusal would need evidence that the implementation can actually identify the unsupported ordering.
RomainROCH commentedon Nov 30, 2026
I put together an independent MIT-licensed CPU replay that may complement the WARP cases in #1942 and #2332. It records the backing generation captured at submit, the current mapping at read, and the last writer of each byte range.
In the synthetic case, compute waits for a copy ticket submitted later. The view is rebound while compute is blocked. Once the producer retires, the captured backing receives
10 20 30 40. A one-byte CPU overwrite leaves10 ee 30 40through the surviving alias, and the new backing remains zero. A separate test allows a CPU read while a disjoint write is still pending.From the pinned lab snapshot, run
python gpumemorylab.py examples/remap.json --explain. The replay reports one blocked step and the writer event for each returned range. It models backing capture at submission. Your gated WARP test can separately distinguish a submit-time byte snapshot from a later read of live backing. Would the mapping event and last-writer ranges help label mismatches in that fixture?runtime: log one adapter-facts line per adapter at device creation