Nothing of the game leaves the machine: the steps below compare numbers and screenshots on the Deck itself.
vulkan: the device shares system memory (UMA); guest buffers read in place where they can be (vk_memory=auto).
If it says copied, the driver has no VK_EXT_external_memory_host: say which driver it is (the vulkan: line
with the device name and driver version).--script, --press-len, snx-run skill), with a screenshot every few seconds (--shot=DIR/s --shot-every=60).
Run with -H --fps-limit=0 --vsync=0 --vk-gpu-profile=1 --vk-buffer-stats=1 so that the frame rate is the
renderer's, not the display's.--vk-memory=1 (copy) and three times with --vk-memory=2 (in place), one after
the other, with nothing else running. Keep each run's log and screenshots apart.vulkan: GPU queue over N presents (X ms each): busy ... and the idle lines after it: in place should
take CPU time off the GPU thread ("the CPU still recording the next one" goes down);vulkan: in place over 600 presents: ...: the ranges read in place against the ones copied, the imports that
failed (amdgpu may refuse user pointers to memory that isn't anonymous, such as the alias pool's: those ranges are
copied), the megabytes the imports hold (amdgpu checks every import's pages at every submission: if the frame
rate falls as that number grows, say so with the number of submissions a present), and the hazards;vulkan: staged by reason and ring MB over 600 presents: the bytes copied, which in place should cut.vulkan validation: lines with --vk-validation=1 (one short run in each mode, the layer from the
distribution's package), and any device lost.On a GPU that shares system memory, guest vertex, index and read-only storage ranges are imported into Vulkan
(VK_EXT_external_memory_host, or on Android with vk_memory=2 moved into AHardwareBuffers) and read in place, as
the sections above say. Every other range takes the copy path that this section is about:
vk_buf_copy copies bytes out of guest RAM into a buffer that vk_stage maps and the GPU reads. Exporting the final
image as a dma-buf, as desktop compositors do, would not remove this copy: ScarletNX already presents its Vulkan image
without an app-managed dma-buf handoff.
With the constant-buffer cache enabled, a 600-present interval of a cave scene in one game staged 3,688,879,936
uncached bytes in 63,098 calls. The largest call was 58,848 bytes and none were zero-filled. The only nonzero-address
staging-copy path with that cache enabled is vk_buf_copy_writable for writable graphics storage buffers in stage_set. A
per-draw wait or allocation is therefore not a viable replacement for the staging ring. The test machine has a
discrete RTX 2080; it cannot establish a unified-memory speedup.
The input to each draw is a snapshot. Guest CPU threads can write the same pages while recorded GPU work is in flight,
and GPU virtual ranges can map fragmented host pages. The current asynchronous userfaultfd write tracker reports writes
after they happen; it does not freeze pages. Guest mapping and decommit operations can also change backing memory.
Importing g_mem directly would let the GPU see later CPU writes, and a shader could write guest memory before the
guest's synchronization point. A direct import must therefore own and pin the imported pages, intercept writes to
them or use copy-on-write, and wait for GPU completion before remapping or releasing them.
Mapping changes now acquire the renderer's memory lock before the guest memory manager's lock. CPU backing changes land all pending storage output because a CPU page may have several GPU aliases. GPU-VA changes land overlapping output before changing the page table and mark the virtual range dirty for buffer caches. This closes the backing-lifetime gap for staged outputs; it does not pin guest pages or make direct host-pointer import safe.
Graphics storage writes now retain each draw's input bytes, destination range, and GPU buffer. A completed frame
invalidates noncoherent output memory and lands only bytes the shader changed where the guest still holds the input
value. Overlapping guest reads and writes, and stream synchronization points, wait for pending outputs. Draws can reuse
an earlier result in the same frame with a storage barrier when the binding is contained and aligned and its guest input
is unchanged; other overlaps land before taking another snapshot. Frame-ring reuse processes output before freeing its
staging allocation. The compute and graphics paths share vk_write_changed.
A compute program of the SM86 translator logs the bytes its stores write instead (see Ounce): its results keep no input bytes, and land exactly the bytes logged, the shader's value winning over a CPU write made to the same byte while the result was pending.
The byte-value reconciliation cannot distinguish a later CPU write that restores the original value from no write. Games must synchronize CPU and GPU writes to the same bytes for deterministic ordering. When writable bindings in one draw share guest backing, the bindings involved in that overlap use a shared page atlas. Each such binding maps its logical word indices to atlas pages, so partially overlapping ranges, fragmented mappings and different GPU virtual aliases see the same bytes. The atlas starts after earlier graphics and compute output has landed. A draw whose atlas would exceed the device's maximum storage-buffer descriptor range is skipped with a warning, rather than rendered with independent snapshots.
The 110-second run of that cave scene with graphics writeback and same-frame reuse completed 1,757 frames, compared with 1,754 for the earlier staging run on this machine. A 600-present interval reused 7,429 GPU buffers but still forced 1,985 lands, totaling 14.7 seconds of waits. The scenes and shader caches vary, so this is a correctness smoke test, not a controlled performance comparison. The resulting cave image still has known cyan rendering artifacts.
Vulkan references: host pointer import, host/device synchronization, and placed memory mapping.
Made from docs/layers/gpu/ownership.md at 69237645142c. GPL-3.0-or-later.