Files
Anees Iqbal 319f54dabb 🆕 Encode an x86-64 guest's HEVC on the host's encoder
An x86-64 guest's hardware HEVC encoding never reached our GPU: macOS's HEVC
encoder plug-in drives only an Intel GPU's driver, found by name, so an app that
required hardware failed at its create (-12908) and others encoded in software
(m3-max-77632, development's set on this host). What the guest sees now, where
the host's video arm lists an HEVC encoder of Main and Main 10 with a constant
QP that codes a frame in place of the last (Linux hosts' VA-API, and NVENC where
its driver codes a frame without advancing its state):

- the accelerator publishes an IntelAccelerator child of its own with
  IOGVAHEVCEncode and IOGVAHEVCEncodeCapabilities (Main and Main 10, up to
  the encoder's level), so VideoToolbox lists a hardware HEVC encoder
  (hevc.gva);
- RgfxGate keeps the Intel driver path the plug-in loads from
  /Library/GPUBundles a hard link to the bundle's executable, at every boot;
- the bundle's video driver takes the plug-in's encode commands (function
  0x20, sub-ID 0x1000), codes each frame on the host (ENCODE_H265) at the QP
  the plug-in's rate control chose, an IRAP picture as a keyframe, Main from
  an 8-bit source and Main 10 from a 10-bit one, and hands back the access
  unit with 4-byte start codes, whose VPS, SPS and PPS make the session's
  format description;
- a frame the plug-in codes again over its data rate limit, at a higher QP,
  is sent in place of the last one (RGFX_VIDEO_ENCODE_IN_PLACE): a P
  picture of the last frame's order count and source surface; a keyframe
  coded again is sent as a new IDR picture;
- a session of a size the host does not encode is refused at its create,
  so an app that allows software encodes in software as before.

A host whose encoder has Main alone gets no nub: VideoToolbox hands the
plug-in a Main 10 session whatever profiles the nub lists, and the driver
learns a session's profile only from its first frame. Nor does one that
codes no frame in place, where a retry would predict from the frame it
replaces. H.264 encode and both decodes are as before on either. The
plug-in's per-CTU QP map (its pool 27) is not applied, and its frame
statistics record is not supplied. The route is macOS 26.7.1's plug-in's,
booted on 26.7.2. Windows hosts list no encoder, so encode in software as
before.

Rows (macOS 26.7.2 guest, 1080p, 300 frames at 8 Mbit/s, decoded back by
VideoToolbox; the rate band is vboot's RATE_BAND_PCT, 6%, both codecs), the
same with the frames in place (m3-max-77615, m3-max-77613, m3-max-77614),
byte for byte but for 205 bytes of the Iris Xe's Main stream:
- RX 7900 XTX (m3-max-77475): Main 105.1%, 45.02 dB; Main 10 104.8%, 45.17 dB
- Iris Xe (m3-max-77476): Main 103.5%, 48.04 dB; Main 10 98.1%, 48.86 dB
- RTX 3090 (m3-max-77477): Main 100.7%, 44.81 dB; Main 10 106.1%, 45.06 dB,
  where NVENC's own lands 104.6%: known-issues and video/bugs.md B97
At a data rate limit of 1 Mbyte a second, the plug-in coded 2 to 30 frames
of a session again, each sent in place: no gap in the order counts, all 300
frames decoded back, and the most bytes in a second 1.7% to 3.0% over the
limit (RX 7900 XTX m3-max-77611, RTX 3090 m3-max-77609, Iris Xe
m3-max-77627; video/bugs.md B100, to be read on a user's report). With a
keyframe every frame the stream comes to 4.1 to 5.0 times the asked rate, as
a real Intel Mac's comes to 5.7 times with the same QPs frame for frame
(m3-max-77635; design.md, known-issues); every frame decodes back.
Main 10 from a retained pool and from the app's own 8-bit buffers decodes as
from the pool taken per frame on all three. A real Intel Mac's hevc.gva
(macOS 26.7.1, m3-max-77481) replaces the session's pool at the third Main 10
frame, as ours does. Speed (Iris Xe, m3-max-77497): 94 to 118 fps at 1080p
against software's 3.3; 10.3 to 10.8 at 8K against 0.5 (B98, B99).

Tests: the kext's publish condition and its pairing with a host that codes
no frame in place (video_codecs_test: the caps of both decoders and encoders
without the flag publish no HEVC encode and the rest as before), the link's
update on real files (rgfxgate alias_test), and the driver's listing, create
refusals, settings, keyframes, write-back, failures, refused sources and the
frames it sends in place, and those it does not: never a keyframe, so a
session of keyframes from one reused surface sends none (video_driver_tests;
m3-max-77590). Development's set on this host (m3-max-77632) encodes H.264 to
the same bytes as this one and decodes as before. Docs: design.md and
devices.md, video/bugs.md B97 to B100, and known-issues.md's HEVC encoding
line, which now says which GPUs encode HEVC for an Intel Mac guest, and its
section on HEVC over the bitrate asked.
2026-11-27 16:26:01 -08:00

545 KiB
Raw Permalink Blame History

reims-graphics: design

Status: stage 1 done. "Decided" holds what the owner and the research settled, "Stage 2 wire protocol" is what stage 2 builds, and "Open" holds what waits on the owner or on a later stage. The research's notes, with sources and measured, read or inferred tags, are kept outside the repository.

Goal

Our own GPU device for macOS guests, with our own guest kext and Metal GPU bundle, our own protocol, and our own QEMU device and host side. It has its own PCI vendor:device ID, so Apple's paravirt kext never matches it, and it serves x86-64 guests through OpenCore and arm64 guests from macOS 14 on Ambrosia (Decided 13). Resources are stored and rendered in host GPU memory. The guest names them by handle, and the guest CPU reaches GPU memory only where Metal gives it a pointer.

It is engineered for maximum performance from the first version, without cheating: every result a guest observes is Metal's, and no fast path trades correctness.

Stages:

  1. Research and probes, ending in this document.
  2. The kext, unaccelerated: the device, the transport and the display.
  3. Acceleration through the library's platforms (Metal on a Mac, metal2vulkan on Vulkan).

Decided

  1. Device identity. The device has its own PCI vendor:device ID, so Apple's paravirt kext never matches it and nothing of the guest OS is patched. The two lanes live side by side, and QEMU picks one by the device a VM is given. The lane serves x86-64 guests: Apple says third-party kexts are not supported in macOS VMs on Apple silicon, and vmapple guests boot the same way, so arm64 guests stay on the Apple lane. Superseded 2026-11-08: one lane. Apple's paravirt lane is deleted (2026-11-07), and arm64 guests from macOS 14 take this device's arm64e set on Ambrosia (Decided 13).
  2. The cut: Metal-level calls. The guest bundle streams Metal's calls, and the host decodes them into the library's Platform, which has a Metal and a metal2vulkan implementation, so both arms come with it. A Vulkan-level cut would put the Metal-to-Vulkan runtime, its shader translator and its caches in every guest process, translate on the guest's vCPUs, and translate twice on a Mac host.
    • Measured on one AMD host (XDC 2023): API forwarding (virgl, Venus, gfxstream) runs at 37-73% of bare metal, and DRM native context at 64-98.5%. Native context wins by its mechanics, which this protocol keeps: the guest picks GPU addresses and sequence numbers itself, replies sit in shared memory, and mappings are made once.
    • In the Apple lane, copies are the cost and decoding is not: a 4K Finder drag moves 182-938 MB a frame to the GPU, while the decode threads use about 4% of a CPU.
  3. Queues and rings. Each MTLCommandQueue gets one submission ring and one completion ring, created when the guest makes the queue. Thousands are allowed.
    • Encoders stream as they end, and at a size threshold inside a long encoder, so the host lowers encoder N while the guest encodes N+1. Commit is a small message.
    • No VM exit per submit. The host polls a busy ring, and the guest rings the doorbell (an ioeventfd) only after the host has marked the ring idle.
    • Each ring is decoded on its own host worker, so one queue's work never blocks another's. Single consumers are what limited the measured cases: virgl decodes every GL context on one host thread, and a global lock left gfxstream's GPU 8% busy (143 fps against 800 on Venus).
    • Native GPUs have one graphics engine, a few compute and copy engines, and far more queues than engines. RADV and ANV expose one graphics queue and NVIDIA 16, so on AMD and Intel the graphics work of every guest queue meets on one host queue, as native apps' work does.
    • Every queue's work, WindowServer's among them, goes to the runtime's one GPU queue in submission order, and no queue priority reaches Vulkan: the bundle sends 0 for every queue ("Rings", below), and a queue the kext asks unshared is the runtime's plain queue ("WindowServer's queues are unshared", below).
    • Completion records (seqno, status, Metal's error and the failing encoders' info, GPU times) go in the queue's completion ring.
    • An interrupt fires only when the guest armed one, on several MSI-X vectors spread over the guest's CPUs.
    • Presents are never batched. Every command buffer completes exactly, with no grouping.
  4. Memory model. VRAM is the primary allocation. hasUnifiedMemory follows the host GPU.
    • On a discrete GPU it is false:
      • Private buffers and all textures live in VRAM and are never mapped into the guest.
      • Managed resources are two copies: the VRAM copy, which is primary, and a host-cached CPU copy the guest maps.
        • didModifyRange: copies exactly the named range to VRAM, before any command of the next submission.
        • synchronizeResource: copies VRAM back to the CPU copy inside the blit encoder.
        • A range message is ordered before every later commit of its context, on any queue, as Metal promises.
        • Managed textures get two copies too: a linear CPU copy the guest maps, beside the VRAM image. replaceRegion: and getBytes: are then guest memcpys plus a region message, with no round trip.
      • Shared buffers are host-cached system memory mapped into the guest, which the GPU reads over PCIe (measured on a 3090: CPU reads 45 GB/s there, against 0.01 GB/s from resizable-BAR VRAM), whatever their CPU cache mode.
      • A texture made over a Shared buffer shares the buffer's system memory, and the GPU samples it there, as Apple documents for discrete GPUs: no VRAM copy and no dirty log (owner, 2026-10-30).
    • On an integrated GPU (Apple silicon, AMD and Intel iGPUs) it is true, with one copy of each resource.
    • The host allocates every block, and the guest sub-allocates buffers inside blocks, so creating a block is the only memory call that waits for the host. A block mapped into the guest is a dedicated, page-aligned host allocation.
  5. The guest maps host memory only. VRAM is reached by the host alone.
    • What crosses the API (draws, uploads, didModifyRange: ranges and readbacks) reaches VRAM by the host's own GPU copies.
    • The guest maps memory only where Metal gives the app a pointer: contents of Shared and Managed buffers, and IOSurfaces the CPU locks. That memory is the runtime's Shared blocks: host-cached system memory the host's driver allocates, which QEMU maps into the device's pool range a block at a time (crates/reims-vgpu/src/pool.rs), and which the host GPU reads in place. The queues' rings, command buffers' bodies and libraries' staging chunks lie in the device's region (BAR 2) instead. Where the device offers no pool, Shared buffers and heaps lie in the region or in the process's own pages ("The Shared pool").
    • A Linux host needs Linux 7.2 or later, under any accelerator: before 7.2 a udmabuf over large pages is malformed, and an AMD GPU's import of the guest's RAM is bound to the wrong pages (qemu.md, "Linux hosts: guest RAM's pages and the kernel's release"). reims-ctl refuses a start on an older kernel (MIN_LINUX in crates/reims-ctl/src/runtime.rs), and QEMU's device its realize. The floor holds KVM's own for this memory too: before 6.13, KVM maps a page of a driver's mapping only where it can take a reference on the page, which the tail pages of the higher-order pages that the drivers on TTM (amdgpu among them) allocate lack, so the guest's first write to them stops its vCPU ("kvm run failed Bad address"; read from Linux 6.12's hva_to_pfn_remapped and ttm_pool_alloc_page).
    • Real discrete Macs keep Shared in system memory, so this is Metal's discrete model.
    • IOSurfaces are the one place the host reaches guest RAM: where the device has RGFX_FEATURE_SURFACE_PAGES, the host maps a surface's own guest pages for its GPU in place (Decided 14, "Today"), from the guest RAM's map QEMU gives it.
    • VRAM mapped into the guest was considered and dropped. It needed resizable BAR, and was good for guest writes only: measured on amdgpu, CPU reads from VRAM run at 15 MiB/s with memcpy, against about 10 GiB/s for writes. It returns only if a measured frame shows the GPU's reads of Shared memory across PCIe costing.
    • The BAR is one host memory region that the device reserves at start and registers with KVM once. Its blocks are ranges inside it, so making or freeing one never changes the VM's memory map. The pool's blocks do not lie in it: each piece of the pool is a RAM region of its own, which QEMU adds to the VM's memory map on its main loop as the pool grows and removes as the pool gives the piece back (crates/reims-vgpu/src/pool.rs, "The Shared pool"), and a block carved from a piece already mapped changes nothing. The BAR is ordinary cached memory on the host, and the guest maps it write-back where the kext asks for write-back. xnu's x86-64 pmap gives every page it does not manage, and the region is no RAM of the guest's, PAT entry 2 for any ask but write-combined (it sets PCD), and xnu's PAT holds UC- there. An AMD host's nested paging and Windows' hypervisor (WHP) apply the guest's memory type, where KVM on an Intel host ignores it for RAM-backed pages. So the x86-64 kext sets entry 2 to write-back on every CPU at its start, entry 6 left write-combining as xnu sets it, and again at each wake (guest/kext/src/RgfxPat.hpp, which lists what else entry 2 covers: device registers the host traps, where no memory type reaches a device, and RAM a driver asks uncached). xnu writes the PAT again only at a CPU's start and at a wake, and keeps a PAT whose entry 6 is write-combining; a CPU taken offline and back online keeps its PAT under KVM and WHP. Measured on 26.7.2 guests through entry 2: 43-46 GB/s for stores and loads on AMD KVM (the Radeon 780M host) and 16.5/8.8 GB/s on WHP (the UHD 630 Mac mini) with the rewrite, against 78-202 MB/s without it; Intel KVM runs at write-back speed either way. The rewrite takes 10.7-22.6 us a CPU. A write-combined ask takes, since the region's descriptor is physically contiguous and xnu's fault path maps such an object's pages in its own mode (read from the public xnu source: vm_fault's pmap_map_block_addr). With entry 2 UC-, measured on the Radeon 780M host, the guest's stores there ran at 13 MB/s and its loads at 8 to 180 MB/s, against 5.6 to 123 GB/s in its own RAM, and uncached loads cost 79-138 ns against 2-4 ns cached. So what a process's CPU touches most lies out of the region: its Shared and Managed buffers' slabs and its upload chunks in the pool's blocks, or in the process's own pages where the device offers no pool ("Managed storage"), and its indirect command buffers' slots in the process's own pages (ICB_SLOTS_IN_PAGES); and what the process only writes takes a write-combined part of its block, which the kext maps so (a submission ring's data, command buffers' bodies and a library's staging chunks; the bundle's RgfxRegion.hpp): measured on the 780M host, draws.10k's encode took 9.2-9.5 ms with everything in the region, 7.7 ms with the slabs and chunks in the process's pages, and 1.05-1.3 ms with those parts write-combined as well. The kext maps those parts from a descriptor of the region of their own: a mapping's cache mode is set on its descriptor's one VM object, for every page of it, so asked of the region's own descriptor it would hold for every region page faulted after it, and each later write-back ask would walk the object's pages to take it back (RgfxAccelerator::copyWriteCombinedRegion). The kext writes ring 0's submit data the same way on x86-64: the data's whole 4 KiB pages past its header's, through a write-combined map of a descriptor of their own, the header's page in the rings' write-back map (RgfxControlRing.hpp). A write-combined store is ordered with no later store, so the kext fences its stores (SFENCE) before it stores the producer: the host never sees the producer before the data it covers. arm64 maps no write-combined part, and its release store of the producer orders the data's stores before it. control_ring_test holds both orders, under each architecture's rules. Measured in Geekbench's Metal Super Resolution on the 780M host, a SubmitBatch call, the creates and destroys a commit posts there, took 33.6 us p50 (59.4 p90) with the data uncached and 31.3 us (58.2) write-combined, so the data's stores are a small part of it (15.2 us p50 on the Iris Xe host, whose EPT ignores the guest's memory type). The kext's kdebug stamps split the call (33.3 us p50 in the same benchmark): 16.1 us went to the look-up of the framebuffer, which every post made, 5.5 us to ring 0's doorbell write, an exit to the host, 4.7 us to the system call's entry and 3.4 us to its return, and 1.0 us to the data's stores. The look-up is the guest kernel's own code, 1.6-1.8 times slower on the 780M host than on the Iris Xe; the exits, entry and return cost the same on both hosts when warm, and grow after an idle. The kext now keeps the framebuffer it found started, and a commit behind held messages publishes its buffer in the same call ("A commit behind held messages is one call"), so the call now goes to the exits: 18.9 us p50 in the same benchmark (entry 4.6, ring 0's doorbell 5.4, the queue's doorbell 4.1 where the host's queue thread sleeps, return 3.3, the kext's own work about 3), and the benchmark's own doorbell calls fell from 763 to 166. A commit behind held messages, timed in the guest, took 17.4-18.0 us p50 before and 8.7-9.6 us after on the 780M host, and 15.1-15.2 us before and 8.8-9.0 us after on the Iris Xe (11-14).
    • The region is memory of QEMU's process, and the host side runs in that process. On Linux it is a shared mapping of a memfd of the library's (reims-vgpu-vulkan's RegionMemory): RADV refuses a pointer to a memfd's or any shared mapping (measured on the 780M and the RX 7900 XTX), and imports dma-bufs of each block's pages instead, which cost a submission the same at any size, where amdgpu walks every page of every pointer import in each submission; NVIDIA imports it by pointer. On macOS it is private anonymous memory.
    • Blocks are few and large, each imported into Vulkan once, and the guest sub-allocates buffers inside them. RADV lists every import in every submission, and an import costs 17-43 us plus about 16 us per MiB of fresh pages.
  6. Addresses and IDs. The guest bundle picks every gpuAddress and gpuResourceID, and the host pins them in metal2vulkan's own Metal address space. Creating a buffer then needs no round trip, and argument buffers need no patching. A pin lies where the guest picked it while a block the host knows holds its range; one no known block holds is made at the driver's own device address, which the guest's GPU work then sees in place of its pick, counted (reims-vgpu-vulkan's rt_platform::buffer, "A pinned address").
  7. Contexts. Every guest process that opens the device is a context, with its own resources, queues, and slices of the address and ID spaces. Sharing across contexts (IOSurfaces, shared events, shared textures) is explicit, by a global name.
  8. Shaders. AIR crosses once, named by its SHA-256, with each pipeline's descriptor and function constants. The host takes no keys or reflection from the guest, and answers once translation finishes, without waiting for the driver's compile.
    • The bundle resolves a function's constant values as Metal does, against the constants the library's own bytes declare (each function's CNST table): a value set at a constant's index (by index or by range) wins, else the one set under its name; values for constants the function does not declare are ignored; a value of another type than its constant's fails the function with Metal's error; a required constant with no value reads 0, and an optional one stays undefined. Each pipeline create carries one record per constant given a value, by index, with up to 32 bytes (a long4). A function made with no values builds no pipeline: Metal asserts there, and the bundle refuses it.
  9. Synchronization. The bundle sends Metal's own semantics exactly: tracking modes, resource usage, useResource/useHeap, memory barriers, fences and events. The host derives the Vulkan barriers. Shared-event values sit on a page the guest reads, so signaledValue needs no round trip.
  10. Device answers. One versioned blob at device open holds every answer, taken from the host GPU, and the bundle caches it.
  • The device shows the host GPU's real name, and claims the Apple GPU families the host platform claims, with every family and feature set those contain, as an Apple-silicon Mac of that generation answers. It invents no family of its own (owner, 2026-10-31).
  • An Apple family is claimed only up to the highest one whose rows in Apple's Metal Feature Set Tables the lane fully carries, and only where the platform claims it too; the iOS feature sets of a family not claimed answer no with it (2026-10-31). Apple1 answers as Apple2, as Metal does: the tables' first Apple column is Apple2.
  • No Apple family is claimed until the lane carries every piece of Apple7's rows and of the families' before it (2026-11-01). A Mac's GPU answers no Apple family (Intel, AMD) or Apple1 to Apple7 at least (Apple silicon), and the guest's frameworks choose their paths from those answers together. With Apple1 and Apple2 answered yes and Apple3 no, RenderBox made its passes' extra attachments memoryless and used them in a way Metal fails: every command buffer it drew an app icon in failed with MTLCommandBufferErrorInvalidResource, and the Dock's icons were blank (an x86-64 macOS 26 guest). With no Apple family, as an Intel or AMD Mac answers, they draw.
  • Today the lane carries Apple1's and Apple2's pieces (argument encoders, placement in Automatic heaps with the heap texture size, programmable sample positions, texture views and Metal IO queues; the IO queues are Metal's own over the bundle's device, with nothing on the wire) and binary archives, so it claims no Apple family. Apple3 waits on indirect command buffers. Each family's pieces are listed in device_info.rs (APPLE_PIECES), and the claim rises to Apple7 when the last of its pieces lands, then family by family.
  • Mac1, Mac2, Common1 to Common3 and Metal3 keep the platform's answer for now, though their rows need some of the same pieces: argument encoders for Mac1, Mac2 and Metal3, and the heaps, sample positions and IO queues for each of them.
  • architecture.name is the host platform's: Metal's own on a Mac, and on the Vulkan platform vulkan_ with the GPU's PCI vendor and device IDs and its driver's pipelineCacheUUID. The name keys binary archives, so it stays one GPU's from boot to boot and changes where compiled pipelines would (another GPU, driver or driver build). It names no Apple GPU.
  • Binary archives are the bundle's own (RgfxBinaryArchive): no compiled code crosses the wire, so an archive keeps the keys Metal looks each function's compile up by, per architecture, and writes them to a file of its own format. Its answers and errors are Metal's, measured on the M3 Max (guest/bundle/tools/archive_probe.m), including the miss of MTLPipelineOptionFailOnBinaryArchiveMiss. Apple frameworks that load one at start (IconRendering, RenderBox) get a working archive, not the base class's, which needs a target architecture the device has none of.
  • Where the lane's own device can do less than the host GPU, it answers no (Metal4, ray tracing, function pointers and dynamic libraries in render pipelines, and the rest). One table in crates/reims-vgpu/src/graphics/device_info.rs lists each such answer with what it waits on.
  • The guest's architecture, which the host names in the device's config (guest_arch, from QEMU's target), decides one answer: isFramebufferReadSupported is the host GPU's for an arm64 guest, as an Apple silicon Mac answers yes, and no for an x86-64 guest, as an AMD Mac answers (an Intel UHD 630 answers yes). CoreAnimation in an arm64 guest blends its generic shader against a destination it reads by framebuffer fetch, which it compiles in by this answer: with no, the menu bar drew black (2026-11-09).
  • It also decides the class of Mac the host's GPU device presents to metal2vulkan's runtime (GuestArch::mac_class), whose GPU results Metal leaves to the Mac's GPU: an Apple silicon Mac's for an arm64 guest, an Intel or AMD Mac's for an x86-64 guest, whatever GPU the host has. On Apple silicon a new Private texture reads Metal's fixed pattern where Metal keeps it compressed (an RGBA8Unorm one opaque magenta), blits through such a texture write three formats' canonical encodings, a half NaN clear keeps its sign, and a Clear load in a pass without a draw call reaches the whole level of a compressed texture and the render area's 32x32 tiles of another; on an Intel or AMD Mac a new Private texture holds what its memory held (zero, filled so, on an Apple GPU), blits keep their bytes, the NaN clear goes through half, and the Clear load reaches the whole level. The runtime fixes the class of a device as it makes it, so it is the process's, taken from its first graphics device; QEMU makes every device of a process for its own target's guests.
  1. Stage 2 lays the final transport. The rings, doorbells, interrupts, contexts and the display path are the final ones from stage 2 on, and stage 3 adds commands to them. The stage 2 display scans out host memory with no copy on its way to the host window.

  2. The stage 2 guest stack. The kext subclasses IOFramebuffer on our PCI device. It implements the required methods (modes, pixel format, aperture, cursor, vblank and connect interrupts, display info), and matches with a probe score above Apple's generic IONDRV driver, which matches any display-class device. WindowServer composites in software with no Metal device: x86-64 macOS 26.5.2, 26.6.1 and 26.7.1 reach the desktop that way ("Software compositor activated"; measured).

  3. Loading: through OpenCore, bound by Graft. OpenCore injects kexts into the Boot kernel collection and links them only against Boot-collection symbols, but a display kext uses IOGraphicsFamily and AppleGraphicsDeviceControl, which are in the System collection. So ReimsGraphics is built with Graft's consumer rules (guest/graft/sdk/consumer.mk): its System-collection imports point at placeholders inside the kext, and it carries a manifest (__DATA,__graft) of every imported site and of the library classes it derives from, with no System-collection OSBundleLibraries. Its personalities stay, each gated by an IOPropertyMatch requiring ai.aneesiqbal.ReimsGraphics.graft-bound on its provider, and the manifest carries each personality's provider matching (its IOProviderClass and IOPCIPrimaryMatch: the 1234:5247 device). The personalities hold those and the keys that name the driver (IOClass, CFBundleIdentifier, IOProbeScore, IOMatchCategory) alone: the accelerator sets its driver keys on its registry entry in start ("Stage 3 accelerator kext"). OpenCore links that dormant kext in the Boot collection. Graft (guest/graft, a copy of Graft's release build) starts from its own kext start and finds ReimsGraphics among the placed kexts by its manifest. Once the libraries are registered, it checks each parent class's size and vtable against the running library, resolves each site by name, writes the sites and vtables, then sets the gate property on each nub a personality's provider matching matches, the 1234:5247 nub, and registers the nub again. The registry root's GraftClient.ai.aneesiqbal.ReimsGraphics reads bound: imports and vtables committed; waiting for a provider of personality <names> to open the gate once the sites and vtables are written while no such nub is published yet, and bound: imports and vtables committed; activation gate open on a provider of personality <name> once the property is set on one, which the lane gate's graft-bind check requires. Until then the passive property match fails, so IOKit does not even construct ReimsGraphics' classes, whose parent constructors run through the sites (an IOResourceMatch would hold back only start()). On a missing symbol or a layout that differs, Graft declines ReimsGraphics by name in its log and in the registry root's GraftClient.ai.aneesiqbal.ReimsGraphics, and the guest boots on. The image carries the set make -C guest set builds, in this order: Graft.kext, ReimsGraphics.kext and RgfxGate.kext. OpenCore injects it from Darwin 20 (macOS 11), the releases whose x86-64 matrix row passes in full (MIN_KERNEL in guest/tools/prebuilt.py); a release joins once its row passes. Nothing of the guest OS is patched or hooked beyond what Graft does for these two.

    • Iterating: patch a copy of a VM's OpenCore image directly (scripts/internal/opencore-add-kexts.sh). No rebuild inside the guest. Graft reads the sites from the kext's own manifest, so a new ReimsGraphics binds without a new Graft. Swap in the kext make -C guest/kext builds: that build stages it dormant with its manifest. A kext built without Graft's rules carries personalities and System-collection libraries, which OpenCore refuses.
    • Checking: make -C guest set-check links the set into a release's Boot collection with OpenCore's own linker, in user space, and checks with Graft's graft-kext check-prelinked, built from the SDK's sources, that the manifest and every site survive it.
    • Shipping: the repository carries the set prebuilt in guest/prebuilt, with its Kernel > Add entries in set.toml and the record of its sources in sources.toml (make -C guest prebuilt; make -C guest prebuilt-check fails when they differ from the tree). reims-ctl adds the set to an image, since a Linux host cannot build it.
    • Arm64 guests: the same sources build for arm64e (ARCH_NAME=arm64e) into a second set, guest/prebuilt-arm64e (make -C guest prebuilt-arm64e), for the arm64 guests from macOS 14 that Ambrosia boots (arm64 macOS 11 to 13 are not supported for now: 13.6 offers the device no MSI, and the kexts have no INTx path); Ambrosia's config bundle adds it to the guest's kernel collection (docs/qemu.md, "arm64 guests"). An arm64 kernel collection has no AppleGraphicsDeviceControl and no IOAcceleratorFamily2, so the arm64e kext has a Graft declaration and an Info.plist of its own (src/graft-arm64e.json, src/Info-arm64e.plist): IOFramebuffer and IOAccelerator from IOGraphicsFamily, and no device control. The set starts with Graft's arm64e build, Graft-arm64e.kext from guest/graft, which starts each library the arm64e manifest declares, IOMobileGraphicsFamily among them, before it binds against it.
    • The arm64 display (owner, 2026-11-08): an arm64 WindowServer drives no IOFramebuffer (measured on 27.0.1 with SIP on: a bound IOFramebuffer consumer got no user client, and the system had no IOFramebufferUserClient with WindowServer up), so the arm64e display is an IOMobileFramebuffer: a subclass of IOMobileFramebufferLegacy, as Apple's own paravirtual display, AppleParavirtDisplay, is on every release from 13 to 27. Its vtable grows release by release (Legacy's has 445 slots on 13.6 and 484 on 27.0.1), so Graft builds the subclass's vtable from the live parent at bind time and places its overrides by method. The front end (ReimsGraphicsMobile.cpp) publishes the display as the paravirtual display does: its attributes, and its modes as IOAVFamily's timing and colour elements, a timing for each mode the device lists and one 8-bit colour mode. WindowServer sets one of them by its colour and timing IDs (set_digital_out_mode), which the device then shows by SET_SCANOUT, as x86-64's setDisplayMode does. The display is external and plugged in from its start (hotPlug_notify), as the paravirtual display's are: WindowServer reads an external display's modes, and sets one, at its start and at each hot-plug notice, and asks for an internal display's notices only on 27 (QuartzCore's AccelServer and IOMFBDisplay). The display starts in its preferred mode (start_hardware), which WindowServer then sets.
    • The arm64 display's cursor and mode changes, as the paravirtual display has them: a swap's layer 1 is the display's cursor (RgfxMobileCursor.hpp), and the display publishes CursorPlane. A swap that gives layer 1 sets the device's cursor from its surface's image (SET_CURSOR, through the cursor's slot) and moves it (MOVE_CURSOR, the swap's place plus the hot spot), or hides it where the layer has no surface; a surface with no image is shown as the swap's in place of layer 0's. A change of the device's modes (DISPLAY_CHANGED, as a resize of the host's window makes one) publishes the display's attributes and modes again, shows the new preferred mode where the device no longer lists the one shown, and tells WindowServer through the class's hot-plug notice (hotPlug_notify) and kIOMessageServicePropertyChange.
    • The arm64 display's colour. WindowServer sets its accessibility matrix with each swap until the call succeeds (swap_set_color_matrix, function 2), and the display shows it as the device's DISPLAY_COLOR matrix stage, applied to the surface's encoded values (RgfxMobileColor.hpp). WindowServer also sets an ICC chain by set_block: per layer, a Src2XYZ curve and matrix and an XYZ2Blend matrix and curve; for the display, after the layers are blended, a Blend2XYZ curve and matrix and an XYZ2Device matrix and curve; and tone map, user gamma and black point stages between. The blocks' numbers are the release's: 26.6.2 and 14.6.1 number each block one below 27.0.1 (matrix 0x32 and curve 0x33, against 0x33 and 0x34), 14.6.1's curve block is 0x248 bytes where the others' are 0x290, and its curve stages from Blend2XYZ on sit one lower. The display reads each block in its release's numbering, by the kernel's major version, for the releases measured, and refuses every block of another release and every location not measured on its own. The class answers every block kIOReturnUnsupported, and WindowServer logs "Failed to set ICC matrix" or "curve" for each refused block of the four colour-space locations. In every burst measured on 27.0.1 (three at login, and one after each switch of the display's profile to Generic RGB, to Display P3 and back), layer 0's half and the display's half are each the identity: WindowServer composites in the profile's own space. The display applies no chain to layer 0 or the display's half. It takes a block there only where the chain the block leaves is the identity, and so is what the display shows. The halves are judged as pairs, because WindowServer sends each half's first block before its second: the first is held, and the second is taken where it inverts the first (matrices' product, and curves' composition at 1025 inputs, within 2^-14). The cursor's layer 1 is the exception: its standard-sRGB source is not what the display's blend space inverts (0.0024 off at login, from the published white, and 0.25 to 0.35 after a switch to Generic RGB or Display P3, whose curve differs from sRGB's too), so where the host took CURSOR_COLOR the display takes each block of layer 1's chain it reads, and the host converts the cursor's image through it ("The cursor's colour"); where it did not, layer 1 is judged as the others are. It refuses the rest, as the class does: user gamma (the curves CG's transfer formulas and tables set), and what it cannot read (RgfxMobileICC.hpp). So a login logs no "Failed to set ICC" line where it logged 32 before (one, the cursor's matrix, on a host without CURSOR_COLOR), and the host's colour stages stay off: the accessibility matrix stays alone in the matrix stage.
  4. IOSurfaces follow the discrete model. IOSurface.kext allocates surfaces in guest RAM, CAMetalLayer drawables and window backing stores included. The accelerator gets a per-surface device cache with a sync callback when the CPU locks the surface. So a surface's guest pages are its CPU copy, and its GPU copy lives in VRAM as the device cache, synced at the points IOSurface and the bundle define: CPU lock and unlock, and the GPU's use of a CPU-written surface. Surfaces the CPU never touches are never copied. A surface the GPU renders and the CPU locks is two copies synced at lock and unlock, as Managed textures are. A texture over host memory (over a Shared buffer, or a CPU-locked surface) follows metal2vulkan's host-page rules: in place where only sampled, otherwise a shadow copy that is announced. Stage 2 needs none of this, since its compositor is software.

    • Today: the GPU works on a surface's own guest pages in place, and copies them only where the host cannot use them. Where the device has RGFX_FEATURE_SURFACE_PAGES and the host's linear textures can lie over every plane (the base is a page's, each plane's offset from it and its rows are multiples of the host's linear texture alignment, every plane lies in the allocation), the bundle asks the kext for the surface's shared block in place. The kext wires the surface's whole allocation (on x86-64 it first faults in the pages from the last down, so that the kernel lays them out in runs of a 16 KiB clump: RgfxTopDown.hpp), writes its page runs into the block past the part the processes map, and hands them to the host (SURFACE_PAGES, answered), which maps them as one view. Each process's buffer lies over the view (BUFFER_OVER_SURFACE_PAGES), and each texture over its plane's own offset and rows. The block holds only the header and the writers, and nothing is copied or synced: the GPU and every CPU use the same pages, so such a surface has no GPU copy to keep in step. A surface whose layout misses the host's alignment, a device without the feature, or pages the host refuses (not whole pages of guest RAM, or a view it cannot map) keep the copy below; so does every other holder of that surface, since the kext gives a surface's blocks in one mode.

    • The copy: a surface's GPU copy is one region block, holding every plane in plane order, that every process holding the surface shares (the kext's, found by plane 0's pages; "Processes name only their own"), so one process's GPU writes reach another's GPU with no copy, and a texture over one plane that reads another (a two-plane YCbCr texture over plane 0 would read plane 1's chroma; the bundle ends the process at one, as the x86 Macs do, dgpu-oracle.md Q13) finds both in one buffer. In either mode, its TEXTURE_FROM_IOSURFACE carries the surface's facts (RgfxSurfaceFacts: OSType, planes, size, plane 1's place, YCbCr matrix), which the host's surface creator reads as Metal reads the surface. The copy syncs from the pages before a commit where the surface's seed moved since any holder synced it, and back to the pages, with no lock of the surface, at the completion of each command buffer that writes it. The block's header holds the seed every holder agrees on (guest/bundle/src/RgfxIOSurface.h). Moving the copy's write-back to the CPU's lock (the device cache's op 0) is what is left of this item.

    • CPU locks wait for the GPU's pending writes, as Metal's do on the x86-64 Macs (measured on a MacBook Pro's AMD Radeon Pro 5300M and Intel UHD 630 under macOS 26.7, guest/bundle/tools/lock_probe.m). Where the Macs measured agree, their answer is the contract and is kept exactly; where they differ, the docs promise neither answer and the cheapest one within them is taken:

      • a read-only or read-write lock of a surface, in any process, returns once every buffer that writes the surface has finished and its results are in the pages. The AMD, the Intel and the M3 Max agree: contract, kept exactly;
      • a pending buffer that only reads the surface holds no lock. The AMD and the Intel agree; the M3 Max's read-write lock waits for it. Divergent, so the cheaper rule, which tracks writes only. A buffer writes a surface it draws to, a blit writes to, it uses with Write usage, or binds where a draw's or dispatch's function declares a write or read_write texture: the bundle reads each entry point's arguments from the AIR metadata of its bitcode in the .metallib (guest/bundle/src/RgfxAirArguments.hpp), since the host gives no binding reflection. Those declared under function constants are the function's whatever the constants' values. Where the arguments do not read (a binding of a kind the reader does not know among them), or a written texture's binding index is an expression of function constants, a bound texture counts as written where its usage has ShaderWrite or is unknown. A surface used without Write usage counts as written at a draw or dispatch whose function's arguments do not read or whose argument buffer may write a texture: Metal takes useResource's usage for the app's promise, but a discrete Mac's driver lands a write the promise left out. Narrowing may only drop a write the function cannot make. The same rule decides the copy's write-back: a buffer writes a copy back to the pages only where it writes the surface, never for a surface it only reads;
      • the committer's own lock waits from the buffer's submission on. At the commit itself the AMD's returns at once, a race. Loose: ours waits from the commit on;
      • a read of the pages with no lock after the buffer completes sees the GPU's pixels on ours and stale ones on the AMD and the Intel. The docs ask for a lock before the CPU reads, so either holds.

      The kext drives IOSurface's device caches as those Macs' drivers do (measured with fbt on the AMD's IOAcceleratorFamily2 and the guest's IOGPU; the kext's RgfxIOSurfaceKPI.hpp). At the first write a process names of a surface's shared block, the kext looks the surface up by the IOSurfaceID the process gives and takes it only where its memory holds the block's first page, makes its device cache for the accelerator with the kext's control function, and keeps both with the block. Each write named marks the cache current, which moves the surface's seed once, as Metal's submission does, and has IOSurface call the control function in every CPU lock of the surface: op 2 waits while a write is pending, and op 3 releases the reference IOSurface took on the cache for the lock, or for a purgeable change (ops 6 and 7), as the AMD's driver does. A write retires at the bundle's retire call after the buffer's completion and write-back, or, for a surface drawn in place, once the queue's completion ring's completed_seqno reaches the buffer, whichever comes first. A lock waits with no deadline until the device has completed every pending write's buffer, however long the host takes, a compile the buffer waits behind among it, as Metal's lock waits for the GPU's writes; then it waits 2 s at most for the bundle's retire, so a process that locks a surface on the thread that would retire its own writes goes on, with an "RGFX: WARN" line (guest/kext/src/RgfxAcceleratorLocks.cpp, rgfxLockGivesUp). The device's stop and the locking thread's abort end the wait.

    • The device cache: every host that maps the surfaces' pages has RGFX_FEATURE_SURFACE_CACHE, within a budget on any GPU (Device caches on a GPU that shares the CPU's memory, below), and a block the kext marks cached (RGFX_SURFACE_PAGES_CACHED) gets a device cache on the host: a Private buffer of the surface's bytes, which every buffer over the block is, so every texture over the surface, of any shape, plane or format, lies over the same bytes. The block's SURFACE_PAGES carries the surface's RgfxSurfacePagesLayout where the bundle gave it, a deferred block's too, and the host lays the cache out by it as by an ask's layout (below, Device caches on a GPU that shares the CPU's memory): its first plane's first byte where the host's GPU's textures over the cache may start in place, as CoreVideo lays a frame's planes 32 bytes into their surface, past every linear image's alignment measured (128 bytes on an RTX 5080 Laptop GPU, 256 on RADV), so the textures over a decoder's planes are images of the cache's own memory, not the runtime's shadows, which copy them in before each command buffer's use; and its copies into the pages take the surface's texels alone, each plane's rows, so its buffer declares the bytes between a texture's rows unobserved, and a texture whose rows lie with bytes between them may be an image over the cache's memory too, where the runtime makes one (on an RTX 2080 it makes none, for reasons of its own: decode::surface_cache). Where a plane's rows lie at another pitch than the GPU's own linear images lay them (CoreAnimation names its backing stores' rows at multiples of 64 bytes, and RADV lays its images' at 256), the host lays the cache's planes out at the GPU's pitch instead, each texture over a plane at the same byte of the same row there, and the cache's copies move each row between its place in the pages and its place in the cache (decode::surface_cache, "Laid out at the GPU's pitch"). A texture over the surface that does not lie in its plane's texels there (wider than the plane's row, or taller, which Metal makes inside the surface's rows) lies over the block's wide home at the surface's own place and pitch: over its view of the pages where it has one, else a stand-in of their layout; each encoder that writes through either side is followed in its command buffer by a copy of its texel rows into the other (decode::surface_cache, "Wider than the plane"; dgpu-oracle.md Q37). The answer is that of a message with no layout. Each command buffer names the cached surfaces it uses (RGFX_OP_SURFACE_USE), on the arm64 device those committed to a residency set it uses or its queue holds among them (named as read, a set carrying no usage: a shader's write to a cached surface the buffer reaches only through a set is not downloaded at the CPU's next lock, where Metal on an Apple GPU shows it; naming every member as written would download each at every lock), with the kext's count of the surface's read-write locks when it was committed; the host fills the cache from the pages before the first buffer of a newer count, on its own transfer queue, after every buffer that used the cache before. A new cache is made as zeros and owes its first fill from the pages, as of the count in the block's header then, which the first thing that reads it makes: a named use, a present, a buffer of render, compute or blit work in the process that made the block's first buffer, and a buffer over the block in any other, so a texture that a buffer reaches through an argument buffer with no useResource: (which no RGFX_OP_SURFACE_USE names) reads the pages. A buffer of decodes alone that writes the whole of both planes of a new two-plane 4:2:0 surface (a decoder's new output) takes the fill as met instead: its picture lands over the zeros, and the cache's copies into the pages copy those planes' rows alone from then on, so the pages' other bytes (CoreVideo's header) stay as the CPU wrote them; a decode that answers no picture makes the fill. A block named again over the same pages is filled again, as of the count then. The count moves at a read-write lock, and IOSurface calls no control function at its unlock, so a fill made while a CPU holds the lock (a buffer's committed then, or one the host makes at that count for its own reasons: the first fill a block owes, a block named again) holds the pages as they were mid-write. Where the kext took RGFX_FEATURE_SURFACE_REFILL, each count has a refill record in the block's header (the bundle's RgfxSurfaceHeader, which the kext's count shares; the kext's RgfxSurfaceRefill.hpp): the kext writes it as it caches the block and at each read-write lock, before the count, with the surface's unlock seed then, which the lock's unlock moves (the kext moves the count inside the lock, before IOSurface moves its lock seed). A commit that names a count whose record is not settled reads the surface's lock and unlock seeds from the kext (kRgfxAccelMethodSurfaceSeeds); while the unlock seed is the record's, the lock held or being taken, it asks nothing, and the first commit once it has moved past it, in any process, carries RGFX_SURFACE_USE_REFILL and settles the record. The host then fills the cache again at the count it holds, unless a buffer that may write it was committed since the cache was last copied into the pages, whose write a fill would lose: it keeps the cache, as without the flag. Both are counted, the bundle's in its surface copies' summary and the host's in the caches' (reims-vgpu's surface_cache.rs, "Refill"). The pages are written from the cache only at SURFACE_DOWNLOAD, which the kext asks at a CPU lock that follows a GPU write, and at the block's BLOCK_RELEASE, and only where a buffer that may write the surface was committed since the last copy (reims-vgpu's graphics/decode/surface_cache.rs). The one exception is a surface the CPU reads back after each GPU write: once a download copied a write that was the only one since the cache's last copy, the next command buffer that is again the surface's only writer is followed by a copy of the host's into the pages, which starts as the write ends, and the lock's download is answered as that copy lands; a write no download followed stops it. A writer that holds a video encoder has the copy on its own queue; any other's goes on the host's read-back queue, waiting on the GPU for the writer, so the writer's queue goes on behind it. A write the host's own devices make into the pages (a video device's frame, in a CPU lend or by a device of the host) moves no count: the host watches each cache's pages, and such a write has the cache's next use fill it whatever the count, and keeps a download or a release before that from copying the cache over the write (reims-vgpu's device_writes.rs). Each choice, by what real GPUs show (M3, AMD and Intel Macs):

      • Contract, where all agree: a CPU lock after a GPU write sees it, and a GPU use after a read-write lock sees the CPU's writes; the seed moves at a read-write lock (not at its unlock), not at a read-only one, and by one at a GPU write's commit (the kext's).
      • Loose, where they diverge, the cheapest chosen: a CPU write without a read-write lock reaches the GPU only at the next fill, as on a GPU of its own memory (the M3 sees it at once); a command buffer committed before a CPU write and still running reads what it read, since a fill waits for it; a buffer committed while a CPU holds the surface locked for writing reads the pages as they were then, and the CPU's writes after it reach the first buffer committed after the unlock that names the surface (the refill, above), whatever filled the cache while the lock was held; a buffer of an older count taken after a fill of a newer one (two queues' buffers committed apart and taken in the other order) reads the newer bytes; a download of a cache nothing wrote since its last copy copies nothing; a decoder's new output whose picture fails to land, lands short of its planes, or lands with its copy into the caches skipped (the runtime made no blit encoder for it, docs/video/devices.md), reads zeros where the picture did not write, where the pages would give their bytes (Metal leaves a failed decode's output undefined, and a new surface's texels are the kernel's zero-filled pages unless its client wrote them under a lock, which moves the count and has the decode's use fill the cache); and a host whose GPU shares the CPU's memory keeps no cache of a surface past its caches' budget, which lies in place as above (below).
      • Which surfaces are cached: the guest's choice, and the host's invalidation. The bundle asks every block in place cached, of any planes and format, as a GPU of its own memory keeps a copy of each surface it uses: the windows, layers and drawables the guest's compositors and apps draw, and video frames, which the GPU writes as a decode's output or a conversion's destination. Measured on the RTX 5080: VideoToolbox's 10-to-8-bit conversion of a 1080p frame into a 420v surface not cached takes 4.8 ms of the GPU, its writes crossing the bus into the pages. The outputs of the bundle's own video driver ask no cache where the host lands no picture in one (no RGFX_VIDEO_CAPS_OUTPUT_CACHED, item 16), its decode writing their pages: their textures ask under RgfxAskUncachedScope. A host whose hardware video lands pictures in device caches says the flag wherever the kext makes them, of every surface (SURFACE_CACHE, on every host) or of those the host answers need one (SURFACE_CACHE_REFUSED), where the outputs then ask with their layout as any other surface does. Correctness does not rest on that choice: a surface a host-side device writes (the M2 scaler, the VideoToolbox decoder) may be cached all the same, and the host invalidates the cache of a block whose pages such a device wrote, so the next SURFACE_USE fills it from the pages and a download copies nothing. The device says RGFX_FEATURE_SURFACE_CACHE only with that invalidation in place.
      • The guest's side: the kext makes a cached block's IOSurface device cache with the block, and its control function, at op 2 of a CPU lock once the GPU's writes are done, asks SURFACE_DOWNLOAD where the GPU wrote the surface since the pages last took the cache, and waits for the answer, one lock of a surface asking at a time. A read-write lock then moves the surface's CPU generation, the count the kext writes into the block's header for the processes. IOSurface calls op 2 at every read-write lock of a surface with a device cache, current or not, and at a read-only lock only where a GPU write made the cache current (RgfxIOSurfaceKPI.hpp), so the count misses no read-write lock and a read-only lock after a GPU write downloads. Once the block's last holder lets it go, the block sleeps rather than going: dormant, it keeps the host's cache, its generation and its watch of device writes, the kext keeping the surface and its device cache retained and the surface's memory wired, so its IOSurfaceID and its cache are no other surface's meanwhile. The next ask of the surface, which IOSurface answers with the same device cache, holds the block again (BLOCK_SHARE with no SURFACE_PAGES), and the cache is used again rather than made and filled anew, as a GPU of its own memory keeps a surface's copy past the textures over it: in a window drag 98% of the blocks asked were such a surface's, most back within 100 ms. A dormant block is let go on the release thread, never in IOSurface's call: at op 5 (a client of the surface going, or the surface made nonvolatile after empty); at op 7 to empty, and a surface made empty while held does not sleep; at its sleep where the surface has no client left, its last gone while the block was held (IOSurface's client count, read once there); past 1024 dormant blocks or an eighth of the guest's memory in their surfaces' wired bytes, and where the table or the region has no room for a new block, those of surfaces made volatile first (IOSurfaceRef.h lets a volatile surface's contents go), then the oldest; where an ask of the pages names another cache or the other mode; and once it has slept 10 s (kRgfxDormantAgeMs), the host's age for a shape no texture references, on a timer armed for the next block's age, and for none while no block sleeps. Made nonvolatile again (op 6, or op 7), a surface is neither volatile nor empty for this. A let-go block's BLOCK_RELEASE copies the cache into the pages where a buffer wrote it since the last copy, and a lock waits for the answer. Of the blocks let go for their age, one whose release copies is in flight at a time, the next let go at its answer, so the dormant blocks a close leaves, which age together, copy one after another rather than as one burst of releases beside the frames; one that copies nothing goes at once. The surface's next ask then takes a new block over its pages, which hold its bytes. The host makes the releases' copies one at a time, each once the last has landed and as long again as it held the GPU has passed, or 2 s after its ask at most, so a burst of let-gos leaves the GPU to other work, the host's NVDEC among it, between them (reims-vgpu's surface_cache.rs, "Releases' pace"). The kext releases the device cache, then the surface, then unwires the memory. Where the surface has no client left as the release is posted, the release says so (RGFX_BLOCK_RELEASE_NO_CLIENT), and the host copies all the same, counting it: a mach port or an XPC object holds a surface with no client, and a process that looks the surface up from one reads its pages (a Dock icon showed another app's icon, the bytes its pages held before the GPU drew it, while the host dropped such a cache uncopied). The kext logs the dormant blocks' count and the let-gos by cause, and, for eight a minute at most of those let go for their age with clients of the surface left, which processes with a context open find the surface by its ID. Op 6, which IOSurface calls as a surface turns nonvolatile again, is answered as the AMD's driver does (a byte set to 0xff), so IOSurface answers the old state volatile, after volatile and after empty alike, the contents kept, which IOSurfaceRef.h's old states allow. A present of a cached surface carries its generation. In the bundle, a commit names each cached surface its buffer binds, attaches, blits or declares it uses, with the generation the header holds and whether the buffer writes it, before the first encoder; and a texture's own CPU access (getBytes, replaceRegion) locks the surface as a CPU access does (guest/kext/src/RgfxSurfaceCaches.hpp, guest/bundle/src/RgfxIOSurface.h).
      • Deferred pages: a fresh surface only the GPU touches has no guest pages until a CPU lock needs them, as on a GPU of its own memory (the AMD 5300M's footprint grew 0 KiB from a 3840x2054 surface's first GPU use). Where the kext took RGFX_FEATURE_SURFACE_DEFERRED, and no IOSurface mapper device (IOSurfaceParavirtMapperService) is matched, a cacheable ask in place of a surface that reads fresh (its seed 0, none of its pages resident, compressed or paged out) defers its block: the kext makes the device cache and sets its control function first, then reads the seed and the pages' counts under a read-only lockSurface, which waits out any lock calling the control functions, so a read-write lock either moved the seed before the read or calls the control function after it (RgfxIOSurfaceKPI.hpp). A page a writer that takes no lock dirtied is resident, or, compressed or paged out since, counted so, and holds bytes the cache's zeros would lose. The kext counts only a surface whose memory is a buffer the kernel allocated (IOBufferMemoryDescriptor, anonymous memory, never a client's own, which may be a file's). It counts them on every kernel the same way: it maps the memory read-only into the kernel's map for the count (IOKit puts a pageable buffer's kernel mapping inside one of its pageable maps, a submap of the kernel's, which the kext finds through IOIteratePageableMaps), and mach_vm_region's VM_REGION_EXTENDED_INFO walks the mapping's regions, which count each page resident or compressed or paged out (pages_swapped_out; measured on 11.7.11 against each page's disposition, with the pages in the compressor and on swap). mach_vm_region and kernel_map are strong imports from com.apple.kpi.unsupported, which every release kernel checked exports (x86-64 11.7.10 to 26.7.2, arm64 13 to 26). The regions must be the mapping exactly, none a pager's: a region past it, a gap, or one with nothing to count refuses the count. A surface not counted is never fresh, so its block's pages are named at its ask (guest/kext/src/RgfxAcceleratorLocks.cpp). Found fresh, its SURFACE_PAGES carries DEFERRED and no runs, the block keeping room for one run a page of the whole allocation, every plane's; the host makes the cache as zeros. Not fresh, or refused, the kext names the pages at once, as for any block. A surface no CPU lock touched may still have a few pages resident, written by a process that takes no lock: measured on the 780M, VTDecoderXPCService writes page 0 of each new decoder output before the first decode (all 208 of a 4K HEVC session's in Safari, macOS 26, the other pages never resident), so a test of no page resident named each one's 12 MiB at once, wired and filled with zeros (5 to 7 ms of the guest's each). Where the kext took RGFX_FEATURE_SURFACE_DEFERRED_CARRY, the bundle's cacheable ask lists after the layout the surface's resident pages it finds in its mapping (mach_vm_page_range_query), 16 at most, and the kext defers a surface fresh but for them: under the same read, the fresh test's own verdict on its counts with as many pages resident as listed and none compressed or paged out (so where nothing is counted nothing is carried), the listed runs wired with kIODirectionPrepareNoFault, and the counts read again after the wire the same, so a listed page not resident either fails the wire or, faulted in, raises the count, and a page written or compressed meanwhile shows too (measured on a macOS 26.7.2 guest: such a wire fails, kIOReturnNoResources, faulting nothing in; guest/kext/src/RgfxDeferCarry.hpp). Its SURFACE_PAGES then carries DEFERRED with runs: the surface's bytes in order, each carried page at its guest address, every other run RGFX_PAGE_RUN_ZEROS. The host makes the cache of zeros and copies the carried pages into it as a new cache's first fill, after the zeros: before what reads the cache next, or never where a decode writes the planes whole first. The kext keeps the carried pages wired until the block's pages are named or its release is answered, and lets them go at a refusal; any other read, a wire refused or a page faulted in names the pages at once, as before. A deferred block is found by its surface, never by pages, and its holders wire none. Its first read-write lock, or a read-only one after a GPU write, wires the pages and names them (ATTACH) before it goes on, one lock at a time, under no lock of the contexts'; a read-only lock of a surface the GPU never wrote names none, a fresh page reading as the zeros the cache holds. A dormant deferred block stays at a client's going (op 5) while others are left. Its release names its pages first where the GPU wrote it and the surface is retained past the kext's own three references (the table's, the device cache's, and the release thread's), so the release copies the cache into them; else nothing reads them. Deferred blocks fit the host's budget (DEFERRED_BUDGET_LO and _HI), held and dormant, and dormant ones are let go past the smaller of half of it and an eighth of the guest's memory, the cap of the other dormant blocks' wired bytes, the oldest first (guest/kext/src/RgfxSurfaceBlocks.hpp), and once they have slept 10 s, as every dormant block is. Only the host's cache holds a dormant deferred block's bytes, so the guest's cap and the age bound what the host keeps for surfaces no process holds, and how long. Half the budget alone is sized by the host GPU's memory and left the count of 1024 to bind: after the browser closed, the dormant blocks' caches held 3,862 MiB of images on the host, on an 8 GiB arm64 guest (measured, macOS 27.0.1 on an M3 Max, walk m3-max-63600).
    • Device caches on a GPU that shares the CPU's memory: such a host offers SURFACE_CACHE, SURFACE_DEFERRED and SURFACE_DEFERRED_CARRY, as a GPU of its own memory does, so the kext caches every surface it asks cached and defers the fresh ones. A Mac on an Intel GPU, whose GPU shares the CPU's memory, does the same: it keeps a GPU copy of each IOSurface the GPU uses, in the GPU's own tiled layout, made with the first texture over it, and copies it into the pages at a CPU lock after a GPU write, so a surface both drawn and locked costs twice its bytes (measured on a MacBook Pro's UHD 630 under macOS 26.7.1, jobs m3-max-37817 and 37822: a 4K read-only lock after a GPU write took 2.2 ms warm and 6.7 ms clocked down, and the GPU's fills of the copy ran at 1.0 to 1.8 times those of a Private texture, where ours over the guest's pages on the Iris Xe run at 4.1 times). On the Iris, 96.5% of Launchpad's GPU writes land in three compositor surfaces the CPU never locks, which a cache keeps in the GPU's memory (lane tiledlock, jobs m3-max-37869 and 37870). The caches fit one budget together, deferred or not, on any GPU, a share of the GPU's memory budget as the platform answers it at the device's start. They are host RAM beside the guest's pages here, and the budget is half of it, twice the deferred blocks' (a quarter held a WebGL page's surfaces in place on a Radeon 780M with an 8 GiB guest, at 1385 MiB, and its frames fell from 33.0 to 24.6 a second; unbounded, the caches held 1762 MiB at most, jobs m3-max-38033 and 38034). On a GPU of its own memory they are that memory, beside everything else the runtime places there for the guest, and the budget is two thirds of it: unbounded on a 4 GiB Radeon RX 550, the caches were the most of what QEMU asked of the card when it asked for more than the card has (a browser's 3D page and a video), and two thirds lies under what they hold that no budget can trim there (jobs m3-max-63976 and 64138; reims-vgpu's graphics.rs, cache_budget). A cached block past it gets no cache and lies in place in its pages, its buffers over its view, as where the platform makes no cache; a deferral past it is refused, and the kext names its pages. In the per-shape form, the Vulkan platform's, every block keeps its cache past it, and the budget trims the shapes no texture references instead, least recently used first (reims-vgpu's decode/surface_cache.rs, "Within a budget"). The device's summary of its caches counts the blocks past the budget and the most bytes the caches held.

      Before 2026-11-16 such a host offered the mode below instead, which the kext and the host still carry out and no host offers now: SURFACE_CACHE_REFUSED, a cache only of the surfaces whose pages its textures could not use in place. There a surface's textures use its pages in place, but not every surface's can. The runtime makes a texture over pages it cannot place one over (rows that end inside the line of memory the GPU writes back whole, on an Intel GPU; more pieces than one dma-buf takes, on RADV) its own copy, a shadow, which every command buffer copies in before its first use and merges back after a write. Such a surface takes a device cache instead, copied only at CPU locks and unlocks, as on a GPU of its own memory: IOSurface's own protocol, with no tracking of its own, while every other surface stays in place. The host offers RGFX_FEATURE_SURFACE_CACHE_REFUSED and not SURFACE_CACHE, and decides surface by surface: the kext asks at a new cacheable block in place (RGFX_SURFACE_PAGES_ASK_CACHE), with the surface's planes as the bundle gives them (each plane's offset, rows, row pitch and the bytes of a row's texels), and the host maps the pages and asks its platform whether textures over them, for any access (a read, a render, a shader's write), lie in place (GpuDevice::surface_pages_in_place; the Vulkan platform's gpu/pages_in_place.rs, which asks the runtime where a texture over each plane lies, as its making decides: the device's check of the pages, the rows' pitch and place, the texels' reach). Where they do, where the runtime's verdict is not known yet, or where a texture over a cache would be the runtime's copy too, it answers OK, the block in place. Where they do not, it answers RGFX_STATUS_CACHE, its view of the pages left in its cache of views, and the kext makes the surface's device cache and posts the block again cached, which takes that view and the host's cache, kept from then on as above. It answers RGFX_STATUS_CACHE too, with no view made, where the platform has no room for the view's kernel mappings (HostVm::view_room; on Linux the views' budget short of its headroom, which Intel's ANV, importing a view's pages only mapped from their files, a mapping a run, reaches at a stock vm.max_map_count; a view one udmabuf holds, within 1,024 runs and 64 MiB at its stock limits, takes one mapping instead on a device whose textures over it lie in place, ONE_DMA_BUF_VIEWS, ANV at metal2vulkan fb33065288): past that room the view's buffers would be copied rather than imported. Such a cache's copies into the pages copy the surface's texels alone, each plane's rows from the layout the ask gave, so the bytes between rows stay as the guest's CPU wrote them, whatever a render over the cache leaves in its own (decode/surface_cache.rs, "Download"). So the cache's buffer declares the bytes between a texture's rows unobserved (GpuDevice::new_buffer_of_length_padding_unobserved; metal2vulkan's BufferDescriptor::padding_unobserved), and a texture over it whose rows lie with bytes between them, the desktop's among them, is an image over the cache's own memory that holds them, not another copy of the texels. A block asked with no layout (an older bundle's) stays in place, as every block of such a host did before (reims-vgpu's graphics/decode/surface_pages.rs, "Device caches where the pages cannot serve"). Such a surface's pages are the CPU's copy alone, so where it is fresh they wait for a CPU lock that needs them, as Deferred pages above has them on a GPU of its own memory. The host offers RGFX_FEATURE_SURFACE_DEFERRED_ASK beside SURFACE_CACHE_REFUSED, with a budget as SURFACE_DEFERRED's, and the kext's deferral then asks with the surface's layout (DEFERRED with ASK_CACHE and no runs). The host defers the block only where textures over the layout would lie in place over no import of any pages the surface may come to have (GpuDevice::fresh_surface_never_in_place, the runtime's answer before any import of the pages, which makes no image): rows that end inside the GPU's lines, which no pages change, or, on RADV, a plane of more pages than one dma-buf takes pieces, each counted a piece of its own, as a fresh surface's come (measured on the 780M: Safari's WebKit tiles of 1,824 pages came in 1,379 to 1,824 runs). It refuses every other with nothing made, as it refuses one past its budget, and the kext then names the block's pages asking as above: answered a cache, it posts them again cached; answered OK, the surface is not cached, and the device cache's entry the deferral made goes. So no surface whose pages could serve in place takes a cache for being deferred, and a full budget leaves a surface as it was without the feature. A deferred block is the deferred block above from then on: its pages wired, named (ATTACH) and copied into the cache only at a CPU lock that needs them. Before it, Safari's WebKit tiles, which the GPU alone draws, wired each its 7 MiB of the guest's memory at its first use, with the host copying the zeros into the cache, and the wired pages counted in the owner's footprint though WebKit marked the tiles volatile: about 400 of them took a WebContent past its 2 GB footprint limit (measured on the 780M and the Iris, an 8 GiB macOS 26.7.2 guest scrolling a long page), whose corpse and memory pressure stalled it for 100 to 800 ms. The guest lays its surfaces' rows out as the GPU's images take them in place: where the host's GPU aligns a linear image's rows to more than IOSurface's 64 bytes (256 on RADV), the host says so in the device info's linear_row_alignment, and the kext has IOSurface align the bytes per row and the plane offsets it works out for a surface to it, at the accelerator's start, as a GPU's accelerator does (IOSurfaceRoot::updateLimits; guest/kext/src/RgfxSurfaceRows.hpp), since the GPU's linear image of a plane starts at such an offset too. IOSurfaceGetPropertyAlignment answers both to the processes that work out their own. A client that places its planes or rows itself keeps them (CoreVideo's first plane 32 bytes into its surface, its rows at its own alignment, measured in a macOS 26.7.2 guest whose IOSurface answered 256): a device cache of the surface places that plane where the GPU's images may start (above), and a texture over it in the pages that the GPU's linear images cannot hold is the runtime's shadow. Macs answer 64 bytes there (Intel) and 128 (the M3), and an Intel Mac's GPUs answer 256 for minimumLinearTextureAlignmentForPixelFormat:, so rows at 256 bytes lie inside what Macs do. A host whose GPU has memory of its own answers its GPU's alignment as well (the runtime's minimumLinearTextureAlignmentForPixelFormat: of BGRA8: 256 on RADV, discrete or not, and 128 on the RTX 3090 and RTX 2080, docs/lessons.md): a texture over a surface's pages takes the GPU's own linear image there only where its rows lie at the GPU's pitch, and otherwise is the runtime's shadow; a device cache of a surface whose layout the kext gives lays the planes' rows at the GPU's pitch (The device cache, above), so a texture over it takes the GPU's image whatever the surface's pitch. At the same start the kext lowers the largest surface IOSurface answers to IOSurfaceGetPropertyMaximum, as a Mac's GPU accelerators do: as wide and as tall as the device's 2D textures (the device info's max_texture_width_2d and max_texture_height_2d, which the bundle answers to Metal: 16384 on our device), and 16 bytes a pixel of that width a row, the largest pixel a texture over a surface has (guest/kext/src/RgfxSurfaceLimits.hpp). Macs answer 16384 wide and tall (the Intel and AMD Mac with 131072 bytes a row, the M3 with 32768). Left at IOSurface's own INT_MAX, Safari 16.6 under macOS 13 drew no tiles of a page that scrolls only vertically at 1x (measured, 13.7.8; docs/lessons.md).

    • Measured, 2026-11-13: surfaces in place first on a GPU of its own memory. A host whose GPU has memory of its own caches every surface (The device cache, above). The unlanded branch steelbrain/routeb has such a host offer what a GPU that shares the CPU's memory offers (SURFACE_CACHE_REFUSED, SURFACE_DEFERRED_ASK and SURFACE_DEFERRED_CARRY, never SURFACE_CACHE or SURFACE_DEFERRED), so every surface lies in place first and takes a device cache only where its pages cannot serve (Device caches on a GPU that shares the CPU's memory, above). One walk per GPU, the same in each run: the desktop, Finder, Launchpad, Mission Control, Safari (a page's scroll and autoscroll, WebGL, a GL 3D page, a video) and Maps. Each GPU ran it on development at b615cec64 and on the branch over the same base, and the runs counted the compositor's presents, the GPU's busy time per present, and the bytes on the GPU's link (nvidia-smi dmon). In place first laid 3800 to 6900 textures in place where the base laid 240 to 590, and on the NVIDIA GPUs the link then carried 100 to 560 MB a present where the base's carried 1 to 44 MB: the GPU reads the layers it composites from guest RAM at each present, changed or not.

      • RTX 5080 (laptop, PCIe 5.0 x16): presents 6839 to 6415 (-6%), GPU time 2.6 to 7.8 ms a present. Safari's scroll fell from 636 presents to 543, its longest gaps (p99) from 92 to 309 ms. The link carried 130 MB/s to 6.6 GB/s over the walk, 16 GB/s at Launchpad.
      • RX 7900 XTX (PCIe 4.0 x16): level, 5468 presents to 5503, 3.4 to 3.8 ms a present; the GL 3D page's GPU time 2.0 to 4.5 ms a present. Its link's bytes were not read: amdgpu gives this GPU no pcie_bw.
      • RTX 3090 (PCIe 3.0, the link trained at x4): presents 4818 to 1236 (-74%), GPU time 19.9 to 109 ms a present, and a present shown 3.5 to 110 ms (median) after its take. Launchpad fell from 197 presents to 30 with 559 MB a present at 2.1 GB/s, Mission Control from 602 to 203 with the GPU 99% busy, Safari's scroll from 369 to 90 with its longest gaps (p99) from 0.4 to 6.3 s.
      • RTX 2080 (Thunderbolt 3), the steps up to the GL 3D page: the GPU fell off its bus (Xid 79) in the in-place run's video step, as it had once before that day with neither run going. Launchpad fell from 219 presents to 30 with 429 MB a present at 1.6 GB/s, Mission Control from 607 to 200 with the GPU 99% busy, Safari's scroll from 374 to 91 with its longest gaps (p99) from 0.6 to 6.4 s, the GL 3D page from 498 to 56; a present was shown 3.5 to 84 ms (median) after its take. The cost is the reads, and the link sets how much it is. At 16 GB/s (the 5080) the GPU's time per present triples and the presents fall 6%; at the x4 links' 1.6 to 2.4 GB/s the GPU waits on them, and the steps' presents fall three- to ninefold. The path's other work did not grow: the runtime's first copies into its shadows over host pages fell (10.1 to 9.8 GB on the XTX, 2.8 to 2.7 GB on the 5080, 1.7 to 0.4 GB on the 3090). On the XTX, in place first also took the runtime's shadows off most of the video's frames: in the walk's 57 s of 1080p video the runtime copied 74.0 million texels into shadow images with every surface cached and 1.6 million in place first (shadow copies 2230 to 977), the decoder's NV12 frames taking device caches through the ask, whose textures are images over the caches' own memory. A host whose GPU has memory of its own keeps caching every surface until a cache can follow measured use (below).
    • Proposed, not built: in place first, caches by measured use. In place first (above) keeps a surface in place for its whole life, so the GPU reads every layer it composites across its link at each present. The proposal keeps every surface in place first and gives one a device cache only once the guest's own use shows it re-read unchanged, from guest behaviour alone, never from a table of hosts or drivers:

      • Counting, on the host. For each block in place, the decoder counts the command buffers that read the surface (a texture over it sampled or read, a blit from it, a render pass that loads it) since its last write. A write is a command that writes it (a render pass's store, a shader's write, a blit into it), or a CPU write by the guest. The host sees a CPU write as the surface's CPU generation moving in the block's header (surface_cache::cpu_generation), the count the kext moves at each read-write lock in its op 2. IOSurface calls op 2 only for a surface with a device cache, and a block the kext names in place, not cached (on a host that offers no SURFACE_CACHE), has none, so the proposal gives each block in place a device cache that copies nothing, for op 2's count alone. Whether such a cache changes IOSurface's lock path in any other way is to be checked (RgfxIOSurfaceKPI.hpp). A block read by N command buffers with no write between them is promoted. N is measured, not guessed: from the walks' counts of reads between writes per surface, the least N at which the copy a promotion costs (the surface's bytes across the link once, and back once at the next CPU lock where the GPU wrote it) is below the reads it saves.
      • The step. The host posts the kext a notice naming the block. The kext names the block again, cached (SURFACE_PAGES with RGFX_SURFACE_PAGES_CACHED, the naming a block takes today only before any process holds it), once no submitted command buffer holds it, and makes the surface's IOSurface device cache with it. The host fills the cache from the pages and moves every buffer and texture over the block onto it. From then on the block is a cached block as any other: its command buffers name it in SURFACE_USE, and its locks download as a cached block's do. A surface written by the guest's CPU, or written between its reads, never leaves its pages. Whether IOSurface takes a device cache for a surface that is already in use is the first thing to check (RgfxIOSurfaceKPI.hpp).
      • The reverse. A CPU write ends a promotion. IOSurface calls the kext's op 2 at every read-write lock of a surface with a device cache. There the kext asks SURFACE_DOWNLOAD where the GPU wrote the surface since the pages last took the cache, as it does today, and then names the block in place again. The host moves the block's buffers and textures back over the pages, which by then hold every GPU write, and lets the cache go once the command buffers that use it finish. The CPU then writes the pages, and the block's count starts over. A read-only lock leaves the promotion as it is.
      • The contract. Every value that reached the guest stays: object ids, GPU addresses, resource ids, and every texture's contents and layout. CPU locks wait as they do now. The notice is a new event behind a new FEATURES bit: a host whose GPU has memory of its own offers in place first only with it, and a kext without it keeps every surface cached, as now. Where the host can't promote (no room in the GPU's memory, a texture the GPU can't place there) the block stays in place: the fallback is at the refusal, on every driver.
      • What it needs. The host can't move live objects today: each BUFFER_OVER_SURFACE_PAGES buffer is made over either the view or the cache when it is created (decode::surface_pages), and metal2vulkan's runtime rebinds a no-copy buffer only to other host pages (Buffer::detach_backing, rebind_bytes_no_copy). It needs the runtime to move a no-copy buffer, and the textures over it, into device memory at the same GPU address and back (asked of metal2vulkan 2026-11-13), then the event, the kext's naming, the host's counting, and the offer of in place first from steelbrain/routeb.
    • Measured, 2026-11-13: what crosses a GPU's link at each present with every surface cached. On development at 459e76e6a, the walk above, the link of a GPU whose compositor runs on another GPU carries the window's presents, and little else:

      • RTX 3090 on PCIe 3.0 x4, its host's one screen (3840 x 2160, scale 2.1) on a Radeon 780M, which KWin composites on: the window's swapchain (3648 x 2039) handed KWin four LINEAR XRGB8888 buffers of 29.75 MB, and each of its 4010 presents moved one across the link, 0.93 to each of the guest's 4324. nvidia-smi counted 34.8 MB from the GPU a window present and 2.3 MB to it a guest present, and the GPU was busy 20.2 ms a present (Mission Control: 43 window presents a second, the GPU 96% busy, in P2).
      • RTX 5080 Laptop GPU, which drives its panel: the window's buffers are the GPU's own tiled images, and nothing crosses: 5985 window presents to 5984 of the guest's, 0.8 MB from the GPU and 1.4 MB to it a present, the GPU busy 2.8 ms a present.
      • On the host of the RX 7900 XTX and the RTX 2080 the screen is the XTX's: the XTX's presents cross nothing, and the 2080's cross its Thunderbolt link (28.4 MB from the GPU a present, the base runs above).
      • The link is the limit, not the GPU's engines. The 3090's carries 1.83 GB/s from the GPU to the host: a 3648 x 2060 image (30.1 MB) copied into host memory takes 16.4 ms from its graphics family, its compute family and its family of transfers alone alike, and a bare swapchain of that size presenting a cleared image to the 780M's compositor reaches 61 presents a second, 1.84 GB/s. Only the graphics family presents to the window's surface. Smaller copies keep the rate: 16 regions of 256 x 256 (4.2 MB) in 2.4 ms, 64 of 64 x 64 (1.05 MB) in 0.63 to 0.69 ms.
      • The compositor's GPU does its part fast: the 780M copies a 30.1 MB image from host memory in 1.25 to 1.44 ms, and presents a cleared image of the window's size 4656 times a second.
    • The window shown by the compositor's GPU, built on the platform before rt and deleted with it: rt makes one device for everything, and the window presents from it, each image crossing to the compositor's GPU through the window system (reims-vgpu's graphics/rt_window.rs, "The compositor's GPU"). Where the compositor ran on another GPU, the window's swapchain was made on that GPU, whose buffers are its own, and only what changed of each frame crossed the runtime's GPU's link. Two routes were weighed. Route 2 was measured and rejected (below); route 1 was built:

      • Which device, either route. The GPU the compositor composites on is the main device of the window's surface's dma-buf feedback (zwp_linux_dmabuf_feedback_v1), matched to a physical device by its DRM nodes (VK_EXT_physical_device_drm). Where it is the runtime's own GPU, the window stays as it is. Otherwise the window makes a second VkDevice there (one graphics queue, VK_KHR_swapchain, VK_EXT_external_memory_host), apart from the runtime's, and its swapchain over the window's surface.

      • Route 1, built and since deleted: a mirror of the changed tiles (reims-vgpu's graphics::mirror). The window's mirror is a frame-sized buffer of host memory of its own. The runtime's device and the window's device each make a buffer over it. At each draw of a presented surface on the compositor's GPU:

        • The runtime's GPU copies the presented texture into a buffer of its own memory, as rows of the mirror's pitch.

        • It compares that copy with the frame it sent last, in 64 x 64 tiles (displayMirrorTile, a kernel of the display's shaders, since deleted). It copies each tile that differs into the mirror, and a tile that changed nothing crosses no link. The copy then stands for the frame sent. A mirror made again (its first sync, a frame of another format or size) sends every tile.

        • The compositor's GPU draws from a linear texture over its import of the mirror, through the draw the runtime's device would make: the same bytes, so the same pixels.

        • The compositor's GPU waits for the sync. The sync's command buffer exports its completion as a sync file (metal2vulkan's add_completion_sync_file), which the draw that reads the mirror imports and waits for before its work, so the window's thread waits for no GPU work of the sync's. The next sync waits on the host for that draw and for the sync before it. Where the runtime exports no sync file (MoltenVK), the sync finished before the export looked, or the compositor's device imports none, the window's thread waits for the sync before it encodes the draw.

        • A present drawn this way is answered, and its surface's block let go of, once the sync has copied the surface: the draw reads only the mirror, which the next sync writes only after the draw has finished. On um870's Radeon 780M, with the compositor on its RTX 3090, the draws there ran 16.5 ms on the GPU on average and up to 228 ms, the syncs 3.35 ms (a traced boot, 2026-11-15).

        • It touches the window's path alone: no guest, kext or placement change. Its fallback, at each refusal on every driver, is the window's present from the runtime's GPU, as before: no feedback, the runtime's own GPU, no second device or swapchain, a surface the mirror does not carry (not 4 or 8 bytes a pixel), or a mirror, sync, import or texture refused.

        • um870's compositor. Since 2026-11-15 um870's KWin composites on its RTX 3090 (DRM 226:129, renderD129, 0000:67:00.0), not on its Radeon 780M as in the measurements of 2026-11-13 and 11-14 below.

        • Measured 2026-11-13: route 1 against today. The walk above on um870's RTX 3090, whose compositor composites on its Radeon 780M, with every GPU's driver listed to QEMU and the 3090 picked: route 1 (steelbrain/x4route) against development at fe56cae17, on the same runtime, both mostly in P2. For each guest present: the megabytes the 3090's link carried from and to the GPU (nvidia-smi), the window's presents, the 3090's busy time, and the time from a present's take to its show (median / 99th percentile):

          step build link MB, from / to the GPU window presents busy ms take to show, ms
          Mission Control today 28.3 / 2.2 0.92 20.1 2.2 / 55.5
          route 1 1.2 / 2.7 1.00 6.7 14.4 / 45.7
          autoscroll today 28.7 / 0.3 0.88 17.0 5.1 / 15.0
          route 1 9.9 / 0.6 1.00 8.9 3.3 / 7.1
          GL 3D today 23.8 / 0.4 0.84 17.0 5.7 / 8.4
          route 1 16.6 / 0.3 1.00 12.9 3.6 / 4.3
          the walk today 31.2 / 2.0 0.93 21.0
          route 1 6.1 / 2.5 1.00 9.5
          • The guest's presents a second held: 47.8 and 57.7 in Mission Control, 45.7 and 45.0 in the autoscroll, 40.9 and 40.5 in GL 3D. The pages' own rates were 60, 59.8 and 60 both times.
          • The window presents every guest present.
          • Ordered on the CPU, as route 1 was first built, each sync cost the render thread a wait for the 3090's copy of the changed tiles over its link: 1.6 ms a present in Mission Control (1.0 MB of tiles at most), 7.3 ms in the autoscroll (11.8 MB) and 10.8 ms in GL 3D (18.5 MB). The guest does not wait for it.
          • Mission Control's median from take to show rose from 2.2 to 14.4 ms, while its mean fell from 18.2 to 10.0 ms. Its presents fall in two groups: those whose writers had finished by their take, shown within 4 ms (55% of them, then 46%), and those whose writers still ran, shown at a median of 39.1 ms, then 15.2 ms. Route 1 makes the second group faster and, at 57.7 presents a second against 47.8, larger, so the median moves from the first group into the second. From take to answer, the mean fell from 29.1 to 23.3 ms (1.94 to 1.61 refreshes). The XTX, whose compositor composites on the runtime's own GPU, shows the same two groups: 37% within 4 ms, the rest at a median of 12.0 ms.
          • The runtime's memory log shows the mirror's host pages imported by their pointer on both devices.
        • Measured 2026-11-13: the sync waited for on the compositor's GPU. The same walk on metal2vulkan's pin 83, with each sync waited for by the render thread (development at 36b382f9e) and by the compositor's GPU (steelbrain/x4route), each after a walk that filled the caches the pin left cold: um870's RTX 3090, whose compositor composites on its Radeon 780M, and um790's Radeon 780M, whose compositor composites on its RX 7900 XTX. The render thread's wait for the syncs:

          runtime's GPU sync waited for by syncs on the compositor's GPU render thread's wait a sync
          3090 the render thread 6447 0 4.63 ms
          the compositor's GPU 6416 6416 0.45 ms
          780M the render thread 6709 0 4.25 ms
          the compositor's GPU 6746 6746 0.99 ms
          • On the 3090, by step: Mission Control 1.61 ms a sync, then 0.38 ms; the autoscroll 7.27, then 0.37 ms; GL 3D 10.79, then 0.34 ms.
          • The runtime exported a sync file for each sync, none of them after host copies (its work counts sync_files_exported and sync_files_after_host_copies), and neither compositor's device refused one.
          • The guest's presents a second, the 3090's link and busy time, and the times from take to show stayed as they were. On the 3090: 57.7 and 57.6 presents a second in Mission Control, 44.9 and 45.2 in the autoscroll, 40.3 and 40.6 in GL 3D. On the 780M: 59.7 and 59.1, 45.8 and 45.5, 37.3 and 36.6.
          • Mission Control's take to show on the 3090, median / 99th percentile: 14.7 / 59.1 ms in the walk that filled the caches, 14.2 / 48.6 ms with the render thread's wait, 14.1 / 52.4 ms with the GPU's. Its two groups stayed as they were: 46% of the presents within 4 ms, the rest at a median of 15.6, 15.1 and 15.1 ms. The render thread's wait did not hold the shows, and the median above is where the two groups split.
          • What the render thread still spends on a sync is its encoding, commit and export, and its wait for the last draw and the sync before it.
        • Measured 2026-11-14: route 1 under a GPU-bound guest. The walk's applesample step (a GPU-bound guest app, 125 s) on um870's RTX 3090 on PCIe 3.0 x4, whose compositor composites on its Radeon 780M, the guest at 3648 x 2038, metal2vulkan's pin 92, at d2e5a7d46 (steelbrain/gpupick): with NVIDIA's driver alone listed to QEMU or every GPU's, and with no window or a Wayland one. The 3090 was in P2 throughout every arm:

          drivers listed window frames frame, median ms guest's GPU time a frame, median ms link MB/s from the GPU
          NVIDIA's alone none 1631 33.5 37.8 300
          every GPU's none 1627 38.3 38.2 307
          NVIDIA's alone presents from the 3090 1149 50.1 53.2 798
          every GPU's route 1 1025 83.2 68.1 643
          • Listing every driver cost the guest no frames. A window presenting from the 3090 cost it 30% of them, about the 20.2 ms the 3090 is busy at each of its 15.0 window presents a second (measured 2026-11-13, above). Route 1 cost another 11%: 1025 frames against 1149.
          • Route 1 made 13.5 syncs a second, each sending 1651 of the frame's 1824 tiles (27.1 MB), every one waited for on the 780M. The render thread waited 71.4 ms a sync, for the sync before it.
          • The tile kernel writes the changed tiles into host memory itself. Those writes hold the engine every queue of the 3090's graphics family runs on for as long as they take to cross the link, at least 14.8 ms for 27.1 MB at 1.83 GB/s. No other queue of that family runs meanwhile: in metal2vulkan's measure, a readback on another queue of the family waited 1.88 s behind a 2 s kernel, and one on the copy engine took 7.8 to 13.5 ms beside it (its src/device/staging.rs). Each sync also waits behind the guest's command buffers.
          • The arms without a window had none at all: with WAYLAND_DISPLAY left out and no XAUTHORITY, Xwayland refused SDL's connection.
        • Built: the copies on a copy engine. Where the platform gives a queue whose copies run on a copy engine of the runtime's GPU (GpuDevice::new_command_queue_for_copies):

          • The sync's command buffer copies the presented texture into the runtime's buffer and compares it with the frame sent last, as above, but only lists the tiles that differ (displayMirrorTileList, since deleted). It writes nothing into host memory.
          • The render thread commits it at once, then waits for it, for the last draw that read the mirror and for the last copy into it. Then it copies the listed tiles into the mirror on the copy engine: a run of tiles side by side is one copy in each of its pixel rows, a run of whole rows of tiles one copy.
          • The draw waits for that copy as it waited for the sync. No tile changed means no copy, and the draw waits for nothing.
          • The bytes that cross the link are the changed tiles' bytes, as before. The compositor's GPU still waits for the compare, which runs on the engine the guest's work runs on.
          • Where the platform gives no such queue, each sync is the one command buffer above. That is the case on the Vulkan platform until metal2vulkan's runtime gives a program a queue on a copy engine (asked 2026-11-14). It is also the case where the runtime refuses the list's kernel.
      • Route 2: the presented surfaces in place. The surfaces the display pipe presents lie in place in guest RAM (route B's placement for them alone; every other surface keeps its device cache), and the compositor's GPU imports their pages and copies from them into its image. Nothing computes damage: the runtime's GPU writes into guest RAM what the guest's composite draws, through the runtime's shadow of the surface, whose copies in and back cover only the rectangle a pass loads and writes inside its draws' scissors (metal2vulkan's shadow.rs at 522a8245e2, read from its code). The link carries the composite's passes over the surface, its loads as well as its writes, and each of the compositor's two or three surfaces catches up on the frames it was not drawn in. It is in place: the runtime's GPU writes the guest's pages, and the compositor's GPU reads them.

        • It touches placement and the window: the kext names the presented surfaces' blocks in place on a host whose GPU has memory of its own (route B's offer, for those blocks alone), and the window's second device imports the pages of the surface each present shows. The window part is route 1's but the copy.
        • Its fallback: a presented surface whose pages the compositor's GPU cannot import, or no second device, keeps today's device cache and the window's present from the runtime's GPU, at the refusal, on every driver.
      • Route 2, measured 2026-11-13: rejected. A prototype placed the presented surfaces alone in place. The kext named WindowServer's single-plane surfaces of the scanout's shape in place, not route B wholesale. The window stayed as today. The build was steelbrain/x4route-proto on development at 9cb5693ab. It ran the walk above on the RTX 3090, against the same walk on development at 459e76e6a, both mostly in P2. Megabytes a guest present (route 2's are the prototype's, less today's 34.8 MB window copy):

        step today, from / to the GPU route 2, from + to the GPU what changed (below)
        Finder 48.3 / 4.4 54.8 + 304.6 2.7
        Apps 34.5 / 5.0 99.6 + 257.1 0.65
        Mission Control 30.2 / 2.0 28.6 + 63.6 1.6
        Safari's scroll 41.6 / 4.9 132.7 + 107.5 6.1
        autoscroll 26.2 / 0.3 91.9 + 93.3 12.1
        the WebGL page 34.6 / 0.1 9.4 + 37.4 0.3
        GL 3D 23.9 / 0.4 93.2 + 66.0 18.2
        video 31.0 / 0.8 122.3 + 44.3 6.2
        Maps 31.1 / 11.3 77.0 + 203.6 1.6
        the walk 30.8 / 2.2 90.5 + 78.8 6.27
        • About 169 MB crossed the link a present, five times today's copy, and the guest slowed to match. Its presents over the walk fell from 4324 to 1735, and the GPU's busy time went from 20.2 to 80.0 ms a present.
        • Rates fell in Mission Control from 47 to 20 presents a second, in the autoscroll from 45 to 9, and in GL 3D from 41 to 7.
        • The median from a present's take to its show went from 23 to 147 ms in Finder, and from 5.6 to 182 ms in GL 3D.
        • The runtime's shadow counts barely moved: the texels it copied into shadows from host pages stayed under 1.3 MB a present. The bytes are the composite's own passes. The runtime's GPU renders and blends WindowServer's frame straight into guest RAM over the link, its loads as well as its writes, several passes a frame: an in-place display surface puts the whole composite on the link, not one write of the frame.
        • So the presented surfaces keep their device caches, as every surface does on a GPU with memory of its own (route B's decision holds for them too).
        • Route 1's bytes are the change measured below.
      • What the guest's frames change. The same walk on the RX 7900 XTX, with a measuring build (steelbrain/x4link-damage at 32bfa734c, not landed: a thread that reads what the display shows as read_display does, about once a present, 8 ms a read, and compares each read with the one before in 64 x 64 tiles): 6.27 MB of the 29.7 MB frame changed a present on average, 136 MB/s over the walk, where the 3090's link carried 599 MB/s. By step: the GL 3D page 18.2 MB a present, the autoscroll 12.1, the video 6.2, Safari's scroll 6.1, Finder 2.7, Maps 1.6, Mission Control 1.6, Apps 0.65, the WebGL page 0.3. Presents that come closer together than a read are compared as one, so where presents come fast the figure a present is low. At the 3090's rate that change is 3.5 ms of its link a present on average, where the window's copy takes 16.4 ms now (the GL 3D page 10 ms, Mission Control 0.9 ms).

      • The contract, either route. Nothing the guest sees changes: presents are taken, shown and answered as now, and the window shows the same pixels.

  5. The stage 3 stack is IOGPUFamily. x86-64 macOS 26 carries IOGPUFamily and IOGPU.framework, and the x86-64 port runs Metal compositing on them: WindowServer composites with Metal through an IOSurface display pipe on IOGPU that the driver provides. Our accelerator does the same.

  6. Hardware video is AppleGVA's vendor driver, in our bundle. On an x86-64 Mac, VideoToolbox's hardware decoders and encoders run in VTDecoderXPCService and VTEncoderXPCService, one of each per client process, through AppleGVA. AppleGVA reads the accelerator's IOVARendererID and IODVDBundleName, loads /Library/GPUBundles/<name>.bundle/Contents/MacOS/<name>, and calls its AVD_CreateAVDAccelerator for the driver's identity, its capability block and a table of sixteen entry points (sessions, bitstream and pixel buffer pools, command scheduling and status, parameters). Both services allow the bundle: their library validation is off, and their sandboxes read /Library/GPUBundles and open IOAccelerator user clients. A video plug-in of our own in /Library/Video/Plug-Ins is no way in: CoreMedia lists only Apple-signed plug-ins.

    • Identity: where the host's caps list a decoder (H.264 or HEVC), the accelerator's registry entry names the bundle, reims-graphics, as the video driver, with IOVARendererID 0x1020004, the AMD Navi family's, and IOGVACodec (publishVideoCodecs, before it registers); the bundle exports the two entry points beside its Metal device (guest/bundle/src/RgfxVideoDriver.cpp). On a host that decodes nothing, one with no video arm, it names no video driver: with the three keys VideoToolbox answered VTIsHardwareDecodeSupported true for H.264 and listed AppleGVA's H.264 encoder as hardware, though no session requiring hardware could be made (−12913 to decode, −12903 to encode); without them it answers false and lists no hardware encoder, and sessions requiring hardware fail as on a Mac without it (−12906, −12908) (measured, macOS 26.7.2 guest, Windows host with a UHD 630, 2026-11-16). The arm64e kext names none on any host, nor HEVC decode or H.264 encode: the route is x86-64's, and with the keys an arm64 guest answered hardware HEVC decode true while a session requiring it failed −17692 and none reached the host (measured, arm64 macOS 14.6.1 guest, VA-API host, 2026-11-16). Arm64 macOS 26 lists Apple's own AVE encoders as hardware whatever the kext publishes, and a session requiring a hardware encoder fails −12903 there (measured, arm64 macOS 26 guest under TCG, 780M host, 2026-11-16). AppleGVA drives an AMD driver through high-level commands (picture parameters and slice data; rate-control settings), which map onto Vulkan Video. The driver decodes H.264 and HEVC, each where the host's caps list it; HEVC in the profiles they list (Main into NV12, Main 10 into P010). It encodes H.264 where the caps list an H.264 encoder with a rate control, and the accelerator then publishes IOGVAH264EncodeCapabilities, the ratings VideoToolbox ranks the encoder by, as an AMD Mac's (VTRating 350, VTQualityRating 50 on a Radeon Pro 5300M's, macOS 26.7.1): AppleGVA's h264.gva is listed as hardware, and a session requiring hardware is made and encodes on the host's encoder. It encodes HEVC Main and Main 10 where the caps list an HEVC encoder of both with a constant QP, through the HEVC encoder plug-in's Intel route ("HEVC encode takes the plug-in's Intel route", below).
    • Routing: AppleGVA hands a session to the AMD driver only on the Macs without an Intel GPU, or where com.apple.AppleGVA's gvaForceAMDKE is set; elsewhere, an iMac20,1 among them, it looks for an Intel GPU and gives up without one. RgfxGate's install thread keeps the key set at every boot, after the bundle step (guest/rgfxgate/src/RgfxGatePrefs.cpp), in two files: /Library/Preferences/com.apple.AppleGVA.plist, and on x86-64 the global domain's for every user, /Library/Preferences/.GlobalPreferences.plist. In each, a key already true leaves the file untouched, an absent file gets a fresh XML plist of the key alone, an XML plist gets the key with every other byte kept, a binary one, as cfprefsd writes it (defaults delete leaves an empty one), gets the key with every other object's bytes kept, and an unreadable one is left and logged. An arm64 guest keeps the key in the AppleGVA file alone, as before: AppleGVA's AMD flow, the key's one reader, is x86-64's, and the arm64e shared cache of macOS 27.0.1 holds no image with the key's name. AppleGVA reads it from the next service start (measured on the guest, macOS 26.6.1). The global domain is for the processes that run AppleGVA in a sandbox of their own: Safari's H.264 decodes in WebKit's GPU process, not in VTDecoderXPCService, and that process's sandbox denies it com.apple.AppleGVA.plist (the kernel logs deny(1) file-read-data) while it reads the global domains. With the key in the AppleGVA file alone, AppleGVA there found no Intel GPU and every H.264 video in Safari decoded in software; with the key in the global domain the same process's sessions reached the driver (measured on the guest, macOS 26.6.1, a 4K60 H.264 clip on the RTX 5080: NVDEC decoded all 980 of its pictures). Safari's HEVC decodes in VTDecoderXPCService either way.
    • The GPU is named GFX0. AppleGVA's video routing finds the GPU by the name real AMD Macs give its PCI device, GFX0. HEVC needs it: the accelerator names its IOPCIDevice provider GFX0 in start, before registerService, and without that name VTDecompressionSessionCreate refuses every HEVC stream with −12913 and the driver is never called. H.264 decodes either way, and the IOGVACodec string makes no difference (measured on the msi 5080, 2026-11-03: three boots with the provider's default name refused HEVC with −12913; a fourth that changed only the provider's name to GFX0 decoded every frame, H.264 still working). Where a device already carries the name (a renamer such as WhateverGreen, or a second GPU), the name is left as it was and that is logged, so two are never published (guest/kext/src/RgfxAccelerator.cpp, nameProviderForVideo).
    • macOS 11 keeps small H.264 pictures off the hardware. AppleGVA's H.264 decoder on 11 declines a picture of at most 480×320 pixels (153,600) where the session plays video (read from AppleGVA's code, 108.7.2). Its session create fails with −12913 (kVTVideoDecoderNotAvailableNowErr), which VTIsHardwareDecodeSupported still counts as supported. AppleGVA logs why only with its debug preference set. From 12 the floor is 64×64 (AppleGVA logs "Playback Usage, resolution constrains: 64x64"). A Mac on 11 declines the same streams, so nothing of the device answers it, and a check of 11's hardware H.264 decodes a larger picture. Measured on the 780M host, 2026-11-08: on 11.7.11, 320×240 and 480×320 failed their create and 496×320's succeeded; on 12.7.6 all three decoded.
    • Capabilities are the host's: the block lists the engines and, per codec and direction, a function record (its ID, sub-ID, input format rawb for a bitstream or NV12 for frames, and output formats), from what the host's Vulkan Video answers (RgfxVideoCaps in the device info). A codec the host lacks is not listed, so VideoToolbox falls back to software, as on a Mac without it.
    • The wire: a video session is an object of the device's (VIDEO_SESSION_CREATE), with a command queue of the driver's; each picture is a command buffer of that queue holding one video encoder, whose op (RGFX_OP_VIDEO_DECODE_H264 or RGFX_OP_VIDEO_DECODE_H265, the 0x4xxx group) names the bitstream buffer and range, the parameter sets where they changed (H.264's SPS and PPS; HEVC's SPS and PPS, the host making the VPS from the SPS), and textures over the output surface's two planes. The host decodes on its Vulkan Video decode queue and has the command buffer wait for the decode on the session's shared event, so the buffer completes, and AppleGVA's token is answered done, once the picture is in the surface. For HEVC the driver writes the parameter sets from AppleGVA's parsed form, as for H.264 (guest/bundle/src/RgfxVideoH265.cpp): each short-term reference picture set by its pictures, each scaling list and, where the stream's random access skips a leading picture, no output for it. AppleGVA holds a set the SPS predicts from another by its pictures as well, derived, so the driver writes every set by its pictures, a predicted one too (measured on the guest with a stream of 25 sets in its SPS, 22 of them predicted).
    • An encode takes the same path. AppleGVA's H.264 encoder sends one encode command a frame (function 0x20, sub-ID 0x800), naming the source IOSurface, its own SPS and PPS records (laid out as the decoder's parsed ones), the picture's NAL header, its rate control (mode 0, a QP of AppleGVA's own a frame) and a bitstream buffer of the driver's, which it uses as a ring. The driver sends a command buffer of the session's queue holding one video encoder, whose op (RGFX_OP_VIDEO_ENCODE_H264) names textures over the source's two planes and a Shared buffer the host writes the access unit and its result into, with the session's settings where they changed. When AppleGVA asks the command's status and it is done, the driver copies the access unit into the ring at AppleGVA's start cursor, wrapping at its capacity, then writes the end cursor and the access unit's length in bits, which AppleGVA reads to take it out (guest/bundle/src/RgfxVideoDriver.cpp). The same bits go in the length record's word at +0x3c, which AppleGVA's rate control reads: with 0 there it keeps one QP a session, and an 8 Mbit/s stream at 1080p came out at 6.6 Mbit/s; with the bits it moves its QP each frame toward the session's average bitrate (measured, macOS 26.7.2 guest, Iris Xe host, 2026-11-16). AppleGVA schedules a frame only once it has the last one's status, so one frame is in flight.
    • HEVC encode takes the plug-in's Intel route. AppleGVA's HEVC encoder plug-in (hevc.gva) drives no AMD driver. On an x86-64 Mac it finds its GPU encoder by name: the last service named IntelAccelerator whose IOGVACodec names an Intel generation, with IOGVAHEVCEncode and IOVARendererID on it; VideoToolbox lists that encoder with the capabilities its IOGVAHEVCEncodeCapabilities carries. With no such service, a session requiring hardware failed −12903, one naming our GPU too (measured, macOS 26.7.2 guest, RX 7900 XTX host, m3-max-77226). So where the caps list an HEVC encoder of Main from NV12 and Main 10 from P010 with a constant QP among its rate controls, which codes a frame in place of the last (RGFX_VIDEO_ENCODE_CAP_IN_PLACE, below; rgfxHevcEncode), the accelerator, once registered, attaches a plain IOService named IntelAccelerator as its child (publishHevcEncoder, guest/kext/src/RgfxAccelerator.cpp): IOGVACodec "Gen9", IOGVAHEVCEncode "2", our IOVARendererID, and Main and Main 10, up to the encoder's level, rated as the H.264 encoder. It carries no IODVDBundleName, which AppleGVA's own loader looks for, and no Metal device or framebuffer hangs off it.
      • Both profiles, or no nub. The plug-in names two profiles, Main and Main 10, and reads four source formats, 420v, 420f, x420 and xf20 (macOS 26.7.1's plug-in). VideoToolbox hands it a session of a profile the nub does not list: a Main 10 session on a nub of Main alone was made on hevc.gva, and its first frame came to the driver with a 10-bit source (Iris Xe and Radeon 780M hosts, m3-max-77365 and m3-max-77368). The driver's create sees only the session's size, so it cannot refuse such a session, and the nub stands only where the host encodes both profiles. A host of Main alone gets none, and VideoToolbox encodes HEVC in software, as before.

      • The driver path is a link to the bundle. The plug-in loads the driver the generation names, AppleIntelSKLGraphicsVADriver.bundle, from /Library/GPUBundles before /System/Library/Extensions, and macOS ships none in /Library/GPUBundles. RgfxGate's install pass keeps the driver's executable path there a hard link to the bundle's executable at every boot, made again whenever the executable is a new file, as each install writes it (guest/rgfxgate/src/rgfx_alias.h, tested on real files by tests/alias_test.cpp; x86-64 only). One inode, so the link carries the executable's signature and rootless tag, and dyld maps one image whichever path a process loads it by.

      • The commands. The plug-in calls the bundle's entry points as its Intel driver: one encode command a frame (function 0x20, sub-ID 0x1000) whose parameters name the source IOSurface (+0x10), the NAL unit type the plug-in chose for the picture (+0x33c) and the slice QP its rate control chose (+0x3d8), beside its own VPS, SPS, PPS and slice headers, which are for a driver that codes under them. The driver sends RGFX_OP_VIDEO_ENCODE_H265 at that QP as a constant QP, an IRAP type (BLA, IDR, CRA) forcing a keyframe, Main from a 420v or 420f source and Main 10 of P010 from an x420 or xf20 one; the host codes under its own parameter sets. Once the command is done, the driver writes the access unit at the start of the plug-in's bitstream buffer (pool 0), each VCL NAL unit, VPS, SPS and PPS after a 4-byte start code and the other NAL units left out, and its length as the words at +0x3a0 (0) and +0x3a8; the plug-in makes the session's format description from that VPS, SPS and PPS, and each sample from the slice segments. A failed frame publishes a length of 0 and fails the context's next schedule, as H.264's does.

      • A frame coded again is coded in place. Where a frame's access unit comes out over the session's data rate limit (kVTCompressionPropertyKey_DataRateLimits), the plug-in codes the same frame again at a QP 3 higher, twice at most, and drops the first; nothing of the limit reaches the driver. Sent as a new frame, the retry was coded on the host after the dropped one and predicted from it: at a limit of 1 Mbit a second at 1080p, each session's 5 retries, all of P pictures, left gaps in the stream's order counts, and VideoToolbox decoded 134 and 149 of 300 frames back, failing the rest −17694 (measured, Main and Main 10, RX 7900 XTX host, m3-max-77530; H.264's encoder made no retry there, and its 300 frames decoded). The command carries no frame counter, so the driver takes a command of a P picture whose order count (the whole PicOrderCntVal, +0x4, not the slice header's least significant bits) and source surface are the last frame's as the retry (hevcCodesAgain), and sends it with RGFX_VIDEO_ENCODE_IN_PLACE and the last frame's index; the host codes it from the references the last one was coded from, with its order count (video/devices.md, "An encode"). A keyframe is never sent in place: the host codes each as an IDR picture, whose order count, 0, a new keyframe from the last one's surface shares, and a keyframe coded again is sent as a new IDR picture, which the stream decodes as well, the host's rate control counting one picture more. A frame after one the host failed is never coded in place. The host's sessions for the plug-in have no B pictures (the driver sends none), and a host refuses a frame in place in a session of B pictures, failing it. The nub stands only where the host codes in place: an NVENC host whose driver refuses it gets none (checked_in_place). Sent in place, at the same limit the plug-in coded 2 to 30 frames of a session again: no gap in the order counts, all 300 frames decoded back, and the most bytes in a second 1.7% to 3.0% over the limit (measured, Main and Main 10, m3-max-77611 RX 7900 XTX, m3-max-77609 RTX 3090, m3-max-77627 Iris Xe; video/bugs.md B100).

      • What the driver does not take. The plug-in writes a QP for each 32×32 CTU before each frame (pool 27, one 32-bit value a CTU, within a few steps of the frame's QP); the host codes the frame's QP alone. The frame statistics record the plug-in hands the driver (+0x3b8) is not supplied: it stays as the plug-in zeroes it. Of its values, the plug-in's rate control reads one, a measure of the picture's complexity per 16×16 block, which neither VA-API nor NVENC reports; with none, it chooses each QP from the bits the frames before came to, and lands a session's average bit rate within 6% of the one asked on two of the three GPUs below. The record's per-CTU statistics steer only the QP map, which the host does not take.

      • The route is macOS 26.7.1's plug-in's, booted on 26.7.2. On an Iris Xe host (m3-max-77329), a session requiring hardware was made on hevc.gva, and its 10 frames at 1080p were coded on iHD, with the keyframes where the session asked for them.

      • What a session gets (measured, macOS 26.7.2 guest, 1080p, 300 frames at 8 Mbit/s, each decoded back by VideoToolbox and compared with its source; the host's own encoder, ffmpeg's NVENC at P4 or its VA-API encoder as it comes, on the same frames at the guest's bit rate):

        GPU Main: bit rate, luma Main 10: bit rate, luma host's own luma, Main / Main 10
        RX 7900 XTX (m3-max-77475) 105.1%, 45.02 dB 104.8%, 45.17 dB 45.19 / 45.63 dB
        Iris Xe (m3-max-77476) 103.5%, 48.04 dB 98.1%, 48.86 dB 47.92 / 49.35 dB
        RTX 3090 (m3-max-77477) 100.7%, 44.81 dB 106.1%, 45.06 dB 45.76 / 46.60 dB

        NVENC's own Main 10 encode of the same frames at 8 Mbit/s came to 104.6% (the 3090's 106.1% is video/bugs.md B97). Main 10 sessions whose frames came from the session's pool taken once and kept, or from the app's own 8-bit buffers, decoded back as the pool's did (30 frames, as ffmpeg decodes them: 45.09 dB of luma on the XTX, 48.97 on the Iris Xe, 45.03 on the 3090). A session of a size the host does not encode, 64×64 or 128×96, was made on the guest's software encoder (hevc.vcp), as before. With frames coded in place (m3-max-77615, m3-max-77613, m3-max-77614), the same sessions' streams came out byte for byte the same on the XTX and the 3090, and on the Iris Xe but for 205 bytes of one.

      • A keyframe every frame comes to 4 to 5 times the asked rate, as on a real Intel Mac (measured, MaxKeyFrameInterval 1, 1080p, 30 distinct frames from one reused source buffer at 8 Mbit/s). The plug-in lowers its QP frame after frame, its slices' QPs falling from 20 to 13, so each frame comes out larger than the one before: 411.5% of the asked on the Iris Xe (m3-max-77627), 427.8% on the RTX 3090 (m3-max-77609) and 496.8% on the RX 7900 XTX (m3-max-77611), every frame decoding back. A real Intel Mac's hevc.gva (a 2019 MacBook Pro, macOS 26.7.1) came to 571.8% in the same test, with the same QPs frame for frame (m3-max-77635). The host's own encoders, given the same frames with a keyframe every frame, came to 99.6% to 122.3%.

      • VideoToolbox replaces a session's pixel buffer pool. On hevc.gva, the pool VTCompressionSessionGetPixelBufferPool answered before the encoder started is replaced when it starts: at the third frame of a Main 10 session, by another pool of 420v, on a real Intel Mac (macOS 26.7.1, m3-max-77481) as on ours (m3-max-77475), and at the first frame of a Main session on ours. An app that keeps the first pool without retaining it reads freed memory from then on; one that takes the pool again for each frame, or retains it, does not.

      • Speed (measured, Iris Xe, m3-max-77497, the host's whole machine): at 1080p, 94 to 118 frames a second, where the guest's software encoder made 3.2 to 3.3; at 8192×4320, 10.3 and 10.8, where software made 0.5 (B98). Per 8K frame, of 93 to 97 ms, the host's GPU wrote the encoder's input in 12.4 to 12.7 ms and the app copied into its buffers in 8.5 to 10.9 ms; the rest is the host's encode and the guest's round trip. Those 30 8K frames at 60 Mbit/s came to 118% of the rate asked and 44.87 dB of luma, where software's came to 91% and 48.12 dB (B99).

    • The HEVC output surface is named in the parameters, not on the command. An H.264 decode arrives as a pipeline whose transfer command carries the output surface; an HEVC decode is a bare decode command with no output on it and no transfer command. AppleGVA names the output frame in its own decoded-picture record instead: the record pointer at the parameters' +0x10, its current frame at the record's +0x08, and in that frame a description of its surface: the global IOSurface id, a size, the width, the height, a pitch, 8 bytes, then the pixel format. Where the fields start and how wide each is differ by release: fields of 4 bytes from the frame's +0x70 on macOS 11.7.10 and 11.7.11, from +0x78 on 12.7.6 and from +0x80 on 13.7.8; fields of 8 bytes from +0x80 on 14.8.9 and from +0x88 on 15.8.2 and 26.7.2 (measured on the guest with the RTX 5080, and 13.7.8 and 26.7.2 with the 780M; on 26 the id is that of the IOSurface VideoToolbox hands back for the picture, 7 for picture 0 and 27 for picture 1, and an IDR with no references resolves there too). So the driver searches for the layout rather than listing them: every start from +0x60 to +0xa0 in steps of 4, with fields of 4 or 8 bytes, where the id names a live surface whose width, height and pixel format the description gives. The window starts two 8-byte steps below 11's +0x70, for the 11 releases before 11.7.10, which no base boots; in the frames of every release measured, no start and width in it but the release's own reads the surface's width, height and pixel format. The first picture of a session whose frame describes its surface in exactly one layout shows the session's layout, which the session keeps; a picture whose frame describes no surface, or one in more than one layout, or none in its session's layout, is refused before it reaches the host (guest/bundle/src/RgfxVideoDriver.cpp, hevcOutputSurface).
    • A decode the driver cannot complete is a decode error, never a silent success. AppleGVA reports a decode error only when scheduling the command fails: a schedule that answers 5 reaches the client as kVTVideoDecoderMalfunctionErr (-12911). It takes every query of a decode for its completion, reading neither its status nor its error word (read from AppleGVA's code on macOS 26.7.1), and a detail word, a failed query call, and the statuses 0 and 3 alike deliver the picture as decoded (measured on the guest with the RTX 5080). So a command the driver cannot resolve or send (no output surface, refused parameter sets, no command buffer) fails its own schedule, and logs one line. The schedule of an HEVC picture the driver sent waits for the host's verdict on it, out of the lock that orders the sessions' pictures, and fails where the host failed it: AppleGVA reports the error from that picture on, and no frame of it reaches the client (guest/bundle/src/RgfxVideoStatus.hpp, waitsForHost and scheduleFails). AppleGVA's H.264 decoder reports no failure, neither a failed schedule nor any query answer tried, and a picture whose schedule failed is not decoded at all (measured on the guest with the RTX 5080, 2026-11-07); its pipelines schedule their commands one at a time and keep no decode's result (read from its code). So an H.264 schedule waits for no verdict, and an H.264 picture the host fails reaches the client as decoded (D25). What the driver can tell before a picture, the coded size AppleGVA gives each context it asks for, it checks at the create: a size outside the host's H.264 decode entry fails CreateContexts with kUnsupported, AppleGVA fails the session's create, and VideoToolbox decodes in software (sizeTaken, guest/bundle/src/RgfxVideoStatus.hpp). The host reports a failure as the picture's command buffer failing: an op it cannot carry out faults the buffer, and a picture it took but could not land (its planes refused, or a decode the hardware failed once it ran) still signals the session's event, so the buffer completes, failed with Metal's internal error (crates/reims-vgpu/src/graphics/decode/video.rs, Landed).
    • Bitstreams: AppleGVA asks for one bitstream buffer and writes the next access unit into it as soon as a picture is scheduled, without waiting for the decode that reads it. The driver copies each access unit, from its first 3-byte start code and padded with zeros to the host's bitstream_alignment, into the next of its session's eight Shared buffers, which the host's decode reads in place. That copy of the compressed data is the only one.
    • Pictures: AppleGVA's commands name no references, and AppleGVA reuses an output surface whatever the stream still references, so the host keeps the decoded picture buffer in images of its own, from the stream's slice headers. Where the device decodes only into its DPB pictures (DPB_AND_OUTPUT_COINCIDE, as the RTX 5080's decoder), each picture then takes one GPU copy from its DPB image into the output surface's planes, and nothing else copies a frame on the GPU. AppleGVA's surfaces lie in place (§14, measured on the guest with the RTX 5080). On a GPU of its own memory, the host says RGFX_VIDEO_CAPS_OUTPUT_CACHED in the video caps, each output surface's block is cached as every surface's is (item 14, Which surfaces are cached; without the flag the driver asks them uncached), and the copy writes the surface's device cache, within the GPU's memory, on the queue the runtime reserves for the decoders (family 0 on the RTX 5080), which no runtime work runs on, so the copy waits for its decode on the GPU and holds no guest work behind it. The guest's GPU work then reads the picture where it landed, and it crosses the bus only at a CPU lock, as the cache's download. Measured on the RTX 5080: a 4K picture lands in 100 us of the GPU, where the copy into the pages took 3.5 ms across a link idled down by a load of decodes alone; a CPU lock downloads it in 1 to 5 ms. Where the GPU shares the CPU's memory, the copy writes the surface's pages, on the decode queue.
  7. An arm64 guest's hardware video is VideoToolbox's paravirtual path, over the arm64e kext. AppleGVA's vendor-driver route is x86-64's (item 16). An arm64 guest's VideoToolbox has the path Apple's VMs use instead: where VideoToolboxParavirtualizationSupport finds a service of class AppleVideoToolboxParavirtualizationDriver and opens it, the guest's VideoToolbox counts itself as running in a guest, asks the host for its decoders and encoders, and registers each one the host lists as paravirtualized:<ID>, hardware-accelerated; its own ParavirtualizedVideoDecoder and ParavirtualizedVideoEncoder then run each session as messages to the host (read from VideoToolbox and the support framework, macOS 27.0.1 arm64e). Apple's VMs carry those messages over a virtio device of their own; ours carry them over the device's rings, and reims_vgpu_video::paravirt reads and writes them on the host.

    • The guest's side is the arm64e kext's. Where the guest took RGFX_FEATURE_VT_MESSAGES and the caps list a decoder, display 0's framebuffer publishes a service of that class (RgfxVtService.hpp), whose user client answers the framework's five selectors as Apple's kext of that class does (read from AppleVideoToolboxParavirtualization.kext 15.0.0, the macOS 27.2.1 arm64e VM kernel collection): 0 sizes the message buffer (at most 10 MiB) and answers its capacity and the user addresses of the buffer and of the host-message queue, an IOSharedDataQueue the kext maps into the process; 1 and 2 register and deregister a 16-byte session UUID for the client; 3 sends the buffer's first length bytes, lending the host the IOSurfaces of up to five IDs, and answers the host's status for it, as its output and as its return (a surface the client's task cannot see answers kVTParameterErr, posting nothing); 4 moves the host messages kept while the queue was full into it. The notification port is type 0. Apple's kext of that class binds only to Apple's VM device (106b:1a03), which no VM of ours has, so it never loads beside ours.
    • The wire: VT_MESSAGE on ring 0 carries one message: its length, the guest RAM runs of the client's message buffer that hold it, and each IOSurface it lends as a record (RgfxVtSurface: the kext's name for the lend, the surface's ID, pixel format, size and planes) and the runs of its pages. A command on ring 0 is at most 16 KiB, about 1,000 runs: a surface whose pages make more (a large frame's, its pages scattered: a 4K frame of 10-bit samples is about 1,500 pages of 16 KiB) sends the runs of its run table instead (RGFX_VT_SURFACE_RUN_TABLE), wired memory of the kext's that lists its runs in order, which the host reads as it takes the message and the kext frees as it lets go of the lend (measured: a 4K Main 10 stream's hardware decode on arm64 macOS 15.6.1 under TCG on a 780M host failed every frame -12902 while the kext refused such lends, and matched the software decode with a run table of 1,520 runs, 2026-11-16, lane a64video, potluck jobs m3-max-39017 and m3-max-39070). It waits for no command buffer and no buffer waits for it. The host reads the message from guest RAM, hands it to its session layer, and answers VT_STATUS with the status VideoToolbox's host side would return. A message from the host (a reply, a request, an emitted frame; 16 KiB at most, the framework's dequeue buffer) goes into the VideoToolbox ring, a 2 MiB ring of the device's at region offset 0x20000, and a 24-byte VT_RING on the control completion ring carries the ring's count through it; the kext takes the ring's messages through that count as it takes the event, so each keeps its place among the control ring's events. Where the guest did not take VT_RING, or the ring has no room for the message, it comes as a VT_MESSAGE event on the control completion ring, its bytes inline. The kext gives it to every client that registered its UUID, and a Bye! to every client with each UUID written in, as Apple's kext does.
    • The host's messages keep off the control completion ring. An encode's frame at 1080p and 8 Mbit/s is two or more messages of 16 KiB, and two of them do not fit that ring's 32 KiB at once: while the messages went there, an encode filled it about once a frame (control-ring-full and control-ring-post-waited about 590 times in a boot's encode bench, arm64 26.6.2 under TCG, lane a64video, potluck job m3-max-38178), and a full ring holds back the display's VBLANKs and the presents' answers. The VideoToolbox ring holds 127 such messages, and the session waits for the guest only at a frame's last, so a frame of up to about 2 MiB goes in at once. The ring is the device's memory, in the room between the control completion ring's span and the guest's allocations, which the kexts map with the control rings: the kext wires nothing of the guest's RAM for it, and there is nothing to free at the service's stop or the kext's unload. A message that finds it full goes onto the control completion ring (vt-ring-full, once a spell). A deregistration of a UUID the client registered sends the host -uui for it, and so does a client's close for each UUID it holds, as Apple's kext does.
    • A lent surface is the host's until its rels. The kext holds each surface it lends, retained and its memory wired, from the send until the host's rels names its lend (a VT_MESSAGE event of the box alone: its size, rels, then each lend, big-endian), whatever becomes of the client; the service's stop lets go of every lend. The host lets go of a message's surfaces at once where no session takes the message, and of a decoder's output once it has emitted the frame written into its pages.
    • The answers are the host's arms'. decs lists one decoder for each codec the caps decode, dcap its profiles and level from the caps' entry; a codec the host lacks is not listed, so VideoToolbox decodes it in software as on a Mac without it. AV1 is listed with no entry in the caps, which carry what an x86-64 guest's AppleGVA reads, and AppleGVA decodes no AV1: where the arm's own query lists AV1's Main profile, decs lists av01, dcap profile 0 at level 19 (6.3, the top level an M3's own AV1 decoder lists), and a stream of another profile is refused at its session's start, as no output format holds its frames whole (devices.md, "AV1 on arm64 guests"). A create of a listed decoder starts a decoder session (reims_vgpu_video::paravirt's decoder), whose pictures the host's video arm decodes and lands in the surface the guest lent for each (crates/reims-vgpu/src/graphics/vt.rs; on VA-API, written there by the driver's video processing where it takes the surface's layout, on NVDEC by the GPU into the surface's pages registered with CUDA, else copied by the CPU). A decoder session also starts a tile session (dsts), as CMPhoto's VTTileDecompressionSession asks of a HEIC image's grid, where the arm lands a part of a picture (on VA-API and on NVDEC: the picture's crop narrowed to the tile's region, written as a whole picture is): each tile (dtil) lands in the surface it lends, emitted (TDem) before its reply. An arm that lands no parts answers kVTUnimplementedErr, and VideoToolbox decodes the image in software. So does a tile session on a stream whose pictures the host decodes none of, and a decoder session's dsta on one is refused with kVTVideoDecoderUnsupportedDataFormatErr: the arms decode 4:2:0 pictures, of 8 bits, or 10 in HEVC, in the profiles and tools the codec's check_supported takes, at the coded sizes the arm's own query of its decoder lists (NVDEC's caps of the codec at the stream's chroma format and depth; the VA driver's decoder of the stream's profile, from its surfaces' least size up to the least of its config's and its surfaces' largest; devices.md, "A stream outside the host decoder's sizes"), and NVDEC and VA-API also HEVC's range extensions, 4:2:0, 4:2:2 and 4:4:4 at 8, 10 and 12 bits, where the arm's own query lists a decoder of the stream: NVDEC's caps for its chroma format, depth and size, or the VA driver's decoder of the stream's range extensions profile with the render targets and surfaces it needs at that size (iHD's). Each picture lands in the format the guest's own software decoder gives the stream, which TDrs names (PixelFormat::of: '420v', 'x420' and 'tv20' at 8, 10 and 12 bits of 4:2:0, '422v', 'x422' and 'tv22' of 4:2:2, '444v', 'x444' and 'tv44' of 4:4:4, and their full-range forms): NVDEC's 4:2:0 and 4:2:2 (NV16, P216) and VA-API's P012 by a copy, as Main 10's; NVDEC's three 4:4:4 planes interleaved by the runtime device's GPU at 8 bits where CUDA imports the device's exportable buffers, else by the CPU; VA-API's XYUV split by the runtime device's GPU where the display's import check passed XYUV, else by the CPU, and its other packed surfaces (YUY2, Y210, Y212, Y410, Y412) split by the CPU, each picture the CPU converts counted (video-pictures-cpu-converted; graphics::nvidia's, graphics::gather's, graphics::vaapi's and graphics::vaapi::xyuv's module docs, and devices.md, "HEVC's range extensions on arm64 guests"). A stream the codec refuses (monochrome, a HEIC image's alpha item, a depth past 12 bits, screen content coding), or one the arm declines (a stream of a coded size outside its decoder's, as HEVC under NVDEC's 144x144; a range extensions stream on a VA driver without its decoder, radeonsi's, or on an NVIDIA GPU whose caps lack it, as the RTX 3090's lack HEVC 4:2:2: the arm's guest_declines), is then refused at the session's start, not at each tile or frame, and every tile a session takes lands in the format its TDrs names. The refusal's warning names the stream and why: the codec's refusal or the arm's decline, its codec, its profile (HEVC's general_profile_idc, H.264's profile_idc, AV1's seq_profile), its chroma_format_idc, its luma and chroma bit depths and its coded size, written for the first stream of each codec, profile, chroma format and depths in a boot, and counted for the rest. On arm64 macOS 26.6.2 under TCG on a 780M host (2026-11-21), sips's decodes of a 356x356 4:4:4 thumbnail and of a 512x512 picture's monochrome alpha item each start a tile session that is refused so; VideoToolbox decodes them in software, within 2/255 of the M3's own decode of each file, where a tile session that took them left sips no picture. Measured on an M3 Max on macOS 27.0.1 (oracle job m3-max-39549): CMPhoto decodes Mac Blue, 6016x6016, as 36 tiles of 1024x1024, each whole into a 1024x1024 420f buffer of its own, asynchronous, and Apple's hardware decoder answers each synchronously. encs lists one encoder for each codec the arm encodes the guest's frames of (on VA-API and on NVENC, each codec it encodes a profile of), by the ID of Apple's hardware encoder of the codec (com.apple.videotoolbox.videoencoder.ave.avc, .ave.hevc): the guest's VideoToolbox registers each entry as paravirtualized:<ID>, and its own two paravirtual encoders, the hardware encoders its apps get, open the one of Apple's ID and fail (kVTInvalidSessionErr) where the host lists none. A create of a listed encoder, by that ID or by none, starts an encoder session (paravirt's encoder): the arm encodes each source frame from the surface the guest lent for it, copied by the GPU from a buffer over its pages into an input surface of the encoder's (on NVENC, into memory CUDA imported, which NVENC registers as input; else read through the host's view of the pages), and the session emits the samples, asking the guest for the stream's format description first (Efds), then lets go of the surface. meps lists no processor; a create of an encoder not listed is answered with a refusal in its reply's ,err, as for a codec the host lacks. A host with no arm offers no caps and the kext publishes no service: the guest's VideoToolbox is then not a guest's.
    • VP9 is this route's alone. Its caps entry is codec 3 (RGFX_VIDEO_CODEC_VP9), with RGFX_VIDEO_VP9_PROFILE_0 (4:2:0 at 8 bits) and RGFX_VIDEO_VP9_PROFILE_2 (4:2:0 at 10) as the arm decodes them, and its level as vpcC numbers it, ten times VP9's: 62, level 6.2, the top one, as the arms answer no level. Apple numbers its own levels so: the M3's AV1 decoder answers VTMaxDecodeLevel 63 for level 6.3, and lists no capabilities of VP9's, whose decoder is supplemental (read from AppleAVD's registry on the M3, macOS 27.0.1, potluck job m3-max-77311). The x86-64 kexts read no entry past HEVC's, so an older guest skips it and a newer one on an older host finds none, and the device makes no session of codec 3. decs lists VP9's decoder as reims-vgpu-video.videodecoder.vp9, dcap its two profiles as 0 and 2; encs lists no VP9 encoder. A session's samples come one container sample a dfrm, a superframe whole, hidden altref frames inside it (measured: libvpx's streams on arm64 macOS 26.6.2 under TCG on an RX 7900 XTX host, 2026-11-27, potluck job m3-max-77263), and dsta carries the stream's vpcC. The host splits each superframe by its index and decodes every frame, after checking each size against the bytes it holds (reims_vgpu_video::codec::vp9). dsta refuses with kVTVideoDecoderUnsupportedDataFormatErr a stream the arm declines (a profile, chroma format, depth or size its driver lacks) and one of 4:4:0 or VP9's RGB colour space, and arm64 macOS then has no VP9 decoder for it (devices.md, "Which hardware"). The guest's VideoToolbox, on macOS 14.6.1 as on 26.6.2, lists the decoder once a process registers VP9, and hands it every VP9 stream, though dcap names profiles 0 and 2 alone (measured under TCG, 2026-11-27, potluck jobs m3-max-77373 and m3-max-77382). So a host whose driver decodes profiles 1 and 3, or 12 bits, takes them with no change to the wire (devices.md, "VP9's profiles 1 and 3 on arm64 guests").
    • The host offers VT_MESSAGES where its arm lands decodes in the guest's surfaces: on VA-API and on NVDEC, each where it decodes H.264 or HEVC. The arm64e kext publishes the service on macOS 14 and later (rgfxVtServesRelease), every arm64 release it loads on: macOS 14's and 15's VideoToolbox run the host's sessions as 26's does (measured: arm64 macOS 14.6.1 and 15.6.1 guests under TCG on a 780M host decoded and encoded H.264 and HEVC to the checks 26.6.2 passes, 2026-11-16, lane a64video, potluck jobs m3-max-38882 and m3-max-38778).
    • A lend locks the surface first. Before it lends a surface, the kext takes a read-write CPU lock of it and lets it go, as a process would: what the GPU wrote of it is in its pages, its seed moves, and a device cache of it is filled from its pages at its next use, after the host's picture is there. Nothing uses the surface on the GPU while VideoToolbox holds it lent.

What metal2vulkan adds in stage 3

  • No-copy Managed heaps over our host blocks, whose VRAM copy syncs at didModifyRange: and synchronizeResource:, as a no-copy Managed buffer's does on a GPU of its own memory since metal2vulkan's runtime 2050.
  • Two-copy Managed textures, whose host copy is one of our blocks.
  • Per-context address and texture-ID tables. Today one device has one address space and one texture table of up to 2^16 entries.
  • A completion hook on its waiter thread, saving a thread hop.

Stage 2 wire protocol

Stage 2 builds the device, the transport and an unaccelerated display. The transport is final: stage 3 adds rings per command queue and commands, in the same formats. All values are little-endian.

PCI. Class 0x0380 (display controller, other). The vendor:device ID is the owner's call (Open); development uses the placeholder 1234:5247. Apple's paravirt kext matches only 106b:eeee. In the guest's registry the kext states the class an x86 Mac's GPU states, 0x030000, as the PCI device's class-code, which software that lists the Mac's GPUs reads (guest/kext/src/RgfxPciClass.hpp); configuration space keeps 0x0380.

BAR0: registers, 4 KiB of MMIO, 32-bit accesses. The MSI-X table and PBA sit in BAR0 from 0x800.

offset name access meaning
0x000 MAGIC RO 0x58464752 ("RGFX")
0x004 VERSION RO the wire's version, RGFX_VERSION (below)
0x008 FEATURES_LO RO feature bits 0-31; 0 in stage 2; the device info's features_lo holds its low byte for the processes
0x00c FEATURES_HI RO feature bits 32-63
0x010 STATUS RW writing 0 resets the device; the guest writes 1 (driver ready) once it has read the rings' headers
0x014 REGION_SIZE_LO RO BAR2's size, low 32 bits
0x018 REGION_SIZE_HI RO BAR2's size, high 32 bits
0x020 DOORBELL WO writing a ring's id wakes its consumer (an ioeventfd); under DOORBELL_ASKS bit 0 set asks for the answer at the doorbell
0x024 DRIVER_FEATURES_LO RW feature bits 0-31 the guest's driver takes; reads back the ones the host took ("Negotiated features", below)
0x028 DRIVER_FEATURES_HI RW feature bits 32-63, likewise
0x02c CONSUMED WO writing a completion ring's offset wakes its producer waiting for room, under CONSUMED_DOORBELL; no host handles it yet, so it reads 0 and a write is ignored
0x030 DEFERRED_BUDGET_LO RO under SURFACE_DEFERRED or SURFACE_DEFERRED_ASK, the bytes of the host GPU's memory deferred blocks' device caches may hold, low 32 bits: a quarter of the device-local heap's budget, the same for the device's life; 0 without either feature
0x034 DEFERRED_BUDGET_HI RO its high 32 bits
0x038 HOST_TIME_LO RO under HOST_TIME, the host's monotonic clock at the read in ns, low 32 bits, at the rate the guest's clock runs ("Refresh times"): the clock VBLANKs are stamped on; nothing is latched, so the guest reads HI, LO, HI and takes the second HI where LO is below 2^31, else the first; 0 where the guest did not take the feature
0x03c HOST_TIME_HI RO its high 32 bits
0x040 DOORBELL_PAGE_BIND WO under DOORBELL_PAGES, binds doorbell page value & 0xff of BAR4 to context value >> 8, or unbinds it for context 0 ("BAR4: the doorbell pages", below); a reset unbinds every page; reads 0

The wire's version. VERSION reads RGFX_VERSION (crates/reims-vgpu-graphics/src/wire.rs), the version of the wire the host speaks. The kext's framebuffer and accelerator, and the option ROM, each accept only the version they were built with. They read it right after MAGIC, before anything else of the device, and on any other version they leave the device and say why, naming both versions: the kext in the kernel log, the ROM on the firmware's console where it has one.

The bundle maps the region and speaks the messages too, so it must be of the kext's version, and it says which it is: its package carries an empty Contents/Resources/wire-version-N, N the RGFX_VERSION it was built with, under its signature. The kext registers its accelerator only for a bundle carrying the marker of its own version ("Registration waits for the bundle", below); for any other it says so in the kernel log and stays unregistered, so WindowServer composites in software, as with no bundle. The bundle does not check the version itself: a bundle that declined to make a device under a registered accelerator would leave WindowServer aborting, as with no bundle at all.

Leaving the device means writing nothing to its registers or its region. The framebuffer's start resets the device (STATUS 0) only once every check that needs no command has passed, and resets it again on the way out only if it did so. With the kext refused, or failed after its reset, the OS drives the display through the firmware's framebuffer, which the host shows through the scanout the firmware set up: a reset keeps the scanout (Reset, below).

Every change a guest built before it would misread moves RGFX_VERSION on by one, in the same commit:

  • a register's offset, width or meaning;
  • an offset or a size in the region: the control rings, the device info, the scanout's room, the blocks' room, the cursor;
  • a message's or an op's number, layout or meaning, a ring's format, or a status the guest acts on.

A change that no guest built before it can misread leaves it: a new feature bit (FEATURES_LO, FEATURES_HI), or a new message or op that older guests never send. A version number is never used twice. The host speaks one version, and a host and a guest of that version from different builds meet through the features they negotiate (below).

Negotiated features. A change lands as a feature bit, and moves VERSION only where no negotiation can carry it.

  • The host offers its bits in FEATURES_LO and FEATURES_HI. Bits 0-2 (SURFACE_PAGES, SURFACE_CACHE, CB_SUBMITTED) need no answer: the host acts on them as it offers them.

  • From bit 3, the host acts on a bit only where the guest's driver took it. The framebuffer kext writes DRIVER_FEATURES_LO and _HI after STATUS 0 and before STATUS 1, in ReimsGraphics::start, with the bits it and its bundle carry out, masked by the offer (RgfxFeatures.hpp). It reads back the bits the host took: those written that the host offers and knows. It logs the three words, and sets them on its service as RgfxFeaturesOffered, RgfxFeaturesWanted and RgfxFeaturesTaken, which ioreg reads at any time after the kernel's message buffer has let go of the line.

  • The host ignores a write while STATUS is 1, and a reset (the guest's STATUS 0 or the host's) clears the set. A guest that never writes it (the option ROM, a kext built before the registers) gets the wire as it was, and a host built before them reads them as 0, so its guest takes nothing.

  • A feature with a mode per queue rides QUEUE_CREATE's tail, RgfxQueueCreateFlags (flags, RGFX_QUEUE_*) after its 56 bytes. The kext sends the tail only with a flag set. A flag whose feature the guest did not take, or that the host does not carry out, refuses the create (INVALID_ARGUMENT).

  • New ops and messages are decoded wherever the host offers their bit, as RGFX_OP_SUBMITTED is.

  • The accelerator answers its processes' Features call (selector 3) with three words: the device's, which they work by (bits 0-2 as offered, and from bit 3 the bits taken), the kext's own, and the kext's selector map (below, "The accelerator's user client"). QueueCreate (0x103) takes a seventh input, the flags the process wants, and answers a second output, the flags granted: those whose feature the device's word holds. A kext whose map is not the bundle's, one of the map before it (whose Features was 0x10f) among them, and a sandbox that refuses the call, leave the process with no Metal device, logged: the bundle works by no guess at the words.

  • Bits 3-8 are named (QUIET_SCHEDULED, CONSUMED_DOORBELL, QUEUE_BARRIER, CB_PARTS, PAGES_BUFFERS, QUEUE_VECTORS; wire.rs). Of them the host offers bit 7, PAGES_BUFFERS, where it offers SURFACE_PAGES, and the kext takes it: a process's no-copy buffers lie over its own pages, wired by the kext in a pages block (selector 4, "The accelerator's user client"; BUFFER_OVER_PAGES). No host offers the others yet, the kext takes none of them, and the host carries out none of their queue flags: each lands with its feature, which says what it changes.

  • Bit 9 is IMPORT_ADDRESSES_LATER: a pages block's SURFACE_PAGES is answered before the host gives the block's view its address, and the host places the buffers over the block ("Import addresses", below). A host offers it where a view's address is an import of the block's pages, on metal2vulkan-runtime's device, and on no other platform.

  • Bit 10 is reserved for a pipeline's warm-up, bit 11 is SURFACE_ORDER: a command buffer that uses IOSurfaces runs after the buffers of other queues it names (RGFX_OP_SURFACE_ORDER; "Surface order", below), and bit 12 is INDIRECT_COMMAND_BUFFERS.

  • Bit 13, UNSHARED_QUEUES, every host offers and the kext takes: the queue flag RGFX_QUEUE_UNSHARED (1 << 3; 1 << 2 is reserved), which the kext sets on WindowServer's queues ("WindowServer's queues are unshared", below).

  • Bit 14 is MANAGED_AT_OFFSET: ring 0 carries BUFFER_MANAGED_AT_OFFSET, a Managed buffer whose CPU copy the host places in a heap over host memory of the sender's, so no buffer imports host memory of its own (the slabs, below). A host offers it where a Managed buffer is two copies, a GPU that does not share the CPU's memory.

  • Bit 15 is HEAP_OVER_PAGES: ring 0 carries HEAP_OVER_PAGES, a heap over the one run of guest RAM a pages block of the sender's holds, made over the host's mapping of the guest's RAM rather than the block's view, so the buffers placed in it cost what those of a heap over host memory do. A host offers it with PAGES_BUFFERS.

  • Bit 16 is SUBMIT_ROOM: a guest producer that finds a submission ring full stores 1 in the ring's producer_waiting, fences, and looks once more before it waits. After each take that moves the ring's consumer, the host fences and reads the flag, and where it reads 1 it stores 0 and posts a header-only RGFX_EVT_SUBMIT_ROOM (0x408) on the ring's completion ring, ring 0's or the queue's. The waiting producer looks again at that record: one interrupt after the host's take, not at a sleep's end. Every host offers it.

  • Bit 18 is COMMIT_ORDER: a command buffer is committed after the buffers of its process's other queues it names (RGFX_OP_COMMIT_ORDER; "Commit order", below).

  • Bit 19 is SURFACE_DEFERRED, which means nothing without SURFACE_CACHE: a fresh cached surface only the GPU touches gets no guest pages until a CPU lock needs them (RGFX_SURFACE_PAGES_DEFERRED and _ATTACH; wire.rs). A host offers it where it offers SURFACE_CACHE, with its budget in DEFERRED_BUDGET_LO and _HI.

  • Bit 20 is HOST_TIME: HOST_TIME_LO and _HI read the host's monotonic clock, the one VBLANKs are stamped on, at the rate the guest's clock runs ("Refresh times"), so the kext measures the two clocks' offset rather than infer it from the VBLANKs' delivery ("Refresh times", below). Every host offers it, and the kext takes it.

  • Bit 21 is MANAGED_TEXTURE_SLABS: a MANAGED_TEXTURE_CREATE may name any Shared buffer over the sender's memory as its CPU copy, and the host reads and writes the copy where the buffer's contents lie, so the bundle takes a Managed texture's CPU copy from its slabs ("Managed storage", below). Every host offers it, and the kext takes it.

  • Bit 22 is MANAGED_BUFFER_SLABS: ring 0 carries MANAGED_BUFFER_CREATE, a Managed buffer whose CPU copy is the first bytes of any Shared buffer over the sender's memory, read and written where that buffer's contents lie, so the bundle takes a Managed buffer's CPU copy from its Shared slabs, its own pages among them, on every host ("Managed storage", below). Every host offers it, and the kext takes it.

  • Bit 23 is SMALL_ID_CHUNKS: ring 0 carries RESOURCE_ID_SMALL_CHUNK, a grant of 16 texture resource ids, so the kext hands each process its ids 16 at a time from the same pool ("Texture resource ids", below). Every host offers it, and the kext takes it.

  • Bit 24 is DISPLAY_COLOR: the guest sends the display pipe's gamma tables and colour matrix as DISPLAY_COLOR parts, which the next PRESENT_SURFACE shows, and a present may keep the surface shown and change only the colour (RGFX_PRESENT_KEEP; "The display's colour", below). Every host offers it; one with no window answers its presents at once.

  • Bit 25 is MESH_PIPELINES: ring 0 carries MESH_RENDER_PIPELINE_CREATE (0x22e), answered by a PIPELINE_REFLECTION of kind MESH (2) whose made answer carries the state's object and mesh limits after its 80 bytes (RgfxMeshPipelineReflection, 104 bytes in all), and command buffers carry the object and mesh stages' bindings and the mesh draws (render ops 0x1051-0x105e). A host offers it where its GPU answers Metal3, and the kext takes it. No mesh pipeline supports indirect command buffers: the bundle ends the process at one that asks, as the x86 Macs' Metal does (dgpu-oracle.md, Q22), so no indirect command carries a mesh draw.

  • Bit 26 is SHARED_EVENT_NAMES: ring 0 carries SHARED_EVENT_NAME, SHARED_EVENT_IMPORT and SHARED_EVENT_UNNAME, which the kext posts for the shared events one process hands another, and the host posts the values one holder gives the event to the others' listen queues ("Shared events across processes", below). Every host offers it, and the kext takes it.

  • Bit 27 is OPENCL_MODE: a COMPUTE_PIPELINE_CREATE may carry RGFX_COMPUTE_PIPELINE_OPENCL_MODE, and the host makes that pipeline of OpenCL mode: Metal links the kernel behind three buffers of its own (the global offsets and dimension count at 0, then 1 and 2) with its arguments at their indices plus three. The bundle makes a kernel's function of OpenCL mode (newFunctionWithPluginData:bitcodeType:2) only where the kext carries the bit. A host offers it where its platform makes such pipelines: the Metal platform where Metal's compute pipeline descriptors answer setOpenCLModeEnabled: (the M3 Max on macOS 27, the AMD 5300M and Intel 630 on macOS 26.7.1), and the Vulkan platform always, its runtime linking the kernel as Metal does.

  • Bit 28 is PRIVATE_RENDER_STATE: a RENDER_PIPELINE_CREATE may carry RGFX_RENDER_PIPELINE_PRIVATE_STATE (flag bit 6), and then an RgfxRenderPipelinePrivateState (24 bytes) follows its head, ahead of the tail. It holds the descriptor's private state that Apple's OpenGL renderer sets: openGLModeEnabled, sampleMask, sampleCoverage, sampleCoverageInvert, logicOperationEnabled, logicOperation and depthStencilWriteDisabled, each the guest's raw value. The bundle reads them by key from every render pipeline descriptor where the kext took the bit. Measured on the Intel 630 (macOS 26.7.1), the renderer sets openGLModeEnabled, a sample mask and copy (2) on every pipeline. It sets a GL logic operation, sample mask or sample coverage as their properties. It sets depthStencilWriteDisabled on a pipeline that writes no depth or stencil. It does alpha test, two-sided colour and the point sprite origin in its shaders. A host offers it where its platform takes that state. The Vulkan platform always does, filling metal2vulkan's PrivateRenderState.

    The guest's renderer sets the same properties on our device. This was measured over gl_cases' 48 cases in arm64 macOS 27.0.1 (the M3 Max under HVF, job m3-max-17093) and in x86-64 macOS 26.7.2 (ms01's Iris Xe, job m3-max-17106). Each case ran in a process of its own, with every setter the renderer sends a render pipeline descriptor, its colour attachments and our render encoder traced. At each create, the descriptor's properties that differ from a new descriptor's were logged.

    • On both architectures, every pipeline gets openGLModeEnabled 1, sampleMask 0xffffffff, sampleCoverage 1, sampleCoverageInvert 0, logicOperationEnabled 0 with logicOperation 2, and depthStencilWriteDisabled (1 where the pipeline writes no depth or stencil).
    • GL's XOR gives logicOperationEnabled 1 and logicOperation 10. GL's sample coverage of 0.5 and sample mask of 3 give sampleCoverage 0.5 and sampleMask 3.
    • The renderer also sets twoSideEnabled, pointCoordLowerLeft, pointSizeOutputVS and needsCustomBorderColorSamplers, always to 0, including in the two-sided colour and lower-left point sprite cases. The record does not carry these four. metal2vulkan measured that they change nothing Metal draws, at any value it tried.
    • The renderer never sets alphaTestEnabled, alphaTestFunction, clipDistanceEnableMask, either depth-compare clamp mask, pointSmoothEnabled, vertexAmplificationMode or explicitVisibilityGroupID. It never calls setAlphaTestReferenceValue: or setPointSize: on the encoder.
    • So every property the renderer sets to something other than Metal's default is in the record.

    On a host whose Vulkan device lacks logicOp, such as MoltenVK on a Mac, metal2vulkan refuses a pipeline of any logic operation other than copy or no-op. The renderer then asks for the same pipeline for its software vertex and fragment fallbacks, each create answers nil, and the draw is lost (gl_cases' logicop case in arm64 27.0.1 on the M3 Max). x86 guests draw the case right on the 780M (RADV), the 3090 (NVIDIA) and the Iris Xe (ANV), whose devices have logicOp.

  • Bit 29 is SURFACE_CACHE_REFUSED: the host's GPU shares the CPU's memory, and it keeps a device cache only of the surfaces whose pages its textures cannot use in place, which it answers surface by surface (Decided 14, "Device caches on a GPU that shares the CPU's memory"). The kext asks at a new cacheable block in place (RGFX_SURFACE_PAGES_ASK_CACHE, with the surface's RgfxSurfacePagesLayout after the cache part), and posts the block again cached where the host answers RGFX_STATUS_CACHE. No host offers it now: one whose GPU shares the CPU's memory offers SURFACE_CACHE and SURFACE_DEFERRED (Decided 14), and a host never offers it beside them.

  • Bit 30 is SURFACE_DEFERRED_ASK, which means nothing without SURFACE_CACHE_REFUSED: a fresh surface that would need a device cache whatever its pages gets none until a CPU lock needs them, as under SURFACE_DEFERRED. The kext's deferral carries ASK_CACHE and the surface's layout; the host defers only such a surface and refuses the rest, whose pages the kext then names asking (Decided 14, "Device caches on a GPU that shares the CPU's memory"). A host offers it where it offers SURFACE_CACHE_REFUSED (none now), with its budget in DEFERRED_BUDGET_LO and _HI.

  • Bit 31 is UNCHANGING_PAGES, which means nothing without READ_ONLY_PAGES: a read-only pages block may be of pages its process can never write and no one else writes, a file's on a volume mounted read-only, anonymous memory with a copy pending, or anonymous memory its process's mapping alone holds, and its SURFACE_PAGES then carries RGFX_SURFACE_PAGES_UNCHANGING (1 << 6), with RGFX_SURFACE_PAGES_COPY_ON_WRITE (1 << 7) where the process maps them private and copy-on-write. The host reads such a block's pages once, as its view is imported ("Unchanging pages", under "No-copy buffers"). A read-only block not so marked may carry why not in its flags' bits 8 to 11 (RGFX_SURFACE_PAGES_WHY_SHIFT, the RGFX_PAGES_WHY_* values), a diagnostic the host counts by. The kext takes it and carries it to the bundle, which names such blocks to the kext (PagesBlock's third input: kRgfxPagesUnchanging, kRgfxPagesCopyOnWrite, and the why from bit 8, where the kext sets UnchangingPages, and kRgfxPagesSoleHolder where it sets SoleHolderPages). A host offers it where it offers READ_ONLY_PAGES.

  • Bit 32, FEATURES_HI's bit 0, is SURFACE_DEFERRED_CARRY, which means nothing without SURFACE_DEFERRED or SURFACE_DEFERRED_ASK: a deferral may carry the few resident pages of a surface no CPU lock touched, its runs the surface's bytes in order, each run of pages not resident RGFX_PAGE_RUN_ZEROS (Decided 14, Deferred pages). The bundle lists them after the layout of its 0x109 call, the kext proves them under its read of the surface, and the host fills the cache from them as a new cache's first fill. A host offers it where it offers either deferral.

  • Bit 33, FEATURES_HI's bit 1, is SCHEDULED_ASK: a queue's ring carries SCHEDULED_ASK (0x303), a thread's ask of a command buffer's scheduling ("Scheduled", below). The bundle posts it from waitUntilScheduled on the rings it writes itself, so the kext takes the bit with nothing of its own to do. Every host offers it.

  • Bit 34, FEATURES_HI's bit 2, is PAGES_16K: every run of guest RAM the guest names, and a SURFACE_PAGES' length, is whole 16 KiB pages from a 16 KiB page's first byte, as an arm64 guest's pages are. A host whose page is 16 KiB (a Mac) can map guest RAM for its GPU only in whole pages of its own, so it offers its features over guest RAM (SURFACE_PAGES, PAGES_BUFFERS, HEAP_OVER_PAGES, and with them SURFACE_CACHE_REFUSED, SURFACE_DEFERRED_ASK and SURFACE_DEFERRED_CARRY) only to a guest that took PAGES_16K, where it maps the guest's RAM at all:

    • until the driver takes it, FEATURES_LO and _HI read the host's other bits and PAGES_16K, and DEFERRED_BUDGET_LO and _HI read 0, exactly as from a host that maps no guest RAM, and a write cannot take the features over guest RAM;
    • the DRIVER_FEATURES_HI write that takes it shows them in FEATURES_LO and _HI (and the budget), and that write and later ones may take them; a write that lets PAGES_16K go lets them go, and a reset hides them;
    • the arm64 kext writes DRIVER_FEATURES_HI with PAGES_16K first, reads the offer again, and then writes both halves as before. An x86-64 kext never takes it, so an x86-64 guest on a Mac reads the features it read before the bit: the guest RAM features stay hidden, and its surfaces are copied into the region. The device info's features_lo and linear_row_alignment stay as a host that maps no guest RAM writes them, as the info is written before any guest takes the bit. A host whose page is 4 KiB never offers PAGES_16K: every guest's runs are whole pages of its own there.
  • Bit 35, FEATURES_HI's bit 3, is DISPLAY_SCALE: each display's record in DISPLAYS is followed by the scale of the host screen that shows it, the screen's pixels a point in 120ths (120 at 1x, 240 at 2x, 252 at KDE's 2.1; 0 while no window has drawn the display), and a change of the scale alone is a change of the display's mode, told with DISPLAY_CHANGED ("Display", below). Every host offers it, and the kext takes it.

  • Bit 36, FEATURES_HI's bit 4, is TEXTURE_DID_MODIFY_DATA: ring 0 carries TEXTURE_DID_MODIFY_DATA (0x232, RgfxTextureDidModifyData, the texture's ObjId), the bundle's post of a mipmapped texture over a buffer's didModifyData (SPI). Such a texture (TEXTURE_FROM_BUFFER of more than one level) is a copy of the buffer's bytes with every level made from them, taken at its first use, as the x86 Macs' (dgpu-oracle.md, Q11), and the platform's didModifyData makes it take them again at its next use. The host carries it out as a range message ("Range messages", below), so a command buffer of the process begun after it takes the bytes, a CPU write made after the call among them. Every host offers it, and the kext takes it; a guest that did not take it posts nothing, and the copy keeps what it took.

  • Bit 37, FEATURES_HI's bit 5, is DISPLAY_POWER: ring 0 carries SET_DISPLAY_POWER (8, RgfxSetDisplayPower: display u32, on u32), answered by COMPLETE, which turns the display's panel off while the guest's display sleeps and on at its wake ("The display's sleep", below). Every host offers it, and the x86-64 kext takes it.

  • Bit 38, FEATURES_HI's bit 6, is RATE_MAPS: ring 0 carries RATE_MAP_CREATE (0x233) and RATE_MAP_RESET (0x234), both RgfxRateMapCreate (the map's ObjId, the descriptor's screen size, its private mutability where set, and its layers' RgfxRateMapLayer records with their samples after them), answered by RATE_MAP_STATE (0x40a, RgfxRateMapState: the status, and the map's screen size, granularity, layer count, mutability and parameter data's size and alignment), and RATE_MAP_QUERY (0x235, RgfxRateMapQuery), answered by RATE_MAP_ANSWER (0x40b, RgfxRateMapAnswer): a layer's physical size, a coordinate mapped either way, or a copy of the parameter data into a buffer of the sender's, which the platform writes where the buffer's contents lie before it answers. A render pass names its map after its other records (RGFX_PASS_FLAG_RATE_MAP, RgfxRenderPassRateMap). The platform compiles each map, so its answers and its parameter data are the platform's, and the layer counts it makes maps of are the device info's (largest_rasterization_rate_map_layer_count). A host offers it where that count is one or more (device_info::makes_rate_maps), and the kext takes it; a bundle on a host that did not offer it makes no map and supports no layer count. rt makes no rate map and answers 0, so a host on rt does not offer it.

  • Bit 39, FEATURES_HI's bit 7, is FUNCTION_POINTERS: a compute pipeline state's function handles and visible function tables. Ring 0 carries FUNCTION_HANDLE_CREATE (0x236, RgfxFunctionHandleCreate: the handle's ObjId, the pipeline state's, and its function as an RgfxLinkedFunction record of RGFX_LINKED_FUNCTIONS, its strings and constants after the head) and FUNCTION_TABLE_CREATE (0x237, RgfxFunctionTableCreate: the table's ObjId, the pipeline state's and its entry count), each answered by FUNCTION_POINTER_STATE (0x40c, RgfxFunctionPointerState: the status, and for a table its gpuResourceID, allocatedSize and resourceOptions), and FUNCTION_TABLE_SET (0x238, RgfxFunctionTableSet: the table's ObjId, the first entry and the count, then that many handle ObjIds, 0 a nil entry), which the device does not answer. The platform makes the handle of the function among those the state's kernel links, and a function it does not link is RGFX_STATUS_NOT_FOUND, Metal's nil; a message naming a state still being compiled waits for it. A set is carried out before any command buffer the process posts after it, so a dispatch encoded before a set and committed after it calls the entry set. A compute pass binds a table at a buffer index (RGFX_OP_COMPUTE_SET_VISIBLE_FUNCTION_TABLE, 0x201e) or a range of them (RGFX_OP_COMPUTE_SET_VISIBLE_FUNCTION_TABLES, 0x201f), and an argument buffer holds a table by its gpuResourceID, which the kernel reads with or without useResource:. Render stages carry no function pointers. Every host offers it, and the kext takes it; a bundle on a host that did not offer it makes no handle or table, and answers NO to supportsFunctionPointers.

  • Bit 40, FEATURES_HI's bit 8, is DYNAMIC_LIBRARIES: a compute pipeline's dynamic libraries. Ring 0 carries DYNAMIC_LIBRARY_CREATE (0x239, RgfxDynamicLibraryCreate: the dynamic library's ObjId and that of the sender's library of type dynamic it is made of), answered by COMPLETE with its status: RGFX_STATUS_NOT_FOUND for a library the sender does not hold, RGFX_STATUS_REFUSED for one the host refused or the platform refuses as a dynamic library (one whose code reads a function constant). A message naming a library still being made waits for it. A COMPUTE_PIPELINE_CREATE with a nonzero library_count ends with that many RgfxPipelineLibrary records (the dynamic library's ObjId, and the offset and length of an install name in the message): one of no name is preloaded (preloadedLibraries, searched first in the run's order), and one with a name is the library that install name loads. Metal reads the file each install name names when it creates the pipeline, for a library made from a file alone; the bundle reads them in the guest's process, each name the kernel's library, its linked functions' libraries and these dynamic libraries name, and refuses the pipeline as the AMD Radeon Pro 5300M does where one loads nothing or a library made of bytes or source names one, so the host links only what the guest sent and reads no file of its own. Render stages carry no dynamic libraries. Every host offers it, and the kext takes it; a bundle on a host that did not offer it makes no dynamic library, and refuses a pipeline whose kernel's libraries name an install name.

  • Bit 41, FEATURES_HI's bit 9, is PIPELINE_KEYS: a render or compute pipeline create may ask for its pipeline key (RGFX_RENDER_PIPELINE_ANSWER_KEY, 1 << 7 of its flags; RGFX_COMPUTE_PIPELINE_ANSWER_KEY, 1 << 3). Where it asks, the device made the pipeline, and the device holds every library the create names under a content key it checked against the library's bytes (one bound by LIBRARY_LOOKUP, or made of bytes sent with their key and kept in the library cache), the PIPELINE_REFLECTION sets RGFX_PIPELINE_REFLECT_KEYED (1 << 2) and carries the key, 32 bytes, after the reflection (RGFX_PIPELINE_REFLECTION_KEY_OFFSET, 80; its size 112). The key is the SHA-256 of rgfx-pipeline-v1, then the create's message with its seqno, its obj_id and every library id it names zeroed, then each named library's content key in the order the ids lie (a compute create's function library, then each linked function's; a render create's vertex and fragment libraries, then each vertex and each fragment linked function's), 32 zero bytes for an id of 0. A mesh create, and a compute create that links dynamic libraries, is never keyed. The kext keeps keyed answers for every process's equal creates ("Known pipeline creates"). Every host offers it, and the kext takes it; a bundle on a host that did not offer it asks for no key.

  • Bit 42, FEATURES_HI's bit 10, is ICB_SLOTS_IN_PAGES, which means nothing without ICB_SLOTS and PAGES_BUFFERS: an indirect command buffer's slots may lie in the pages of a pages block of the process's, its own memory, rather than in a block of the region, which the guest's kernel maps uncached on an AMD host under xnu's PAT (write-back once the kext sets the PAT's entry 2: "The BAR is one host memory region"). Ring 0 carries ICB_SLOTS_IN_PAGES (0x23a, RgfxIcbSlots then RgfxIcbSlotPagesRuns: an ICB_SLOTS run whose first slot lies pages_offset bytes into the pages of the pages block at block_offset), which the host reads and takes in place, in the guest's RAM for a block of one run and in the block's view for one of more. The bundle takes a chunked pages block of the kext's for each buffer's slots, its table's bytes rounded up to whole 64 KiB chunks, and a block of the region where the kext gives none; the block goes back after the buffer's destroy. A host offers it where it offers PAGES_BUFFERS, and the kext takes it; a bundle on a host that did not offer it lays every buffer's slots in the region.

  • Bit 43, FEATURES_HI's bit 11, is DOORBELL_ASKS: a queue's doorbell is written with the ring's id and RGFX_DOORBELL_ASKS (bit 0; a ring's id is a region offset, a multiple of 8) for a command buffer whose stream ends in its ask for its CB_SUBMITTED, and with the id alone otherwise. The host answers at the doorbell only an asking write ("The answer at the doorbell"), and may take a plain one with no exit to its process, waking the queue's thread from the guest's vCPU directly ("Routed doorbells"). A host offers it where it routes doorbells: on Linux, where its host gives the library's route_doorbell (QEMU's KVM ioeventfds); a Mac host (QEMU under HVF or TCG) does not offer it (doorbell_asks_is_offered_only_where_the_host_routes_doorbells_on_linux). The kext takes it, and the bundle sets the bit where the device's word holds it; where it does not, every doorbell write may be answered, as before the bit.

  • Bit 44, FEATURES_HI's bit 12, is GUEST_TIMES, which means nothing without HOST_TIME: a diagnostic. Each command buffer's stream starts with GUEST_TIMES (0x000e), the guest's clock as the buffer was made, committed and put on its ring, and the framebuffer keeps the offset of the guest's clock from the host's in ring 0's header, so the host splits the time before it takes each buffer ("Guest times"). Every host offers it, and the kext takes it; a bundle on a host that did not offer it stamps nothing, and the host reads no times of a guest that did not take it.

  • Bit 45, FEATURES_HI's bit 13, is READ_ONLY_PAGES, which means nothing without PAGES_BUFFERS: the kext makes pages blocks of memory a process maps read-only too, wired for reading alone (kIODirectionOut), and marks their SURFACE_PAGES RGFX_SURFACE_PAGES_READ_ONLY (1 << 5, with RGFX_SURFACE_PAGES_PRIVATE alone). The host keeps every object over such a block from writing its pages: a BUFFER_OVER_PAGES over it carries MTLResourceOptions bit 24, whose GPU writes the platform drops as Metal drops them (accuracy-ledger.md, read-only-pages-written), and one without the bit, a HEAP_OVER_PAGES, an ICB_SLOTS_IN_PAGES and a Managed object's CPU copy over it are refused. The mark is where the host holds that line: a process can post any message on its rings, and the pages may be a file's, so the kext makes such a block only where the host took the bit, and a kext on a host without it refuses read-only memory, which the bundle then copies ("No-copy buffers"). A host offers it where it offers PAGES_BUFFERS, and the kext takes it.

  • Bit 46, FEATURES_HI's bit 14, is DOORBELL_PAGES: BAR4 holds the doorbell pages, which the kext binds to its contexts with DOORBELL_PAGE_BIND and maps into their processes, where the bundle rings its queues with no call into the kext ("BAR4: the doorbell pages"). A host offers it where it maps BAR4 and hands the device its writes: QEMU's reims-graphics-pci does, through the C API's doorbell_pages and rvg_graphics_device_doorbell_write (doorbell_pages_is_offered_only_where_the_host_maps_bar_4). The kext takes it. A guest that does not take it, or a host that does not offer it, has every doorbell on DOORBELL as before the bit: the device ignores DOORBELL_PAGE_BIND and drops every write to BAR4 (without_doorbell_pages_the_doorbells_are_the_register_s).

  • Bit 47, FEATURES_HI's bit 15, is PIPELINE_ANSWERS, which means nothing without PIPELINE_KEYS: the device keeps the keyed answers it gave made pipelines' creates from one run of the host to the next, and ring 0 carries the kext's PIPELINE_ANSWERS (0x2f9, RgfxPipelineAnswersQuery: first and most), which asks for them, newest first, from the firstth, at most most. Each goes on the control completion ring as a PIPELINE_REFLECTION of the query's seqno, a keyed reply (status OK, RGFX_PIPELINE_REFLECT_KEYED, the key after it) with its obj_id, gpu_resource_id, unique identifier and resource index 0, then a COMPLETE of that seqno whose status is how many went, fewer than most where none is left. It makes nothing and holds up no command buffer. The kext seeds the answers it keeps for every process with them at its start ("Known pipeline creates"). Every host offers it, and the kext takes it; a host without it refuses the message as one it does not know.

  • Bit 48, FEATURES_HI's bit 16, is MULTI_DISPLAY: the device has two displays or more, and a guest that takes it drives each ("Multiple displays", below). A host offers it only on a device of two displays or more, and the x86-64 kext takes it.

  • Bit 49, FEATURES_HI's bit 17, is POINTER_OVER, meaningful only with MULTI_DISPLAY: the guest moves its cursor onto the display the host's pointer is over when the event POINTER_OVER says so ("The pointer across displays", below). The device offers it beside MULTI_DISPLAY, only on a device of two displays or more, and sends the event only to a guest that took both. Both kexts take it, the arm64e kext with MULTI_DISPLAY alone (where the firmware placed a node for display 1 too); the firmware drivers do not.

  • Bit 50, FEATURES_HI's bit 18, is DISPLAY_BOUNDS, meaningful only with MULTI_DISPLAY and POINTER_OVER: the guest tells the host each display's rectangle in its desktop with the command DISPLAY_BOUNDS, by which the host carries its captured pointer past one display's edge onto the display the guest placed there ("A drag across displays", below). The device offers it beside the two, only on a device of two displays or more, and carries the pointer past an edge only for a guest that took all three. Both kexts take it, the arm64e kext with MULTI_DISPLAY alone; the firmware drivers do not.

  • Bit 51, FEATURES_HI's bit 19, is POINTER_MOTION: the guest publishes a mouse of its own, which the event POINTER_MOTION drives, and the host's captured pointer drives it while the guest hides its cursor ("A pointer for games", below). The device offers it where the host made it with a window, on a device of one display as of several, and sends the event only to a guest that took it. Both kexts take it; the firmware drivers do not.

  • Bit 52, FEATURES_HI's bit 20, is VT_MESSAGES: ring 0 carries the arm64e kext's VT_MESSAGE (0x2fa, RgfxVtMessage, then its runs, then each surface it lends as an RgfxVtSurface and its runs: one message of the guest's VideoToolbox to its host side), which the host answers VT_STATUS (0x40d, RgfxVtStatus: the status VideoToolbox's host side returns for it), and the control completion ring carries the host's side's messages to the guest's as the event VT_MESSAGE (0x40e, RgfxVtHostMessage, its bytes inline, seqno 0), sent only to a guest that took the bit (item 17 of "Decided", above). The device refuses a VT_MESSAGE of a guest that did not take it as one it could not read (RGFX_VT_STATUS_MALFORMED). The arm64e kext takes it, and publishes the service only where the caps list a decoder; the x86-64 kext and the firmware drivers do not. The host offers it where its video arm lands VideoToolbox's decodes in the guest's surfaces (item 17).

  • Bit 53, FEATURES_HI's bit 21, is UPLOADS_WRITTEN: a command buffer's stream may carry UPLOADS_WRITTEN (0x000f, before its first encoder, once: as many RgfxUploadWritten records, buffer_obj_id and length, as its len holds), the bytes its encoders wrote from the start of each Managed upload chunk it used. The host carries each out as the platform's didModifyRange: of that range as it begins the buffer, before its commit, so the buffer waits at the gate for no range message on ring 0: no command buffer committed before it uses a chunk it names, as the bundle gives a chunk back only once the buffer that used it has completed. A record of an object that is no Managed buffer, or of bytes past one, is dropped (logged once), as a range message the host refuses is, and the buffer runs, the same whether or not it was answered at its doorbell. Every host offers the bit, and both kexts take it. The bundle names the bytes there where its chunks are Managed (the device answers hasUnifiedMemory NO), and on a host that did not offer the bit it sends a BUFFER_DID_MODIFY_RANGE of each chunk ahead of the buffer, as before the bit.

  • Bit 54, FEATURES_HI's bit 22, is VT_RING, which means something only with VT_MESSAGES: the host's side's messages go into the VideoToolbox ring (RGFX_VT_RING_OFFSET, 0x20000: a ring header, then 2 MiB of byte ring; records as the VT_MESSAGE event's, with pads to the ring's end), each followed on the control completion ring by the event VT_RING (0x40f, RgfxVtRing: the ring's count through it, seqno 0). The guest takes the ring's records through that count as it takes the event, then stores the count to the ring's consumer; it never arms the ring. A message that finds the ring with no room, or broken, goes onto the control completion ring as a VT_MESSAGE event, after the VT_RINGs of the messages before it. The device offers the bit wherever the host offers VT_MESSAGES; the arm64e kext takes it with VT_MESSAGES, and nothing else does (item 17).

  • Bit 55, FEATURES_HI's bit 23, is CURSOR_COLOR: ring 0 carries CURSOR_COLOR (10), the colour chain a display's cursor converts its pixels through ("The cursor's colour", below). Every host offers it. The arm64e kext takes it, and takes the cursor layer's ICC chain from WindowServer only where the host took it; nothing else takes it, and a guest that did not has its cursor shown as its pixels are.

BAR2: the region. A 64-bit prefetchable BAR over host memory (1 GiB), mapped write-back by the guest. The device places the control rings at fixed offsets; the guest places everything else. Its pages are committed on the host as they are first touched, and the host imports for the GPU only what it reads: the scanout's pages, and each block a *_OVER_HOST_MEMORY names.

1 GiB is the largest size an x86-64 macOS guest takes (measured on macOS 26, q35, OVMF):

  • macOS's PCI configurator lays the bus out again at boot. It places every 64-bit prefetchable BAR below 4 GiB, never in the host bridge's 64-bit window, and it misreads a 4 GiB BAR as an I/O BAR.
  • Below 4 GiB the window ends at 0xE000_0000, so a 2 GiB BAR cannot fit.
  • A 1 GiB BAR needs the window to start at or below 0x4000_0000. q35 keeps 2 GiB of the guest's RAM below 4 GiB when the guest has more than that, and then the BAR gets no address: the kext finds no BAR2 and IONDRVFramebuffer keeps the display.

So the host starts QEMU with -machine q35,...,max-ram-below-4g=1G wherever the device is present. QEMU then keeps 1 GiB of RAM below 4 GiB and puts the rest above, which leaves the guest's memory size unchanged, and the BAR lands at 0x4000_0000. The device stays on pcie.0: a root port does not help.

offset size what
0x00000 64 KiB control submission ring, id 0 (the kexts to host)
0x10000 64 KiB control completion ring (host to kext), MSI-X vector 0; the device info at 0x18100
0x20000 2 MiB + 256 the VideoToolbox ring (host to the arm64e kext, VT_RING), never armed
0x400000 128 MiB the framebuffer's scanout (RGFX_SCANOUT_SPAN)
0x8400000 to the cursor the accelerator kext's blocks: every process's queue rings, command buffers' bodies and libraries' staging chunks, surfaces' blocks, and Shared buffers and heaps where the device offers no Shared pool
end − 256 KiB 256 KiB the framebuffer's cursor image

The control ring is the kexts' alone: the framebuffer's display commands, and the object lifecycle the accelerator posts for the Metal processes, under the framebuffer's ring lock. Every other ring is one command queue's own ring pair, in a block the accelerator kext handed to the queue's process, so each ring keeps a single producer and a single consumer however many processes run Metal.

BAR4: the doorbell pages. A 32-bit, non-prefetchable memory BAR of 4 MiB: 256 pages of 16 KiB, the largest page a guest maps (an arm64 guest's), so a process's mapping of one page reaches no other. QEMU's reims-graphics-pci always has it, and offers DOORBELL_PAGES with it. Every read answers 0, and a page holds no register: a process that writes its page can wake its own queues and nothing else, never reset or reconfigure the device.

  • Binding. The kext binds a free page to a context as the context opens, with a write to DOORBELL_PAGE_BIND (the page in bits 0 to 7, the context from bit 8, so a context of 2^24 or more gets none), which the device takes before the write returns, and then maps the page into the context's process, uncached (guest/kext/src/RgfxDoorbellPages.hpp). The context's close unmaps it, then unbinds it (context 0), then gives it back. Pages are taken round-robin, so a page given back is the last the next contexts take. A busy desktop held 74 contexts ("Contexts", below); a context past the 256, or whose page the kext could not map, has none, and its process rings through the kext's Doorbell call, as before the pages.
  • A page's write. A 32-bit write at a bound page's first byte of a ring's id, with RGFX_DOORBELL_ASKS as DOORBELL takes it, is that context's own DOORBELL: it wakes the ring where it is one of the context's command queues' rings, and an asking write is answered at the doorbell as there. Every other write is dropped and counted, logged once per kind: at an unbound page or another offset of a page (unbound), or of ring 0 or a ring of another context's queue (foreign). A ring of no queue is ignored, as at DOORBELL (a_doorbell_page_wakes_only_the_rings_of_the_context_it_is_bound_to). A reset unbinds every page (a_reset_unbinds_every_doorbell_page).
  • Routes. Where the guest took DOORBELL_PAGES, a queue whose context has a page is routed on the page's doorbell, not DOORBELL (the C API's route_doorbell_page): QEMU registers its ioeventfd at the page's first byte, matching the ring's id ("Routed doorbells", below). A queue whose context has none is routed on DOORBELL as before, and a host that routes no page leaves a queue of a context with one unrouted, its writes taken by the page's write (a_queue_is_routed_on_its_context_s_doorbell_page). The kext's own publish of a queue's ring ("A commit behind held messages is one call") rings at the context's page too, so its write meets the route. A page bound to another context drops every route on it of its old context's queues, so the host wakes no ring at a page but its context's (a_page_bound_again_drops_the_routes_of_its_old_context); the kext unbinds a page only once its process's mapping is gone, and its context's queues are closed with it.
  • Security. The host trusts nothing a process writes but the ring's id: the context is the page's, bound by the kext. A process maps only its own page, and wakes, and asks the answer of, only its own context's queues, as through the kext's Doorbell call, which writes any ring's id the process names (ring 0's and other processes' included) and so allows more. The one reach past a context: a process that makes an alias of its page's mapping (mach_vm_remap) keeps it past its context's close, as the kext cannot take an alias down, and its writes there reach the page's next context. Their bound is what a page's write does: a wake of a ring of that context's queues, which takes only what the context's process published on it, and an asking write's answer, which goes into that context's own completion ring. Never more than the Doorbell call allows any process today. A storm of writes at a page costs the writing process a VM exit each, as a storm of Doorbell calls does.

Contexts. Each process that opens the accelerator's user client gets a context from the kext: a number c, handed out once from 1 (its object ids are c << 40 and up), and a range of GPU addresses, held until its close, from which its bundle picks every buffer's, heap's and texture's address (guest/kext/src/RgfxContextSlots.hpp). The guest's addresses are [2^46, 2^47) (RGFX_CONTEXT_VA_BASE to RGFX_CONTEXT_VA_END), which the host's own ranges never reach, in 1024 units of 64 GiB (RGFX_CONTEXT_VA_UNIT); a context holds an aligned run of units: one, unless the device's maxBufferLength is more than 32 GiB, and then the least power of two that holds twice it (at most 32), so a buffer of maxBufferLength always fits. The kext reads maxBufferLength from the device info at the first open. OpenContext answers the range's span sixth (kext feature ContextSpan); a bundle that asks for five values picks through RGFX_CONTEXT_VA_SPAN, 2 TiB, and gets an aligned run of 32 units, so an older bundle keeps working on a newer kext, and a newer bundle on an older kext takes the 2 TiB it hands out. Runs go round-robin, so a run given back is the last one the next contexts take, and the last 32 units free go to WindowServer alone, as the blocks' and queues' reserves do. The host knows none of this: it pins each address as given. Sized from what a desktop uses, measured on the RTX 5080 host (a6e722f47's host and guest, macOS 26.6.1): 17 processes held a context on an idle desktop and 74 with 42 apps and 7 WebGL and WebGPU pages open, where the 32 slots of 2 TiB the kext had before refused the 33rd process and every later one. The most GPU addresses one process held at once was WindowServer's 204 MiB (in 1525 picks of RgfxIdSpace::addressSpan), the largest single pick 35 MiB, and the furthest any process's picks went into its range 1.5 GiB (they go forward and come round only at its end), so a 64 GiB unit holds the busiest process's addresses over 300 times. Past the last run, OpenContext answers kIOReturnNoResources, and the bundle answers no device in that process (initWithAcceleratorPort: answers nil), which every Metal client handles, where a device whose every create answered nil stopped the frameworks that make their first objects at its open (Maps, Journal and Photos aborted, Games faulted). The kext hands out its region blocks (first fit, page granular). The process hands each create and destroy of its objects (ids in its range) to the kext by a user-client call; the kext posts it on the control ring and, for a pipeline create, hands the reflection back once the host answers it. A queue's QUEUE_CREATE goes the same way, its rings checked to lie in the process's blocks, and is answered once the host has the rings. At the process's close or death the kext destroys its queues, then closes its context (CONTEXT_CLOSE: the host takes its objects out of its tables, lets go of them on a worker of its own, reims-vgpu.graphics-closes-<n>, and answers once it has and the context's command buffers have finished), then, on that answer only, frees its chunks of resource ids, its blocks and its slot of GPU addresses. A command buffer is decoded once the host has carried out every control-ring message of its context's published before its queue's thread took it, and has taken every message before those.

A buffer's wait on ring 0. A buffer names only its own context's objects and spans in blocks its context holds, so what it can depend on on ring 0 is its context's: a message about an object (every type from QUEUE_CREATE below CONTEXT_CLOSE, which the kext takes from a process only with an object id of the process's), whose id carries the context's bits, or one the kext posts for a context (CONTEXT_CLOSE to SURFACE_PAGES), which names it. Another process's surface reaches a buffer only through the share of its block the kext posts for the buffer's context before the process learns of the block, after the surface's SURFACE_PAGES was answered: what the buffer reads of the surface the host made there, and the buffer names none of the other process's objects, so it waits for its own context's share and for none of the other process's messages. Textures do not cross processes, and a shared event crosses only by its name ("Shared events across processes"): the process that makes an event of another's posts its own SHARED_EVENT_IMPORT, an object message of its context's, which its buffers that name the event wait for, and the kext's SHARED_EVENT_UNNAME is context 0's, which no buffer is. A display command (GET_DISPLAYS to SET_DISPLAY_POWER), a SURFACE_DOWNLOAD or a PIPELINE_ANSWERS holds up no buffer: none reads what they make. A present waits for the writers the guest's record of its surface names, whatever the host has taken, those of a queue created just before among them: the device tells the host of a queue before it answers its create, so the present knows the queue though the host has yet to make its handle. A download waits for the buffers that used the surface's device cache before it was taken, so a buffer posted after it that writes the surface, but taken before it, is among them, as one posted before it is: the guest writes a surface a CPU lock holds only racing the lock. Every buffer waits for a message of any other type, which the host refuses. The queues' threads read ring 0 ahead of the control thread, each message once, and keep the count through each context's last message (reims_vgpu_graphics's device::backlog), so a buffer behind another process's backlog on ring 0 is decoded at once. Tested by a_command_buffer_waits_for_no_other_process_s_creates, a_command_buffer_waits_for_no_other_process_s_later_object_messages, a_process_s_messages_go_on_while_another_s_create_is_carried_out, a_command_buffer_waits_for_its_share_of_another_process_s_surface_not_for_that_process and a_doorbell_write_answers_a_command_buffer_behind_another_process_s_create.

Ring 0's lanes. The control thread takes ring 0 in ring order and carries out only the display commands and the kext's PIPELINE_ANSWERS itself. It hands each context's messages, in ring order, to that context's lane, every PRESENT_SURFACE and DISPLAY_COLOR to the presents' lane, in ring order, and every SURFACE_PAGES and SURFACE_DOWNLOAD to the lane of the block it names, whichever process posted it and for whichever context, so a block's pages handed over from another process's CPU lock, or after its maker closed, and the download or release posted right after them, keep their order without waiting for the maker's lane. A lane carries its messages out one at a time and posts their answers, so one process's slow message (a heap over pages took 469 ms at the median and 4.25 s at most in a boot on an RTX 5080 host) holds up only that process's later messages and command buffers. A message waits for another context's lane only where it reads what that lane's earlier messages change, and only for messages published before it (reims_vgpu_graphics's device::lanes):

  • a present waits for each lane's TEXTURE_FROM_IOSURFACE of its surface's plane 0, its destroy of a texture the host names the surface by, and the close of a context that holds one: the host shows the newest live texture over the surface;
  • a shared block's BLOCK_RELEASE waits for each other context that held it: the host refuses a release while an object of any context lies in the block;
  • a BLOCK_GRANT in the scanout's span waits for every lane: a grant takes the span from whoever held it, and WindowServer's contexts are granted it in turn;
  • a RESOURCE_ID_CHUNK or RESOURCE_ID_SMALL_CHUNK of ids another context held waits for that context's close, and a context's first message for every close before it, whatever the context's number (the kext numbers contexts at their opens, and a process may post its first message after one opened later): the kext frees a closed context's chunks and its slot of GPU addresses once the close is answered;
  • a context's message waits for each block's lane through the context's last SURFACE_PAGES on it, and a command buffer for its context's messages on the blocks' lanes too, as when they shared the context's lane;
  • a BUFFER_OVER_PAGES, HEAP_OVER_PAGES, BUFFER_OVER_SURFACE_PAGES or BLOCK_RELEASE waits for its block's lane: each reads the view or device cache the block's lane makes and copies;
  • a SURFACE_PAGES waits for its context's lane only through the last message of those four kinds that names its block, and for each lane through its last BLOCK_RELEASE of a block described cached whose runs share a page with its own: the release copies that block's device cache into the pages, and the kext makes a surface's new block over them only once the release is answered, however long a slow message on the release's lane holds it (the device's stop and the asking thread's abort end that wait); a SURFACE_DOWNLOAD waits for no other lane, as on the control thread before.

reims_vgpu_graphics's device::lanes lists every message that names a block or its pages by offset, and what orders each against the block's lane.

A close's job on its lane is its table work: it lets go of the context's objects on the closes' worker (reims-vgpu.graphics-closes-<n>), which the close's answer waits for, so a message that waits for a close waits for none of the platform's releases (an event's took 0.4 ms on an RTX 5080 Laptop GPU, measured by the decoder's close_cost). A reset waits for the closes before it to have let go of theirs.

Each wait is for a message published earlier, and every lane with a message has a thread, so the waits end. What the guest can tell apart from one thread: answers to different processes come in another order than their messages, which the kext matches by seqno; and two processes' messages that no answer orders are carried out in either order, as the processes' own posts race. A process that waited for an answer finds its message carried out. A reset drops the messages a lane has not begun, and is told to the host once those begun have returned. A lane's thread is woken only for its own messages and for the lanes its next message waits for, and a lane with nothing to do holds no thread, whatever other processes do.

Ring 0's threads (reims-vgpu.graphics-ring0-<i>) serve the lanes. A lane handed a message while it has no thread is given the thread that went idle last, or one made for it where none waits, and keeps it until it has no message left; the thread then waits for the next lane, and goes once it has waited 10 s for one (reims_vgpu_graphics's keep). So the device holds as many threads as it had lanes busy at once in the last 10 s, whichever contexts and blocks they were. With a thread of each lane's own, made as a message came to a lane with none and gone after 1 s with none, every new block's first SURFACE_PAGES made a thread, and so did every lane's message after a pause of a second: 345 threads were made in 30 s of a WindowServer probe, and a vCPU sat 30 ms or more in a page fault while one of them unmapped its 2 MiB stack, a write of the process's memory map the fault waits behind (car 12's B1, RTX 5080 host; measured). Tested by a_present_waits_for_another_context_s_texture_over_its_surface, a_present_waits_for_a_destroy_or_a_close_of_a_texture_over_its_surface, a_present_waits_for_no_message_that_leaves_its_surface_s_textures, a_shared_block_s_release_waits_for_its_other_holders, an_unshared_block_s_release_waits_for_no_other_context, a_scanout_grant_waits_for_every_context_s_messages_before_it, a_chunk_or_a_new_context_waits_for_the_close_before_it, a_shared_block_s_release_behind_a_holder_s_close_waits_for_none_of_its_releases, a_reset_waits_for_a_close_s_slow_release, a_context_s_first_message_waits_for_the_close_before_it_whatever_its_number, a_sync_create_is_answered_before_its_context_s_later_messages_are_carried_out, a_context_s_answer_comes_before_one_published_ahead_of_it_by_another_context, a_reset_drops_what_the_lanes_have_not_begun, a_steady_load_s_lanes_are_served_by_one_thread_through_its_pauses, a_burst_s_other_threads_go_once_they_have_waited_keep and lanes_keep_every_order_over_random_interleavings, which checks random interleavings of several processes' messages against an order worked out from the messages alone. A synchronous create's answer takes 7.2 us on average from its doorbell, against 4.1 us from the control thread alone (a_sync_create_s_round_trip, release build, M3 Max). After a pause of 1.2 s, in which the lane's thread went to wait for another lane, it took 64 to 171 us at the median of three runs, against 116 to 353 us where the pause ended the lane's thread and the create made it again (the same test, alternating runs on the M3 Max under other builds' load). A context's burst of 200 messages and a synchronous create take as long beside 75 idle lanes as beside none: 0.1 to 1.4 ms at the median either way, on the M3 Max under other builds' load (a_burst_beside_idle_lanes, release build).

A queue's thread waiting for ring 0 before it hands a command buffer on is woken once the control thread has taken the messages the buffer waits for, and once its context's lane has carried out the context's among them, and by nothing else but a reset, its queue's end and the device's (reims_vgpu_graphics's device::gate): no other process's message wakes it. Tested by the_gate_wakes_each_waiter_once_what_it_waits_for_holds, which moves the count and many contexts' lanes at random beside many waiting threads. Beside 75 other processes' queues each waiting on a held create, a context's burst of 200 messages and a synchronous create took 11 to 16 ms at the median when every lane's message and control step woke every waiting queue, and take 49 to 123 us now, as beside none (a_burst_beside_waiting_queues, release build, M3 Max under other builds' load).

A queue's thread that waits so for its context's lane carries out the lane's next job itself where no thread of the lane's carries one out yet, the buffer waits for it, and it is a BUFFER_AT_OFFSET or an OBJECT_DESTROY of no queue: the creates and destroys the bundle holds and posts ahead of each commit ("Destroys and creates no one waits for go together"). The job is the lane's running one meanwhile, so the lane still carries its jobs out one at a time in ring order, and the lane's thread waits for it before its next. The buffer waits for the same messages as before, carried out through the same host code before its begin; only the thread that carries them out changes, and the buffer's wait ends with neither a ring-0 thread's wake before the job nor its own after it. A queue's destroy routes the queue's doorbell and ends a queue's thread, and the other kinds may wait long or for a queue's command buffers, so each stays with the lane's thread. Measured before the change in Geekbench 7.1's Super Resolution on the Radeon 780M (a macOS 26.7.2 guest, development cee5813f2's timed pass, 19.19 s): 3480 of 6289 command buffers waited so, 30.2 us at the median and 87.5 us at the 90th percentile from the take to the gate's end, 138 ms in all. Each waited only for those two kinds, 6 jobs at the median that ran in 17.5 us, and 8.8 us at the median went on the queue's thread's wake after the last of them. 56% of them found a ring-0 thread already carrying one out at the take, which carries the rest on as before. For the others, carried out on the trace's own times with the wakes taken away, the waits shrink by 42.5 ms over the workload (45.5 ms in the warm pass), 0.2% of it: under a walk's run-to-run spread (about 0.5%), so the change was not walked apart. A wait without sleeping before the gate was measured against the same trace and dropped: it saves only the queue's thread's own wake, at most 17 ms over the workload for 34 ms of a core spinning. Tested by a_buffer_s_thread_carries_out_the_creates_and_destroys_it_waits_for, a_buffer_s_thread_leaves_other_kinds_to_the_lane_s_thread, only_a_buffer_at_offset_and_a_destroy_of_no_queue_are_a_buffer_s_thread_s and buffers_wait_for_their_context_s_messages_over_random_interleavings.

The surface and ICB workers. A lane hands what it would wait long for, and the guest learns of only through an answer or a later message, to a worker of the host's: a SURFACE_PAGES, whose view of a 3840x2400 layer took 9000 mappings, made in 16 to 478 ms (msi 5080 host), a pages block's BUFFER_OVER_PAGES that makes or follows such a view, the let-go of a released block's views and device cache and of a buffer over a view at its destroy, and an ICB_CREATE. A worker runs the jobs of one key one at a time, in the order they were handed over, and different keys' at once, on at most four threads (reims-vgpu.graphics-surfaces-<i>, reims-vgpu.icb-create-<i>), each made as a job finds none waiting and gone after 10 s with none; a job wakes the thread that went idle last, so a steady load's jobs stay on the threads it runs at once. The surface worker's key is the block, the ICB worker's the process. So a block's slow view holds up only that block's later jobs, and a key that finds every thread busy waits for the next free one. No job waits for a job of another key, so jobs waiting for a thread never wait for each other: a BUFFER_OVER_PAGES waits only for its own block's SURFACE_PAGES, done before it, and a SURFACE_PAGES for nothing, as a debug build checks. What the guest can tell apart from one thread: two BUFFER_OVER_PAGES of one process on different blocks are made in either order, which no answer orders, and the process's later messages wait for both. Tested by a_key_whose_job_hangs_holds_no_other_keys_jobs, a_key_waits_for_a_free_thread_once_every_thread_is_busy, each_keys_jobs_run_one_at_a_time_in_handed_order, an_idle_thread_ends_after_keep and jobs_after_a_burst_go_to_the_thread_that_went_idle_last. Beside K blocks that each run 25 ms jobs back to back, another block's job starts after its hand-off in 0.015 ms at the median for K of 1 or 2, 5 to 6 ms for 4, 22 to 23 ms for 6 and 35 to 38 ms for 8, where one thread took 24, 54 to 56, 115 to 117, 179 to 182 and 241 ms (another_blocks_job_beside_busy_blocks, two runs of each, release build, M3 Max at load averages of 28 to 52).

WindowServer's reserve. The blocks have no per-process cap: Metal on a Mac refuses an allocation only when memory runs out, never because another process holds much, so neither does the kext. The one process whose refusal would stall every other is the compositor. So the last 160 MiB of the blocks' room and the last 4096 of the table's 16384 entries go only to WindowServer's blocks (RgfxBlockTable's reserve). WindowServer takes the first gap from the start like any process, and reaches into the reserve only once the rest is full; any other process is refused at the reserve's edge, as at the region's end. Of the watched rings, the last 64 are WindowServer's alone in the same way, past room for one process's 2048 queues beside as many of the others' (RgfxQueueLimits.hpp). The kext logs the most WindowServer's blocks and queues came to, which is what the reserve is sized from: on an RTX 5080 host at the display's 3840x2400 mode, WindowServer held 134 MiB at most, at login, and 118 to 126 MiB in 110 to 366 blocks as five apps opened, with 2 queues (measured). With some 70 processes open its blocks came to 1358 and 169.7 MiB, past the reserve's 160 (measured), most of the bytes its no-copy buffers' copies and its Managed textures' CPU copies. Those lie in its own pages now, as its Managed buffers' CPU copies and its encoders' upload chunks do ("Managed storage"), so what WindowServer keeps in the region is what no page of its own can hold: its rings, its command buffers' bodies and its surfaces' blocks. The entries hold three times the 1358 blocks. Four displays of 3840 × 2160 took WindowServer's blocks to 20360 KiB and 460 blocks at most (measured; "Multiple displays", X5).

The kext knows WindowServer's client by two tests at its open: the opening process is named WindowServer, and it holds the entitlement com.apple.private.graphics-restart-no-kill (IOUserClient::copyClientEntitlement). WindowServer holds that entitlement on macOS 26.7.1 and 27, read from its signature (com.apple.WindowServer, a platform binary). With SIP on, AMFI refuses any com.apple.private entitlement to a binary Apple did not sign. So a process that only takes WindowServer's name fails the second test. The direct tests, the process's signing identifier and its platform-binary status (cs_identity_get, csproc_get_platform_binary), are in com.apple.kpi.private, which a kext outside Apple's namespace cannot link. Resolving them at run time through the loader is not worth its risk.

WindowServer's queues are unshared. A runtime that lets command queues share a GPU queue, which raises the rate of small command buffers on a GPU whose switches between queues idle it, can then hold another process's long command buffer ahead of the compositor's frame. So the accelerator flags every queue WindowServer's process creates RGFX_QUEUE_UNSHARED in its QUEUE_CREATE's tail, where the host offered UNSHARED_QUEUES and the framebuffer took it (rgfxQueueFlagsSent, RgfxFeatures.hpp). It decides from its own test of the client's task at the open (above), never from what the process asks: QueueCreate's seventh input never grants the flag. The host makes such a queue with the platform's new_command_queue_unshared (GpuDevice). On the Vulkan platform that is the platform's plain new_command_queue: the runtime submits every command queue's work to its one GPU queue, a VkQueue it makes at priority 1.0 as it makes its queue for presents, with no global priority. So an unshared queue's buffers wait behind every buffer submitted before them, as any queue's do ("A command buffer in parts"), and no queue priority reaches Vulkan (dgpu-oracle.md, Q50). The host logs each unshared queue at debug level, on its own target (reims_vgpu::graphics::queues). Nothing the guest's processes see changes.

Reset. A reset leaves the device as one just made, as a device's function reset does: STATUS 0, which the framebuffer writes at its start, and QEMU's reset of the device, which a reboot inside one QEMU run makes. Every command queue ends, no block is any process's, and the host drops every object of every context, as each one's close does, with no answer owed. The blocks' surface views and device caches go too, uncopied, since their pages are the rebooted guest's again, and so do the library cache, the presents waiting and the pipelines compiling. Nothing begun before the reset reaches the guest after it. The guest then finds what a new device gives it: the ids it picks free from 1 again, every texture resource id and GPU address free (a range a buffer of the guest's before the reset still held would refuse the rebooted WindowServer's pin of it), a library lookup that misses, and VBLANK counts from 0. What the guest wrote in the region stays.

The display keeps its scanout across a reset, as a GPU's display engine goes on scanning out across a reset of its driver: the host's window shows what the guest writes there until the guest sets another scanout or blanks it. The kext's start resets the device to take it, and where the start fails after that (the device lists no usable display, or IOFramebuffer's start fails) it resets it again on the way out; the OS then draws into the firmware's framebuffer, which the firmware's scanout, kept through both resets, still shows. Tested by a_reset_keeps_the_scanout_and_what_the_guest_writes_there_shows (reims-vgpu-graphics) and a_failure_after_the_take_keeps_the_firmware_s_scanout_in_the_window (graphics/tests.rs).

Texture resource ids. Every process's textures share the host's one device, whose texture ids end below 16381: Metal ends the process for a texture placed at 16381 or more (measured on an M4 and an M3 Max), and metal2vulkan imitates that. So ids are not split by slot. The kext keeps one pool for the guest, the ids 1 to 16320, in 1020 small chunks of 16 (small chunk k holds 1 + 16k to 16 + 16k), and hands a process a chunk when it asks (user-client selector 0x106), posting the grant on the control ring before it returns, so the host has it before any create naming its ids. Where the host offers SMALL_ID_CHUNKS the chunk is one small chunk (RESOURCE_ID_SMALL_CHUNK: context, small chunk); else it is an aligned run of four, chunk k of 64 ids, 1 + 64k to 64 + 64k (RESOURCE_ID_CHUNK: context, chunk), as a host from before the bit takes. A process that makes a texture holds a chunk until its close, so 64-id chunks let 255 texture-making processes run at once, fewer than the 1024 contexts the GPU addresses hold (a busy desktop held 74, "Contexts"), where small chunks let 1020; the pool's ids are as many either way. The host reserves the pool's ids on its device as it makes the graphics device, its first call on the device (reserve_guest_texture_ids, crates/reims-vgpu/src/graphics.rs). The Vulkan platform is told the ids before the device is made and reserves them as the device's first call, before its own probes: on Linux, a GPU whose imports of views need their pages mapped from their files makes a command queue as its device is made, where its driver's fold verdict is not kept yet (a cold cache, a new driver or kernel). Metal hands the id of a texture placed at one out again to plain allocation, so without it the guest's textures would share ids with the host's own (the window's drawables, the cursor), and a texture placed past the table a fresh device has corrupts Metal's heap (placements from 10000 up crashed some runs). The reservation keeps the ids from plain allocation and grows the table to hold them (measured on an M3 Max, macOS 27; metal2vulkan imitates both). Metal takes one only before the device's first texture, and once the device has a queue it hands the pool's first range out twice, so the host checks it with a few plain textures and logs an error where one takes a guest id. Were the paravirt lane's device in the same process, on the same GPU, the graphics lane's reservation would win: it is made as the device is, before any guest runs, while the paravirt lane reserves its placed objects as each task starts, and Metal takes only a type's first reservation. That would not make the two safe together: both lanes' guests place textures in the device's one table, at ids each picks alone. So a process runs one lane's device on a GPU, and today a VM has one lane or the other. The bundle keeps each small chunk's free ids in one 16-bit mask, takes the lowest free id of the first small chunk taken that has one, asks for a chunk only when all of its are in use, and gives an id back as its texture goes, after the texture's destroy (below), so a later create with the id follows the destroy on ring 0. The host names an IOSurface by every live texture over its plane 0, and shows the latest. A present holds its own reference to the texture it shows, so a destroy after the present leaves the window's frame drawable. A process keeps its chunks until its close. With every chunk held, a texture create answers nil, as Metal answers a texture it cannot make. The host carries out a texture create only where its id lies in a chunk of its own context (by the object id's context); any other id, 0 and the limit's included, is refused before any platform call, as a refused create is: unanswered, and an id of its own context then stands for a refused object, whose uses are dropped ("Guest input the host refuses"). Sampler states and pipeline states take no guest-picked ids (the host numbers them), and the bundle makes no indirect command buffers, so textures are the only kind with chunks.

Objects go with their wrappers. Every host object the bundle makes goes from the host as the app lets its wrapper go. A buffer, heap, texture, sampler, depth-stencil state, render or compute pipeline, library, event, fence or shared event posts its OBJECT_DESTROY from its dealloc. Samplers and depth-stencil states are made once a descriptor: the device answers an equal descriptor, label included, with the object it made, as the M3 Max's Metal does, and keeps the last 64 of each kind it made after the app lets them go, so an app that makes one every frame pays one create (guest/bundle/src/RgfxStateCache.h). A queue ends through the kext (user-client selector 0x104), which stops watching its completion ring and posts the destroy. Command buffers ride their queues' own rings, so a destroy must not reach the host before a buffer that names the object. A command buffer keeps every object its encoders name, from the encode until its completion handlers have run, or until it goes uncommitted, as Metal's with retained references keeps what it encodes. One made with unretained references keeps them too, though it answers retainedReferences NO, since the host must not drop an object before a buffer that names it runs. A buffer whose completion never comes holds back only what it names. Objects are released in the order they go. What an object lay over goes back only after its destroy: a Shared buffer's or heap's region block, an IOSurface plane's block, a queue's ring blocks (its completion ring read no more first), and a texture's resource id. The block's BLOCK_RELEASE then finds nothing of the object on the host. What a destroy gives back (an object's resource id and GPU address, its heap's bytes, its region and pool blocks, its pages and its ICB slots) also waits until the host has completed every command buffer the process committed before the object was let go, a failed one included (RgfxRetireGate, guest/bundle/src/RgfxSerializer.hpp). The host keeps a destroyed object for the buffers committed before its destroy, but a new object made with its resource id or at its address takes them at once, so a buffer still running there would read the new object for the old one. A buffer committed after the object was let go holds nothing back, and the serialiser's end, the context's, runs whatever still waits. A resource placed in a heap keeps the heap alive (its heap), a command buffer keeps its queue, and a function keeps its library. So a pipeline made from a function whose library the app let go names a library the host still holds. The host makes the pipeline from the library before the library's destroy, and the pipeline needs it no more.

Destroys and creates no one waits for go together. Each call into the kext costs the guest its trip through the kernel, and a post that finds the host's control thread asleep a doorbell's exit too: 14 us a destroy in a Vision request on the RTX 3090 host (9 to 10 us without the doorbell), 3415 destroys and 68 to 70 ms a process, in runs of about 70 an app lets go back to back, and 12 to 15 us a BUFFER_AT_OFFSET, the buffer a heap places (each small buffer of a slab), 3079 and 40 to 48 ms a process, between them; and on the RX 7900 XTX host 8 to 13 us each of a Vision process's 276 TEXTURE_CREATEs, 82 TEXTURE_VIEWs, 46 MANAGED_TEXTURE_CREATEs, 204 MANAGED_BUFFER_CREATEs and 204 BUFFER_DID_MODIFY_RANGEs, 8.8 ms a process. So where the kext carries SubmitBatch (selector 5), the bundle holds each of these messages, none of which anyone waits for or which names a block (RgfxSerializer::postUnwaited, RgfxRingWriter::postLater), and posts what it holds in one call, at most 4096 bytes (170 destroys, 73 buffers, 39 textures), before anything else the process posts or asks of the kext (every IOConnectCall of the device's goes through rgfxKextConn, which posts the held first) and before any command buffer it commits (the host reads a command buffer after the control ring's messages posted before it), once the held fill a call, or 1 ms after the first held. The kext checks each as Submit checks one, all before it posts any, puts the runs on the ring under one hold of its lock with one doorbell at most, ends a queue's as Submit does, after the messages before it, and follows a buffer made for a context that closed since its check with its destroy, as Submit does. What an object lay over goes to RgfxRetireGate as its destroy is held, as it did once its destroy was posted: whatever takes it again, a create over the bytes or with the id, or a block's free, is posted after the destroy, so the host has dropped the object first, and every answer the guest reads (a heap's usedSize, a new object's GPU address and resource id) is the one a posted destroy would give. A texture over an IOSurface goes at once, made and destroyed: a present of the surface, by any process, shows the newest live texture the host names it by, and waits for its create and its destroy. So do the creates that name a block (BUFFER_OVER_PAGES, BUFFER_OVER_SURFACE_PAGES), which the block's lane orders. Where the kext stops taking them (its ring stayed full 5 s, or the device stopped), the rest stay held, first: the process's next post retries them, under its own post's bound, and is refused only where they are refused again, as the full ring refuses it; a commit that finds a buffer still held fails the command buffer, unposted, with MTLCommandBufferErrorInternal, as a GPU recovery's victim fails, as the buffer may name it; so does any message held but a destroy, each of the kinds above (a create the buffer may name, a Managed range it may read). Two answers differ from an unbatched post's then, and only then: an object held when the kext stopped taking them was answered as made, where its refused post answered nil (as Metal makes objects on a GPU that is gone, and fails the work at commit), and its refusal reaches the app at the next post, refused in that call, or the next commit, failed, never later; and what the held destroys lay over has gone back, which a guest reading a heap's usedSize through a 5 s stall of the control ring sees lower than it did. Tested by serializer_tests' test_held_destroys and test_held_buffers and test_held_creates, shell_tests' test_held_destroys_change_nothing_seen, test_surface_texture_destroys_go_at_once and test_commit_behind_an_untaken_buffer_fails, and the kext's by submit_gate_test, spans_test and user_client_words_test.

A commit behind held messages is one call. A command buffer committed while the control ring holds messages (above) made two kext calls: the held went in a SubmitBatch, and the bundle then published the buffer on its queue's ring and, where the host's queue thread slept, rang its doorbell through the kext. Where the kext takes it (1 << 11 QueuePublish), the bundle writes the buffer on its ring and fences its stores, but leaves the producer, and hands the queue, the new producer and the doorbell's flags (whether the host answers the buffer at the doorbell, and whether that doorbell names RGFX_DOORBELL_ASKS) to the SubmitBatch that posts the held (RgfxRingWriter::tryPost's via, RgfxSerializer::publishVia). Once every held message is posted, the kext stores the producer, fences, reads consumer_idle and rings the queue's doorbell as the bundle would (RgfxQueuePublish.hpp), so the host sees what it saw before: the held on ring 0, then the buffer on its queue's ring. The kext keeps a kernel mapping of each queue's ring header for it, made at the queue's create while the ring's block is pinned, and let go at the queue's destroy, at the free of the block the ring lies in and at the context's close, before the blocks go, so it never writes a ring the process no longer holds; a queue past its first 64, or a ring outside the process's own blocks, has its buffers published by the bundle. A commit with nothing held, or behind an encode into an indirect command buffer or a refused destroy waiting, goes as before. Where the kext leaves a held message other than a destroy unposted, it publishes nothing, and the bundle takes the buffer off its ring unseen (its seqno the next buffer's, its completion's handlers dropped) and fails it as above; with only destroys left, the bundle publishes the buffer itself. The buffer's posted time (GUEST_TIMES) is stamped before the call, not just before the producer moves. Tested by shell_tests' test_commit_hands_its_publish_to_the_held (the route, nothing held, a kext without the feature, a refused create and refused destroys) and the kext's queue_publish_test (the publish against the bundle's own, and the headers' table).

A waiter looks for its answer. A lifecycle message the kext waits for (postLifecycle: a heap texture's size, a library's lookup, a surface's pages) is answered within tens of microseconds of its post, 60 to 110 us for a surface's pages on the RTX 3090 host; the answer then waited for the interrupt, the work loop's wake and the waiter's, about 25 us more. So the waiter looks for it for at most 150 us (RgfxAnswerLook.hpp) before it sleeps: where the control completion ring holds a record the work loop has not taken, it takes the ring in the work loop's gate, as the work loop does, and else pauses the CPU. It never waits for the gate: where another thread holds it, the waiter pauses and looks again, so a holder that waits for a lock the waiter's caller holds waits at most the look's 150 us, and the waiter then sleeps as before; the asks that wait with no deadline (below) are posted holding no lock the work loop takes. The rest of the work loop's service follows at the interrupt the record raised. Only a thread whose call waits for an answer looks, and only that long; a later answer wakes it as before. Tested by the kext's answer_look_test.

How a waiter waits. The host answers a process's asks on the asking context's lane, behind what the context posted before them, a pipeline's compile among it, which takes seconds cold and longer on a slow host. So the kext waits for them with no deadline, as Metal's own calls wait for the GPU's driver (RgfxAnswerWait.hpp): a create or a query a process submits, a take of its deferred creates' answers, a shared event's name or import, a queue's create, a surface's SURFACE_PAGES and SURFACE_DOWNLOAD, a CPU lock's wait for its surface's writes and the host's copies, and a new block's wait for its surface's write-back. The bundle's library stream waits for each chunk's ack with no deadline too (RgfxLibraryStream.hpp). Such a wait sleeps THREAD_INTERRUPTIBLE and ends only at the answer, at the device's stop (quiesce wakes every waiter, each finding the device stopped), or at the thread's abort, a SIGKILL, a signal whose default action ends the process, or its exit; a caught signal never ends it. A create whose wait the abort ended has its destroy posted behind it, which cancels its compile on the host (RgfxSubmitGate.hpp). What the guest sees is that a call behind a slow compile waits for it: a lock or a present of a surface the compiling process draws, its queue's create, its next create. A pool or Private block's take waits with no deadline too, THREAD_UNINT, as its context's close waits for it. The asks that keep a deadline wait on no compile: the control ring's room (5 s: the host's reader takes messages off the ring behind no compile), the display's commands (5 s), the kept pipeline answers read at the start (5 s), a context's close (10 s, after which it is parked, not dropped), the display pipe's (5 s, WindowServer's, a transaction not sent being sent again with its next frame), an arm64 guest's video sends (10 s), and a new block's wait for the region's room (100 ms, after which the process makes a copy).

The kext's 64 lifecycle waiters are split by kind, each kind taking only its own, so asks that wait with no deadline never take the waiters WindowServer's asks need: 32 for the creates and queries the processes submit and their shared events' names and imports; 16 for the surfaces' SURFACE_PAGES and SURFACE_DOWNLOAD, any process's, WindowServer's for its own surfaces and at its CPU locks among them; and 16 for the device's own asks, a queue's create, a context's close, a pool or Private take, the kept pipeline answers and an arm64 guest's video sends (rgfxWaiterKind). A thread that finds its kind's waiters taken waits for one in its ask's mode. The display's commands have 8 waiters of their own. Tested by the kext's answer_wait_test, which takes every create waiter and finds the surface and device asks theirs.

Rings. A 256-byte header, then a byte ring whose size is a power of two (64 KiB minus the header for the control rings). Each header field sits in its own 64-byte line:

offset field written by
0x00 producer: u64, free-running byte count producer
0x08 completed_seqno: u64, on a queue's completion ring the seqno of the last command buffer that finished OK, 0 before one has host (queue completion rings)
0x10 producer_waiting: u32, 1 while a producer waits for room (SUBMIT_ROOM, CONSUMED_DOORBELL) the waiting side; host 0
0x18 guest_clock_offset_ns: i64, on ring 0 where the guest took GUEST_TIMES, the guest's clock less the host's guest (ring 0)
0x20 guest_clock_bound_ns: u32, how far that offset may be off; 0 while the guest holds none, stored after it with release guest (ring 0)
0x40 consumer: u64, free-running byte count consumer
0x80 consumer_idle: u32, 1 (RGFX_CONSUMER_ASLEEP) while the consumer sleeps, 2 (RGFX_CONSUMER_WALKING) while a queue's consumer walks a command buffer consumer
0xc0 armed: u32, 1 when the guest wants an interrupt guest (completion rings)
  • A message starts with type: u32, size: u32 (bytes including this 16-byte header, a multiple of 8) and seqno: u64. The guest numbers its commands from 1, per ring. A message never wraps: type 0 pads to the ring's end.
  • Doorbell. The producer writes the message, publishes producer (release), then issues a full fence and reads consumer_idle. If it reads 1, it writes the ring's id to DOORBELL; if it reads 2, it does so only for a command buffer whose last op asks for its CB_SUBMITTED, which the host may answer inside the write. Under DOORBELL_ASKS that buffer's write carries RGFX_DOORBELL_ASKS with the id, and every other write the id alone. Before sleeping, the consumer sets consumer_idle to 1, issues a full fence and reads producer again, so no wake is lost. It clears consumer_idle when it wakes. A queue's consumer sets it to 2 while it walks a buffer on its own thread, after which it takes the ring again with no doorbell. A producer that rings only on 1 rings for nothing on 2, and its asking buffer is answered at that take.
  • Interrupts. The host publishes a completion, issues a full fence and reads armed. If it reads 1, it clears it and raises the ring's vector. The guest sets armed after draining, issues a full fence and checks producer again.
  • The re-arm. A consumer already awake (the completion thread after a buffer's CB_SCHEDULED) can take a record between the host's publish and its clear, and arm again: the clear then takes an arm made after the take, and its vector comes for a record already taken, so the thread sleeps with armed 0 and the host raises nothing for the next record. So where the clear reads 1, the host reads consumer too, and where the guest has taken every record published, sets armed back to 1 and raises nothing (ring.rs, rearm_or_raise). The guest stores consumer before it arms, so a clear that read its arm sees its take, and only the host writes 0, so the 1 undoes nothing of the guest's. The fix is the host's alone: no kext or bundle changes, and ring 0's completion ring takes it too.
  • The completion thread's arm, once. The header is uncached memory to the guest on an AMD host under xnu's PAT (write-back once the kext sets the PAT's entry 2: "The BAR is one host memory region"), so the completion thread writes it only where something changed (RgfxReplyReader::armAndCheck): a ring its last arm found empty, from which it has taken nothing since, it does not arm again while producer reads as it did then, as the host clears armed only in a post, after its publish; and a pump that took nothing leaves consumer as it was. ring/interleavings.rs walks every interleaving of the host's post, the kext's look and the completion thread's take, arm, arm skipped and sleep (up to 3 records and 2 vectors for something else): none leaves a record untaken or the thread asleep unarmed. The kext's take of ring 0's completion ring, at each interrupt of the control vector, which every queue's completions share, and at a waiter's look, keeps the same rule (ReimsGraphics::takeCompletions, RgfxCompletionArm.hpp): it arms only where it took records since its last arm or that arm found records behind it, and stores consumer only where it moved; completion_arm_test walks every interleaving of the host's post against its take. A wake index the host only reads (virtio's used_event) was weighed and declined: it would change a ring's format in the host, the kext and the bundle, and the re-arm closes the race without one.

Control commands (guest to host, ring 0). Each is answered by a COMPLETE with its seqno and a status (0 for success), or by the reply named.

type name payload answer
1 GET_DISPLAYS none DISPLAYS
2 SET_SCANOUT display u32, width u32, height u32, stride u32, offset u64 into BAR2, the scanout inside RGFX_SCANOUT_SPAN's room; width 0 blanks the display COMPLETE
3 SET_CURSOR display u32, width u32, height u32, hot_x u32, hot_y u32, offset u64 of a BGRA8 premultiplied image; width 0 removes the image COMPLETE
4 MOVE_CURSOR display u32, x i32, y i32, visible u32 none
5 SET_VBLANK display u32, enabled u32 COMPLETE
8 SET_DISPLAY_POWER display u32, on u32; 0 turns the display's panel off (DISPLAY_POWER) COMPLETE
9 DISPLAY_BOUNDS display u32, min_x i32, min_y i32, max_x i32, max_y i32, a reserved u32: the display's rectangle in the guest's desktop, in points (DISPLAY_BOUNDS) none
10 CURSOR_COLOR display u32, on u32, then the source's curves (red, green, blue: form u32 and seven f32 parameters each), the source's matrix to XYZ and the matrix from XYZ to the blend space (nine f32 each, row by row), and the blend space's curves (CURSOR_COLOR) none
11 SCROLL_DEVICES devices u32 (RGFX_SCROLL_DEVICE_WHEEL 1, _PRECISE 2), a reserved u32: the guest's own devices that scroll, after each start ("Scrolling") none

Scanout pixels are 32-bit BGRA8 (kIO32BGRAPixelFormat), the one format in stage 2.

Events (host to guest, the control completion ring):

type name payload
0x100 COMPLETE status u32
0x101 DISPLAYS count u32, then per display: id u32, connected u32, preferred mode index u32, mode count u32, where the guest took DISPLAY_SCALE its host screen's scale in 120ths u32 and a reserved u32, then per mode: width u32, height u32, refresh in mHz u32
0x102 DISPLAY_CHANGED display u32; the guest asks GET_DISPLAYS again
0x103 VBLANK display u32, count u64, host time in ns u64
0x104 POINTER_OVER display u32, x i32, y i32, buttons u32 (RGFX_POINTER_BUTTON_*); only to a guest that took POINTER_OVER
0x105 POINTER_MOTION dx i32, dy i32 (right, down), wheel i32 (notches up), buttons u32 (RGFX_POINTER_BUTTON_*, held after it); only to a guest that took POINTER_MOTION
0x106 SCROLL notches_up i32, notches_right i32, fine_up i32, fine_right i32 (1/256 point); only to a guest whose SCROLL_DEVICES named its wheel ("Scrolling")

Display. The modes offered are the host window's size, its width rounded down to a multiple of 16 pixels and its height to even, and its screen's refresh rate (the guest runs at the host screen's rate). 16 BGRA8 pixels are a 64-byte line of the GPU's memory: a guest surface of the mode's width over the guest's RAM, as the desktop's are, starts and ends each row on a line, which Intel's Vulkan driver needs to draw it in place (the window crate's geometry). The host presents the scanout buffer to the display's window at each refresh while the window shows no presented surface, with no dirty log: the scanout shows only at boot and in recovery, where its full cost is paid for the simpler design (owner, 2026-11-07). The GPU reads the buffer in place: the host pages under the scanout are imported at its first draw, and again only when the guest moves the scanout or changes its size, so no copy is made on the way to the window, and no other page of the region is pinned for it. While vblank is enabled, the host sends VBLANK at each refresh of the window's screen. A VBLANK the control completion ring has no room for is dropped, and the next carries the count; the host counts each dropped one (vblank-dropped), each spell of that ring with no room (control-ring-full), and each post onto it that waited for room (control-ring-post-waited) in its degradation counts, and logs the first of each kind. An answer the host gives off the control thread waits for no room on it: a present's at its refresh, a close's or a block release's as the last command buffer it waits for completes (on the platform's thread that sees it, which holds up every queue's completions while it waits), a download's as its copy lands. One the ring has no room for, or that finds answers handed over before it, is handed to the control thread, which posts them in their order ahead of its own answers; a VBLANK that finds answers handed over is dropped, as one that finds no room is.

The cursor's colour. An arm64 WindowServer gives each layer a colour chain of its own (item 13): the layer's source curve and matrix to XYZ (Src2XYZ), then XYZ's matrix and curve to the blend space (XYZ2Blend), the space the layers are blended in. Layer 0's chain is the identity, and the cursor's, layer 1, is not: its image is standard sRGB, and its blend space the display's profile's. Where the guest took CURSOR_COLOR, it sends the cursor's chain as WindowServer set it, the floats as their bits, and the host converts each cursor image through it before the host's screen is handed the image (crates/reims-vgpu-graphics/src/display/cursor_color.rs), so the host's cursor, QEMU's console and the window's drawn cursor all show it converted. Each pixel's straight colour goes through the source's curves channel by channel, the two matrices, and the blend space's curves, is clamped to [0, 1] and rounded to 8 bits; its alpha is kept. A new chain converts the last image again; on 0 turns the chain off, and so does a reset. The arm64e kext posts the chain at the first swap after it changed, before that swap's cursor, as a display engine latches a layer's colour stages with the flip, and posts it off until the chain is whole (no Src2XYZ comes for layer 1 before the cursor's first image) and where the chain is the identity within its own precision (2^-14), so an identity costs the host nothing. The measured chains keep black and white exact; after a switch of the profile to Display P3, sRGB's red shows as (234, 51, 35).

The display's density. Where the guest took DISPLAY_SCALE, the host tells it the scale of the screen its window was last drawn on, and the kext gives the OS the display's density from it, 110 pixels per inch a point (guest/kext/src/RgfxDisplayIdentity.hpp): 110 at 1x, 220 at 2x, 231 at 2.1, and 110 before the window first draws. The x86-64 kext puts it in each mode's size in millimetres and in the EDID's size, which is a 1920 × 1080 display's at that density whatever the window's size, and the arm64 kext in DisplayAttributes' size and the dot pitch. The modes are valid for HiDPI (kDisplayModeValidForHiResFlag, on x86-64) only on a screen above 1x, at any size whose pixels halve exactly. arm64's WindowServer follows the published size (measured): it runs at 1x on a 1x screen and HiDPI above 1x at every size. x86-64 macOS starts a display HiDPI on a default mode of at least 3840 × 2160, from 3800 pixels wide where its EDID is 32 inches across or more, and, where the display is built in, on a default mode of at least 2048 × 1536 at more than 160 pixels per inch (read from macOS 26.7.2's CoreDisplay). The x86-64 framebuffer says its display is built in (kIOConnectionBuiltIn, as a Mac's own panel is), and its EDID is at most 20 inches across, so on a screen at 1.5x or more (above 160 pixels per inch) the guest runs HiDPI at every window size from 2048 × 1536, at 1x below that, and on a screen at 1.45x or less at 1x up to 3840 × 2160 (measured on 26.7.2 at 2.1 and at 1, and on 11.7.11 to 15.8.2 at 2.1). Before, with no connection flags and the EDID at the window's size, it started at 1x on every window from 2400 to 3648 pixels wide at 330 ppi, and HiDPI on a 3888 pixels wide one on a 1x screen (measured). The EDID names the window's size in a text descriptor, so each window size is a display of its own to the guest, which keeps a mode chosen for it. WindowServer keeps a mode while the framebuffer lists it valid: with an EDID that stayed the same across sizes it kept its old mode through every resize, and it restored a mode chosen at one size to a display resized to another (measured; lessons). The framebuffer lists the mode set until another is set, for a WindowServer that reads it mid-change (RgfxDisplayModes.hpp), and answers it never shown and not valid once the device no longer shows it.

Refresh times. The host stamps each VBLANK with its refresh's time on the display's grid, a period after the one before, on its monotonic clock. That clock runs at the counter's own rate, as the guest's does (an x86-64 guest's mach_absolute_time counts its TSC, an arm64 guest's counter is the host's): CLOCK_MONOTONIC_RAW on Linux and macOS, whose CLOCK_MONOTONIC NTP disciplines (+45.1 ppm on homelab-um790-xtx-1, -30.1 ppm on homelab-gem10-1, +3.9 ppm on the M3 Max, measured 2026-11-15), and the performance counter on Windows, whose frequency nothing changes (reims-vgpu-graphics's clock). So the kext's offset of the two clocks holds between its readings, whatever the host's NTP does. It answers a PRESENT_SURFACE in the refresh that shows its surface, right after that refresh's VBLANK: the first refresh after the command buffers that write the surface have finished, whether or not the host's window has drawn it yet. An answer frees the surfaces of the presents before it, never its own, so the host holds it while the window's draw of one of those may still be passed by the guest's next write of it. Where every write of the surface is work on the runtime's queue (a texture over a block's device cache or one of its shapes, whose cache the host's video did not make), the hold ends once the draw is scheduled: the runtime submits every command queue's work, the window's and the guest's, to its one Vulkan queue in commit order, so a write the guest commits after the answer runs after the draw (DrawnPresents::after in crates/reims-vgpu/src/graphics.rs, pinned by reims-vgpu-vulkan's work_committed_after_a_scheduling_runs_after_it_on_vulkan). Otherwise (the surface's pages or the bundle's copy, which the guest's CPU writes, or a cache of the host's video) it ends once the draw has finished. The surface's block waits for the draw to finish either way (BLOCK_RELEASE, below). The kext maps each VBLANK's host time into the guest's mach_absolute_time by the clocks' offset (guest/kext/src/RgfxVblankClock.hpp). Where it took HOST_TIME, it reads the host's clock at each VBLANK, HOST_TIME_LO between two reads of its own, and maps by the reading whose round trip bounds the offset closest, that bound widening by 50 ppm of the reading's age. Without the feature it maps by the offset with the shortest delivery, which moves with the delivery: under Safari's 1080p60 playback the display link's times sat 38 to 76 us rms off a straight line (measured), against 0 idle. A display pipe transaction completes with the time of the refresh it was answered in (or the answer's own time where no VBLANK came within a period), and a display pipe VBL request is answered once, at the next refresh, with that refresh's time and the next one's.

The display's colour. A Mac's display pipe applies colour stages to what it shows: plane 0's gamma table (selector 5), the pipe's gamma table before its colour matrix (6), the matrix, which rides the transaction at 0xb0 with dirty bit 0x40, and the pipe's gamma table after the matrix (7). CGDisplayFade, Night Shift and ColorSync's calibration set them; WindowServer's boot fade is a run of transactions about 16 to 30 ms apart that each set only selector 7's table, with no surface. CoreDisplay sends tables only to a plane that has gamma, from the device control's answer to request 2 of attribute 0x711; a display whose answer names no plane gets "Attempting to get capabilities from plane with no gamma" and its fades drawn into WindowServer's own frames, whose last showed 34% of the fade out and 71% of the fade in on car 13's boot (B4). The device control answers as macOS 26.7.1's AMD Radeon framebuffer does: plane 0 takes tables of type 0x10 (8 bits a channel to CoreDisplay) and 256 entries, values 0.0 to 1.0 (read; guest/kext/src/RgfxGammaCapability.hpp, tests/gamma_capability_test.cpp). The kext decodes the tables as macOS 26's IOAcceleratorFamily2 does and stages each for the transaction begun (read; guest/kext/src/RgfxPipeColor.hpp, tests/pipe_color_test.cpp); the submit sends them, and the matrix where it is dirty, as DISPLAY_COLOR parts of at most 256 entries before the transaction's PRESENT_SURFACE, with no other pipe client's post between them (the framebuffer's presents lock: IOPresentment opens several clients, and any may submit), and a transaction with no surface that sets a colour as a present that keeps the surface shown (RGFX_PRESENT_KEEP), which completes the transaction when the host answers it, at the refresh that shows the colour, as a surface's present does. The host stages the parts on the presents' lane and the present it accepts next applies them, with the frame it shows; each stage keeps its table until a transaction sets it again, and the device's reset turns them all off, though it keeps the scanout: kept, a reset in the middle of a fade would leave the window black, with no transaction left to undo it. While any stage is on, the window draws the display through them (crates/reims-vgpu/src/graphics/color.rs, sink.rs), each table interpolated linearly between its entries (how a Mac's display engine samples between them is not measured). A colour with no matrix is drawn through a table of every input value, which the colour's own pass draws once per colour from a ramp, so each frame costs a lookup per channel and the bytes stay the pass's. Selectors 10 and 11 (the pipe's linearization before the matrix and its gamma after it, in IOPresentment's configuration format), 12 (a surface copy) and 13 (triage) stay refused: no WindowServer seen calls them, and IOPresentment sends 11 only for a gamma entry of the configuration type (1), which the AMD adds as a second entry where its display path has it and the device control does not answer.

The display's sleep. A Mac's display goes dark when the OS puts it to sleep (Energy Saver's timer, pmset displaysleepnow), and lights with the desktop at its wake. Where the guest took DISPLAY_POWER, the kext sends SET_DISPLAY_POWER with on 0 as the guest's display sleeps and 1 as it wakes (guest/kext/src/RgfxDisplayPower.hpp). The x86-64 framebuffer stays out of power management, so it hears of the sleep from the OS's display wrangler (IODisplayWrangler), whose power messages its general interest takes: the panel goes dark as the wrangler goes below its dimmed state (3), and lights as it is dimmed or on again. An arm64 guest has no display wrangler, and the arm64e framebuffer does not take DISPLAY_POWER, so its panel stays lit through the display's sleep. The host's panel follows, as a monitor's does: while it is off, the display's window and the host's reads of the display (rvg_graphics_device_read_display, QEMU's console) show black, and the host is told the guest's cursor does not show (cursor_show). Nothing else changes: the guest's scanout and presents are taken and answered as with the panel on, VBLANKs go on, and modes and the cursor's image stay, so the guest's compositor runs as before and the first frame after the wake shows what the guest shows then. The device's reset turns the panel on. The host code is reims_vgpu_graphics's control.rs (the command) and crates/reims-vgpu/src/graphics/sink.rs ("The panel").

The display pipe's notification words. The kext answers a pipe client with asynchronous results whose words IOAccelerator's notification callbacks read (guest/kext/src/RgfxDisplayPipeUserClient.cpp, completeLocked and sendVbl, which build them with RgfxPipeNotifications.hpp; tests/user_client_words_test.cpp pins them). A transaction's completion holds the transaction's cookie in word 0, its id in the high half of word 1 (the low half 0), the time it was shown in word 3, and, where it has nine words or more, the action 1 in word 8, the rest 0. Its word count is the one the client's IOAccelerator expects, which differs by release, so the kext picks it for each pipe client at the client's first submit (rgfxPipeCompletionCount):

  • 8 for a client that submits 0x108-byte transactions, as macOS 11.7.11's WindowServer does: the 0x118-byte layout without its last 16 bytes, which 12.7.6's and 26's WindowServers send as zeros. The kext reads it as 0x118 bytes with zeros past its end;
  • for a client that submits 0x118-byte transactions, 11 where IOAcceleratorFamily2 exports IOAccelMemoryMap::getAssignedGPUVirtualAddressLength() const, and 9 where it does not. The kernel collections of macOS 13.7.8 to 26.7.2 export it, and those of 11.7.10 to 12.7.6 do not (read). ReimsGraphics references the symbol weakly, through its OSBundleLibraries and its Graft declaration (guest/kext/src/graft.json, where the family is verified through its class IOAccelMemoryMap, which the KCs of 11.7.11 to 26.7.2 define), never calls it, and reads at its start whether its binder resolved it (ReimsGraphics::assignedLengthExported).

Each count was measured by booting the kext with the others: with any other count, WindowServer aborts at its first completion (on 11.7.11 its crash report names a failed assertion in IOAccelerator's transaction callback that the argument count equals its notification's), and with its own it completes every transaction: 8 on 11.7.11, 9 on 12.7.6, 11 on 13.7.8, 14.8.9, 15.7.9 and 26. The callback reads a completion as follows:

  • it refuses any other word count;
  • it takes word 0 as the completion block the client registered with the transaction, so a completion with no cookie is not sent (a null word 0 ends the client: WindowServer aborted there when the kext notified its cookie-less shutdown frames, RgfxPipeTransactions.hpp);
  • it records word 1's high half as the last transaction completed;
  • in the extended mode IOPresentment uses (it registers its handler with IOAccelDisplayPipeTransactionSetCompletionHandlerExt, the one completion setter it imports, on an Intel Mac under macOS 26.7.1 and on the M3 under 27), it accepts action 4 or one with a bit of 0xb set, and hands the block word 1's low half, words 2 to 7 and words 9 and 10.

A VBL request's answer is 6 words: the request's callback and refcon, then the refresh's time and the next refresh's, each split over two words, low half first. These are the reader's layouts (measured 11-03 from the callbacks' code, read as the guest's frameworks run it, for diagnosis only), and the completion's words are the ones Apple's own paravirtual display kext sends. WindowServer completes every transaction through them on the lane.

The bundle presents a drawable when its command buffer is scheduled, as Metal does (guest/bundle/src/RgfxCommandObjects.mm); what an app then sees of it, its presented handlers, presentedTime and nextDrawable's pacing, guest/bundle/tools/present_probe.m measures on a guest and on a Mac alike.

Boot display. The device's option ROM gives firmware a GOP framebuffer in BAR2, and the kext takes the display over when it starts. At its start, before IOFramebuffer moves the console onto it, ReimsGraphics records the boot framebuffer the platform expert's console info names as its RgfxBootFramebuffer property (Answered, Address, Width, Height, RowBytes, Depth; guest/kext/src/RgfxBootConsole.hpp), so a boot's check reads whether the firmware gave the OS a framebuffer from the registry, long after the kernel's message ring has wrapped: ioreg -r -c ReimsGraphics -l | grep RgfxBootFramebuffer. A boot with no GOP mode has an Address of 0.

QEMU's console. reims-graphics-pci's QEMU console carries the window's input, and shows what the display shows: at each of its updates the device reads the display back from the library (rvg_graphics_device_read_display), the scanout or the presented IOSurface through the display's colour, drawn as the window draws it into a texture of the display's mode, so QEMU's own displays and a QMP screendump see what the guest shows (docs/qemu.md, "The reims-graphics device").

Multiple displays

Status: the host's side and both kexts are built (the owner's decision of 2026-11-15: several displays on this device, each in a window of its own, on x86-64 macOS 11 to 26 and arm64 macOS from 14). The wire's definitions are in wire.rs (RGFX_FEATURE_MULTI_DISPLAY, RGFX_DISPLAYS_MAX, RGFX_SCANOUT_ROOM_ALIGN, RGFX_SCANOUT_STRIDE_ALIGN); a host of two displays or more offers the feature (lane mmhost), the x86-64 kext takes it (lane mmx86), and the arm64e kext takes it where the firmware placed a node for each display (lane mma64), which our configuration asks of Ambrosia 0.1.3 or later (A1); reims-ctl sets the count (lane mmctl). The pointer crossing and a captured drag across displays from Linux's windows are built on x86-64 (lanes ptrcross and dragcross: POINTER_OVER and DISPLAY_BOUNDS, below) and on arm64 (lane a64ptr, A3).

A device of one display is what it was. A device has 1 to RGFX_DISPLAYS_MAX (4) displays, 1 by default, fixed when it is made. With one, everything the guest and the host observe stays as before this section: the registers (FEATURES_HI offers no new bit), every message and event, DISPLAYS with display 0 alone, the scanout's room and the modes offered, the C API's results and callbacks, QEMU's one console and its properties, the window and its register (crates/reims-vgpu-window/features.md), and the option ROM's bytes. Each lane holds that line with the tests that hold it today, unchanged, and with a one-display boot that logs the feature words a boot before the change logged (RgfxFeaturesOffered, RgfxFeaturesWanted, RgfxFeaturesTaken).

How the guest learns the count. By MULTI_DISPLAY (feature bit 48, FEATURES_HI bit 16), which the host offers only on a device of two displays or more. A guest that takes it, as it takes any bit ("Negotiated features"), is answered DISPLAYS with every display, ids 0 to count − 1, each connected, and gets each display's events. One that does not (the option ROM, Ambrosia's module under Ambrosia's interface revision 1, a kext built before the bit, the arm64e kext where the firmware placed display 0's node alone) is answered display 0 alone, as by a device of one display: its commands for another display are refused NO_DISPLAY, as now, and the host sends it no VBLANK or DISPLAY_CHANGED of another display, since today's framebuffer reads neither event's display (ReimsGraphics.cpp, the completion ring's service). No register is added: the kext reads DISPLAYS in its start, before it registers a framebuffer, which is the first point the count is needed. A reset clears the take, as it clears every bit's.

The count is fixed; no display is plugged in or out (decided for v1). The count is QEMU's displays property, and every display is connected from the device's start to its end:

  • an arm64 guest's processes count their displays once each, from device-tree nodes the firmware placed before the kernel started ("The arm64e kext", below), so a display added later reaches no running WindowServer;
  • the x86-64 kext would make and end framebuffers while WindowServer runs, which nothing calls for while closing any window powers the VM off (features.md, "Leaving");
  • the device makes its consoles in QEMU's realize, and its windows as it is made. RgfxDisplayEntry.connected stays in the wire for a later lane that disconnects a display rather than ending the VM.

Messages name their display. Each display message carries the display's id already: SET_SCANOUT, SET_CURSOR, MOVE_CURSOR, SET_VBLANK, SET_DISPLAY_POWER, PRESENT_SURFACE, DISPLAY_COLOR, DISPLAY_CHANGED and VBLANK. Display 0 keeps today's encoding exactly, and display i's id is i, so no layout changes and VERSION stays 2. An id at or past the count is refused NO_DISPLAY (a DISPLAY_COLOR dropped and logged, as now). Each display has its own:

  • scanout, in a room of its own (below);
  • mode: the one mode today's rule ("Display", above) gives, from its own window: the window's pixels, the width rounded down to a multiple of 16 and the height to even, at the refresh rate of the window's screen, with that screen's scale where the guest took DISPLAY_SCALE. A resize of window i, or its move to a screen of another scale, sends DISPLAY_CHANGED of display i. Without windows every display offers 1920 × 1080 at 60 Hz;
  • VBLANKs, while the guest has them on for it, at each refresh of its window's screen, stamped on a grid of its own and counted from 0 at a reset; one dropped for want of room counts as vblank-dropped, as now;
  • presents and colour: PRESENT_SURFACE and DISPLAY_COLOR of display i show and colour display i alone, and a present is answered at the refresh of display i that shows it. A block's release waits until no display reads a surface's texture over the block;
  • cursor: SET_CURSOR and MOVE_CURSOR of display i set and move display i's (its image below);
  • panel: SET_DISPLAY_POWER of display i turns display i's panel off and on;
  • across a reset, as display 0 now: its scanout kept, its cursor image gone, its panel on.

The scanout's rooms. The scanout's room, RGFX_SCANOUT_SPAN (128 MiB) at RGFX_ALLOCATIONS_OFFSET, is split evenly among the displays: each room is RGFX_SCANOUT_SPAN / count rounded down to a multiple of RGFX_SCANOUT_ROOM_ALIGN (64 KiB), display i's from RGFX_ALLOCATIONS_OFFSET + i × room. That is 128 MiB for one display, 64 MiB each for two, 0x2aa_0000 bytes (42.6 MiB) each for three and 32 MiB each for four. The host refuses (INVALID_ARGUMENT) a display's SET_SCANOUT outside its own room. Nothing else of the region moves: the accelerator's blocks start at RGFX_CONTEXT_ALLOCATIONS_OFFSET, and a scanout's grant (BLOCK_GRANT in the scanout's span) lies in the span, as now. Growing the span with the count was weighed and declined: each display would take 128 MiB of the blocks' room, about 892 MiB of the 1 GiB region with one display and 508 MiB with four, whose last 160 MiB is WindowServer's reserve ("WindowServer's reserve", above). On a device of more than one display the host offers each display only modes whose rows, width × 4 bytes rounded up to RGFX_SCANOUT_STRIDE_ALIGN (256, the kexts' and the option ROM's row alignment), fit its room height times: a window too large for its room is offered the largest mode of the window's ratio that fits, in the same steps of 16 and 2, which the window draws as it draws any mode of other pixels (the window crate's geometry). So four displays take up to 3840 × 2160 each (31.6 MiB of 32), and two up to 5120 × 2880 each (56.3 MiB of 64). With one display the host offers what it offers today. The option ROM and Ambrosia's module scan out display 0 at RGFX_ALLOCATIONS_OFFSET in display 0's preferred mode, which the host's sizing keeps inside display 0's room. The module, where it takes the bit (A1), also fits its mode to display 0's share of the span, as the host splits it.

One cursor slot. The region keeps one cursor slot (RGFX_CURSOR_SPAN at its end). The host copies a SET_CURSOR's image out of the region before it answers (control.rs, set_cursor), so the kexts set every display's image through the one slot in turn: the framebuffer that owns the device holds a lock from its write into the slot to the command's answer.

Interrupts. Every display's events go on the control completion ring, MSI-X vector 0, as now: RGFX_MSIX_VECTORS stays 1. Four displays at 120 Hz send 480 VBLANKs a second there.

The C API. Additions only. Each function and callback there now is display 0's, so a host of one display, or one built before the additions, sees what it sees today, and QEMU's side changes with them:

  • RvgGraphicsDeviceConfig, version 4: display_count (0 and 1 are one display, as a host built before the field has; 2 to RVG_GRAPHICS_DISPLAYS_MAX; any other value RVG_ERR_INVALID_ARGUMENT), and display_windows, the window configs of displays 1 to count − 1, given exactly where window is;
  • RvgGraphicsCallbacks, version 4: cursor_glyph_at(ctx, display, glyph), cursor_show_at(ctx, display, show) and cursor_move_at(ctx, display), called for displays 1 and up on the display thread, in order with every display callback; display 0's stay cursor_glyph, cursor_show and cursor_move;
  • rvg_graphics_device_read_display_at(device, display, dst, dst_length, width, height) and rvg_graphics_device_cursor_position_at(device, display), whose display 0 is rvg_graphics_device_read_display and rvg_graphics_device_cursor_position; a display at or past the count is RVG_ERR_INVALID_ARGUMENT, and (0, 0) for the position;
  • RVG_GRAPHICS_DISPLAYS_MAX, 4. docs/api.md gives the versions (section 1) and the threads (section 5).

The Rust API mirrors it. Inside the library each display gets what display 0 has now: its Screen (reims-vgpu-graphics' display.rs), its DisplayState and refresh grid (device.rs), and its window (WindowScreen), presented surface, present queue, colour, read-back and host cursor (crates/reims-vgpu/src/graphics.rs and graphics/); Host::present_surface, present_keep, display_color and refreshed take the display. Which threads run the displays' refreshes is free (AGENTS.md, "What is free").

QEMU. reims-graphics-pci takes displays, 1 to 4 and 1 by default (realize refuses others), makes a graphic console per display (qemu_graphic_console_create with head i), fills console i with rvg_graphics_device_read_display_at and gives it display i's cursor, and under -display none has the library open a window per display whose input goes to console i. resolution is every window's first size, and QMP's screendump with head i saves display i. With displays 1 nothing of QEMU's changes.

The pointer across displays. Each window's pointer goes to its display's console, in that display's pixels, and keys from every window reach the one keyboard. A VM has one USB tablet, which reports a position in its range with no display in it. The guest scales it over the display its cursor is on (X1, below), so a pointer over display i's window reaches the guest's display i once the guest's cursor is there. The device moves it there with the event POINTER_OVER (0x104, RgfxPointerOver: display, x, y in the display's pixels of its mode, and the buttons held):

  • The host's side. Each window's pointer callback, on a device of two displays or more, first tells the device the pointer is over the window's display at the event's point with its buttons (reims_vgpu_graphics::PointerLink::pointer_at, wired in crates/reims-vgpu/src/window.rs), then hands the event to the host, which moves the tablet. So the event is in the completion ring before the tablet's report of the same position is queued. The device sends it where the guest took POINTER_OVER and MULTI_DISPLAY, the guest's cursor shows on another display (the display of its latest MOVE_CURSOR with visible set, display 0 from a reset), and the guest was not already told this display while the cursor is on that one: once per crossing, and again only after the cursor has shown on another display or the pointer has been over the cursor's display again. A crossing the guest did not carry out is over then: kept, it left every later crossing onto its display untold, the tablet putting the cursor at the pointer's spot of the display it stayed on (15.6.1 under TCG, lane a64ptr, potluck job m3-max-36608). A crossing that finds the ring held, full or behind answers handed over is posted at the next refresh of any display, unless the pointer is over the cursor's display again by then. A reset forgets it all.
  • The image over an edge. On an arm64 guest a cursor near the edge between two displays shows on both: WindowServer gives each display the part of the image on it, and the display not holding the hot spot a part whose hot spot is held to the image's column (or row) at that edge, with the hot spot at the display's edge pixel (27.0.1, the 28 x 40 arrow, hot spot 5,5, at 1915 of display 0: display 1 showed its last 18 columns at pixel 0, hot spot 0,5, 17 ms after display 0's MOVE_CURSOR; lane a64ptr, potluck job m3-max-35746). Taken as where the cursor is, that MOVE_CURSOR kept the next crossing onto the display beside it from being told, and the tablet then put the cursor at its mirror on the display it was on. So the device takes such a MOVE_CURSOR (its image's hot spot on the image's first or last column or row, at the scanout's first or last pixel on that axis, by the display's last SET_CURSOR) as where the cursor is only while the display the cursor is on hides it, or where that display shows the image's edge too (a hot spot exactly at the edge) and a crossing told the guest the pointer is over this one.
  • The crossing's hold. Until the guest's cursor shows on the new display, the tablet would scale a position over the display the cursor left, and a position sent then lands at its mirror there: a click on display 1 at x 100 would land on display 0 at x 100. So once a crossing is told, the window's positions for that display are held (pointer_at answers false, and the window does not hand them to the host) until the guest's MOVE_CURSOR shows its cursor on that display, for at most CROSSING_HOLD_NS (a second, the arm64e kext's longest crossing: under TCG a guest had not shown it 100 ms after the POINTER_OVER while the pointer went on over the new display's window, and positions handed on then left the cursor at their mirror on the display it was on, potluck job m3-max-37089), after which they go on as before, so a guest that never moves its cursor loses nothing for longer. A cursor the guest keeps hidden never shows, so its crossing holds the positions the whole second; a captured game, which drives the guest's mouse instead ("A pointer for games"), is not held. A position whose buttons changed always goes on: no click or release is held or lost. The device logs, at debug, how long each crossing took the guest.
  • The x86-64 kext. On the event, display 0's framebuffer takes the display's mode and its rectangle in WindowServer's global space (its framebuffer's getBoundingRect, the bounds WindowServer gave it), places the pixel in that rectangle, scaled from the mode's pixels to the rectangle's size, and on a thread call posts IOHIDSystem's own move there: IOHIDSystem::extPostEvent with kIOHIDSetCursorPosition, a mouse-moved, or the drag of the button held (left, then right, then any other), so a move told while a button is held stays a drag: one after the guest moved its cursor to another display during a drag in a window, say (ReimsGraphicsPointer.cpp, RgfxPointerOver.hpp). The kext links IOHIDFamily, where IOHIDSystem lives on 11 to 26.
  • The arm64e kext. The same move, IOHIDSystem's own post, which arm64's WindowServer follows as x86-64's does (A3, below). But no framebuffer holds its display's rectangle on arm64, so the kext learns where WindowServer placed each display from its own moves (RgfxDisplayPlaces.hpp): each post aims at a display, and its landing, the MOVE_CURSOR that shows the cursor's hot spot on that display, gives the cursor's pixel there, which checks the rectangle the post was placed by. A post lands on the display holding its point, or, where none does, is held at the edge of the display the cursor was on, which is never the one aimed at; so only the display aimed at learns from a landing.
    • What is no landing. While a post is out the host's tablet can move the cursor on the display it is on: the host passes positions on once its hold is over, and an arm64 guest under TCG shows a post's landing 18 to 153 ms after the POINTER_OVER (14.6.1 at two displays, potluck job m3-max-35541). Taken for a landing there, the tablet's pixel placed that display over the other. So on another display only the pixel where the post's point lies, or is held at its edge, counts: the cursor went there and not where it was aimed. A cursor near an edge also shows on the display beside it, the part of its image that reaches over, its hot spot past that display's edge or at its first pixel (27.0.1, job m3-max-35515): that is no landing, and a pixel at the edge where the post's point lies within a cursor's reach (256 points) past it is waited on for the landing aimed at as long as any post's landing is, 250 ms after the post, and 50 ms after the image at the least, before the crossing posts again. Under TCG that landing can come well after the image: on 15.6.1 a captured drag back onto display 0 posted at its right edge showed the image at display 1's first pixel 7 ms after the post; after a wait of 50 ms alone the crossing posted again beside display 1, and display 0's landing, 139 ms after the first post, was taken for the second's (potluck job m3-max-36695). In job m3-max-36608 the host was then told display 0 right of display 1, by its log, and sent its pointer back onto display 1.
    • The guess. A display starts where WindowServer places a new one: side by side in their order, tops at 0, each its mode's size at 1x on a 1x screen and half of it above 1x, as arm64's WindowServer runs it ("The display's density", above).
    • A crossing. On the event, display 0's framebuffer posts at the display's pixel of the rectangle held for it. A post that shows no move in 250 ms left the cursor where it was: where its display last showed the cursor at the post's pixel, it was there already (the device told the crossing before it saw the cursor there), and the crossing is over. Where the cursor shows on another display instead, or shows no move and is not there (its point held at the very pixel the cursor was at, as a captured pointer pushed past its window's edge is after the displays were rearranged), it posts again at that pixel of the display placed beside each other display in turn (right of it, left, below, above, top or left edges aligned), until the cursor lands on its display, wherever on it, as the tablet's next position puts it at its pixel. At most four posts: the cursor then stays where it is, counted in the framebuffer's RgfxCrossingsMissed and logged the first time. The posts are bounded by their count, not by the host's hold: a guest under TCG shows even a first post's landing after the hold, and a crossing cut off there would learn nothing of a moved display, so every later crossing onto it would miss too.
    • A post that may land late. A post that shows no move in 250 ms with no display showing the cursor where its point lies or is held at may still land: on 27.0.1 the first post 2 s after the displays were rearranged showed nothing in 250 ms (potluck job m3-max-35865), and its move can then show with a later post's. Every post of a crossing aims at the same pixel of its display, so such a landing cannot be told from the later post's: the crossing ends on its display's landing, as any does, and learns no place from a landing after that post. Only a MOVE_CURSOR posted after the post counts as what it did: the kext numbers each one, and a display whose last one came before the post shows nothing of it. On 15.6.1 under TCG a captured drag had left the cursor at display 1's left edge, where the post onto display 0 is held, and taken for that post's outcome, the crossing's next post and the first post's late landing placed display 0 right of display 1 (potluck job m3-max-36173). A landing 100 ms or more after the POINTER_OVER (the kext's kRgfxCrossingHoldNs) may come after the host passed a position on to the tablet: one whose buttons changed, which goes on at once, or any on a host that holds them for 100 ms alone. So it may show the tablet's move: it confirms the placement it was posted by where it agrees with it on both axes, and otherwise teaches nothing, neither a corner nor a size. On 15.6.1 under TCG a captured drag back onto display 0 posted at its right edge showed the cursor 130 ms later, 26 points short in the drag's direction; taken for the post's landing, it sized display 0 1005 by 628 points, which a later landing confirmed and the host was told (potluck job m3-max-36292).
    • Learning a place. A landing whose pixel lies where the post's placement puts the posted point, 16 pixels or more from the corner on an axis, confirms that placement as the display's rectangle. One that disagrees moves the placement's corner on each axis where the pixel lies inside the display, off its edges, and the rectangle is learned, to be confirmed by a later landing that agrees. On an axis where the landing is held at the display's edge, the post's point lay past the display, so the placement is not the display's there and the rectangle keeps its own: in the job above, the cursor already on display 0, the post beside display 1 held it at display 0's edge, and taking that placement put display 0 past display 1, so each later crossing missed. Two landings 64 pixels apart or more size a display the guess sized wrong (a mode the guest's user scaled), to within a few points.
    • What the host is told. Each confirmed rectangle, in DISPLAY_BOUNDS, as the x86-64 kext tells its own ("A drag across displays", below), after each move of the cursor where it changed. A display the cursor never went to has none told, so a captured drag stays at the edge it meets; after the guest's displays are rearranged, the first crossing onto a moved display lands as before, posts again, and its landing beside the other display confirms the new place.
  • Compatibility. The device sends POINTER_OVER only to a guest that took its own feature bit, POINTER_OVER (49), not to every taker of MULTI_DISPLAY: a kext built before this event, and the firmware drivers, take MULTI_DISPLAY without it (or will), and are never sent it. Each would drop it in any case: the kext's completion ring service passes over an event type it does not know (handleEvent's default), and the option ROM's and Ambrosia's module's waits pass over every event but the answer they wait for.
  • A drag across displays. The click that begins a drag captures input in its window, and capture holds the host's pointer over that window's image (features.md, "Capture"). On a Mac with two displays, a window dragged past the edge where the displays meet goes on onto the other one. The host's two windows may sit anywhere on its desktop, on one screen or two, in any order, so the host cannot hand the pointer from one window to the other by where they lie: what decides is the guest's arrangement (System Settings, Displays, Arrange). And Wayland lets no client warp the pointer into another window or know where its windows lie, so the drag cannot move the host's pointer across either. The drag goes on in the guest's desktop instead:
    • The guest's arrangement. The x86-64 kext, where it took DISPLAY_BOUNDS, POINTER_OVER and MULTI_DISPLAY, posts DISPLAY_BOUNDS (9, RgfxDisplayBounds) with each driven display's rectangle in WindowServer's global space (its framebuffer's getBoundingRect, which is the display's CGDisplayBounds, as lane ptrcross measured), after each move of the cursor, for each display whose rectangle differs from the one last told (RgfxDisplayBounds.hpp, ReimsGraphics::tellBounds), and forgets them at each start. So a rearrangement reaches the host with the cursor's next move. The arm64e kext posts the rectangles its own moves of the cursor confirmed, after each move where one changed ("The arm64e kext", above). The device keeps the latest of each display until a reset; it drops a rectangle of no area or of a display the guest does not see.
    • Leaving the image. The window, captured, with its pointer moving toward an image edge and within 32 points of it (beyond::REACH), asks the device whether a display meets the display's edge there: a point half a pixel past it lies in another display's rectangle (PointerLink::adjoins). Not at the edge alone: KWin keeps a confined pointer where it was when a move would take it out of the region, so a push stops short of the edge by up to a move's length (measured on KWin at a scale of 1.9: a mouse pushed left at about 5 points a move stopped 2.6 points short of the edge and stayed there, potluck job m3-max-35056, and a pointer that had to come within a point of the edge never left). Where one does, the pointer leaves: the window locks the host's pointer where it is (SDL's relative mode: on Wayland the compositor's zwp_locked_pointer_v1, its motion from zwp_relative_pointer_v1, at the desktop's own acceleration, SDL_MOUSE_RELATIVE_SYSTEM_SCALE), and each motion, scaled to the display's pixels, moves the pointer in the guest's desktop from where it left (PointerLink::away_moved), points per pixel by the display's rectangle over its scanout, so the guest's cursor crosses at the edge itself.
    • Where it lands. A point the rectangle of a display holds goes onto that display; one no rectangle holds slides along the edge it met where the move across or down alone lands on another display, else is held at the display's own edge, as a Mac holds its cursor where no display meets it (device/desktop.rs). Each position goes to its display's own window, which tells the device and hands it to the host as its own pointer's (Window::pointer_from_beyond, the bridge in crates/reims-vgpu/src/window.rs): the crossing and its hold are the uncaptured pointer's, the buttons held make the kext's move a drag, and that window draws the guest's cursor, as no pointer of its own moves it.
    • Coming back. A position back on the window's own display, out of reach of the shared edge, ends it: the window lets the host's pointer go at the guest's cursor's place in its image, and the pointer is the window's again. Releasing capture (Ctrl+Alt+Super, Ctrl+Alt+Win on Windows), losing the keyboard or the window's end let the host's pointer go where it was held. Buttons pressed and released while away go to the display the pointer is on.
    • Compatibility. A guest that did not take DISPLAY_BOUNDS (a kext built before it), or told no rectangles (the arm64e kext before the cursor went to the display past the edge), keeps the pointer held at the image's edge, as before; so does a compositor that refuses the lock. The macOS window keeps it so too: the logic is the window crate's, free of the OS (beyond.rs), and the SDL window on Linux and Windows drives it; on macOS a captured drag stays on its display (features.md). A device of one display offers no bit and sends nothing new.
    • What QEMU sees. Nothing new: each position is window k's pointer callback, which QEMU scales over console k by the width and height it gives, and the buttons are the one tablet's.
    • Walked on x86-64 macOS 26.7.2, 15.8.2 and 11.7.11 at two displays, with KWin on Wayland at a scale of 2.1 (lane dragcross, potluck jobs m3-max-35149 to 35151), and on 26.6.1 at a scale of 1.9 (job m3-max-35092). A Finder window's title bar, pressed in display 0's window and pushed with a mouse past the edge display 1 meets, went onto display 1, the cursor and the window, and back again, both with display 1 right of display 0 and, rearranged in the guest, left of it. The uncaptured crossings landed where the pointer was, and the guest's cursor showed on the new display 126 to 744 us after its POINTER_OVER (medians 267 to 358 us a walk), well inside the hold.

The windows. One window per display, as the window crate already makes them (Window::new(config, port, title(port)), screens::screen_for_port): display i's is port i's, titled "Reims vGPU (port i)", opened on host screen i or the main screen (REIMS_VGPU_WINDOW_SCREENS picks), and cascaded where two share a screen. In features.md:

  • each window keeps the entries of "The picture", "Matching the host's screen", "Borderless", "Pointer", "Keyboard", "Capture", "Scrolling" and "Cursor" for its own display ("Pointer"'s first entry, the guest's pointer under the host's, waits on X1 for displays 1 and up). A capture holds the pointer over its own window's image, so reaching another display's window takes a release (⌃⌥⌘) or a move uncaptured, but for a captured pointer on Linux pushed past an edge where the guest placed another display ("A drag across displays");
  • "The VM is an app", the switches and "Leaving" (closing any window powers the VM off) are the process's;
  • the entries written for several windows were never walked with a second display driven, since apple-gfx's guests drove port 0 alone (docs/qemu.md): one window per guest display, the port in the title, display i on screen i, the cascade, the screens changing, and on Linux the cursor set only by the window the pointer is in (manual (a VM with two displays));
  • new entries, in a commit of their own: each window offers its display its own mode, rate and scale; a window whose display the guest does not drive shows black; and the pointer's, which POINTER_OVER gives each window (features.md, "Pointer").

The x86-64 kext. ReimsGraphics stays the device's driver and display 0's IOFramebuffer. Where it took MULTI_DISPLAY and DISPLAYS lists more displays, its start makes an IOFramebuffer of the kext's for each display from 1 (a head), attached to the PCI device as display 0's is and registered after it, each with:

  • its own connection, mode list (RgfxDisplayModes.hpp), timings, EDID (its serial is the display's already, rgfxDisplaySerial), cursor, vblank and connect interrupts, and server connection's scanout owner;
  • IOFBDependentID display 0's registry ID and IOFBDependentIndex i, as IOGraphics groups one GPU's framebuffers, IOAccelTypes the one accelerator, and IOAccelIndex i, the display's pipe of it, as a Mac's GPU numbers its framebuffers (measured on a MacBook Pro 2019 on macOS 26.7.1: its Radeon Pro 5300M's five framebuffers have IOAccelIndex 0 to 4, each its IOFBDependentIndex; with IOAccelIndex 0 on both, a guest's system_profiler listed one display);
  • its aperture and VRAM range in display i's room (scanoutLimit per display);
  • its commands posted on display 0's control ring under its lock, naming display i; the work loop hands display i's VBLANK and DISPLAY_CHANGED to framebuffer i. The device control (RgfxDeviceControl, the AGDC) lists every display's framebuffer in its attribute 0x980 and answers 0x925, 0x711 and 0x986 for each display by its index (RgfxAgdcDisplays.hpp): IOPresentment builds a framebuffer's display pipe only where 0x980 lists it, and CoreDisplay shows nothing on a framebuffer without one (read from macOS 26.7.1's IOPresentment, ioPresentmentPopulateIOFramebufferEntries; measured on 26.7.2: with display 0 alone listed, display 1 stayed black, WindowServer logging "Unable to find display pipe for IOFB service"). With one display the control answers as it did before (tests/agdc_displays_test.cpp). Each display pipe client works on the framebuffer whose index IOPresentment associates it with, the framebuffer's index in 0x980's list (X3), and the scanout grant (selector 0x108) grants the room of the display the surface is drawn for. DisplayPortCount is the count where the bit was taken (X4). The x86-64 build carries the bit (kRgfxCarriedFeatures) only once all of this lands, and the arm64e build once its own lane lands.

The arm64e kext. ReimsGraphics stays display 0's IOMobileFramebuffer, on /arm-io/reims-display0, and each display i from 1 gets a head of the same class, as on x86-64, attached to the PCI device and started by display 0's start: an IOMobileFramebuffer service of its own on the node /arm-io/reims-display<i> the firmware placed, with its own attributes (IOMFBUUID and DisplayAttributes carry the display's serial), timings, swaps (layer 0 its surface, layer 1 its cursor, RgfxMobileCursor.hpp), VBLANKs and republished modes (ReimsGraphicsMobile.cpp). The kext takes the bit only where the firmware placed a node for display 1 as well as display 0 (RgfxFeatures.hpp), and only displays with a node get a framebuffer (rgfxFramebuffersOf), since a process expects a service for each node it counts and the nodes are counted before the kext loads (A2). With display 0's node alone the kext writes the feature word it wrote before the bit and drives display 0 alone. The services register together (A2): the class's start registers its service as it ends, so the arm64e class overrides registerService (a Graft synthesized override, graft-arm64e.json), and display 0's start holds each display's registration while it starts the heads, then registers them back to back, display 0's first (RgfxRegisterHold.hpp). A head that fails to start, or a hold past 10 seconds, ends the hold at once, so display 0's service always registers; with one display nothing is held. Back to back is not enough on its own: each registration matches on a thread of its own, so a process can read the first service and find no other before the second's notification comes (arm64 15.6.1 under TCG, potluck job m3-max-34657: its WindowServer took one of two services and gave up on the other after its one batch). So the release registers the services on a thread call and opens a window until each has matched or 5 seconds have passed. In the window a process's read of a key the framework reads of each service it takes before it asks for the next (dfr, AppleTV and external) waits until the next display's service has matched, so it is in the process's batch by the time the process asks for it. The arm64e class overrides copyProperty(const char *) for it, the overload a process's property read asks first (read from 14.6.1's and 27.0.1's kernels). The kernel's own reads never wait, nor does a read of any other key; the hold and the window together end well inside the process's 30 seconds. The window opens only where heads started, at two displays or more.

The window also keeps the displays' order. A process's notification hands it the services waiting for it last first (read from 27.0.1's kernel), and the first service a process takes is its main display, the one with the menu bar and the Dock, at the left. With both services waiting, an arm64 15.6.1 guest took display 1's first in one of two boots (m3-max-34945). So the release registers one display at a time: the next display's service registers only once a process has read one of those keys of the one before, or the window's deadline has passed. A process waiting for the services then finds them one at a time, in display order, and display 0 is its main display, as on x86-64.

The window rests on the order in which WindowServer reads those keys: of each service it takes, before it asks for the next. That order was read from 27.0.1's framework alone; 14.6.1's framework was not read (its guest has no disassembler), only its kernel's read path and WindowServer's log. A release whose framework reads none of the three keys before it asks for the next service gets nothing from the window: it can take fewer services than it counted nodes in its one batch, and then drives those displays and leaves the others black. It never hangs, as each read waits only until the window's deadline, and the hold and the window end inside the 30 seconds. So a new release's boot at two displays checks the desktop on every head, and that display 0 is the main display.

The option ROM drives display 0 alone, unchanged: it takes no feature, so it sees one display, and its GOP framebuffer lies in display 0's room. Its bytes do not change. Displays 1 and up show black until the kext drives them. Ambrosia's module likewise brings up display 0 alone; under Ambrosia's interface revision 2 it takes the bit only to count the displays for Ambrosia's nodes (A1).

reims-ctl. A VM's [display] takes count, 1 to 4, saved only above 1, so a one-display VM's file is unchanged. It is the key reims-ctl saved for apple-gfx's display ports (1 to 8), which it reads past since apple-gfx was dropped (crates/reims-ctl/src/vm.rs, apple_gfx_s_settings_are_read_past): such a VM's count comes back, one above 4 read as 4. The QEMU command gives reims-graphics-pci displays=N only above 1, as it gives resolution only where it is not the device's own, since a QEMU built before the property refuses it. resolution and borderless are every window's. The VM form of the terminal UI has a Displays field beside Resolution, shown on reims-vgpu and hidden on VMware SVGA, which has one display; create and set take --displays N; a VM's summary says how many windows it opens. The terminal viewer shows display 0, the head its screendumps name.

Unknowns. None is guessed: each lane measures its own before it builds on it.

  • X1, the pointer. Where macOS 11 to 26 puts the USB tablet's position with two displays. Measured on x86-64 26.7.2 with two displays, display 1 at (1920, 0) of the guest's arrangement (lane mmx86's potluck jobs m3-max-33937 and m3-max-33972, on homelab-um790's RX 7900 XTX: QMP's input-send-event of the tablet, then a tool of our own reading CoreGraphics' displays and cursor): the tablet's 0 to 32767 is scaled over the display the guest's cursor is on, neither the box around the displays nor the main display alone.

    • With the cursor on display 0, x 3276, 16384 and 32700 (y 16384) put it at 192, 960 and 1916, y 540, of display 0, and no position reached display 1.
    • With the cursor moved onto display 1 first (CGWarpMouseCursorPosition to 2880, 540), x 16384, 8192 (y 8192) and 32700 put it at 2880, 2400 (y 270) and 3836, all on display 1.

    So the tablet reaches display i once the cursor is on it, and never carries it across: the pointer needs a crossing that moves the guest's cursor onto display i when window i takes the pointer, after which window i's positions, sent as the tablet's over display i's pixels, land on display i. The host knows which display the cursor is on: the one whose MOVE_CURSOR shows it. A relative mouse beside the tablet, pushed over a shared edge, was declined: it depends on the guest's arrangement and its pointer acceleration. The crossing is a lane of its own, after mmx86 ("pointer crossing" below): an event under MULTI_DISPLAY, added to the wire before a kext that takes the bit ships, says the pointer is over display i at x, y, and the kext moves the cursor there. mmx86's boot matrix repeated both sweeps on 11.7.11, 12.7.6, 13.7.8, 14.8.9 and 15.8.2, with the same reading on each as on 26.7.2.

    • Which move WindowServer follows, measured by lane ptrcross on x86-64 11.7.11, 15.8.2 and 26.7.2 with two displays (potluck jobs m3-max-34584, 34585 and 34583; a scratch kext that never landed, our CoreGraphics tool reading the cursor): from the kernel, IOHIDSystem::extPostEvent of a mouse-moved at (2880, 540) with kIOHIDSetCursorPosition puts the cursor at (2880, 540) on display 1, and the tablet's next position (8192, 8192) lands at (2400, 270) on display 1. IOHIDSystem::extSetMouseLocation to the same point answers success and leaves the cursor on display 0, and so does the tablet after it. From a process, IOHIDSetMouseLocation and IOHIDPostEvent are refused (kIOReturnNotPermitted, the HID control check) and CGEventPost is dropped; CGWarpMouseCursorPosition moves the cursor. Each framebuffer's getBoundingRect equals its display's CGDisplayBounds (0, 0 to 1920, 1080 and 1920, 0 to 3840, 1080). IOHIDSystem's class lives in IOHIDFamily on those releases: a kext naming com.apple.iokit.IOHIDSystem as a library is not injected (m3-max-34528), one naming com.apple.iokit.IOHIDFamily is.
  • X2, the second display's connection. Whether macOS 11 to 26 runs two displays that both say they are built in (kIOConnectionBuiltIn, which display 0 says so that its HiDPI start follows its density): booted with displays 1 and up built in, then external, reading CoreDisplay's choice of default mode and System Settings' names. External would start display 1 at 1x below 3800 pixels wide ("The display's density", above). Measured on x86-64 26.7.2 with two displays, each 1920 × 1080 with no window (potluck jobs m3-max-34242, displays 1 and up built in, and m3-max-34261, external; diagnosis builds of the kext): both run the desktop on both displays, each at 1920 × 1080 at 1x and named "Reims Display". With display 1 external, CoreGraphics says it is not built in and system_profiler gives it no connection type, where built in it says "Internal". So the arms differ only in the density rule, which built in keeps on every display: the kext says every display is built in. With two displays, both built in, x86-64 11.7.11, 12.7.6, 13.7.8, 14.8.9, 15.8.2 and 26.7.2 each ran the desktop on both displays (lane mmx86's boot matrix, m3-max-34283 to m3-max-34294, on an RX 7900 XTX and an RTX 3090).

  • X3, the pipe's index. Which index IOPresentment associates display 1's pipe client with (today's kext takes 0 and 0xffffffff), read from the kext's log of each associate on the first boot with two displays. Measured on x86-64 26.7.2 with two displays (potluck job m3-max-34242, a diagnosis build of the kext logging each associate): WindowServer opens two pipe clients per display, display 0's associating index 0 and display 1's index 1, the framebuffer's index in the device control's 0x980 list. With one display, the same two clients associate index 0 (m3-max-34138). Before 0x980 listed display 1, display 1 had no pipe client at all (m3-max-34102).

  • X4, DisplayPortCount. What on x86-64 reads the accelerator's DisplayPortCount; on arm64 IOMobileFramebuffer.framework reads it only of an AppleParavirtGPU (ReimsGraphicsMobile.cpp). Measured on x86-64 26.7.2 with two displays (m3-max-34242, a build logging each property a process reads of the accelerator by its key): no process read it. The trace does not see a read of every property at once, nor the kernel's. A Mac's GPU has none: the Radeon Pro 5300M's accelerator on a MacBook Pro 2019 (macOS 26.7.1) has no DisplayPortCount (measured). The kext states the count all the same, as arm64 needs it.

  • X5, WindowServer's reserve. WindowServer's peak blocks at four displays of 3840 × 2160 against the reserve's 160 MiB and 4096 entries, from the kext's log of its peak ("WindowServer's reserve", above). Measured on x86-64 26.6.1 with four displays, each a window on an RTX 5080 Laptop host's screen at 1.9x and run at 3840 × 2160 HiDPI at 120 Hz (potluck job m3-max-34342, a diagnosis build of the kext keeping its log): at login WindowServer's blocks came to 20360 KiB at most, in 30 blocks; with five apps opened they stayed at that most and came to 460 blocks, the table holding 535 entries. With one display of 1920 × 1080 (26.7.2, m3-max-34242) they came to 18284 KiB at most. The reserve holds four displays with room to spare, so it stays as it is.

  • A1, the arm64 display nodes. Ambrosia adds one node, Graphics > DisplayNode (a string; Ambrosia's docs/configuration.md), and a process waits up to 30 seconds for a service for each node it counted, so the nodes must number the device's displays. Ambrosia needs a change, its owner's to make: its graphics driver interface's next revision lets the module say how many displays the device has (it reads DISPLAYS having taken MULTI_DISPLAY), and Ambrosia adds that many nodes from a list in the configuration; or DisplayNode takes a list, and each configuration bundle is made for one count. The first leaves no bundle that disagrees with its device. Answered by the first: Ambrosia's interface revision 2 (Ambrosia 0.1.3) turns the framebuffer's reserved word into Displays, and DisplayNode takes a list of names, display 0's first, of which Ambrosia adds a node for each display the module reports, as far as the names go. The module takes MULTI_DISPLAY only under revision 2 and reports the count (architecture.md 11.5). A single name still makes display 0's node alone, which every Ambrosia from 0.1.1 takes; a list is refused before 0.1.3. Our configuration gives the list (reims-display0 to reims-display3, one bundle for every count), so it needs Ambrosia 0.1.3 or later.

  • A2, the arm64 services. How IOMobileFramebuffer.framework pairs the displays it counted with services, and what a second service of one kext needs for WindowServer to drive it (its index, its UUID, its swaps and cursor): read from macOS 14.6.1's and 27.0.1's framework (iomfb_populate_all_display_infos and the service matching) and from how AppleParavirtGPU publishes a display per port, kept local and never committed, then checked by a boot of arm64 14 with two displays under TCG. Read from 27.0.1 (the framework, and the kernel collection's IOMobileGraphicsFamily and AppleParavirtGPU):

    • The framework pairs by count alone. It counts the children of /arm-io whose device_type is display-subsystem or ext-display-subsystem, with an AppleParavirtGPU's DisplayPortCount where a child's compatible names Apple's paravirtual GPU, and never compares a node's name with a service. It then asks for the IOMobileFramebuffer services by a first-match notification and takes those registered already; where it has fewer than it counted, it runs its run loop once, for at most 30 seconds and returning after one source is handled, takes what that one batch of notifications brought, and goes on with what it has. Each service it takes is an entry of its display list (at most 16), named external-N for an external display, numbered in the order taken. So a service registered after that one batch is never driven by the process, and the kext registers every display's service together.
    • AppleParavirtGPU starts every display of its ports first (for each, an AppleParavirtDisplay made, attached to the GPU and started) and registers the GPU's service after them. IOMobileFramebufferLegacy's start takes the display a framebuffer ID and an index of its own, from counts every instance shares (at most 16), fails unless start_hardware answers true, and registers the service as its last step, a virtual registerService call, which a subclass can hold.
    • A second service of one kext is a second instance of the class: its own index, its UUID from its own display's serial, its own swap queue and clients (the class's, per instance) and its own cursor plane, layer 1. On 14.6.1, IOMobileFramebufferLegacy's start ends with the same virtual registerService(0) (read from its kernel collection), and WindowServer logs the same steps of the framework's wait: a populate thread that waits for as many framebuffers as it counted (pthread_dependency_wait_np expect: 1) and runs its run loop "for 30 seconds" (a boot of arm64 14.6.1 at two displays with display 0's node alone, potluck job m3-max-34581). The guest's dyld_info has no disassembler there, so the framework's code itself was read on 27.0.1 alone.
  • A3, the pointer on arm64: X1's question on an arm64 guest, found on mma64's first boot of arm64 14 with two displays, as X1 is. Measured on arm64 14.6.1 under TCG with two displays, display 1 at (1920, 0) of the guest's arrangement (potluck job m3-max-34656, on homelab-um870-1's Radeon 780M: QMP's input-send-event to usb-vmapple-tablet, the pointing device Virtualization.framework gives a macOS guest, on qemu-xhci, then the same tool of ours reading CoreGraphics' displays and cursor): it reads as X1 does.

    • With the cursor on display 0, x 3276, 16384 and 32700 (y 16384) put it at 192, 960 and 1916, y 540, of display 0, and no position reached display 1.
    • With the cursor moved onto display 1 first (CGWarpMouseCursorPosition to 2880, 540), x 16384, 8192 (y 8192) and 32700 put it at 2880, 2400 (y 270) and 3836, all on display 1.

    So the arm64 pointer needs the same crossing as x86-64's, built by lane a64ptr ("The arm64e kext", in "The pointer across displays"). Measured on arm64 27.0.1 under HVF with two displays, display 1 placed in turn right of, left of and below display 0 (CGConfigureDisplayOrigin), with a test kext of ours posting IOHIDSystem's moves from a kernel thread call (potluck job m3-max-35345), and on 14.6.1 under TCG with one (job m3-max-35287):

    • IOHIDSystem's own post, extPostEvent with kIOHIDSetCursorPosition, answers success in 15 to 23 us. WindowServer puts its cursor at the point posted: 2880,540, -960,540 and 960,1620 put it on display 1 at its 960,540 in the three arrangements, and display 1's swap showed it there (its MOVE_CURSOR). A drag (NX_LMOUSEDRAGGED) moves it as a move does, and the tablet's next position scales over the display the cursor went to. A point past every display is held at the edge of the display the cursor is on (2880,540 with one 1920-wide display; 5755,600 with the cursor on display 0, held at its right edge, job m3-max-35450). A cursor near display 0's right edge shows on display 1 too, the part of its image over the edge (the same job: display 1's MOVE_CURSOR came first, its hot spot at x -5; at x 0 for a post at 1915,650, job m3-max-35515).
    • Under TCG (14.6.1 at two displays, job m3-max-35541) the guest showed a crossing's landing 18 to 153 ms after the POINTER_OVER (the device's debug log), past 100 ms more than once, so on a host that holds its positions for 100 ms alone the tablet's positions reach the guest before the landing and move the cursor on the display it is on.
    • WindowServer tells the kernel nothing of where it placed each display: it registers none with IOHIDSystem (its screen count stayed 0, and its work bounds 0,0 to 1920,1080 in every arrangement), an IOMobileFramebuffer has no bounds, and IOHIDSystem's DisplayState property is compiled out of IOHIDFamily (read from its source). So the kext learns each display's place from its own posts' landings.

The lanes, in the order they land:

lane owns waits for checks
mmhost the device crate (each display's state, rooms, mode sizing, events by the bit, the offer), reims-vgpu (each display's screen, window, presents, colour, read-back and cursor), the C API, its header and docs/api.md, vendor/qemu (displays, a console and window per display), features.md's new entries, docs/qemu.md, and the pointer's host side once X1 is settled this design cargo xtask check (the Mac's and Linux's); QEMU built, realized paused (-S) at displays 1 and 4, refused at 0 and 5; boots of x86-64 26.7 at displays 1 (the feature words unchanged) and 2 with today's kexts (display 0 as before, display 1's window black); features.md's entries for several windows walked on a Linux host
mmx86 guest/kext: the owner's code per display shared by both architectures (the display table, events by display, the cursor slot's lock), the x86-64 framebuffers per display, X1 to X5 and the guest side of the pointer; both prebuilt sets mmhost, for its boots make -C guest test; make -C guest prebuilt and prebuilt-arm64e committed; boots of x86-64 11.7, 12.7, 13.7, 14.8, 15.8 and 26.7 at displays 2 and 1
mma64 the arm64e framebuffers per display (ReimsGraphicsMobile.cpp), firmware/ambrosia's nodes, A1 to A3 mmhost; mmx86's shared code; Ambrosia's nodes (A1) make -C guest test; make -C guest prebuilt and prebuilt-arm64e committed (each set's record lists every kext source); make -C firmware/ambrosia bundle and config-bundle; boots of arm64 14, 15 and 26 under TCG and 27 under HVF on the M3 at displays 2 and 1
pointer crossing the event that says the pointer is over display i at x, y (wire.rs, the host's side in the window and the library, with the ROM's and both sets' records), and the x86-64 kext's move of the cursor onto display i (X1) mmx86 as mmhost's and mmx86's, for what it touches; boots at displays 2 where a pointer over each window moves the guest's cursor on that window's display
mmctl crates/reims-ctl: the setting, the QEMU command, the terminal UI and the command line mmhost's displays landed, and the pointer reaching display 1 (X1) cargo test, cargo fmt --check and cargo clippy --all-targets in it; an install and a boot at displays 2 on a Linux host
a64ptr the arm64e kext's crossing and its displays' places (A3: ReimsGraphicsPointer.cpp on arm64, RgfxDisplayPlaces.hpp), and both sets mma64; the pointer crossing and dragcross make -C guest test; make -C guest prebuilt and prebuilt-arm64e committed; boots of arm64 27 under HVF on the M3 and 14, 15 and 26 under TCG at displays 2, each with crossings and a captured drag onto display 1 and back with display 1 right and left of display 0, and at displays 1 with the feature words of a boot before it; a boot of x86-64 26.7 at displays 2

mmhost, mmctl and the reading for X2 to X5, A1 and A2 start at once; mmx86 builds and unit-tests its framebuffers at once and boots them on mmhost's branch; mma64 builds once mmx86's shared code has landed. A boot at displays 2 passes where system_profiler SPDisplaysDataType lists both displays at their windows' modes, a screendump of each head shows the desktop, both displays get VBLANKs, the cursor shows on the display it is on, no reims-vgpu: fatal line is logged, and the boot's usual checks pass; one at displays 1 passes the usual checks with the feature words of a boot before the change.

A pointer for games

A VM's pointer is QEMU's USB tablet: absolute, a position in the display's range. Captured, the host's pointer is held over the window's image, and the tablet at the image's edge (features.md, "Pointer"). A game that hides the cursor and turns its camera by the mouse's motion (a cursor disassociated from the mouse, CGAssociateMouseAndMouseCursorPosition(false), read through NSEvent's or CGEvent's deltas, an event tap, or GCMouse) gets no motion once the tablet reaches the edge: the tablet stays where it is. Measured (lane gamemouse, potluck job m3-max-35167, x86-64 26.7.2 on a 780M, a probe app of our own pushing right in ten chunks of 200 counts): all four sources gave +669 points over the first four chunks and exactly 0 over the next six, the tablet at the last column; GCMouse listed one mouse, the tablet. So the guest gets a mouse of its own, whose motion has no edge:

  • The guest's mouse. A guest that took POINTER_MOTION publishes a mouse: the kext's RgfxPointerDevice (guest/kext/src), an IOHIDDevice named "Reims vGPU Mouse" by "Reims vGPU", vendor 0x1234 and product 0x5247 (the device's own PCI IDs), a report of five buttons, 16-bit relative X and Y and an 8-bit wheel (RgfxPointerMotion.hpp), with no resolution of its own. IOHIDFamily's event driver makes it a mouse for WindowServer, NSEvent, CGEvent, event taps, GCMouse and IOHIDManager. Display 0's driver starts it once its own start is done, only where the guest took the bit, so a guest without it sees no new device, and stops it at its stop. Each POINTER_MOTION (0x105, RgfxPointerMotion) becomes one report, or several where its motion or wheel passes a report's range, the buttons in each.
  • The device. The device tracks the guest's cursor on each display from MOVE_CURSOR's visible: the cursor is hidden while no display the guest has moved it on shows it, counted from the hide that made it so (PointerLink::cursor_hidden_for, None for a guest that did not take the bit), or, while a POINTER_OVER has yet to show the cursor on the pointer's display, from a second after it at the earliest (CROSSING_HIDE_NS): the guest hides the cursor on the display it leaves before it shows it on the next, and an arm64 guest under TCG showed it there up to 491 ms after the POINTER_OVER, so that hide, counted as a game's, drove the guest's mouse in the middle of captured drags across displays (potluck jobs m3-max-36283, m3-max-36434, m3-max-36435). A window's motion (PointerLink::motion) is owed as a POINTER_MOTION and posted at once; while the completion ring is held, full or behind answers handed over, the owed wait in order for the next refresh, a motion of the same buttons joining the last owed and a change of buttons owed after it, so a press or a release is never merged into a move; past 64 owed, the last takes the new buttons. A reset forgets the hidden cursor and the owed motion.
  • The window. Captured, a hide's first move goes to the tablet, as while the guest shows its cursor. Once the guest's cursor has stayed hidden for 50 ms past that move (reims_vgpu_window::game::SETTLE_NS), the window's next move locks the host's pointer where it is and hands its motion to the guest's mouse in the device's own counts, unaccelerated, so the guest accelerates it once, as its mouse settings say: SDL's relative mode with SDL_MOUSE_RELATIVE_SYSTEM_SCALE 0 on Linux, and on macOS CGAssociateMouseAndMouseCursorPosition(false) with the events' kCGEventUnacceleratedPointerMovementX and Y. A hide that outlives a move is a game's: macOS hides the cursor while text is typed until the mouse moves, and shows it at that move (about 1 ms after the move that reached the guest: lane ptrswitch, potluck job m3-max-75911, x86-64 26.7.2), so typing never drives the guest's mouse and no move after it is lost; a show, or a hide that reads shorter than at its first move, starts the count over, and so does a change of capture. The settle is also past WindowServer's dozen hides and shows as it starts, and the hide and show of the cursor crossing displays, which the device counts from a second after its POINTER_OVER. Buttons pressed meanwhile and a mouse wheel's notches go to the guest's mouse too. At the guest's next show of its cursor (the game's menu), the pointer is the tablet's again, the host's pointer let go over the guest's cursor where it shows on the window's display, else where it was held; releasing capture, losing the keyboard and closing let it go where it was held. The release chord (and macOS's Release Input) also leaves the rest of that hide to the tablet, captured again or not, until the guest shows its cursor: the way out of a hide that is not a game's, as macOS keeps one while the guest's screen is recorded or shared (lane ptrswitch, potluck job m3-max-75965: the framebuffer saw one setCursorState(x, y, false) and no call while the pointer moved, as in a game's hide). A button comes up by the route it went down by, the tablet or the guest's mouse, so one held across either switch never stays down. On a device of several displays, a pointer gone past a shared edge ("A drag across displays") drives the guest's mouse from there once the guest hides its cursor.
  • Compatibility. Nothing changes on the C API, in QEMU or in reims-ctl: the tablet stays the guest's pointer, and the guest's mouse rides the device. A guest that did not take POINTER_MOTION (a kext built before it, the option ROM, Ambrosia's module) publishes no mouse and is sent no event, its hidden cursor drives nothing, and the window's pointer is the tablet's only, as before. A kext that does not know the event passes over it (handleEvent's default).

Scrolling

QEMU's USB tablet, an x86-64 guest's pointer, has a vertical wheel and no sideways one: a sideways scroll of the host's never reached the guest. An x86-64 guest's scrolling goes to its own mouse ("A pointer for games") instead:

  • The guest. The x86-64 kext's mouse has AC Pan (consumer page 0x0C, usage 0x238) after its wheel, both 8-bit relative, which IOHIDEventDriver makes the scroll event's sideways axis (IOHIDFamily's IOHIDEventDriver::handleScrollReport). A notch either way is the tablet's notch field by field: line delta 1, point delta 1, not continuous, and the same acceleration, since the mouse declares the tablet's resolution, none (9 notches an inch, HIDScrollResolution), and notches 16 ms apart scroll as far through both, 585 points for ten (measured, lane scrollhid, potluck job m3-max-75987, x86-64 26.7.2). Once its mouse is up, after each start, the kext sends SCROLL_DEVICES (11) naming it (RGFX_SCROLL_DEVICE_WHEEL), and hands each SCROLL (0x106, RgfxScroll) to it as reports of at most 127 notches each way, with the buttons its last POINTER_MOTION left held. The arm64e kext sends none: vmapple's tablet scrolls smoothly and sideways.
  • The guest's precise scroller. Beside the mouse the x86-64 kext starts "Reims vGPU Scroller" (product 0x5248): the mouse's descriptor and reports, with a physical range of -1 to 1 on its wheel and pan against their logical -127 to 127, which IOHIDEventService::determineResolution reads as 127 counts a unit. macOS marks its events continuous and precise, in points, as a touchpad's. Its acceleration is off (HIDSupportsScrollAcceleration false on the device, which IOHIDInterface and the event service copy down and the scroll filter reads), and then a count scrolls 10 points however fast counts come: 120 counts made 1200 points slow (100 ms apart), fast (8 ms) and in lumps (4 every 16 ms), on both axes, at 127 and at 90 counts a unit, on 26.7.2 and 11.7.11 (measured, potluck jobs m3-max-75987 and m3-max-75994). Apple's driver passes each count whole (getValue() << 16) and reads no resolution multiplier, so no descriptor makes a count worth less: precise scrolling moves in steps of 10 points. With the acceleration on, neither a flat HIDScrollAccelerationTable nor one linear HIDScrollAccelCurves curve scrolled as far a count at every speed: the table up to 6.3 times as far fast as slow, the curve 25% further in lumps (job m3-max-76084). With the scroller up, SCROLL_DEVICES names it too (RGFX_SCROLL_DEVICE_PRECISE), and each SCROLL's distance goes to it as counts, one per 10 points (kRgfxScrollerFinePerCount), the rest carried on and started afresh where the scrolling turns back, at most 8 x 127 a SCROLL.
  • The device. From a guest's SCROLL_DEVICES to its next reset, a window's scroll (PointerLink::scroll) is owed as a SCROLL and posted after the owed motion, joined into the owed one while the ring is held or full, field by field, saturating. A precise device's distance goes where the guest names a precise device (RGFX_SCROLL_DEVICE_PRECISE), and otherwise as the notches in it, one per 10 points each way (FINE_PER_NOTCH, a line of SDL's, so a touchpad on Linux and Windows turns the guest's wheel a notch a line, as SDL counts the tablet's), the rest counted on and counted afresh where the scrolling turns back.
  • The window. Where the guest's devices take scrolling (PointerMotion::scrolled), every scroll over the image goes to them, and the host's wheel and scroll callbacks hear none of it: a wheel's whole notches, and a precise device's distance (SDL's events in parts of a line, at 10 points a line, on Linux and Windows; AppKit's precise events, momentum included, in points). The pointer's position still goes by the tablet, before the scroll, by another path: a scroll that follows a move within a tablet's poll may land where the cursor was.
  • Compatibility. A guest that does not send SCROLL_DEVICES (the arm64e kext, a kext built before it, the option ROM, Ambrosia's module) is sent no SCROLL, and its scrolling reaches the tablet as before.

Stage 3 wire protocol: the Metal-call stream

Stage 3 keeps the stage-2 transport unchanged — the registers, the region, the 256-byte ring header, the doorbell and interrupt handshake, and the 16-byte message header (type, size, seqno). It adds rings per command queue, a family of device-level object-lifecycle messages, command-buffer encodings on the per-queue submission rings, and completion records on the per-queue completion rings.

Our guest Metal GPU bundle is the host of Apple's Metal SPI: every Metal call an app makes lands in one of the bundle's objects, and the bundle serialises it into this stream. The host reads the stream and drives the library's Platform (Metal on the Mac, metal2vulkan on Linux), the same trait core already drives from the Apple-lane command stream. So the host decoder is: wire message → handle-table lookup/insert → Platform call → completion. The bundle's serialiser is the mirror of that decoder.

Guest input the host refuses. Everything on the wire comes from the guest, which the host does not trust, and no guest input ends QEMU. A message the host cannot carry out (one shorter than its record, a span it does not cover, an object it does not hold or of the wrong kind, the platform refusing the create) is refused at its op, and nothing of it is made. A create the guest waits on (a pipeline's reflection, a library create or lookup, a queue's create, a context's close) is answered at that op: a refused PIPELINE_REFLECTION, or a COMPLETE with the refusal's status, so no guest thread waits out the kext's timeout. A refused command buffer completes with an error status, as a buffer Metal could not run does: a stand-in on its queue, holding the buffer's event waits and signals alone, finishes in the queue's order, and its completion posts the values the buffer signalled its shared events to, then the buffer's internal-error CB_COMPLETE. So a buffer that names anything the host does not hold fails after the buffers committed before it, and nothing waiting for one of its events, a later buffer on the GPU or a guest thread, waits for good. An object whose create the bundle answered at the call, without the host's answer (a buffer, heap, texture, view, depth/stencil state, event, fence, video session, or a pipeline equal to an accepted one), is one the guest goes on naming where the host refused it, as Metal would have made it. Its id stands for a refused object until its destroy (the decoder's refused), and what names it is dropped, never the command buffer that names it: an op that uses it (a copy, a fill, an indexed or indirect draw from it, a fence update or wait) is dropped; a binding of it binds nil and marks its slot until the slot is bound again. The draws and dispatches of an encoder with a buffer, texture or sampler bound so run, as Metal's do with nil bound there (the x86 Macs read a texture as zero, oracle_nilbind, dgpu-oracle.md Q25), and an offset op at such a buffer slot sets nothing; while a pipeline state, depth/stencil state or tessellation factor buffer slot is marked, they are dropped. An indirect command buffer's CPU encode of it is dropped and its command reset, and that command's later draws and dispatches are dropped until the guest resets it or copies a command over it; a use list's entry of it is nil; a render pass with it as an attachment, and a video encoder of its session, are skipped whole; a wait for it as an event is dropped, and a signal of it as a shared event still reaches the guest's value; a create over it stands refused in turn. The buffer then completes as it would have. So does a buffer with a pass the platform makes no encoder of (on the Vulkan platform, a pass its runtime refuses, as a resolve it builds none of, which it counts): the pass is skipped whole, its ops dropped up to its end, as a Metal app's sends to a nil encoder do nothing and fail no command buffer. Where there is no stand-in (a message too short to name its queue, a queue the process does not hold), the error status is posted at once. Nothing in this lane ends the offending context or its process on malformed input. The host runs each op in a refusal scope (reims_vgpu_vulkan::core::raise::refusals): a death at a platform call, where the platform refuses a create or an encode and the paravirt device ends the process, unwinds to the op's scope instead, and the op is refused there, logged once at WARN with the platform's reason. A panic in the lane's code, a bug, is refused there too, logged at ERROR. An assertion inside Metal is no death of the library's, which no scope takes on a Mac host, so where the lane knows Metal asserts it refuses the op before any platform call: a texture, a view, a heap's size for a texture, or a render or mesh render pipeline state's attachment, of a pixel format the device describes none for. A command buffer refused mid-stream has its open encoder ended and is never committed. Work an op registers to run on another thread takes the op's scope with it (refusals::carry): a command buffer's completed handler runs the platform's read of the buffer, and itself, in the scope of the decode that added it. A death in that read (a failure no Metal answer matches, which the Vulkan platform reads on the runtime's thread) fails the command buffer, whose CB_COMPLETE is an internal error (MTLCommandBufferErrorInternal), and nothing else: the context's later command buffers, creates and queries are carried out as any context's. On a Mac a GPU error fails the command buffers it strikes, WindowServer's among them, and their processes' later buffers run (docs/lessons.md, the test that faults the GPU, measured on macOS 27.0.1), so a failed buffer of WindowServer's leaves its later frames to be carried out, and the display goes on. A release the platform dies at (at a destroy, a context's close, or the display's swap of the texture it shows) is refused alone, and the destroy or the close is carried out whole. So is each of the Vulkan platform's releases of what a command buffer's commands used, and each change it makes, as the command buffer ends on the runtime's thread, and so is each such release while a death in the op unwinds past it: a scope a release opens in the unwind takes a death in it, where one outside any such scope still ends the process. A draw of the display (the window's, and the host's reads of it) reads what the guest set and presented, and runs in a scope of its own: a death in it refuses that draw alone, its encoder ended and nothing of it committed, and the window keeps the frame it shows, while the read answers that the platform refused the draw. What dies elsewhere off the op's thread still ends the process: a notice the runtime's scheduler thread announces at a host step, which names no command buffer, and the runtime's own releases after the platform's handlers ran. This is the lane's own rule: the paravirt device's rule of ending the process at the op (AGENTS.md, the contract) is Apple's framework's behaviour, which that device keeps.

Processes name only their own. A process names only its own objects and its own memory. The accelerator kext checks, before it posts a lifecycle message, that the object the message creates or destroys is in the process's id range, and that the region the message names lies in the process's own blocks: a queue's rings, a heap's or a buffer's block over host memory, and a library chunk's bytes and ack slot. The host checks these spans too, and also the span a COMMAND_BUFFER_IN_REGION on a queue's ring names, which never passes the kext. Each span must lie in one block the sender holds. The kext posts a block's BLOCK_GRANT (context, offset, size) on ring 0 before its allocation returns, keeping the block pinned until then so no free overtakes it. A block's offset is given out again once the device answers its release or its holder's close, to any process, and the region keeps its bytes across the device's reset and the guest's reboot; so before a new block is in the process's window the kext writes zeros over every span the window maps of it, each through a kernel mapping of the cache mode the window maps it with, and a surface's new block over the part its holders map. Those mappings are two, one a mode, of the whole blocks' range, made once at the kext's start and kept: they hold the kernel's address space and page tables only, and no memory of the host's, since no page of the region is touched until it is zeroed or used. On a Windows host (WHP), the kext's zeros are the first touch of a region page that was never touched before (RgfxBlockZero.hpp; the kext's feature bit 1 << 14 ZeroedBlocks, after which the bundle zeroes no region slab it takes; the guest's guest/bundle/tools/block_zero_probe.c checks it across processes). The host keeps the grant until the block's BLOCK_RELEASE or the context's CONTEXT_CLOSE, and copies a buffer out of a block only while the grant stands. An IOSurface's shared block (§14) is held by every process that holds the surface: the kext finds it by the physical pages of the surface's plane 0, which a process presents through its own CPU mapping of the plane (user-client selector 0x109), so only a holder of the surface can reach the block, whatever id it claims. The kext wires those pages while the process holds the block, posts BLOCK_SHARE (context, offset, size) for each holder before the process learns of the block, and BLOCK_UNSHARE as a holder other than the last lets it go (selector 8, or its close). The last holder's let-go frees the block as a free does, and its BLOCK_RELEASE ends every hold; a cached block in place instead sleeps, its last holder's BLOCK_UNSHARE posted, until an ask of its surface holds it again with a BLOCK_SHARE alone or the kext lets it go with its BLOCK_RELEASE (§14, "The device cache"). A block in place (0x109's fourth input) is found by the pages of the surface's whole allocation, which every holder's ask wires. Before its first BLOCK_SHARE, the kext writes their runs into the block, past the part the processes map and are granted, and posts SURFACE_PAGES; other asks for the surface wait for its answer. A refusal frees the block as a share not posted does, and the ask answers kIOReturnUnsupported, so the process copies the surface. Where the device has RGFX_FEATURE_SURFACE_CACHE, 0x109's fifth and sixth inputs (the surface's IOSurfaceID, and 1 where the process asks it cached) have the kext mark a block it makes cached in its SURFACE_PAGES, and a fifth output answers whether the block is, whichever ask made it. Where the device has RGFX_FEATURE_SURFACE_CACHE_REFUSED instead, a struct input with the six (RgfxSurfacePagesLayout) is the surface's layout, with which the kext asks the device whether the block needs a cache, and marks it cached only where the device answers so; the surface's resident pages may follow the layout (RgfxSurfaceResident), where the kext took RGFX_FEATURE_SURFACE_DEFERRED_CARRY, for a deferral that carries them. The kext then writes the surface's CPU generation at offset 16 of the block, and asks SURFACE_DOWNLOAD (block offset) at a CPU lock that follows a GPU write, answered once the surface's pages hold the host's device cache (Decided 14, "The device cache"). A command buffer that writes surfaces' shared blocks is named to the kext after it is posted and before its commit returns (selector 0x10c: the queue, the buffer's seqno, and a pair of the block's offset and the surface's IOSurfaceID for each surface), and its completion retires the queue's writes up to it once any copy is written back (selector 9). Only a holder of a block names it, only for one of its own queues, and the kext keeps a block's surface only where the surface's memory holds the block's pages, so no process makes another's locks wait (§14, "CPU locks").

Processes map only their own. No process maps the region whole: it holds every process's blocks, the control rings and the device page. Each connection has a window, a range of the process the region's size that the kext makes at the context's open (selector 0x100 answers its base and size). The window is memory of the connection's own, mapped read-only, and holds no page until one is read, which then reads zeros. It is purgeable, never made volatile, so the process's footprint counts only the pages it reads there: xnu charges an IOKit mapping of anonymous memory to the task's footprint at its whole size as it is made, but a purgeable object's resident pages to its owner, the process that opened the context (read from the public xnu source: vm_map_enter, mach_make_memory_entry). A window of plain pageable memory charged every Metal process the region's size at its open, past many processes' memory high watermarks. The spans are device memory, which no footprint counts. Region offset o of what the process is given lies at the base plus o, so the bundle's pointers stay base plus offset. The kext maps in, over the window at the span's own offset, only the process's blocks, the shared blocks of the surface planes it holds, and the scanout it is granted. It maps a span in before the process learns of it. Before the span can go to anyone else, it maps the window's own memory back over the span, read-only: before a block's free marks it freed, and when a hold ends, a scanout grant goes or a mode change moves the scanout. At the close the whole window goes, every span in it, before the context's blocks are freed. Each span is whole pages past the region's head, so no mapped page holds a byte of anything else. A page here is the process's: 4 KiB on x86-64 and 16 KiB on arm64, where the kext maps the whole 16 KiB pages of a block's part a process uses (a plane's bytes, whole 4 KiB guest pages) and of the scanout's rows. Every block is whole such pages, and a surface block's runs start past the mapped pages. The device info shares its page with the control completion ring's tail, so the kext reads it for the process (selector 0x10b), and the region's own map (kRgfxAccelMemoryRegion) is refused. One difference from Apple's: a process that touches a block after releasing it reads zeros, and faults only on a write, where Apple's faults on both. Only a guest that uses memory it released sees it. A mapping that fails fails its op; a span that cannot be taken back closes the window, so the process reaches nothing of the region from then on. A placed mapping is IOKit's overwrite mapping, which IOKit never takes down itself (read from the public xnu source, IOMemoryDescriptor::doUnmap), so only another mapping over it takes a span back; vm_protect is not a KPI a third-party kext may link.

The scanout is its owner's. The scanout holds the display's pixels, so only the process that drives the display reaches it: the task that holds the framebuffer's server connection (kIOFBServerConnectType), WindowServer. The kext grants the scanout (selector 0x108), locks an IOSurface with no backing of its own over it, and gives out the framebuffer's VRAM range (which IOFramebuffer maps on its server connection, and on its shared connection into any process of the console's user) to that task and the kernel alone. Any other process gets kIOReturnNotPermitted, or no memory for the VRAM range, and nothing is mapped. The server connection is the test because IOFramebuffer opens it for one task at a time, and the task that holds it maps the scanout through it already (the system aperture), so the rule gives no process what IOFramebuffer does not. An open in flight counts too, since IOFramebuffer sets the display up inside it. A new connection's task replaces the last one, and every other task's hold of the scanout is taken back then: each grant, its span mapped back out of the context's window, and each lock's mapping, unmapped from the task. What IOFramebuffer itself mapped for a task (the VRAM range on its connections) is IOFramebuffer's, and goes only with its connection. The room keeps what its last owner left there, so a task that is not the last owner (the next WindowServer, after a crash or a logout) owns nothing until the framebuffer has taken every other task's hold back and written zeros over the display's room, through a write-back mapping, the mode the windows and the locks map it in (RgfxScanoutOwner.hpp). The display shows black, not the last owner's frame, until the new owner presents. The last owner opening again keeps its bytes, and the first owner finds the boot screen, which no process wrote and which the first present clears. A room the kernel will not map for the zeros fails the open. So the zeros are written only when a new WindowServer process opens the server connection: never at boot, and never when the same WindowServer opens it again. The new owner maps the whole room through the VRAM range, so the pass zeroes the display's whole share of the region (128 MiB in the boots measured here), and the host then backs all of it: up to 128 MiB of the host's RAM committed per VM from its first WindowServer replacement on, where the last owner's frames had touched only a frame or two of it. The stores took 103 ms on a Linux host under KVM (Radeon 780M, job m3-max-49882) and 802 ms on a Windows host under WHP (UHD 630, job m3-max-50087), and the room's mapping 1.2 ms and 3.8 ms. How often the pass comes was measured on a Linux host under KVM (RTX 3090, job m3-max-50552), with the guest's kernel buffer read before and after each step and each read found to continue the one before it. A logout, with autologin turned off, replaced WindowServer, and the new one made one pass over display 0's room and was given the VRAM range once. The login typed at the login window kept that WindowServer and made no pass. So a session costs one pass per logout, and a login none. The boot's own count was not read: its lines had left the guest's 128 KiB buffer before the first read.

Command buffers do not pass through the kext, so the host checks each object a message names: it must be of the message's context, which is the context of the object a ring-0 message creates or destroys, or the context of the queue whose ring carried the command buffer. A command buffer runs only on the queue whose ring carried it, and a queue's ring carries nothing but command buffers: a message of any other type there is refused, since it would pass the kext's checks by. A create the kext posted but whose answer did not come in time is destroyed by the kext right behind it, so a retry under a new id leaves nothing behind.

A block outlives what lies in it. A region block is given out again only once the host has said that nothing of it is in use. A process's free marks the block freed: from then on no message of the process can name it, and no one can take it. The free returns at once, as Metal's releases never block. The kext's one release worker, a thread call that runs one at a time, then posts the block's BLOCK_RELEASE on ring 0, behind every message the process posted before the free. It posts every freed block's release, 16 under one hold of the ring's lock with one doorbell at most, up to 256 in flight, and returns without waiting. Each release has an entry of its own, which the work loop finds by seqno when its answer comes and then runs the worker to retire it. Answers come in whatever order the contexts' work finishes, so a slow context holds back only its own blocks, and a storm of frees waits for each context's work once, not once a release. A full table leaves the rest freed until entries retire. The host refuses the release at once where an object it holds lies in the block: a buffer or heap over host memory, or a buffer, texture or heap placed in one, which keeps its parent's span after the parent's destroy. It also refuses one where a live queue's ring lies in the block. Otherwise it answers OK once every command buffer the host has begun for the context before the release has run its completion handler, and, for a shared block, every one it began for each other holder before its BLOCK_UNSHARE, before its close, or before the release itself where neither came first: the kext unwired that holder's pages at its unshare, or at a close it took for refused, and gives the surface's memory back at the answer. A command buffer posted on a ring and not yet begun is not waited for. The kext posts an unshare out of its lock, so another holder's release can come first, and the host then takes the release as that holder's unshare too; the unshare that follows is not counted again. It also waits while the host's display holds a surface's texture over the block, as a compositor holds the IOSurface it shows: from the surface's present until the display pipe's next present (or the device's reset), and each window draw of it until the draw has finished. Command buffers committed later do not hold it up. On OK the block goes back to the pool; on a refusal it stays out of use until its process's close posts its release again. A release not answered in 10 s is logged and stays in flight: the host may still run a buffer over the block or copy a cached surface's GPU copy into the surface's pages, so the block, its wired pages, and a cached surface with its wire are held, never handed back to macOS, until the answer comes. A block a create in flight names is pinned from the kext's check until the create is answered, and a free of it meanwhile fails busy, so no block changes hands between the check and the host's carrying out of the message. A context's close is answered under the same rule, after its objects are dropped and its queues' threads are past their rings, and the kext frees the process's blocks only on that answer. None of them is released from the close's post on, and a release the kext took just before and posts behind the close waits for the close's buffers on the host too. A close not answered in 10 s keeps everything the process held from every other process until its answer comes, however late: its blocks with their wired pages, its holds of shared blocks, its GPU address units and its resource-id chunks, which the host may still use or map to the context's objects. None of its blocks is released meanwhile. The late answer lets go of all of it as an answer in time does. A close never answered, or refused, keeps it for good.

Handles and addresses. Every guest Metal object has a 64-bit ObjId the guest picks, unique per device; the host keeps an ObjId → Platform handle table (handles are refcounted in core, clone_ref/Drop). The guest also picks buffer/texture/heap GPU addresses and resource IDs, and the host pins them where a block it knows holds the range; a pin no known block holds is made at the driver's device address, counted (section "Addresses and IDs", above). A destroy carries the ObjId alone; the host drops its handle.

Rings. Ring 0 stays the control ring: the framebuffer kext's stage-2 display commands, and the device-level object lifecycle below, which the accelerator kext posts there for each process. Every other ring is one MTLCommandQueue's ring pair (one submission and one completion ring per queue, created on demand), which the bundle places in its kext-given blocks and creates through the accelerator kext. Each ring keeps a single producer and a single consumer, so their consumer_idle handshakes never race. A create carries a priority, which the bundle sends as 0 for every queue and the host does not read: each queue is the platform's plain newCommandQueue. So the priority marks a guest sets on its queues (setGPUPriority:, setBackgroundGPUPriority:), which the bundle keeps and answers back, reach no host queue, and a buffer committed behind another queue's long buffers waits for all of them on the one VkQueue ("A command buffer in parts"), where a Mac's Intel 630 starts it within 0.44 ms when its queue's GPU priority value is below theirs, and its AMD 5300M does so marked or not (dgpu-oracle.md, Q50).

Object lifecycle (ring 0, through the accelerator kext, request/reply). Each *_CREATE carries our schema for the Metal descriptor (plain little-endian fields, decoded straight into the Platform descriptor struct — core keeps descriptors as public-field structs), the guest-picked ObjId, and, where it applies, the address, id or offset. Resource creates with a guest-picked id/address are fire-and-forget (the host builds the mirror and pins lazily on first use); pipeline creates block for the reply, which carries the reflection the guest needs (threadExecutionWidth, max total threads per threadgroup, static threadgroup memory) — m2v's "take state answers from the created pipeline".

When a pipeline create's reply comes. The host compiles a pipeline create off ring 0's threads and posts its reply as soon as the platform's make of the state has made every answer the reply carries. The make's last step, the platform's create of the driver's pipeline where it defers it, then runs on the same compile thread, and the pipeline is stored after it. Until the store, whatever names the pipeline waits for it: a command buffer that sets it, on its queue's lane, and an ICB_WRITE, ICB_SLOTS or ICB_SLOTS_IN_PAGES that sets it, or a function handle or table create that names it, on its context's lane. A destroy, a context's close or the device's reset between the reply and the store cancels it as before the reply, and a create cancelled before its last step begins skips that step (crates/reims-vgpu/src/graphics/compile.rs, "Order"). On the rt platform the last step is the driver's create of the state's main pipelines, so the reply no longer waits for it; the store, and the command buffers that name the pipeline, still do. A failure of the last step is a known gap: the create was answered made, and the failure reaches the guest only in the pipeline's draws and dispatches, which make the pipeline again and, where that make fails too, the platform answers as encodes it refuses, while a Mac's synchronous create answers it as the create's error. The host counts it (pipeline-finish-failed), logs the first of the process, keeps no answer of its key for the next runs, and the VM goes on.

Known pipeline creates. A pipeline create whose message equals, in every byte but its header and object id, one the device accepted for the same process does not wait for its reply (the bundle's RgfxKnownPipelines.hpp). It is posted with Submit's kRgfxSubmitDeferred flag, and its state takes the earlier create's reflection at once. Its gpuResourceID, the one value the host gives each create alone, waits at its first read for the create's own reply, which the kext keeps until the process takes it (TakeAnswers). The process also takes the replies no one asked for every 32 such posts. Each create is still a new object with its own resource ID, as Metal's equal creates are. The first create of each message waits as before, so a refusal is still known at the create. A refusal is never kept, so its equal create waits again. Where the kext has no slot left (64 per process, 256 in all), the create waits as any. The bundle posts this way only where the kext's feature word has kRgfxKextFeatureDeferredAnswers.

Across processes, the key is the create's pipeline key (PIPELINE_KEYS, above), which names its libraries by their content, not by the process's ids. The kext keeps the device's answer to every create it waited for that carries a key (RgfxSharedPipelines.hpp): the reflection with its header, object id, gpuResourceID, unique identifier and resource index zeroed, in a table of 2,048 answers (256 sets of 8, a full set replacing the answer found or learnt longest ago), seeded at each start of the kext with the device's answers of earlier runs (below). The bundle computes the key of each create whose libraries all have content keys, and posts it with Submit's kRgfxSubmitShared flag and the key: where the kext keeps an answer of that key and has a slot left, it posts the create as a deferred one and hands back the kept answer, stamped with the create's seqno and object id, which the state takes as it takes a known create's; the process then knows the create too. Else the create is posted and waits as any, and its answer is kept. A process sees the same answers as with its own equal create before: the reflection at once, its own gpuResourceID at the first read, and a refusal at the create only where no process's equal create was accepted. Where the device refuses a create a kept answer answered, the kext forgets that answer (the deferred slot holds the key), so the next equal create of any process waits for its own answer and takes the refusal at the create. And the kext keeps the device's own answer to every create posted so that made a keyed pipeline, so a kept answer the device answers otherwise, which only a seed of an earlier run can be (below), answers no later create. The create it answered keeps the kept values: a state takes its reflection once, and only its gpuResourceID from its own answer. The kext learns only answers the device gave, whose key the host computed, so no process can place an answer for another's key; a process naming a key that is not its create's only takes a wrong reflection for its own pipeline. The bundle posts so only where the kext's feature word has kRgfxKextFeatureSharedPipelines and the device's has PIPELINE_KEYS.

Across runs, the device keeps its answers to keyed creates (PIPELINE_ANSWERS, above), as a Mac's Metal keeps its compiled pipelines on disk. The host keeps each made pipeline's keyed answer, with the fields it gives each create alone zeroed, in a file of its own, under the identity of what decides its answers: the platform's translation profile (its fingerprint), its runtime's semantic, artifact and runtime versions, the driver's version, the build of the library that runs (the host's executable, which links it, by path, size and modification time: how the library decodes a create and replies is its build's), and the file's format (crates/reims-vgpu/src/graphics/answers.rs). A file of another identity is never read, so an upgrade of the library or of its host starts from none. The file is a header (its magic, format, record size and identity, with their checksum) and 128-byte records, each one key's answer or the drop of a key's answer, with its checksum over the identity and its bytes; a damaged or foreign file, or one holding an answer no create could be given, reads as none and is started again. A record is appended when an answer is learnt or dropped, and the kept record again at a run's first create of a key an earlier run kept, so an answer is as new as the last run that used it. The file holds at most 8,192 records (1 MiB): one past half of that is written again at the next open, and one at all of them before the run's next record, with its newest 2,048 answers, the kext table's size. A drop that cannot be written removes the file, so no dropped answer reaches a later run. The QEMUs of one build on a host share the file: each appends, writes it again or removes it only under the file's lock, and then to the file its path names, and a rewrite takes every QEMU's records from the file, so none is lost and no dropped answer comes back. The host keeps the 8 newest files. A refusal is never kept, and a create of a kept key that the device refuses or answers with other values drops the kept answer, the second a degradation logged once per boot. At its start, once the display is listed and before any process can make a pipeline, the kext asks for the kept answers, 64 a query, newest first, until the device has no more or it has asked 2,048, and seeds its table with them: a seed takes only a free entry of a key the table does not hold, so a full set keeps the newer seeds, and ranks below every answer the run learns or finds, the newer seed above the older. A create of a key the device accepted in an earlier run then takes its answer at once, as an equal create of another process does; its gpuResourceID still waits for its own answer. The kext seeds only where the host took PIPELINE_KEYS and PIPELINE_ANSWERS.

Every reason the host refuses a pipeline create is either impossible for an equal create or known to the process when it posts:

  • its object id is new;
  • its libraries are held by its functions;
  • its bytes are the accepted create's;
  • the platform's pipeline resource IDs are not refused (measured to 1,000,000);
  • the ring and the context are checked by the kext before it posts;
  • a command buffer's failure fails no other work of its context ("Guest input the host refuses", above).

One reason stays: the platform failing to make again what an equal create needs (read from metal2vulkan's code at the pinned commit). The Vulkan runtime gives a state of an equal descriptor the live variant of an earlier state (its shader modules, layouts and VkPipelines) with no driver call, or the objects of one among the last 16 it released, and the VkPipeline it begins at a create never refuses the create. Where no such variant is left, the create makes the variant's objects again, which can fail for want of memory; where the runtime's memo of compiled pipelines has let the pipeline go and its shader cache misses, it compiles it again, under a compile attempt's 20-second deadline. That refusal shows at the state's first gpuResourceID (as 0) and in the command buffers that name it, whose draws with it are dropped on the host ("Guest input the host refuses"), instead of at the create. Only a create that waits for its answer would close it, at the cost the known creates remove.

group messages Platform call
memory HEAP_OVER_HOST_MEMORY, HEAP_CREATE, BUFFER_CREATE, BUFFER_OVER_HOST_MEMORY, BUFFER_AT_OFFSET, BUFFER_MANAGED_AT_OFFSET, HEAP_OVER_PAGES, TEXTURE_CREATE, TEXTURE_FROM_BUFFER, TEXTURE_FROM_IOSURFACE, MANAGED_TEXTURE_CREATE, MANAGED_BUFFER_CREATE, *_DESTROY new_heap_over_host_memory, new_heap, new_buffer, Heap::new_buffer_at_offset, new_texture, Buffer::new_texture, drop
Managed ranges BUFFER_DID_MODIFY_RANGE, TEXTURE_REPLACE_REGION Buffer::did_modify_range, Texture::replace_region
a texture's bytes changed TEXTURE_DID_MODIFY_DATA (not answered; carried out as a range message) Texture::did_modify_data
heap sizes HEAP_TEXTURE_SIZE_AND_ALIGN (answered SIZE_AND_ALIGN on the control completion ring; makes nothing) heap_texture_size_and_align
rasterization rate maps RATE_MAP_CREATE, RATE_MAP_RESET (answered RATE_MAP_STATE), RATE_MAP_QUERY (answered RATE_MAP_ANSWER; makes nothing), *_DESTROY new_rate_map, RateMap::reset, RateMap::physical_size, screen_to_physical and physical_to_screen, RateMap::copy_parameter_data
function pointers FUNCTION_HANDLE_CREATE, FUNCTION_TABLE_CREATE (answered FUNCTION_POINTER_STATE), FUNCTION_TABLE_SET (not answered; makes nothing), *_DESTROY ComputePipeline::function_handle, ComputePipeline::new_visible_function_table, VisibleFunctionTable::set_functions
dynamic libraries DYNAMIC_LIBRARY_CREATE (answered COMPLETE), *_DESTROY; a COMPUTE_PIPELINE_CREATE's run of RgfxPipelineLibrary new_dynamic_library; the compute descriptor's libraries (preloaded, and loaded by install name)
state SAMPLER_CREATE, DEPTH_STENCIL_CREATE, *_DESTROY new_sampler_state, new_depth_stencil_state
shaders LIBRARY_LOOKUP (the content key of the .metallib's AIR slice: a hit binds the library the device made for any process, and no bytes cross), LIBRARY_CREATE and LIBRARY_FROM_REGION (the slice's bytes forwarded unchanged on a miss, answered once made), RENDER_PIPELINE_CREATE, MESH_RENDER_PIPELINE_CREATE, COMPUTE_PIPELINE_CREATE, *_DESTROY the device's library cache, new_library_with_data, new_render_pipeline_state_full, new_mesh_render_pipeline_state_full and new_compute_pipeline_state_full (the whole descriptor the guest set: vertex or stage-input descriptor, every colour attachment, a render pipeline's tessellation state and vertex and fragment call stack depths, each stage's linked functions, those made with options or a specialized name by Library::new_function_with_options; the Vulkan platform refuses a specialized name, which its runtime's function descriptor lacks)
sync EVENT_CREATE, SHARED_EVENT_CREATE, FENCE_CREATE, *_DESTROY; the kext's SHARED_EVENT_NAME (answered COMPLETE), SHARED_EVENT_IMPORT (answered SHARED_EVENT_VALUE) and SHARED_EVENT_UNNAME (not answered) new_event, new_shared_event, new_fence; an import's value SharedEvent::signaled_value
queue QUEUE_CREATE (priority, region offset, vector), QUEUE_DESTROY new_command_queue

*_OVER_HOST_MEMORY map guest region blocks (Shared) and the host builds a placement heap/buffer over them.

Shared and Managed buffers lie in slabs (guest/bundle/src/RgfxSlabs.hpp). A device buffer of either mode takes whole 4 KiB pages of a slab, a region block the bundle holds, so its create and its free call neither the kext nor the host's import, and the kext's block table holds one entry per slab:

  • A Shared slab is one Placement HEAP_OVER_HOST_MEMORY of the buffers' options, hazard tracking resolved, and each buffer a BUFFER_AT_OFFSET there, at the heap's GPU address plus its offset. Where the device took MANAGED_BUFFER_SLABS, a Managed buffer lies in the Shared class of its cache and hazard tracking modes: its CPU copy is a Shared buffer of that class, made as any (a BUFFER_AT_OFFSET, or the BUFFER_OVER_PAGES of a larger slab of the process's own pages, below), and the buffer a MANAGED_BUFFER_CREATE over it at an address of its own, so a Managed buffer of any size lies where a Shared one of its size does, on every host; its range goes back once the copy's destroy follows the buffer's. Without that feature, where the device took MANAGED_AT_OFFSET, a Managed slab is a Shared Placement heap too, and each buffer a BUFFER_MANAGED_AT_OFFSET at an address of its own: the host's GPU copy, beside a CPU copy placed in the heap at the buffer's range. Elsewhere a Managed slab is a plain block, and each buffer a BUFFER_OVER_HOST_MEMORY over its own range, its CPU copy. The buffer's heap is nil: the slab is no object of the app's.
  • allocatedSize is the pages taken, 4096 for a 256-byte buffer, and contents and GPU addresses start a page, as both x86-64 Macs' GPUs answer (AMD 5300M, Intel 630, measured with tools/shmem). Every new buffer reads zeros: a create zeroes what of its range is dirty, and a background thread zeroes freed ranges first. So a Managed buffer's MANAGED_BUFFER_CREATE says which bytes of its CPU copy read zero (RgfxManagedBufferZero, after the create): all of them for a buffer made with no bytes, those past the bytes given for one made with bytes, and none for one over the app's own memory, which its program wrote ("Managed storage", below).
  • A buffer up to 1 MiB shares a slab of its class, the slabs growing from 128 KiB to 2 MiB, and a class left with no slab, none holding a buffer and none kept, starts again at 128 KiB; a larger one takes a slab of its own, which is cached for reuse at offset 0 once freed (a sixteenth of the region at most, 2 s idle).
  • A class keeps two empty slabs, each for 2 s at most, so a process at rest holds only the slabs its buffers lie in. A slab let go destroys its heap, then frees its block on the background thread, so no buffer's free waits for a BLOCK_RELEASE.
  • Where the device has a Shared pool, the kext maps its blocks (POOL, the kext's Pool; "The Shared pool", below) and Managed buffers lie over Shared copies (MANAGED_BUFFER_SLABS, which every host that offers the pool offers), the pool is every slab's one source, in place of the region and of the process's own pages below: each slab is one block of the pool, made one Shared Placement HEAP_OVER_POOL, its buffers placed in it as in a region slab's heap. A class's slabs grow to 16 MiB and hold buffers of up to 4 MiB, as chunked slabs do, and a larger buffer takes a block of its own of its length rounded up to 64 KiB, with its heap, up to 4 GiB. The pool's slabs are kept once empty as the region's are: two empty slabs a class, and large buffers' own slabs cached up to a sixteenth of the guest's RAM, each for 2 s at most; a slab let go goes with its heap's destroy and then its block's give. No slab falls back to the region: where the kext refuses a take (the pool full, or no GPU address left) for the slab and for slabs half as large down to the buffer's size, the buffer is nil, as Metal's newBufferWithLength: is where memory runs out, and so is one past 4 GiB.
  • Where the host maps a process's own pages (PAGES_BUFFERS, and the kext's PagesBlock) and makes heaps over them (HEAP_OVER_PAGES), a heaped slab of 2 MiB is the process's own memory instead: the kext's chunks where it gives them (PagesChunked, below), else 2 MiB of plain pages (mach_vm_allocate, tagged VM_MEMORY_IOACCELERATOR), which the take asks for, wired into a pages block and made one HEAP_OVER_PAGES, its buffers placed in it as in a region slab's heap. The host makes the heap over the block's view, which it makes off ring 0 as a BUFFER_OVER_PAGES's, or over the run where the guest's RAM is mapped where the block is one run. Where the kext gives chunks, a class's slabs grow past 2 MiB, doubling, to 16 MiB, each one heap, and a buffer of up to 4 MiB lies in them, where past 1 MiB it would take a slab of its own: the host maps one view a slab and imports it once, and a device that lists every import in every submission (RADV, and ANV on i915) lists one a slab, whatever the buffers in it. Such a slab is 256 chunks at most, which one dma-buf holds at udmabuf's stock limits; a class's slab past 2 MiB is never plain pages. A larger dedicated Shared slab is plain pages too, with no heap: its one buffer is a BUFFER_OVER_PAGES over the block's view, or a Managed buffer's CPU copy. A larger Managed slab of a class of its own (no MANAGED_BUFFER_SLABS) is the region's, as is a slab where the kernel gives no pages or the kext gives no pages block. Why the process's own pages: in the region the guest's stores ran at 13 MB/s (Decided 5, "The guest maps host memory only"). A queue's upload chunks, the bytes set*Bytes: hands in, are buffers of the slabs too: Shared where the device answers hasUnifiedMemory YES, so the GPU reads them in place, and Managed where it answers NO, each commit naming each chunk's written bytes in the buffer's own stream (UPLOADS_WRITTEN, bit 53), or, on a host without the bit, in a BUFFER_DID_MODIFY_RANGE of each ahead of the command buffer, so the host copies them into the GPU's own memory before the buffer runs, as Metal's driver copies setBytes: data into its own memory on the AMD 5300M (guest/bundle/src/RgfxUploads.h). A slab let go destroys its heap, releases its pages block (the kext answers once the host let go of it, and unwires the pages), then deallocates its pages.
  • The kext's chunks first (selector 12, PagesChunked, where the kext's word holds PagesChunked): the kext takes the slab's bytes in physically contiguous chunks of 64 KiB, each at a multiple of 64 KiB of guest RAM (the physical mask 0x0000FFFFFFFF0000), zero-filled, maps them into the process in order and makes the pages block of their runs, so a 2 MiB slab is 32 runs of guest RAM at most, where plain pages are up to 512. Each run starts and ends at a multiple of 64 KiB. On RADV the host binds a buffer over a slab of several runs as a piece of one dma-buf of the runs of the host's view of those pages, which the view's other buffers share, one import on every submission's list: bound as pieces of the guest RAM's import in a sparse buffer, it cost a GPU page-table update of each piece at its bind and again at its release (crates/reims-vgpu-vulkan/src/os/linux/dma_buf.rs, "Several pieces" and "Views"). The host maps each run of a view apart, against a budget of mappings per process (vm.max_map_count on Linux, 65530 by default): on NVIDIA, views of scattered pages, slabs' among them, used it up, and the buffers made after were copies (docs/qemu.md). The memory is the block's: the slab's release takes it, the kext unmapping it from the process and freeing the chunks once the host has let go of the block, and the process unmaps nothing. A 64 KiB run is one the kernel finds at once however long the guest has run: on the guest and host the superpages below were measured on, 4,096 chunks in a row each took 0.033 ms, and 0.036 ms once 978 MiB of 4 KiB pages had been taken, the slowest 0.74 ms, none refused (chunks then at any multiple of 4 KiB). A slab the kext gives no chunks for is plain pages.
  • Plain pages, never superpages (VM_FLAGS_SUPERPAGE_SIZE_2MB, 2 MiB of RAM in one run): superpages run out, and asking for one stalls the process, on whatever thread asks. Measured on an x86-64 macOS 26.7.2 guest of 8 GiB on the Radeon 780M host, a process got 19 at boot with 2.5 GiB free, then KERN_NO_SPACE, and none three minutes later; each refused ask spent 140 to 190 ms in the kernel's search for a contiguous 2 MiB (vm_map_enter's superpage path, in cpm_allocate, which sleeps as it goes and moves pages to make a run), sampled with spindump. The search runs with the process's map held: in the public xnu-12377.101.15 source, vm_map_enter holds the map's interlock and the new entry locked exclusive across it, and a walk of the map past that entry (vm_map_region) waits for it. Sampled with tailspin on that guest: asked on the thread that takes the slab, WindowServer's main thread, making a texture over a layer's image as a window moved, was in cpm_allocate in two samples 100 ms apart, and Safari's page drew no frame for 151 ms; asked ahead on the slabs' background thread instead, the main thread, making such a texture as a window was resized, waited in mach_vm_region behind it, and the page drew no frame for 179 ms. Plain pages are what every slab took once superpages ran out, minutes after a boot.
  • Where no source has memory for a new slab, the process's own empty and cached slabs go first, then smaller slabs of the same source (the region's, or the pool's) are tried down to the buffer's size; nil only past that. Any other block of the process's the kext has no room for (a texture's CPU copy, a heap, an upload chunk, an IOSurface's block) is asked again once those slabs went (RgfxRegion::setReclaim).

The host makes an Automatic heap a Placement heap: the guest places what the heap makes itself, as Metal's Automatic heap places it (lowest free offset at the resource's alignment; guest/bundle/src/RgfxHeapRanges.hpp), a buffer at its length and a texture at the size HEAP_TEXTURE_SIZE_AND_ALIGN answers, and sends each as a placement at that offset. The heap's usedSize and maxAvailableSizeWithAlignment: answer from those placements.

The Shared pool. The device's Shared pool is a range of guest physical addresses past the guest's RAM with no RAM under it, which the host fills with its own memory a piece at a time as the guest's buffers need it (crates/reims-vgpu/src/pool.rs; QEMU reserves the range at realize, docs/qemu.md "The reims-graphics device"). The device offers it (POOL, feature bit 57) to an x86-64 or arm64 guest on a Linux or macOS host where it has a pool, and to an x86-64 guest on a Windows host too, and both kexts take it; what a pool block costs under WHP beside a region block is in docs/qemu.md, "Windows hosts: the Shared pool". A Windows host offers none to an arm64 guest, which runs under TCG there and was not measured: such a guest keeps the region's slabs and the process's own pages (kIOReturnUnsupported for selector 16). An arm64 guest's processes use their blocks write-back, as an x86-64 guest's do: the kext maps each into its process with kIOMapCopybackCache, and an unaligned access to memory left Device faults under TCG and on the hardware alike. arm64 boots ran on pool blocks with no fault: under TCG, macOS 26 and 14 with the range just past an 8 GiB guest's RAM, at 0x300000000 (m3-max-51507, m3-max-51493), and macOS 26 with it moved to 2^36 (m3-max-51364); under HVF on an M3 Max, macOS 27.0.1 at 0x300000000 (m3-max-51499), where each 256 MiB piece maps into the VM as RAM, 16 KiB aligned (hv_vm_map). Where the guest took the bit, POOL_BASE_LO to POOL_LENGTH_HI read the range, the same for the device's life, and the kext reads it once.

  • A take. A slab asks the kext for a block of the bytes it needs (selector 16, PoolTake): the kext posts its context's POOL_TAKE on ring 0 and waits for the answer, POOL_BLOCK. The host carves the block from a piece with room, first fit at a multiple of 64 KiB, on the thread that carries the take out, neither allocating nor zeroing there; the context's own worker (reims-vgpu.graphics-pool-take) zeroes the block through the host's mapping and answers. Where nothing fit, the worker first takes a block of the take's length from rt itself, so only that take waits for rt's allocation; the pool's thread places it ahead of the headroom's blocks and carves the take at its first byte, and the worker zeroes the take while the host maps the piece, answering once it is mapped. rt says nothing of a block's bytes as it hands it out, so bytes no block of the piece held before are zeroed too. Ahead of the takes, the pool's zeroer (reims-vgpu.graphics-pool-zero) zeroes, off every take's path, the bytes no block holds in each piece a block lies in and in the headroom's pieces (below), a new piece's from its place on, and a take over them leaves them as zeroed (pool-zeroed-ahead-bytes, pool-take-zero-skipped-prezeroed-bytes); a take over bytes it has not reached zeroes them itself. The zeroer claims 64 KiB at a time with the pool's lock held, writes it with the lock let go of, and marks it zeroed with the lock held again; a take whose first fit holds some of the claimed 64 KiB waits for its write (pool-take-claim-waits), so a block lies where it would with no zeroer. No other empty piece is zeroed: it goes back whole. The device's release waits for the zeroer and the take workers to let go of the pool. So a context's takes are answered in its order, and never wait behind another context's growth or zeroing, nor behind the headroom's blocks or the pieces going back. The host keeps 64 MiB of empty pieces ahead of the takes from the kext's take of POOL on (Host::pool_taken), each 16 MiB, metal2vulkan-runtime's unit, so a take grows the pool only where those pieces have no room for it, as a take longer than a unit does. The answer is the block's offset in the pool and its length, the bytes asked for rounded up to 64 KiB, every byte zero, or REFUSED where the pool has no room; where the guest took POOL_ADDRESSES (below), also its GPU address. The kext maps the block into the process, read and write and write-back, as a range of its own, and answers its address, offset and length, and its GPU address where the process asks for a fourth output. The bundle writes none of its zeros again; the slab's buffers are zeroed only where one reuses a range another freed in it. The take happens on the thread whose buffer found no room, and only then: nothing is taken ahead.
  • No deadline. The kext waits for a take's answer with no deadline, THREAD_UNINT, where its other asks behind the host's work wait with none interruptibly (How a waiter waits). A take ends at its answer, its context's close or the device's reset; the host gives back the block of a take whose context closed first and sends no answer. Where the host stops answering (the library stalled), each taking thread waits holding one of the kext's 16 waiters for the device's own asks, and a kill of its process completes only once the host answers; the process's other threads, and other processes, go on, their asks ending at their processes' kills. A paused VM runs no guest thread. The kext resets the device only at its start, before a process can open it, and at its stop, once every process closed it.
  • A heap. The bundle makes each block one Shared Placement heap, HEAP_OVER_POOL (an RgfxHeapOverHostMemory whose region_offset is the block's offset in the pool) at the block's GPU address where the host gave one, else at one it picks, and places the slab's buffers in it. The host makes it over the block's bytes in place, as HEAP_OVER_HOST_MEMORY makes one over a region block; a span outside the blocks the sender's context holds is a bad reference. The heap holds the block.
  • Its GPU address. The device offers POOL_ADDRESSES (feature bit 59) wherever it offers POOL, and both kexts take it (kext feature bit 1 << 16 PoolAddresses, PoolTake's fourth output). Where the guest took it, each POOL_BLOCK that answers OK carries the block's GPU address (RgfxPoolBlock.gpu_address, at byte 40 of 48; a kext that reads 40 bytes reads the rest of the answer as before), and the bundle, where its kext answers the fourth output, makes the block's heap there, picking no address of the context's and giving none back at the heap's destroy; its buffers lie at their offsets from it. On metal2vulkan-runtime's device the address is the block's Vulkan device address. On a platform whose blocks have none (the testkit's, whose blocks are the host's own memory), the host picks it in [2^45, 2^46), below the context's range, where the platform places none of its own ranges: next fit, each address holding the span a guest pick of the block's length holds (its pages and a guard page, on the 32 KiB granule), a freed one picked again only once the picks wrap (crates/reims-vgpu/src/pool/addresses.rs); the platform pins the heap there, as it pins the guest's picks. A take that finds no address left there is refused, as one that finds no room. A guest that did not take the bit reads 0 there and picks its heaps' addresses itself, as before.
  • A give. When a slab goes (2 s after its last buffer at most, "Empty slabs kept", below), the bundle destroys its heap and gives the block back (selector 17, PoolGive); every call into the kext first posts the destroys the control ring holds, so the heap's destroy goes first. The kext takes the block's mapping out of the process, then posts POOL_GIVE, after every message the process posted before. The host refuses it while an object lies in the block, and otherwise answers once every command buffer the host has begun for the context has finished, and only then does the block go back to the pool. A command buffer posted on a ring and not yet begun is not waited for. A context's close takes every mapping out of the process before its CONTEXT_CLOSE, which gives back every block the context still holds the same way. The device's reset frees every block at once.
  • What moves. Buffers' slabs: a class's and a large buffer's own, and so every buffer that lies in one, upload chunks and Managed buffers' copies among them; and a Shared heap, which an Apple GPU's device makes (an arm64 guest's), a block of its own of the heap's size rounded up to 64 KiB, made one HEAP_OVER_POOL of the heap's size, type and options. None of them falls back to the region: a buffer the pool has no block for is nil, as is a Shared heap, and an upload chunk none, which fails its command buffer as out of memory. The rings, command buffers' bodies, surface copy blocks, the scanout and the cursor stay in the region, and the ICB slots where they were (the kext's chunks, else the region).
  • Empty slabs kept. A class keeps two empty slabs of the pool, and large buffers' own slabs are cached, as the region's are ("Shared and Managed buffers lie in slabs", above), each for 2 s at most, the cache up to a sixteenth of the guest's RAM (the kext reads the pool's length, POOL_LENGTH, and tells the bundle nothing of it). A kept or cached block is its process's alone for those 2 s: a take that finds no block lets go of its own process's kept and cached slabs and asks again (above, "Where no source has memory for a new slab"), never another's, so where the pool is full (its range holds as many bytes as the host GPU's memory heaps, docs/qemu.md "The guest's Shared pool", and the host's memory backs it) another process's take may be refused for up to 2 s where it would have found a block. Without them, a process that makes a buffer and frees it again and again in an otherwise empty class takes a block, makes a heap over it and gives the block back for each buffer, and as each new slab doubles its class's next one, the block is 16 MiB for a buffer of a page, which the host zeroes as it gives it: the slab churn lines of an x86-64 guest on a Windows host counted one process making and letting go about 17 such slabs a second, none taken from again. On the Radeon 780M host (an x86-64 macOS guest's boot to its desktop, a window dragged for 31 s, and a GPU benchmark's run) the kept slabs were taken from again 5 times before the desktop and never in the drag or the benchmark. The bundle's churn line carries the pool's takes too: blocks taken and given back, takes refused, and how long the takes waited for the host.

Private blocks. Where the guest took PRIVATE_BLOCKS (feature bit 60), a context's Private objects lie in blocks of GPU addresses the host gives the context, rather than in the context's own range: its Private buffers (BUFFER_CREATE), its heaps that are not Shared (HEAP_CREATE) and its Managed buffers' GPU copies (MANAGED_BUFFER_CREATE, BUFFER_MANAGED_AT_OFFSET), but where it took MANAGED_AT_COPY ("Managed buffers at their copies", below). Every host offers the bit, and both kexts take it (kext feature bit 1 << 17 PrivateBlocks); the bundle uses blocks where its kext sets that bit and the device took the feature.

  • A take. Where no block the context holds has room for a pick, the bundle asks the kext for one (selector 18, PrivateTake): 16 MiB (kPrivateBlockBytes), metal2vulkan-runtime's allocation unit, which its block maker makes ahead of need, so the host answers it with no allocation of the driver's in the take. Where the pick's span and alignment are more, the block is the pick's own: their length rounded up to 64 KiB, holding that pick alone, which rt allocates in the take. The kext posts the context's PRIVATE_TAKE on ring 0 and waits for its answer, PRIVATE_BLOCK, with no deadline, as it waits for a pool take: the block's GPU address and its length, at least the bytes asked for rounded up to 64 KiB, or REFUSED where the host has no block for it. The kext maps nothing and keeps no list of blocks: the host holds each against the context. The take happens on the thread whose create found no room, and only then.
  • Picks. The bundle picks an object's address in its blocks as it picks one in its range: next fit through the blocks in address order, each pick holding its span on the 32 KiB granule (its pages and a guard page), a freed span picked again only once the picks wrap round. Free ranges never join across blocks, so no pick spans two of them, side by side as the host may give them. A heap's address lies at a multiple of 256 KiB from its block's first byte (kHeapAddressAlign), not from 0: on metal2vulkan-runtime the host binds a heap's texture at the heap's offset in the block's memory plus the texture's offset, and rt refuses a texture whose place there is off its image's alignment (counted as rt-refused-heap-texture-place). 256 KiB is the largest image alignment measured on the hosts' GPUs (a multisample target on an RX 7900 XTX; 64 KiB on a Radeon 780M and an Iris Xe), and the block's memory starts at a multiple of 2 MiB there, which its address need not be.
  • Refused. Where the host refuses a take, the bundle picks the object's address in the context's own range, as a guest that did not take the bit does, and logs the first refusal of the process.
  • A give. When a block's last object goes and the context holds another empty block, the bundle gives the block back (selector 22, PrivateGive); the one empty block left is kept for the next picks. A pick's own block goes back with its pick. Every call into the kext first posts the destroys the control ring holds, so the last object's destroy goes first. The kext posts PRIVATE_GIVE and returns. The host refuses it while an object it holds still lies in the block, answers NOT_FOUND for a block the context does not hold, and otherwise lets the block go once every command buffer the host has begun for the context has finished. A command buffer posted on a ring and not yet begun is not waited for. A context's CONTEXT_CLOSE lets go of every block it still holds, and the device's reset of every block.
  • Its addresses. On metal2vulkan-runtime's device a block is device memory no process maps, its address the memory's Vulkan device address, and the host answers the whole block it took. On a platform that gives no Private blocks (the testkit's), the host picks a block's addresses in [2^44, 2^45), below the Shared pool's and every context's range, where the platform places none of its own ranges: next fit, as it picks the pool's (crates/reims-vgpu/src/pool/addresses.rs, private_blocks.rs), with no memory behind them; the platform pins each object made there, as it pins the guest's picks. A buffer made in a block reads zero from its create, as one made in the context's range does.
  • What the guest sees. The gpuAddress of a Private buffer, a heap that is not Shared and the buffers in it, and a Managed buffer (but at its copy, below) lies in [2^44, 2^45) on the Vulkan platform, and wherever the host's device memory lies on metal2vulkan-runtime's, rather than in the context's range in [2^46, 2^47). Shared buffers, the pool's heaps and no-copy buffers keep theirs.

No-copy buffers. newBufferWithBytesNoCopy: over bytes in a block of the process's lies over them in place (BUFFER_OVER_HOST_MEMORY at their offset). Metal makes one over any range the process maps readable, at any alignment: malloc'd, vm_allocated, read-only, or a file mapping (measured on an M3 Max, 16 KiB and 4 KiB pages). Writable Shared or Managed memory the kext wires lies in place (PagesBlock, BUFFER_OVER_PAGES). A Managed one is a Managed buffer whose CPU copy is the Shared buffer over the pages (MANAGED_BUFFER_CREATE, as a slab's, above): two copies where the host's GPU has memory of its own, as the AMD Radeon Pro 5300M's no-copy Managed buffer is, its GPU copy filled from the pages at the create, and one copy, over the pages, where the GPU shares the CPU's memory, as the Intel UHD 630's is (dgpu-oracle.md Q3). Its didModifyRange:, and a blit's synchronize of it or of a texture over it, go to the host as any Managed buffer's do; Apple's OpenCL makes them around its maps of a buffer's memory. Shared memory the process maps read-only lies in place too, where the device took READ_ONLY_PAGES: the kext wires it for reading alone and marks its block read-only, and the buffer over it is made with MTLResourceOptions bit 24, sent to the host alone (the buffer's options answer the app's, as Metal's leave the bit out), whose GPU writes the host drops as Metal drops them: Metal makes a buffer over read-only memory whose GPU reads see the memory and whose blit fills and kernel stores complete with their writes dropped, a file mapped under it unchanged (the AMD 5300M and the Intel UHD 630, oracle_bundle nocopy.ro; the M3, accuracy-ledger.md read-only-pages-written, whose row the host's drop follows). A texture over such a buffer takes the same answers: a draw's, a kernel's or a blit's write of it completes, dropped, and so does a render pass that stores into it or resolves into it, its stores and resolves dropped with the buffer's other writes, as the 5300M and the UHD 630 complete one over pages the process maps read-only, the pages unchanged; the M3 fails its command buffer with a page fault (PageFault). The host counts such a pass, rt-copied-store-outs, the process's first with a line (accuracy-ledger.md read-only-pages-written, dgpu-oracle.md Q38). Over any other memory (read-only Managed memory, whose copies the host would write back to its pages; read-only memory where the kext makes no block of it; a Managed buffer's where the device makes no Managed buffer over a Shared one; or memory the kext or host makes no pages block of) the buffer lies over a range of a slab of its own options, as a device buffer of them does ("Shared and Managed buffers lie in slabs"): the process's own pages where the device takes them, so no app-sized copy lies in the region. contents stays the app's pointer. The range syncs with the memory as the IOSurface copies do (Decided 14): from the memory before the commit of each command buffer that uses the buffer, and back to it as one that may write it completes, before its completion is reported. Each side's bytes that moved since the two last agreed go to the other, byte by byte, so CPU and GPU writes beside each other both stand (guest/bundle/src/RgfxMemoryShadow.hpp). A GPU write shows in the memory at its command buffer's completion, not as it runs. Memory mapped read-only is never written back and keeps no agreed copy: the whole of it is written into the range before each commit that uses it, with no compare, so the GPU's writes to the range are dropped at the next such commit, as Metal's are dropped. The bundle counts the commits that sync each kind, the bytes and the time, and logs the process's totals at the info level within a minute of a change.

Unchanging pages. Read-only memory under a no-copy buffer is read from a copy where the host's GPU cannot import it as it is (the rt platform's copied module), so memory that provably cannot change is named so, and the host reads it once (UNCHANGING_PAGES). "Cannot change" is the guest OS's word, read once at the buffer's make, never a compare of the bytes. The bundle classifies the range (guest/bundle/src/RgfxFilePages.hpp) as a file's pages or as anonymous memory. A file's pages cannot change where:

  • it lies in one VM region mapped from a file: no submap, the region's object has a pager of its own, and proc_pidinfo's PROC_PIDREGIONPATHINFO names a vnode for it;
  • the mapping's maximum protection has no write, so the process can never write it, as no mprotect or vm_protect raises a protection past the maximum: a shared mapping of a file opened read-only, or a private copy-on-write one (share mode SM_COW) whose maximum protection was taken down (vm_protect with set_maximum), since mmap gives a private mapping write in its maximum;
  • every page the process sees there is the file's own: the region's object is the file's (mach_vm_region_recurse's shadow depth 0), or each page resolves to the file's object below the private objects over it (mach_vm_page_range_query, VM_PAGE_QUERY_PAGE_EXTERNAL on each page). xnu enters every private mapping of a file over a delayed copy object (vm_object_copy_strategically, the vnode pager's MEMORY_OBJECT_COPY_DELAY), so such a mapping's shadow depth is 1 from its make on;
  • and the file's volume is mounted read-only: the vnode's fsid, matched among getfsstat's volumes, has MNT_RDONLY. No path is opened or looked up: every Metal process loads the bundle, sandboxed ones among them, which log a refused file operation (guest/bundle/tests/bundle_files_check.sh).

Anonymous memory, in one region with no submap and no pager behind it (mach_vm_region_recurse's external_pager 0), cannot change where its maximum protection has no write and the kernel answers it SM_COW at shadow depth 0 (xnu's vm_map_region_walk, osfmk/vm/vm_map.c:16088-16098 of its main as read on 2026-11-20): a copy pending on the region's own object. Such a copy is vm_object_copy_quickly's of an object whose copy strategy is still symmetric (osfmk/vm/vm_object.c:3586-3605; the source's entry marked at vm_map.c:12727, 14046 and 18604), which leaves both sides' entries over the one object, each with its copy pending, and the object was not wired before it, as a wire makes its object's copy strategy a delayed one (vm_object_iopl_request, osfmk/vm/vm_pageout.c:8404-8423). The other side's write goes to a copy of its own: a write through an entry whose copy is pending shadows it first (vm_map_lookup_and_lock_object, vm_map.c:14866-14897), and so do a wire (vm_map_create_upl, vm_pageout.c:7140-7188) and a share of it (vm_map_remap_extract, vm_map.c:18314-18396). A share of the region takes no protection its maximum lacks (vm_map.c:18037-18058 and 18733-18734).

Anonymous memory is unchanging too where its maximum protection has no write, the kernel answers it SM_PRIVATE at shadow depth 0, and the region's object has one reference, the mapping's own, where the kext sets SoleHolderPages: a sole holder's, named kRgfxPagesSoleHolder. The share mode alone leaves the count in doubt, as the walk takes one from it while paging on the object is in progress (vm_map.c:16002-16005), so an object another mapping holds then reads private. mach_vm_page_info's VM_PAGE_INFO_BASIC answers the count as the kernel keeps it, read before the query takes a reference of its own, with the object's id, whose low 32 bits are the region's object id, and the depth it found the page at (vm_map_page_range_info_internal, at xnu-12377.121.6's osfmk/vm/vm_map.c:18686-18692 and 18802-18805). The ids must match: a process that asked for its regions' footprint (task_self_region_footprint) is answered a count of 1 at depth 0 for every page, with an id of none of its objects (that file's 18644-18676). With one reference no other mapping and no memory entry holds the object, and none made after takes a protection the maximum lacks, so nothing maps the pages for writing; a copy of them, mach_vm_remap's or VM_PROT_COPY's, writes pages of its own. What the count leaves out is a wire, which holds no reference (vm_object_iopl_request, vm_pageout.c:8331; upl_destroy, 5683-5685). A wire for writing is refused once the maximum protection has no write (vm_map_create_upl, at xnu-12377.121.6's osfmk/vm/vm_pageout.c:7659-7661, and vme_allows_upl_write, 7408-7415), but one taken while the memory was writable may write its pages still, under a count of one. The kext knows its own: it makes a sole holder's block only where, once its pages are wired, no writable block of its own in its table and no in-place surface block covers a page of them, and no block of writable memory is being made, and refuses it otherwise (kIOReturnNotPermitted; guest/kext/src/RgfxPagesBlock.hpp), and the bundle then asks for a read-only block, why RGFX_PAGES_WHY_REFUSED. A write another driver started before the app removed write for good, still landing after the make, is the clause's residual. The rules it rests on were read in the published kernel source of every release from macOS 11.0.1 to 26.5 (xnu-7195.50.7.100.1 to xnu-12377.121.6); later releases are checked by test: guest/bundle/tools/sole_holder_probe.c, which the lane gate's guest checks (its info phase) and Ambrosia's check-boot.sh run at each boot, reads the count as 2 with a second holder and 1 once it goes, and sees the kext's writable wire of memory with no write in its maximum protection refused.

Every other share mode is neither, why not a file, and so is memory whose maximum protection has write. At a shadow depth of 1 or more another mapping may share the region's top object with write, and SM_PRIVATE leaves in doubt that no one else writes the object's pages where the kext does not set SoleHolderPages or the count is more than one.

The block is of the app's own memory, as every pages block is, named kRgfxPagesUnchanging (and kRgfxPagesCopyOnWrite). The kext wires it for reading as any read-only block and marks its SURFACE_PAGES RGFX_SURFACE_PAGES_UNCHANGING (and _COPY_ON_WRITE). A shared mapping's wired pages are the file's own. A private mapping's entry still needs its copy, and the wire makes it: vm_map_create_upl resolves the entry's copy and vm_object_iopl_request faults each page into the process's own object, so the wired pages are the process's copy of the file's bytes, as a Mac's driver's wire of an app's memory makes it (read from xnu's osfmk/vm/vm_pageout.c, which holds both). Anonymous memory's wire takes the region's pending copy the same way (vm_pageout.c:7140-7188) and faults each page into the region's own new object (vm_pageout.c:8584-8592), which no one else holds. A sole holder's wire takes its object's own pages, as only the mapping holds the object. The process can write none of them. Where the kext refuses the block, the bundle asks again for a read-only block, why RGFX_PAGES_WHY_REFUSED.

Where the host's GPU cannot import the pages as they are, the rt platform copies an unchanging block's pages into its copy once, as the view is made, and never compares them: it writes the whole copy again from the pages only at the completion of a command buffer that can write it, which drops the GPU's writes (crates/reims-vgpu-vulkan/src/rt_platform/copied.rs). A copy of any other read-only block has no base either: the whole of its pages is written into it at each commit that uses it, with no compare, which drops the GPU's writes there.

Memory that is neither takes a read-only block, as before, with why not in PagesBlock's third input from bit 8 (kRgfxPagesWhyShift), which the kext carries on in the block's flags' bits 8 to 11 (RGFX_SURFACE_PAGES_WHY_SHIFT): not a file or unchanging anonymous memory (1), spans regions (2), a shared mapping with write in its maximum protection (3, writable mapping), a private one with write in its maximum protection (4, writable max protection), a page not the file's (5, shadowed), a writable volume (6), a call that failed (7), and the kext's refusal of the unchanging block (8). The host takes any value and only counts by it: the read-only blocks that are not unchanging, with their bytes and page runs, in the views' summary line, and the textures made over them (read-only-pages-textures-why-N in the degradation counts), each pixel format, size and why logged once with the bytes and page runs of its range.

The bundle counts its classifications (makes, bytes by clause and by why for memory that is neither, the time the classification took, and blocks the kext refused) and logs the process's totals at the info level within a minute of a change.

Import addresses. Where the guest took IMPORT_ADDRESSES (feature bit 61), a no-copy buffer over a pages block lies at the GPU address the host gives the block's view, rather than at a pick in the context's range. Every host offers the bit, and both kexts take it (kext feature bit 1 << 18 ImportAddresses); the bundle uses it where its kext sets that bit and the device took the feature.

  • The answer. Where the guest took the bit, the host answers a pages block's SURFACE_PAGES with an RgfxPagesAnswer: the COMPLETE's 24 bytes, then the GPU address of the block's view at byte 24 of 32, 0 where it gives none. A kext that reads 24 bytes reads the answer as before. The kext returns the address as PagesBlock's third output where the bundle asks for three outputs, and 0 where the answer was not OK or carried none. The blocks of the kext's own chunks (PagesChunked) are given none.
  • Where buffers lie. The bundle makes each BUFFER_OVER_PAGES over such a block at the view's address plus the buffer's offset in the view (its pointer's offset in its first page). It picks no address in the context's range for it and gives none back at its destroy. A no-copy buffer over the same bytes as a live one joins its block, and so lies at the same address. A Managed no-copy buffer's CPU copy, the Shared buffer over the pages, lies there; the Managed buffer's own address is its GPU copy's, as before, or its CPU copy's where the guest took MANAGED_AT_COPY. Where the address is 0, the bundle picks one in the context's range, as a guest that did not take the bit does. Slabs over the process's own pages keep their picks.
  • Its address. On metal2vulkan-runtime's device the address is the Vulkan device address of the import of the block's pages. On the Vulkan platform before it, the host picks it in [2^43, 2^44), below the Private blocks' range, where the platform places none of its own ranges: next fit, as it picks the pool's (crates/reims-vgpu/src/pool/addresses.rs), at the block's first answer that asks for one, and held until the block goes. The first buffer made there is pinned there, as a buffer at the guest's own pick is, and the block keeps it until the block goes. A buffer over the same bytes made after it is made where the platform places it, and the guest's pointers to it reach the same pages through the first. A block of memory the process maps read-only is given no address there: each buffer over it lies over a copy of its own. On metal2vulkan-runtime's device it is given its import's address as any block is, and its buffers lie in the import, where a GPU write through one reaches the pages (Metal drops it).
  • What the guest sees. The gpuAddress of a no-copy Shared buffer over writable memory the kext wires lies in [2^43, 2^44) on the Vulkan platform, and at its pages' import on metal2vulkan-runtime's, rather than in the context's range in [2^46, 2^47). Two no-copy buffers over the same bytes answer the same gpuAddress, where each had a pick of its own before. Buffers over read-only memory (on the Vulkan platform), over memory the bundle copies, and Managed ones keep theirs.
  • Addresses given later. Where the guest also took IMPORT_ADDRESSES_LATER (feature bit 9), the host answers a pages block's SURFACE_PAGES once it has checked and kept the block's runs, with the address 0, and then makes the view and gives it its address on the same surface-worker job, before the block settles. On metal2vulkan-runtime's device that is the import of the block's pages, which the guest's no-copy call then no longer waits for. The sender's later messages that name the block (its BUFFER_OVER_PAGES, and the textures and command buffers over those buffers) wait for the block to settle on the host's side, as they wait for its view elsewhere. The bundle makes each BUFFER_OVER_PAGES over such a block at gpu_address 0, which the host places at the view's address plus the buffer's offset, where it would lie had the answer carried the address: what gpuAddress answers is unchanged. The bundle learns the address only where the process asks for it, with PAGES_BUFFER_ADDRESS (ring 0, 0x23d), answered by an RgfxPagesAnswer once the buffer is made. A host offers the bit only where its platform imports the views as blocks it knows (ViewImports), so the Vulkan platform's guests see IMPORT_ADDRESSES alone, as before.

Every surface cached. Where the guest took SURFACE_CACHE_EVERY (feature bit 62), the host's GPU form of every IOSurface is its device cache: it keeps one for every block in place named cached, lays no texture over a surface's pages, and refuses a block in place named uncached. A host offers it where its platform caches every surface (metal2vulkan-runtime's per-shape form) and it offers POOL; both kexts take it, read with SURFACE_CACHE. A surface's copy block is then a second copy beside the device cache its other holders use, so the guest keeps it only as the fallback, counted by why.

  • The kext. A block in place is cached or not made. An ask in place that names no surface, or asks no cache (the bundle's video outputs where the host lands no picture in one), is refused before anything is posted (uncacheable); one whose IOSurface device cache the kext cannot make, or whose deferral comes back uncached, goes back as if never made, nothing posted (no device cache). The kext asks the device nothing (RGFX_SURFACE_PAGES_ASK_CACHE is not sent). Its tables grow rather than refuse: a block's holders past 16 into an array of its own, doubled each time; the table of the surfaces' blocks by chunks of 512 entries, up to 32, which never move, before a dormant block gives its entry; and the table of the cached surfaces into a larger array. It counts the asks in place it refuses by why, and the copy blocks made and held again, logging the first of each, with all of them and the growths on a line beside the dormancy line ("every surface cached").
  • The bundle. A view not in place is still a copy, made as before, never nil: counted by why (RgfxSurfaceCopyReason) in the minute's surface copies line. The reasons are alignment; unsupported, where the device uses no surface in place; refused by the kext; no room in the kext; asked uncached where every surface is cached, the kext's uncacheable; and refused by the device, which refused the surface's pages. The kext answers the last three alike, and the bundle tells them apart by the ask and by the device's SURFACE_PAGES and SURFACE_CACHE_EVERY. The line is logged at the default level where a copy was made in that minute, and the first of each reason logged at the default level with the surface's format and shape (rgfxIOSurfaceSetCacheEvery). A plane goes in place where its offset and rows are multiples of 16 bytes rather than of the host's linear texture alignment: the host's textures over it are views of images it fills from the plane's place and pitch in the cache and writes back there, by copies that address them in texels of the view's format, and 16 bytes is the largest texel of a format of texels (kShapeCopyAlign).
  • What the guest sees. No Metal answer changes: a texture over a surface is in place or over a copy, as before. A process's surface whose block the kext refused uncacheable or uncached is a copy where it lay in place uncached before; on the host that offers the bit, the host refused such a block's pages all the same. A surface whose planes lie at multiples of 16 bytes but not of the host's alignment is in place where it was a copy.
  • The host. A block in place named cached whose pages the host makes no view of, or no buffer over (on metal2vulkan-runtime, whose platform holds no lease of the guest's RAM to map views by, every block), still takes its device cache, answered OK: each fill and download of the cache goes through a Shared buffer of its own that the host's CPU fills from the pages, or empties into them once the GPU's copy is done, through its mapping of the guest's RAM, as a deferred block's copied pages do. It was refused, and the kext gave the surface a copy block, whose textures the host lays over no shape. The host counts it (rt-surface-pages-copied) and logs the first. Runs that are not the surface's bytes in whole guest pages, or that the host maps no part of, are refused as before.

Managed buffers at their copies. Where the guest took MANAGED_AT_COPY (feature bit 63), a Managed buffer's gpuAddress is its CPU copy's: on a GPU that shares the CPU's memory a Managed buffer is its bytes, one copy, so the address the guest's pointers hold is the address of those bytes. A host offers it where its GPU shares the CPU's memory, its platform keeps a pin only inside a block it knows (metal2vulkan-runtime's), and it offers the Shared pool, whose blocks the slabs' copies lie in; both kexts take it (it is carried, with no kext feature bit of its own), and the bundle reads it from the device's features.

  • The bundle. A MANAGED_BUFFER_CREATE (a slab's Managed buffer over its Shared copy, and a Managed no-copy buffer over its Shared buffer over the pages) carries the CPU copy's address as its gpu_address, the copy's first byte as the copy's create gave it, and the buffer answers that gpuAddress. The bundle takes no Private block pick and no pick in the context's range for it, and gives none back at its destroy: the copy's own address goes back with the copy, as before. BUFFER_MANAGED_AT_OFFSET is not offered on such a GPU, and stays as it is.
  • The host. The platform makes the buffer at that address, a range of the known Shared block its CPU copy lies in: a pool block's, or a pages block's view's import. Where it does not make the buffer at the guest's address (a copy in no block the platform knows, a pin that is not the copy's bytes), the host keeps the buffer where the platform made it, as the same create makes it from a guest that did not take the bit: Metal makes the buffer, so the create is not refused, and the guest's pointers to it hold the address it posted. Each is counted as managed-at-copy-unkept, the first logged. A guest that did not take the bit is answered as before.
  • Why not on the Vulkan platform. There the guest's own pick of a Managed buffer's address is pinned, as every pin is, and a pin inside the range the CPU copy holds would be refused. On a GPU of its own memory a Managed buffer is two copies, and its address its GPU copy's, in a Private block, as before. With no pool the slabs' copies lie in heaps over the region, in no block the platform knows.
  • What the guest sees. A Managed buffer's gpuAddress equals its CPU copy's: the pool block's address plus the copy's offset, or the pages block's view's import's address plus the pointer's offset in its page, where it lay in a Private block before, at an address the platform did not keep. An argument buffer or a set*Bytes word holding it reaches the buffer's bytes.

A buffer's escaped identity. The host reads a no-copy buffer's bytes in place: one over bytes in a block of the process's (BUFFER_OVER_HOST_MEMORY), or over pages the process maps, writable or read-only (BUFFER_OVER_PAGES), Managed neither. A slab's buffer made by the same messages with an address of its own (a Shared buffer past 2 MiB over a slab of the process's own pages, a device buffer or a no-copy buffer's shadow) is one too, since the host cannot tell it apart; one placed in a slab's heap (BUFFER_AT_OFFSET) is not. Where the device took BUFFER_ESCAPED, the bundle posts RGFX_CMD_BUFFER_ESCAPED (the buffer's id and the act) the first time in the buffer's life that its identity leaves the guest's Metal with no message naming the buffer:

  • the app reads its gpuAddress;
  • an argument encoder's setBuffer: or setBuffers: writes it, or setTexture: or setTextures: writes a texture over it;
  • the app reads the gpuResourceID of a texture or view over it (gpuHandle and resourceIndex answer through it);
  • the buffer, or such a texture, joins a residency set.

A texture's or view's act names the buffer. From then on the GPU may reach the buffer through memory alone, and the host takes it as named for its life (decode::escape). The note is unwaited and changes nothing the guest observes: the host marks the buffer and counts the escape by its act in the degradation counts (buffer-escaped-*, beside no-copy-buffers, the no-copy buffers made), and a host that records its platform's calls (REIMS_VGPU_RECORD, docs/api.md) writes it into the stream as m2v.bufferEscaped on the buffer, for a replay player's typed stop.

The note goes ahead of any command buffer that could use the identity:

  • the bundle marks the buffer as it makes it, and each act reads the mark with one relaxed load, all an act costs after the first;
  • the first act takes the buffer's lock, which no post path takes, posts the note on ring 0 (or holds it to go before the next commit's messages, where the bundle batches them), and clears the mark with a release store. A concurrent act waits on the lock, and a texture's mark clears only after its buffer's note has gone;
  • a command buffer's commit begins with an acquire fence, which pairs with that release store where the committing thread's act found the mark clear, so the note is on ring 0, or held, before the command buffer is published; the post of a command buffer sends the held messages first;
  • the host carries out a command buffer only after every ring-0 message its process published before its queue's thread took it.

A note the ring refuses leaves the mark set, so the buffer's next act posts it, and is logged once. What the order cannot cover is a command buffer committed before the act that reads memory the act writes: the app racing its own GPU work. An identity handed between the app's threads through the app's own synchronisation keeps the order through it.

An escaped buffer over pages the process maps read-only lies over a copy of its pages on Linux and Windows, and the GPU may then read the copy through memory, with no binding naming it, after the CPU changed the pages. Metal requires such a reach to be made resident by the encoder (useResource:usage:), which names the buffer as a use, and the Vulkan platform's runtime brings every copy a command buffer's uses name up to date at its commit, and every copy where its work may reach memory no use names. So the host adds nothing to the commit: it keeps each process's count of its live escaped copies and counts each command buffer begun of a process that holds one (escaped-copy-commits). A test holds the runtime's copy in: a kernel that reads such a copy only through its address, made resident, reads the CPU's new bytes.

Each pages block's view is one import. The host imports each pages block's view once, as a buffer over the whole view that the block's BUFFER_OVER_PAGES buffers lie in. On metal2vulkan-runtime's device, where the guest took IMPORT_ADDRESSES, that import is made at the block's SURFACE_PAGES, before its answer ("Import addresses"); else at the block's first message that needs it. On RADV the import is one dma-buf a view, or several where its pages pass udmabuf's limits (the Vulkan crate's rt_platform/buffer.rs, "Dma-bufs of the pages"), and the driver lists every import in every submission, so each live view is one more buffer object every vkQueueSubmit lists, at about 0.5 us each. Measured on the Radeon 780M (Geekbench 7.1 Metal in a macOS 26.7.2 guest, 2026-11-14), and again at 0.49 to 0.50 us an import by metal2vulkan's own control on 2026-11-22: at Super Resolution's midpoint about 580 such imports were live, under about 1,573 no-copy objects, of the 945 buffer objects the process held (about 605 of them the runtime's own memory), and a submission took about 494 us.

Managed storage (Decided 4). A Managed buffer's or texture's CPU copy is memory of its process's, which the guest maps: a buffer's a Shared buffer of the slabs where the device takes RGFX_FEATURE_MANAGED_BUFFER_SLABS, else a range of a slab ("Shared and Managed buffers lie in slabs") or a region block; a texture's a Shared buffer of the slabs where the device takes RGFX_FEATURE_MANAGED_TEXTURE_SLABS, else a region block. The slabs are the process's own pages where the device takes them, so no app-sized copy lies in the region.

  • A buffer, on any host: a no-copy Managed buffer over its CPU copy's bytes at the guest's address, whose copies the platform keeps as Metal does. Where the GPU shares the CPU's memory that is one copy. Otherwise the Vulkan platform's runtime keeps a GPU copy in the GPU's memory, with the guest's bytes its CPU copy: copied in whole at the create, a range at each didModifyRange: before the next submission, and out whole at each synchronizeResource: where the blit encoder runs it. The bytes a MANAGED_BUFFER_CREATE says read zero (its RgfxManagedBufferZero, from zero_from to the length) are not copied in: the GPU writes zeros there in its own memory, so a buffer made with no bytes moves nothing over the GPU's link at its create, as a Mac's GPU copy of one starts as zeros. A guest write there reaches the GPU copy by a didModifyRange:, as Metal's does; a create without the tail, an older guest's, is copied in whole. Where the GPU's memory has no room for that copy, the buffer lies in its bytes, as a Shared one does, which the runtime announces. BUFFER_DID_MODIFY_RANGE is the platform's didModifyRange: of the range, and a blit's synchronize of the buffer the platform's own.
  • A texture takes its form from the platform's answer of whether the GPU shares the CPU's memory:
    • Shared memory: one copy. A one-level 2D texture or 2D array of a linear format is a texture over its block's Shared buffer (an array by the linear SPI, whose slices lie as the layout's); the range messages are checked and do nothing more. A texture of any other shape (more levels, a cube, a 3D texture, a block-compressed format) is two copies, as below: no texture over a buffer has its shape, and without the CPU copy an upload would be a staging blit the call waits for, hundreds of times a Managed one's (dgpu-oracle.md Q17). The guest's getBytes: of it reads its GPU copy, copied on the device: on a GPU that shares the CPU's memory Metal's CPU reads of a Managed texture see the GPU's writes with no synchronize (the Intel UHD 630 and the M3, dgpu-oracle.md Q2).
    • Otherwise: two copies. The object the command buffers name is the platform's own Managed texture, and the block sits beside it as a Shared buffer. TEXTURE_REPLACE_REGION is the platform's replaceRegion: from the block, done before the call returns, and a blit encoder's synchronizeResource: and synchronizeTexture: become copies of the GPU's copy into the block at that point of the encoder.
  • Ring 0 is carried out before any later command buffer of the process, on any queue, so a range message is ordered before every command buffer committed after it, as Metal promises.
  • Where the platform refuses a buffer, or a texture's GPU copy, the create is refused, as Metal's answers nil. Metal makes Managed resources past a discrete GPU's memory (measured on the AMD 5300M: 12 GiB of Managed buffers, three times its 4 GiB, made, used by one command buffer and read back as written), and the platform does too (the Vulkan platform's runtime places a texture in system memory past a full device-local heap, and lays a buffer in its bytes), so it refuses one only where that memory is gone as well.
  • A buffer comes from BUFFER_OVER_HOST_MEMORY with Managed options; a texture from MANAGED_TEXTURE_CREATE, which names the copy's Shared buffer and the texel block of its format (bytes, width, height). The host reads the copy where the buffer's contents lie: its block, its heap's bytes at its offset (over a block or over a pages block's guest RAM), or a pages block's view. Both sides compute the copy's linear layout from it (crates/reims-vgpu-graphics/src/managed.rs, guest/bundle/src/RgfxManagedLayout.hpp): levels in order, then slices, images and rows of blocks, each row rounded up to 256 bytes.
  • In the guest, replaceRegion: and getBytes: are memcpys of the block, and replaceRegion: posts its region; neither waits for the host, but for the getBytes: of a two-copy texture on shared memory, above. A format the layout has no block for (PVRTC) keeps no CPU copy: the texture is the platform's alone, one copy on any GPU, and the CPU reaches it through the staging blit a Shared texture's calls wait for, which sees the GPU's writes with no synchronize, as the Intel 630's and the M3's Managed textures do (dgpu-oracle.md Q2). A depth or stencil texture in Managed storage ends the process first, as on both x86 oracles.
  • Until the device's identity answers carry hasUnifiedMemory, the host takes a texture's two copies on every GPU, which hold Metal's contract on any of them.

Command buffers (per-queue submission ring). A COMMAND_BUFFER message is one command buffer: its ObjId, then a byte stream of encoder ops. The decoder opens the Platform command buffer and walks the ops:

  • ENCODER_BEGIN_RENDER (our render-pass schema: colour/depth/stencil attachments by texture ObjId, load/store actions, clears), ENCODER_BEGIN_BLIT, ENCODER_BEGIN_COMPUTE; ENCODER_END.
  • one op per Platform encoder method — set pipeline/buffer/texture/sampler/ bytes, viewport, scissor, draw / draw-indexed / dispatch, copy/blit, update/ wait fence, useResource/useHeap. The op set is the trait's encoder methods; the first slice is the subset WindowServer and simple Metal apps issue.
  • SIGNAL_EVENT / WAIT_EVENT (event ObjId, value), between encoders, as Metal's encodeSignalEvent:value: and encodeWaitForEvent:value: are → encode_signal / encode_wait, for an MTLEvent and an MTLSharedEvent alike (an event op with an encoder open, or naming no event, faults the buffer). The end of the message closes it: the host commits and registers an add_completed_handler that writes the completion record.
  • SURFACE_USE (block offset, the kext's count of the surface's read-write locks, whether the buffer may write it, and, where the guest took SURFACE_REFILL, whether a CPU wrote the pages after the lock that moved the count: RGFX_SURFACE_USE_REFILL), one for each IOSurface with a device cache the buffer uses, before its first encoder: the host fills the cache before the buffer's work where it holds an older count, or the refill asks it at the count it holds (Decided 14, "The device cache"). One naming a block with no cache does nothing.
  • SUBMITTED (no body), where the device has CB_SUBMITTED: the buffer is committed by commitAndWaitUntilSubmitted, or by a queue one of whose buffers has presented a drawable ("Present hold", below), and asks for its CB_SUBMITTED ("Submitted", below). The bundle puts it last, as it commits; the host reads it as it takes the buffer, before its other ops.
  • GUEST_TIMES (made, committed and posted, each the guest's clock), where the guest took GUEST_TIMES: first in the stream, once, a diagnostic the host reads as it takes the buffer ("Guest times", below). The walk steps past it.

A command buffer too large for half its queue's submission ring goes out of line: the whole COMMAND_BUFFER message lies in a block of the process's own, from its queue's pool, and the ring carries a COMMAND_BUFFER_IN_REGION (region offset and length).

  • The bundle builds the message on its own heap, write-back memory, whatever its size. When it outgrows half the ring, its buffer grows at once to the queue's recent largest message, and doubles after that.
  • The header and the commit's SURFACE_USE ops go into room kept before the ops, so they move nothing.
  • At the commit, the whole message is copied once into a block of the pool, from the block's start. It is not built there: the block is write-combined where the kext maps it so, and on an AMD host, which applies the guest's memory type, a write-combined store still pending stalls the encoding thread's next locked instruction (an app's retain or release among them) by about 90 ns (RgfxEncoder.hpp).

The queue's service thread copies the message out of the block once, as it does a ring's, with the reference's seqno, and the host walks and commits the buffer from that copy, on its lane, copying it no more. It does not read the block in place: the process may write its block at any time, and what the host checked must stay what it carries out (the region's rule, region.rs). The bundle gives the block back to the queue's pool when the buffer completes. The pool keeps every block given back and reuses the smallest that holds the next message, so of each size a queue makes blocks only up to the most of its buffers in flight at once, and a stream of large buffers asks the kext for none past them, where handing a block back at each completion beyond a few kept cost a later buffer a block allocation, a mapping into the process and a grant and release on the control ring. Measured on an RTX 5080 host, an out-of-line buffer costs what an inline one does, about 2.1 to 2.5 us a dispatch, up to 2000 in flight either way. Encoders do not stream as they end yet (Decided 3): that needs a command buffer in several messages, which the wire does not have. The whole buffer goes at its commit. Metal sets no maximum size, so nothing is refused for size. A queue holds maxCommandBufferCount buffers (64 by default) alive and not completed. -commandBuffer blocks past that, as Metal's does, which keeps the ring from filling in the common case. A commit that still finds the ring full rings the doorbell and, where the device's word holds SUBMIT_ROOM, sets the ring's producer_waiting, looks once more, and waits for the host's SUBMIT_ROOM record on the queue's completion ring, which the queue's reader hands to the ring's writer, with a 20 ms backstop. Without the bit it sleeps 20 µs, doubling to 1 ms, between looks. Each buffer's completion is expected before the host can see it, under the ring's lock.

Metal splits one command buffer into several kernel submissions (a render pass; a run of blits or of computes with no event between) — m2v's measured granularity. The host preserves it so IOGPU error reporting lines up.

Completion (per-queue completion ring). A CB_COMPLETE record: the command-buffer ObjId, status, GPU start/end time, and on error the CommandBufferError the host maps 1:1 from the IOGPU code the runtime returns (page fault, hang/timeout, recovery victim, access revoked, invalid resource — the map m2v gave). The guest takes the GPU times as the run's length alone, the device's clock being the host's: the bundle answers GPUEndTime with the guest's own clock as it takes the record, and GPUStartTime with the record's end less its start before that, no earlier than the buffer's post (rgfxNoteGPUTimes:, held by test_reply_reader_completion); a buffer with no times (a failed one) starts as it ends. A buffer committed in parts sends its first part's start and its parts' GPU time summed, so its record's end can fall before its last part's end ("A command buffer in parts"). The host places the platform's GPU times on the device's clock as it writes the record (reims-vgpu-graphics's clock::runtime), both by one paired read of the two clocks, so the run's length stays the GPU's: unchanged while the platform counts the device's clock, as metal2vulkan's runtime does on Linux and Windows. The ring's armed/interrupt handshake is the stage-2 one. The buffer's completion-seen handler posts it, with the values of the shared events it signalled ahead of it: on metal2vulkan the runtime's thread that saw the buffer complete runs it, in its queue's commit order, and with no completed handler on the buffer no handler thread is woken; on Metal, which tells of a completion only on its completed handlers' thread, a completed handler. Where a queue's completion ring has no room, the host counts each spell of it (queue-ring-full) and each post onto it that waited for room (queue-ring-post-waited) in its degradation counts, and logs the first of each kind, naming the thread that waited. No handler of the buffer's waits for room: the platform's thread that runs one holds up every queue's completions or submissions behind it. A record the ring has room for, with no record handed over before it, is posted on the handler's thread; any other is handed to the queue's service thread, which posts the records in the order handed, waiting for room, and runs what follows each right after it: a value's posts to the other holders of the event's name, the shows of the presents waiting for the buffer, and the answers waiting for its context's drain. So the guest sees them in the order it would had the handler waited, and every later post onto the ring goes behind them.

Scheduled (per-queue completion ring). A CB_SCHEDULED record (the command-buffer ObjId, at the buffer's seqno; 24 bytes, and the guest reads a record of at least that size) goes on the queue's completion ring once, ahead of its CB_COMPLETE. A buffer that gets its CB_SUBMITTED at its take (it asks for one and waits for nothing, below) gets it there too, right after its CB_SUBMITTED, where no buffer begun before it on its queue owes its own, so a queue's records keep their order; one answered on its doorbell's thread gets it there, with its CB_SUBMITTED, where the same holds there. A buffer that does not ask keeps it to its scheduling, or to a waiting thread's ask ("Scheduled at an ask", below): posted at its take, it would need the buffer's ticket in its process's commit order there, as the CB_SUBMITTED does, and a walk held on one of the process's queues would then hold up the commits of its others (a_walk_held_in_a_draw_holds_up_no_other_queue). Metal makes such a buffer Scheduled within a fraction of a millisecond of its commit, whatever its queue runs on the GPU before it (below); waiting for the platform's submission instead put the scheduled handler of a tiny buffer on an idle queue 0.39 ms after the commit on the RTX 5080 host (car 12, submit_probe), against 0.20 ms on an AMD 5300M Mac and 0.05 ms on Apple's paravirtualized device. Such a buffer gets no submission handler where it holds nothing. Any other buffer gets it at its commit, behind an order on the GPU ("Surface order", below), or once the host's platform has taken the buffer's work for the GPU: the buffer's submission handler posts it. On metal2vulkan it runs on the thread that took the buffer's last batch for its VkQueue, once every wait of the buffer is satisfied, before the buffer reads Scheduled, and nothing committed later on the queue runs before the buffer. That thread may be any that commits, since the runtime takes the ready batches inside a commit (commit_and_submit): where it is not one the header names for the device's raise (the window's render thread, a paravirtualized device's, the host's inside rvg_graphics_device_read_display), the handler hands the buffer's records to its queue's service thread, which posts them and raises, and every later post onto that ring goes after them (a_foreign_commit_hands_a_decoder_buffer_s_records_to_its_queue_s_thread); on Metal, which tells of no point before scheduling, it is a scheduled handler, run once every wait of the buffer is satisfied and its work is submitted. A buffer the platform fails before it takes its work runs no submission handler, and its completion handler posts its CB_SCHEDULED first (a_buffer_never_submitted_is_scheduled_ahead_of_its_completion). The guest's buffer is then submitted (commitAndWaitUntilSubmitted returns, before the scheduled handlers run), becomes Scheduled, runs its scheduled handlers, then lets waitUntilScheduled return, as Metal's does (measured on the M3 Max, macOS 27: on an idle queue commitAndWaitUntilSubmitted returns in 0.05-0.1 ms with the buffer Committed and its scheduled handler about 10 us from running; behind a 120 ms buffer it and waitUntilScheduled return in 0.1 ms, Scheduled; a buffer that waits for an event nothing has signalled is neither submitted nor scheduled until the event is signalled, or Metal's timeout fails it after 5 s). A CPU lock of a surface the buffer writes waits for the GPU's writes from the commit on (§14, "CPU locks"), so a reader handed the surface at submission reads the GPU's results. A buffer the host could not carry out has no CB_SCHEDULED, and its CB_COMPLETE stands for both; so does every CB_COMPLETE from a host that posts none.

Scheduled at an ask. A thread that waits for a buffer that does not ask for its CB_SUBMITTED to be scheduled (waitUntilScheduled) asks for it, where the device's word holds SCHEDULED_ASK: the bundle posts SCHEDULED_ASK (RgfxScheduledAsk, the buffer's ObjId and the seqno of its message; 32 bytes) on the buffer's queue's ring, after the buffer's message, once, unless the buffer is held as far as the process knows or is scheduled already. The queue's service thread takes the ask after its begin of the buffer. Where the buffer would have got its CB_SCHEDULED at its take had it asked for its CB_SUBMITTED (it waits for no event, follows no deferred copy of a device cache, is behind no buffer of its queue that waits for one, and found no buffer before it on its queue owing its CB_SCHEDULED), the host issues the buffer's ticket in the commit order, given back at its commit, and posts the record then, whether or not the walk is done; for a buffer already committed, the record goes at once with no ticket. Any other ask changes nothing. So a walk held on one of a process's queues holds up the commits of its other queues only for buffers sent once a thread has asked to wait for it, as after a CB_SUBMITTED at its take (a_held_walk_holds_up_its_process_s_other_queues_only_once_waited_for). Without the ask, during a window's live resize on a 780M host (macOS 26.7.2, 11-09), the guest's GPU process waited in waitUntilScheduled 349 times for 291.5 ms over 50 s, 288 ms of it before the host posted the buffer's record at the platform's submission, 1.3 to 1.5 ms after the buffer's begin on average; 192 of the waits, 205 ms, came in the busiest second. The ask is posted for blocking waits alone: a scheduled handler, which no thread waits on, runs at the buffer's scheduling.

Submitted (per-queue completion ring), where the device has CB_SUBMITTED (FEATURES_LO bit 2; every host sets it). A command buffer committed by commitAndWaitUntilSubmitted carries a SUBMITTED op, and the host posts its CB_SUBMITTED record (the command-buffer ObjId, at the buffer's seqno; 24 bytes) once, ahead of its CB_SCHEDULED and CB_COMPLETE: as soon as the host takes it, before it walks the buffer's ops and before the fills of device caches it makes at the take, where the buffer waits for no event (its WAIT_EVENT ops), it follows no copy of a device cache asked before it and not yet made, nor needs a fill of one that must wait for buffers begun before it (decided at the take from its SURFACE_USE ops, which lead the stream; "What a walk sees", "Device caches"), and no buffer before it on its queue waits for one and is not yet scheduled; else at its scheduling. A fill made at once at the take, or one made before and not yet done, holds back nothing, as a wait for another queue's buffer does not ("Surface order"): it waits for nothing of the guest's to come. The call returns there. A guest whose bundle sends no such op never sees the event, and a bundle sends it only where the bit is set, which it reads in the device info's features_lo. What Metal does, on the M3, the 5300M and the 630 (docs/graphics-kext/dgpu-oracle.md, Q6 and Q7), and the class of each choice:

  • Contract (all three agree): the call returns once the buffer is submitted, about 0.1 to 0.4 ms behind a long buffer, and not before the signal where the buffer, or one before it on its queue, waits for an event. A buffer committed on any queue once the call returned is ordered after it for a tracked resource. The host answers as it takes the buffer, once its ticket in the commit order is issued, and commits every command buffer the buffer's process sends after the answer, on any of its queues, after that buffer's commit; a range message the process sends after it waits for that commit too ("What a walk sees", below). Another process's buffers do not wait for it: a tracked resource is one process's, and what processes share, an IOSurface, is ordered on the GPU by the order of IOSurface accesses ("Surface order", below), as a Mac orders it (Q16). metal2vulkan orders by commit across queues, and Metal orders behind what it has submitted, which a held queue's buffers are not, hence the rule for a queue held by a wait. Tested through the decoder on both platforms (a_later_commit_on_another_queue_sees_a_submitted_buffer_s_writes).
  • Loose (they race): whether the buffer is Scheduled, and its scheduled handlers have run, by the time the call returns. Ours is the cheapest: still Committed, the handlers at its CB_SCHEDULED, as on an idle queue on all three.
  • Loose (later than Metal, inside the envelope): a buffer that waits for an event already reached is answered at its scheduling, not at its take; so is one that follows a deferred copy of a device cache, which Metal has none of.
  • Loose (inside the envelope): a buffer whose take fills a device cache at once is answered before the fill, as Metal, which has no fill, answers it at once. The host takes its ticket in the commit order first and holds the caches it uses from the answer until it has made their fills, so no other begin counts a use of one between and defers a fill decided at once. The answer comes at the take, not at the doorbell: a doorbell cannot know the fill will be made at once, as another queue's begin before the take may count a use of the cache.
  • Loose (what "submitted" means on the host): Metal answers once it has submitted the buffer; ours once the host has taken the message, before it encodes the buffer on its platform, which the guest cannot tell apart, as nothing the guest sends after the answer is carried out before that commit. Where nothing need be waited for, the answer comes earlier still: on the guest's vCPU, inside its doorbell write, before the queue's thread takes the buffer ("The answer at the doorbell", below).
  • Loose (what "scheduled" means on the host), the same way: a buffer that asks for its CB_SUBMITTED and waits for nothing is Scheduled once the host has taken it, or at its doorbell, before its platform has its work, where Metal makes it so once it has submitted it, which the guest cannot tell apart either: nothing of the guest's is ordered by a buffer's scheduling but its later commits, which the ticket orders, and what the GPU reads and writes, which a present, a CPU lock and another queue's or process's buffer wait for from the commit or the post on, not from the scheduling (§14, "CPU locks"; "Surface order", below). A buffer that waits on an event or a deferred copy of a device cache, or is behind one that does, is Scheduled at its scheduling, past its waits, as on a Mac.
  • Inside the envelope (a fault): a buffer whose ops the host cannot carry out after it was answered fails at its CB_COMPLETE, as Metal reports a command buffer's errors at its completion, not at its commit.

Shared events. The host's event is the one command buffers wait on and signal; the bundle keeps the value as the process knows it. It only rises, as Metal's does (measured on the M3 Max: a CPU set or a GPU signal to a lower value leaves it). A CPU setSignaledValue: posts SHARED_EVENT_SET_VALUE on the control ring, which sets the host's (so its GPU waits are released), and raises the bundle's value. A command buffer's signal of a shared event reaches the process as EVENT_SIGNALLED (ObjId, value), which the host posts on the buffer's queue completion ring, once for each signal, ahead of the buffer's CB_COMPLETE and whatever its outcome. Where the buffer has more work after the signal (an encoder, or a wait for an event), the host posts it as its own event reaches the value: it asks its platform for a notification at that value, on one listener of the device's (notifyListener:atValue:block: on Metal; on the Vulkan platform the runtime sees the value rise as the batch that ends at the signal finishes), which may come while the buffer runs, or while it waits to be scheduled. A signal at the buffer's end, and any no notification posted, go with the buffer's completion; so does a signal of a shared event whose create the host refused, wherever it lies ("Guest input the host refuses"): the host holds no event to watch for it, and the walk runs ahead of the GPU, so a post there could come before the buffer's earlier work is done. So a thread that waits on the CPU for such a mid-buffer signal before it sets a value the buffer waits for later waits for good, the one case where ours deadlocks where Metal's goes on (below). The queue's reader hands each to the device's, where the process's shared events listen. notifyListener: blocks run on their listener's queue with the value they were registered at, at once where the value has reached it, as Metal's do (measured). A shared event made at another value is set to it on the host after its create.

Shared events across processes. A process hands its shared event to another as Metal's do: by the event's eventPort (SPI), or by its handle (newSharedEventHandle), Metal's own MTLSharedEventHandle, which NSXPC carries with the port; the other process makes an event of its own from either (newSharedEventWithMachPort:, SPI, and newSharedEventWithHandle:). Both are the one host event: each process's command buffers signal and wait on it on the GPU's timeline, and each process's CPU sets, waits and listeners work on it. What Metal answers was measured on the AMD 5300M and the Intel 630 under macOS 26.7.1 (guest/bundle/tools/oracle/oracle_events.m, identical on both): the port is the same name at each ask, and the event holds one send reference of it; a handle takes a reference of its own and keeps the event's label; an event made from the port or a handle takes one more, is a new object of the same value, and is labelled as the handle (nil from a port); each lets its reference go at its dealloc; MACH_PORT_NULL, a dead name, a port the process receives, a task port and a nil handle are answered nil, the references as they were; and the event and its handle code only through an NSXPCCoder (a keyed archiver's encode and decode raise NSInvalidArgumentException, "This object may only be encoded by an NSXPCCoder.", and the convenience archiver answers NSCocoaErrorDomain 4866). An event made from a port keeps working once the event that gave it is gone, while the port is held.

  • The port is a connection of the kext's. The kext can give a process no port of an object of its own (IOUserClient::copyPortNameForObjectInTask is in com.apple.kpi.private alone), so the bundle opens a connection of its own type on the accelerator for each event it hands out (RgfxSharedEventUserClient, user-client type 'RGSE'), and its send right is the event's eventPort. Its Export (10) has the kext name the event device-wide: SHARED_EVENT_NAME, a name from 1 the kext never gives again, answered COMPLETE; the kext answers the bundle only then, so an import that follows finds the name. Its Import (11), by any process that holds the port, has the kext make the caller's new event of the name: SHARED_EVENT_IMPORT, answered SHARED_EVENT_VALUE with the host event's value, which the new event starts at. A call on the port proves the caller holds it, and each names the caller's context: the kext finds the client of the calling task that holds that context open, and posts through its asks, so a process names and makes events in no context but its own. Submit refuses the three messages: only the kext builds them. Before it calls on a port it was handed, the bundle asks its own connection whether the port is one of these (IOConnectAddClient, which the kext's connectClient answers): the kernel looks the port up in the caller's space and sends it nothing, so a send right of another process's own port is answered nil at once, as Metal's, where an IOKit call made on it kills the caller (dgpu-oracle.md, Q23).
  • One host event, its values to every holder. The host keeps the event of each name (decode::shares): each holder's id in its own table is that one event. The values one holder's command buffers signal it to, as the host posts each to that holder, and its CPU's sets, as the host carries them out, are posted to every other holder as EVENT_SIGNALLED for its own id, on the completion ring of a queue the bundle keeps for that (its listen queue, which no command buffer uses), each tried at once and kept for a thread of the host's where the ring has no room, so a process that stops taking its rings holds up no other process's.
  • The port holds the event. The name holds the host event as a holder does, until the connection goes: once no task holds a send right of it, IOKit frees it, and its free posts SHARED_EVENT_UNNAME. Its close, and IOKit's word that its creator died, only detach it from the accelerator, so a port another process holds outlives a creator killed with it. The host event goes once its last holder and its last name have.
  • Residual: a value read across processes waits for its post. Metal's event is a kernel object whose value page each process maps, so a CPU set in one process is read at once in the other (measured: "read 8 at once" across a spawned pair). Ours raises the other process's value as its post arrives, on its listen queue's ring, so a read right after another process's set may see the value before it. Two events of one process over one port are one object's (the second is the first's alias), so within a process a read sees a set at once, as Metal's does.

Metal's CPU sees a signal from the middle of a buffer while the buffer runs (docs/graphics-kext/dgpu-oracle.md, Q18): on the 5300M and the M3 within a few milliseconds of the GPU reaching it, on the 630 about 100 ms after the commit, which is later where the buffer runs on. On all three, a thread that waits on the CPU for a mid-buffer signal before it sets a value the same buffer waits for later goes on, and the buffer completes. So does ours: the host's notification comes as its GPU reaches the signal, as the 5300M's and the M3's do. A signal at the buffer's end reaches the CPU with the buffer's completion on all three, its listener's block within 0.3 ms of the completed handler, either one first, and ours comes ahead of the completion record. GPU waits are not affected either way: another buffer's WAIT_EVENT waits on the host's event, which the host's GPU signals at the point Metal's would.

A command buffer that waits on an event is watched: one not finished 5 s after its commit is named in the log at WARN, with each event and value it waits for, and again at INFO once it finishes (at most 32 per device). It is diagnostics only: Metal waits without end for a value nothing reaches (measured: the buffer stays Committed), and so does the host while the process lives. Once its context is gone, at its close or a reset of the device, nothing is left to set or signal its events: the host sets each shared event past every value and signals each plain event past every value from a queue of its own, so a buffer still waiting on one runs and finishes. A shared event another process or a name still holds is left to them ("Shared events across processes"), and set past every value once its last hold goes. It then lets go of what it holds (its buffers' GPU addresses among them, which the rebooted guest picks again after a reset), and the close's answer, which waits for the context's buffers, comes. A Mac drops such a buffer instead (measured, the 5300M and the 630 under macOS 26.7.1: a buffer that waits on its process's own shared or plain event when the process exits or is killed never runs; its writes to a shared-memory buffer and to an IOSurface never land, 2 s and 5 s after). The host has committed the buffer to its platform behind a GPU wait by then, and a platform takes back no committed buffer: running it is the only end that holds nothing for good, so its writes land where a Mac's never do.

Who takes the completions. Every queue raises the device's one vector, the control ring's. The accelerator kext maps each queue's completion-ring header into the kernel at its QUEUE_CREATE. The vector's interrupt source is a filter source: its filter, at primary interrupt context as the interrupt arrives, has the accelerator scan the watched rings, and a ring whose producer moved since the last scan, and still holds records its process has not taken, wakes that process. Then the framebuffer's work loop services the vector as it did without the filter, and the accelerator scans the rings again, waking a process only for a producer the filter's scan has not looked at (RgfxQueueWakes.hpp). So a completion thread is woken as the interrupt arrives, not after the work loop's thread is scheduled and has taken the control ring. The filter's scan takes only the watch table's spin lock and each woken client's wake-count lock, spin locks every holder takes with interrupts disabled; the work loop's scan takes the watch table's lock, which no submit path takes. Tested by the kext's queue_wakes_test. Each process has one completion thread in the bundle. It sleeps in the kext (user-client selector 0x107, an interruptible wait on a per-client wake count it passes back), and each pass it drains every queue's ring, arms it, fences and looks again. A completion posted while it works shows in the count or in its last look, so none is missed and nothing polls. The thread takes each command buffer's records whether or not anything waits, and runs no handler. At a CB_SUBMITTED or CB_SCHEDULED the buffer is submitted there, and at its CB_COMPLETE what the host is done with goes back: the queue's slot, the message's block and the inline bytes' chunks. The rest runs on the queue's completion queue, in ring order: the dispatch queue setCompletionQueue: gave (WindowServer sets one), or a serial queue of the queue's own, labelled com.Metal.CompletionQueueDispatch at user-interactive QoS. That is where Metal runs a queue's handlers: one queue's one at a time, two queues' at once (measured on the M3 Max, an AMD 5300M and an Intel 630). The scheduling makes the buffer Scheduled and runs its scheduled handlers, and the completion runs its write-backs, its status, its completed handlers and its waiters. waitUntilScheduled and waitUntilCompleted return once the handlers have run, as Metal's do. A buffer with no scheduled or completed handler and nothing to write back (every surface it writes in place, no copy of app memory) behind none of its queue's records still to run has its records run by the completion thread itself, which wakes its waiters: one wake where the queue's would be two, as Metal's waiter for a buffer with no completed handler is woken by the thread that saw it complete. So does the scheduling of a buffer with no scheduled handler, behind none of its queue's records still to run, whatever its completion runs: it flips the status and lets waitUntilScheduled go there, so a buffer with only a completed handler pays the completion queue's wake once, for its completion. A wait for a buffer of a queue from that queue's completion queue, a handler's for its own buffer or a later buffer of its queue, waits for good, as Metal's does on all three GPUs; a wait for another queue's buffer is released. commitAndWaitUntilSubmitted returns at the submission, whatever handlers run. Waiters take the ring themselves only once the thread has ended (its context closed), and then run the records too.

Enqueue order. A queue's command buffers go on its submission ring in the order they were enqueued, whatever order they are committed in, as Metal runs them (measured on the M3 Max, an AMD 5300M and an Intel 630). The queue keeps its enqueued buffers that are not yet posted, oldest first; a commit with no enqueue before it enqueues the buffer there. A buffer committed behind one not yet committed stays Committed and unposted, and the commit that readies the front posts every ready buffer behind it, in order, on its own thread. An enqueued buffer let go uncommitted stays, holding back the buffers after it, as Metal's does.

Present hold. A buffer that presents drawables (presentDrawable: and its variants) holds back its queue's later buffers until each of those drawables reports its present scheduled, as Metal's queue does. Metal's base command buffer asks the drawable for that report (addPresentScheduledHandler:, CoreAnimation's), and its queue submits up to and including the presenting buffer, then waits for one report a present before it submits more (read from code, macOS 27). On the MBP16's AMD 5300M and Intel 630 (macOS 26.7.1), with a drawable that reported 200 ms after its present, a buffer committed right behind the presenting one was scheduled and ran at 200.7 to 210.5 ms, against 0.3 to 1.3 ms with an immediate report, and both commits returned in 0.03 ms. So the bundle asks every drawable for the report as Metal does (a drawable that cannot report ends the process there, as on the MBP), the queue counts the presents each posted buffer owes and the reports that came, and posts nothing past a buffer while they fall short: the later buffers stay Committed and unposted, as behind a buffer not yet committed, and the report posts them, on a thread of its own. A report that came first counts, so a drawable with no layer on screen, which CoreAnimation reports at once, holds nothing. A CAMetalDrawable reports once its layer's image queue has taken the present, which WindowServer paces (CoreAnimation's layer_collectable_signal, the layer's next drawable or flush, or after 1.1 s, read from code), so a GPU-bound app's frames reach the GPU paced by what WindowServer takes. The report comes after the presenting buffer is scheduled, where its present is made, and the next frame waits for it. Metal schedules a buffer that waits for nothing within a fraction of a millisecond of its commit, whatever its queue runs before it ("Scheduled", above); the host schedules a buffer that does not ask for its CB_SUBMITTED at its platform's submission, which can wait for the queue's earlier work on the GPU. On the RTX 3090 host, the Modern Rendering sample's presenting buffer behind its frame's 89 ms pass was scheduled at the pass's end, 88.6 ms after its commit, and the GPU stood idle 19 to 22 ms a frame until the next frame came. So once a buffer of a queue presents, it and every buffer the queue commits after it ask for their CB_SUBMITTED (SUBMITTED), and the host schedules each at its take where it waits for nothing and no buffer before it on its queue owes its scheduling.

Surface order, where the guest took SURFACE_ORDER (FEATURES_LO bit 11). On a Mac, a GPU access to an IOSurface committed after another process's pending GPU access to it runs after that access, where either writes: read after write, write after read and write after write. Accesses to other surfaces are not ordered (measured on the MBP16's AMD 5300M, macOS 26.7.1: a blit of the surface committed just after another process committed a 212 ms pass over it waited for the pass in all three cases, and read or left what the order says; a blit of another surface took 2.4-4 ms; the Intel 630 runs one process's work at a time, so it orders all of it; dgpu-oracle.md, Q16). Behind a queue of work, a read waits out the writing process's whole queue ahead of the write, and on the 5300M nothing that process committed after the write, where the 630 runs both processes' work first in, first out (measured, the same Mac: dgpu-oracle.md, Q48). Queues and processes here reach the host on rings of their own, which the host takes apart, so the order the host takes buffers in is not the order they were committed in. The bundle names the order instead, as it posts each buffer:

  • Each surface's shared block holds its writers (RgfxSurfaceWriters, one slot a queue: its latest buffer that writes the surface) and, after them, its readers (the same record, the latest buffer of each queue that only reads it), which only the bundles read. Every block has both: a copy's planes start and end on 256 bytes, so its header, its writers and its readers (152 bytes) fit in the page its planes end in, and a block in place holds the header and the slots alone, from its start. Every holder asks a block's size from the writers' end, as a bundle without readers did.
  • A slot names a buffer only while it runs: once the host has finished it, and its post has named it, its process empties the slot where no later buffer of the queue raised it, as a buffer that named it would wait for nothing. A buffer of a video decode alone into device caches, which the host completes as the decode is done, ahead of its copy into the caches (docs/video/devices.md), leaves its slot then, and the host itself has every later buffer of another queue that uses the surface, every download and every present wait for its end, as they would for a slot that named it. Four slots of each record are shared by every process's queues. A queue that finds none free takes one of its process's that names a buffer of another of its queues which its own buffer runs after, its post having named that buffer: whatever names the slot from then on runs after both. A read that finds no reader slot is named among the writers instead (its queue's writer slot, a free one, or one taken so), which every later buffer that uses the surface names: a later read, and a present, then wait for it too, later than a Mac would and never sooner. Only an access whose record holds every slot for other processes' queues, or for buffers it does not run after, is not named (its process logs it once), so a later write of the surface by another queue waits for none of that queue's reads, nor a present or a read for its writes.
  • The post of a buffer that uses surfaces, just before it goes on its queue's ring, reads, for each, the writers of other queues, and where the buffer writes the surface the readers too, and names each queue once, at its highest seqno, in one SURFACE_ORDER op before its first encoder. Once the buffer is on its queue's ring it raises its own queue's slot: a writer's for a surface it writes, else a reader's. The post, not the commit, is where Metal submits the buffer: a buffer committed behind one enqueued before it and not yet committed is submitted once that one is, as Metal's enqueue order has it, and goes on its ring here then, so it runs after the accesses of other queues submitted meanwhile (read from Metal's enqueue order; no oracle has measured a held buffer's surface order).
  • So each buffer named was posted before the post that names it read the slots: the buffers' waits run from later posts to earlier ones, and cannot meet in a cycle.
  • A buffer named that the host has not walked yet holds back the buffer that names it until it is committed. The host takes each queue's ring on a thread of its own, so it may take a buffer before one it names on another queue is walked. Waiting on the GPU alone, the naming buffer could wait for itself: the named buffer's begin may fill a device cache the naming buffer uses (a decode's output, for the CPU's newer generation); the fill waits for the end of each buffer that used the cache before, the naming buffer among them where it was begun and finished first; the naming buffer waits on the GPU for the named buffer's signal, which comes with that buffer's commit after its walk; and the walk's decode waits on the CPU for the fill. Seen on the Windows host, where a guest's video decodes stopped there. So the naming buffer's begin waits, on its queue's thread, until the named buffer is committed, before any of its uses counts among a cache's users and before it takes its ticket in the commit order ("Commit order", below); then it waits on the GPU as any other buffer. Only a queue the host holds, whose ring has published the seqno named, is waited for so. Past 2 s the wait is named in the log, with the buffer it waits for and how far the host took and committed that queue.
  • That wait, too, runs from a later post to an earlier one, and every other wait of a begin, a walk or a commit is for a buffer posted or begun before the one that waits. A buffer waiting at its begin is not begun, and a doorbell's thread never answers it, as the buffer it names has not finished, so it holds no ticket; it keeps its queue's claim on its ring, so no later buffer of its queue is taken or answered meanwhile. No wait is for it.
  • A buffer that comes after a decode whose picture the host lands by work of its own (VA-API, NVDEC, and on Windows a draw over Direct3D 11 textures) is held at its begin until the picture's planes are said written. That work writes the planes off the platform's queues, and the platform's reads see it only in command buffers committed after the landing says it done (the acquire, SurfaceMemory's external_writes_done, recorded ahead of every command buffer committed after it). A GPU wait for the decode's end does not keep that: the reader would be committed first, and read the planes as they were before (seen on the Windows host: a reader taken after the decode's buffer and committed before its acquire read the surface's earlier picture through a plain shape). The key is the decode's buffer, named in the reader's SURFACE_ORDER (which names surfaces, whatever shape of one the reader binds), or kept by the host for a block the reader uses as a decode completed ahead of its end (above), which is how a reader ordered by the decode's early CB_COMPLETE alone comes after it. The begin waits, on its queue's thread, until that buffer is committed, where its ring has published it, and then until the session signals the decode's value, which the host's landing gives once the planes are said written, or once the picture ended without landing. So the reader's CB_SUBMITTED, its ticket and its commit come after the acquire. Nothing times the hold out: it ends with the session's signal, the end of either queue, or a reset. The decode's buffer was posted before the reader, and the landing waits only for the hardware, the session's earlier pictures and the decode's own fill, made while the reader was not begun, so the hold ends. A doorbell's thread answers no buffer that uses the block of a decode completed ahead of its end, so a held buffer holds no ticket. A buffer of the decode's own queue is not held: its ring orders it behind the decode's buffer, which the platform holds on the host until the session's value (below). Counted on the order's summary line, with how many waited for a landing, the longest, and the buffers named that their rings had not published, which nothing holds; past 2 s a hold is named in the log with what it waits for.
  • Names written wrong (a process that writes the slots itself, naming a buffer not yet posted) can name each other across two queues, of any processes, both published before either begins. Their two queues' threads, and their doorbells' answers, then hold until either queue is destroyed or its process's context closes, or the device resets, which ends both waits. Nothing else of the host is held.
  • The host keeps each queue's surface timeline, a shared event. A buffer that holds SURFACE_ORDER signals its queue's to its seqno as it ends, and waits first, on the GPU, for each named queue's to reach the seqno named, except where the host has seen that buffer finish, or the queue is the buffer's own, whose order is its ring's. A queue the host does not hold, or a seqno past every one the queue's ring has published, names no buffer and waits for nothing.
  • A Mac orders no access after a buffer it has not submitted: one that waits on an event not yet at its value, or is behind one on its queue (measured, the 5300M and the 630 under macOS 26.7.1: another process's blit of the surface, and its read-only CPU lock, went on at once while the write waited on its event, the blit reading the surface as it was). So the bundle holds such a buffer's accesses: one that waits on an event below its value as the process knows it (a shared event's value as the host posted it and the CPU set it, a plain event's as the host finished the buffers of the process that signalled it), or is posted behind a held buffer of its queue, raises its slots and names its writes to the kext at its CB_SCHEDULED, which the host posts once its platform has scheduled it, past its waits. A read posted meanwhile names none of it and waits for none of it, and nor does a CPU lock.
  • The wait for a buffer the host has walked is an order on the GPU and nothing more (but for a decode's planes, above), as a Mac's is: a Mac answers a command buffer it runs after another queue's or process's pending access to a surface submitted and scheduled within a millisecond of its commit (the 630, and the M3 in a run's first round, within 1 to 5 ms), and completes it after that access (dgpu-oracle.md, Q16). So the wait holds back none of the buffer's records, nor its queue: it gets its CB_SUBMITTED at its take, as a buffer that waits for nothing does, and its CB_SCHEDULED there too where it gets that and no buffer before it on its queue owes its own, else at its commit, though the platform may hold it until the buffer it waits for finishes (the Vulkan platform holds a wait for a shared event's value on the host until it is reached). So does every buffer committed behind it on its queue while the platform holds it, and each buffer's records still go in its queue's order. A buffer that waits for an event, or for a deferred copy of a device cache it follows, or is behind one, keeps its records at its scheduling; a fill the host makes at once holds back none of them.
  • Work the host starts off a buffer's own GPU timeline waits for the same buffers on the CPU first: a video session's decode runs on a queue of its own as the host walks the buffer, so its output lands only after the reads and writes of other queues the buffer names.
  • What will not signal is signalled for it: a buffer stood in for signals from its stand-in, and one with no stand-in from a command buffer of its own on its queue. Where the queue makes no command buffer (the platform out of memory), the host sets the timeline on the CPU, once it has reached what the queue's command buffers committed before signal, so no signal comes before the queue's earlier work. A queue's destroy, or its context's close, signals the last value a buffer waits for of it. A buffer the host has taken that holds no SURFACE_ORDER signals where another queue's buffer waits past what the queue has signalled.
  • A queue is known to the order from its create's answer on: the device tells the host of it before it answers, so a buffer of another queue that names one of its buffers waits for it though the host has yet to make the queue's handle.

Measured on the lane's RTX 5080 laptop host with a macOS 26.6.1 guest, one boot each of the effort's tip before the order (18fd065e5) and with it: the sweep's video.h264.reader, an AVAssetReader of frames VTDecoderXPCService decodes, failed 35 of 40 runs, then none of 40; vlprobe's AVAssetReader of 420v frames read another frame than its sample's in 96 of 100 runs (39 an earlier one, 56 a later one), then in none of 100. A CPU lock needs nothing more: on the MBP16's AMD 5300M and Intel 630 (macOS 26.7.1), once a command buffer that writes a surface is scheduled, every lock of the surface waits for it, read-only or read-write, in its process or another, and then reads what it wrote; a lock taken before the buffer is scheduled may not wait. The kext's locks wait for the writes named from the commit on, which is inside that.

Commit order, where the guest took COMMIT_ORDER (FEATURES_LO bit 18). Metal orders a tracked resource across a process's queues by the order the command buffers were committed in: a copy committed on a second queue right after the first queue's commit of a 30 ms kernel that writes its source read what the kernel wrote in every run on the AMD 5300M, the Intel 630 and the M3 (dgpu-oracle.md, Q6). The platform orders a tracked resource across its queues by the order the host commits to it, so the host has to commit in the guest's order. A plain commit returns once the buffer is on its queue's ring, and each queue's ring is taken on a thread of its own, so a buffer the guest committed later on another queue could reach the platform first (before this op, the oracle's two-queue row raced in 4 of 15 runs on the lane, each with every word stale). The bundle names the order as it posts each buffer:

  • The process keeps its command queues in a list, each with the seqno of its latest buffer on its ring (posted), raised once the buffer is there.
  • Before a buffer goes on its ring, it names each other queue of the process whose posted rose since this queue last named it, at that posted, in one COMMIT_ORDER op before its first encoder; then it goes on its ring, and its queue's posted rises.
  • So each buffer named was on its ring before the post that names it read posted: the names run from later posts to earlier ones and cannot meet in a cycle. A buffer committed but held behind an uncommitted one on its queue is not on its ring, and is not named, as Metal does not submit it either.
  • The host keeps two marks for each queue: the highest seqno whose buffer took its place among the commit order's tickets (its begin), and the highest whose buffer was committed, stood in for or failed, raised in the queue's order as each buffer's job ends. A buffer that holds the op takes its own place among the tickets only once each buffer it names has begun, and is committed only once each named queue's commit mark reaches the seqno named, after its turn in its queue and the tickets. The first wait keeps the tickets from crossing the names. Without it, a queue's service thread could take a buffer that names another queue's buffer, then a later buffer that asks for its CB_SUBMITTED and takes a ticket, all before the named buffer's begin. The named buffer would then wait for that ticket, the ticket's buffer for its turn, and the naming buffer for the named one. With it, every wait of a commit is for a buffer begun before it. An answer on a doorbell's thread, which waits for nothing, is left to the service thread where a named buffer has not begun.
  • A name of its own queue, of another process's queue, of a queue the host does not hold, or past every seqno the queue's ring has published, waits for nothing. The waits hold no lock. A queue's destroy, its context's close and a reset of the device end them, and while a reset is under way none waits, so a process that names a cycle holds up only its own queues, until it closes.
  • Nothing else changes: no GPU wait is added, the buffer's records go as they did, and the platform orders what the buffers share by the commit order.

Guest times, where the guest took GUEST_TIMES (FEATURES_HI bit 12), a diagnostic. The host sees a command buffer only once its queue's thread takes it off the ring, so the time before that, the app's encode and the buffer's way to the host, shows as one span with nothing pending on the host. The guest stamps each buffer so the host can split it:

  • The bundle reads its clock (mach_absolute_time in nanoseconds, the kext's clock) as the buffer is made (commandBuffer), as its commit is entered, and as its message goes on its ring: under the ring's lock, after the copy and before producer is published, written in the ring's copy at RGFX_GUEST_TIMES_POSTED_OFFSET (64), as the seqno is stamped; for a buffer in a block, into the block, under the ring's lock as its reference goes on the ring. The op, 32 bytes, goes first, the last op put before the stream.
  • At each VBLANK's reading of HOST_TIME the framebuffer writes ring 0's guest_clock_offset_ns, the held reading's offset, then guest_clock_bound_ns, its bound (half the reading's round trip, widened by 50 ppm of its age), with release. The host zeroes both at a reset.
  • The queue's thread stamps the host's clock as it takes the buffer, before the gate, and as it comes back to the ring after the buffer before it (ring_free, 0 for the first of a take). It reads the bound with acquire, then the offset, and gives each buffer encode (committed − made), post_wait (posted − committed: the ring's room, the queue's buffers committed before it, its commit order's naming), and where the bound is not 0, queued (ring_free − posted, where the thread came back after the post: behind the queue's buffer before it, the host's) and transport (the take less the later of posted and ring_free: the doorbell, the thread's wake and the ring), posted mapped to the host's clock by the offset.
  • The host writes them to its trace (REIMS_VGPU_TRACE) as cbguest queue seqno encode post_wait queued transport bound held (cbguest queue seqno encode post_wait held with no offset held), held the time from the take to the event (the buffer's wait at the gate, the read of a block), so a reader places the take at the event less it. Once a second a debug line of target reims_vgpu_graphics::guest_times gives the buffers' count, each span's sum and median and the longest transport.
  • The offset is off by at most its bound, microseconds, under the millisecond spans it splits, as the host's clock runs at the guest's clock's rate ("Refresh times"), though the kext reads it only at a VBLANK, seconds apart while the display's VBLANKs are off. On CLOCK_MONOTONIC, which NTP disciplines, the offset drifted between readings: homelab-um790-xtx-1's +45 ppm showed in Geekbench 7.1's compute as a transport that climbed from about 10 us to 230 us between readings 5 s apart (p50 128 us over 20,597 buffers), where a host trace of the same run placed each doorbell's write 13 us p50 before the take, and homelab-gem10-1's -30 ppm as a transport of 0. The stamps cost three clock reads a buffer. Nothing else the guest or the host observes changes: a guest that did not take the bit stamps nothing, and the host ignores the op.

Left for later (extends the same op families, not the transport): command-buffer/queue descriptors and errorOptions; labels and debug groups answered guest-side; residency sets (useResource/useHeap are in); MTLIOCommandQueue; Metal 4.

Where the decoder lives. In reims-vgpu (graphics::decode), generic over P: Platform, beside the Apple-lane decode it mirrors (same handle machinery, descriptor structs and Platform calls). The reims-vgpu-graphics crate stays the transport (rings, region, registers); the decoder consumes ring bytes and drives Platform.

What a walk sees. No lock of the device's is held across a command buffer's walk and commit. Each context's objects are in a table of their own, each message is carried out on a decoder of its own, and every lock is held for a short section (the list is in crates/reims-vgpu/src/graphics/decode/mod.rs). Ring 0 goes on while a queue walks, and so does every other queue, and the queue's own later buffers are walked beside it. Under the single lock this replaces, the decoder's lock was held from a command buffer's take to its commit, so each other message came wholly before the take or wholly after the commit. Each outcome the new design allows is one of those two:

  • Objects. A command buffer names objects as its context's table was when its first lookup (its queue, at its begin) took its view of the table. A create, destroy or close carried out on another thread after that is not seen, and each such change began after the buffer's take, so under the lock it would have waited for the commit. An object destroyed during the walk is named whole, and let go of once the walk's view closes, after the commit, as one destroyed after the buffer. An object made during the walk is not named: the op naming it faults, as it would before the create. An id destroyed, made again and destroyed again during the walk is named as the object it was at the begin. A close during the walk empties the table at once and the walk keeps naming its objects; the buffer took its context's drain before its view, so the close is answered after the buffer's completion handler. The begin comes after ring 0 has carried out every message of its context's published before the buffer was taken (reims_vgpu_graphics's queue gate, "A buffer's wait on ring 0"), so a buffer finds every create its process sent before it. Tested by a_walk_names_what_its_table_held_at_its_begin, a_walk_names_nothing_made_after_its_begin and a_close_during_a_walk_leaves_it_its_objects (the decoder's cmdbuf tests), and through the device by ring_0_is_carried_out_while_a_walk_is_in_flight, a_close_during_a_walk_is_answered_after_the_buffer and a_queue_s_buffer_runs_beside_another_queue_s_walk (graphics/tests.rs).

  • The commit order. A buffer answered CB_SUBMITTED at its take holds a ticket, issued before the answer is posted, until it is committed (or its stand-in is); one answered at its doorbell holds the answer's. Every command buffer notes the tickets issued at its begin and is committed only once each of its own context's is given back. A buffer its process sends after an answer is begun after its ticket, so it is committed after the answered buffer, as under the lock the answered buffer held through its commit. A buffer begun before the answer does not wait: the guest sent it with no answer in hand, so under the lock it could have been taken first. Another context's buffer waits for no ticket of this one, though the lock held it too: it names none of the context's objects, and what it shares with it, an IOSurface, is ordered on the GPU (SURFACE_ORDER) and by the device cache's users, not by commit, as a Mac orders tracked resources by commit only within a process (dgpu-oracle.md, Q6 and Q16). So one process's answered buffer whose walk is long (a cold make in a draw) holds up only its own process's commits, where under a device-wide order every process's buffer begun meanwhile, the compositor's among them, waited for it. A ticket is issued after its buffer's begin, and a buffer waits only for older tickets, so the waits end. Tested by a_buffer_sent_after_an_answer_is_committed_after_it, a_held_walk_answered_its_submitted_holds_only_its_process_s_later_commits (graphics/tests.rs), and the sequencer's a_commit_waits_only_for_the_tickets_issued_before_its_begin, a_commit_waits_for_its_own_context_s_tickets_alone and tickets_given_back_out_of_order_hold_through_the_oldest.

  • Range messages. BUFFER_DID_MODIFY_RANGE, TEXTURE_REPLACE_REGION and TEXTURE_DID_MODIFY_DATA reach the platform's next submission. One is carried out once every ticket its context held when it came is given back, so a buffer answered before the message was sent does not see its bytes, as under the lock, where the message waited for that buffer's commit. Another context's tickets are not waited for: its buffers cannot name the object, which is its own process's. A buffer of the same context not answered at its take is not waited for either: the guest sent the message with no answer from it, so under the lock the message could have come before its take, and the buffer may see the bytes, as it may on Metal. Ring 0 does not wait for those tickets: the message is checked there (a bad reference or a range past its object is found at once), and its platform call is made where the last ticket is given back, after that buffer's commit, a context's range messages one at a time in the order they came. Every command buffer of the context begun after it came is committed after it, as one begun after ring 0 carried it out was, and it holds its context's drain, so the context's close and its blocks' releases are answered after it. It reads the block when it runs, not when it came: a CPU write made after the message and before the next commit may reach the GPU with it, as Metal's copy of a Managed resource is made at the next submission. Tested by a_buffer_sent_after_an_answer_is_committed_after_it (its range messages), a_texture_s_modified_data_is_carried_out_before_a_later_command_buffer (graphics/tests.rs) and the sequencer's a_range_message_is_carried_out_once_its_context_s_tickets_are_given_back.

  • Device caches. A command buffer counts among the users of each cached block it uses from its begin to its commit, each use under a number of its own in the order they are counted. A fill follows every user counted before it was asked, and a copy out of a cache (a download, a release, the block named again) every such user that may write it, so each copy comes before a user's begin or after its commit, as under the lock. No thread that asks a copy waits for those users: a copy none holds up, and no copy asked before it, is made at once; any other is made in the finish of the last of them, after its commit, in the order the copies were asked, a download and a release answered once their copy is done, as before. So a fill at a begin waits for no other queue's walk, nor does a present's fill on the control thread: on a GPU of its own memory, a WindowServer buffer whose surface a page's long buffer used waited on its queue's thread for that walk (13.5 s behind a WebGPU page's buffer on the RTX 5080 Laptop GPU host; measured). A buffer counted after a copy was asked is ordered after it on the GPU instead: it waits for the cache's own event, which the copy's command buffer signals to the copy's number, where it reads what the copy writes (a fill) or may write what the copy reads (any copy), and it holds its queue, as a buffer that waits for an event does; its marks of the cache and its end value are kept apart until the copy is made, so the copy follows none of them. A buffer finished before a copy it follows is made stays counted among the users of every cache it used until it is: the copies run on one queue in the order they are made, and one made behind the buffer would wait there for its end, and so for the copy it follows, behind it on that queue. A buffer that only reads follows no copy out, which leaves the cache as it is. A copy that copies nothing signals from a command buffer of its own, after the copy before it; where the platform makes no event, the begin waits for the copy on the CPU, as it did for the users. Nothing of ring 0's names the block meanwhile that a copy changes: a download leaves the block's buffers as they are, and the kext names a released block again only once its release is answered. The block named again still waits there, for the writers and the copies asked, as the buffers ring 0 makes over the block after it lie over what it leaves. A buffer's uses are counted together, after those of the buffers begun before it; a copy follows only buffers begun before it was asked, and a buffer waits only for copies asked before it was begun, so the waits end, on the CPU and on the GPU. Tested by a_fill_follows_the_buffers_using_the_cache, a_begin_waits_on_the_cpu_for_no_other_queue_s_long_walk, a_present_s_fill_behind_a_walk_is_made_in_its_finish, a_begin_behind_a_download_waits_on_the_gpu_only_where_it_writes, a_copy_behind_a_buffer_waiting_for_a_copy_is_made_after_that_copy, two_queues_take_one_fill_and_a_download_waits_for_both and a_copy_out_of_a_cache_is_made_as_its_writers_finish (surface_cache).

  • The device's reset. A reset ends every queue at once and is passed to the host on the control thread, before anything the guest publishes after it. Under the lock, the host's reset waited for the message holding the lock, and each message after it found its queue's poster stale and was not carried out. Here each message carried out off the control thread (a queue's command buffer, create or destroy) holds a gate shared, from before it asks whether its poster is stale to its end, and so does each compile's and library make's store. The host's reset holds the gate alone. So the reset waits for every message that passed its check, each of which could have run whole before the reset under the lock. A walk in flight names its objects and commits, and then every object goes, none outliving the reset; a message after the gate finds its poster stale. Only the reset makes ring 0's thread wait for a walk, as the lock did. Tested by a_reset_during_a_walk_comes_after_it and a_reset_drops_every_object_the_guest_made (graphics/tests.rs), and by the decoder's fuzz (decode/fuzz.rs).

  • A queue's own order. A queue's service thread begins each of its command buffers in the order the guest published them and hands the walk and the commit to the queue's lane (decode/lane.rs), whose threads walk several at once, so one process's busy queue is not bound to one thread. Under the lock a queue's next buffer was taken after the commit of the one before it. Here each buffer gets its turn in its queue's lane at its begin, before anything of it can fail, and its commit, its stand-in's commit and the failure posted at once for it wait for every turn before its own, so they come in the order the buffers were taken, as under the lock. A walk encodes into its own command buffer, which the platform runs in commit order: Apple's Metal guide lets a queue's buffers be encoded on several threads and run in the order they are committed, and metal2vulkan resolves barriers, layouts and fences at submit, in commit order. Four things a buffer does before its commit are seen beyond it, and each keeps the lock's order:

    • its hold of its queue: a buffer that waits for an event, or for a deferred copy of a device cache it follows, holds its queue from its begin, not its commit, so a buffer after it that asks for its CB_SUBMITTED is answered at its scheduling, as behind one already committed;
    • a video encoder's work, which its session starts as it is walked: a buffer that holds one is walked only in its turn, and one whose turn is next at its begin is walked and committed on the service thread itself, where it waits for no buffer of its queue, rather than handed to a lane thread that would first be woken or made for it (so is a short buffer, its message of 2 KiB at most, whose commit would wait for nothing at its begin: its turn next, and no buffer of its process it is committed after still to commit; on the lane, each buffer of a drain paid a thread's wake for its walk and another for the turn its commit waited on; and so is one of 8 KiB at most whose commit would wait for nothing and behind which the guest had published nothing on its ring as it was taken: no buffer of its queue was there to be taken beside a lane thread's walk, and the thread's wake, 74 µs at the mean on an RTX 5080 Laptop host, was about the walk's own time). Such a buffer lets go of its queue's claim on its ring's messages once it is begun, and the service thread offers the queue's next buffer to the host there, as a doorbell's thread does, so a buffer that asks for its CB_SUBMITTED behind it is answered before the walk, or at its own doorbell during it, as behind a walk on a lane thread. Through the walk the thread marks the ring walking (consumer_idle 2), for which the guest rings a queue's doorbell only for a buffer that asks for its CB_SUBMITTED; it clears the mark when it takes the claim back, and takes what the guest published meanwhile. With the ring marked as before a sleep (1), the guest would ring for each buffer it publishes during a walk, a VM exit that answers nothing for a buffer that does not ask (measured on a 26.7.2 guest of a 780M host: 11.9 µs a doorbell, in two of three commits of a back-to-back run). Held through the walk, the claim kept the doorbell from answering, and with the ring marked busy the guest rang none, so a guest's commitAndWaitUntilSubmitted behind a buffer of fills waited for that walk and its commit (tested by a_buffer_that_asks_behind_a_walk_on_its_service_thread_is_answered_before_the_walk_ends);
    • its signal of its queue's surface timeline ("Surface order"), and the release that stands in for one of a buffer that does not run: each is decided in the buffer's turn, after its walk, since the order reads a queue's buffer taken past a seqno as every buffer up to it taken, and a waiter that saw a later buffer taken while an earlier one still walked would wait for nothing;
    • its answer at its take, posted at its begin, before the buffers before it on its queue commit: everything its process sends after the answer is committed after the buffer (its ticket), which commits after them, so nothing sent later sees the difference, and those buffers are Committed or Scheduled at the answer by a race, as Metal's are.

    A turn passes as its buffer's work ends, and a buffer waits only for turns and tickets of buffers begun before it. A lane's threads take its jobs in the order they came, and every lane with work has a thread of its own, so the oldest unfinished buffer of each lane is on a thread, and so is the oldest of the device: the waits end, by induction on the begin order. A buffer carried out on its service thread is its lane's oldest unfinished one, and the lane gets no job while it runs. A job that comes while every thread of the lane is busy gets another, only where the device-wide budget has one free, which a lane never waits for. At most eight of a lane's jobs walk at once; a job that waits for what is committed before its buffer (its turn, its tickets, the buffers its COMMIT_ORDER names, a split of its context) is not among them while it waits, so the lane starts its next job meanwhile, up to 64 threads a lane, as many command buffers as the host's queue holds uncompleted. The budget is twice the host's cores and 64 more, for a busy queue's buffers walked ahead of their turns. So 2048 busy queues hold one thread each and the budget's at most. The waits are the same and where they were, so the commits, records and interrupts are too; only how far the walks run ahead changed. A job held back by the eight is later than every job started, so it holds none of their waits. A job goes to the thread that went idle last, and a thread goes after 10 s with no job, the budget's before the lane's own: the threads a burst made go 10 s after it, while a steady load's stay through its pauses and jobs that come one at a time stay on one thread (a_lane_keeps_its_thread_through_a_steady_load_s_pauses, a_burst_s_other_threads_go_after_keep_while_one_takes_the_jobs). Each lane thread gives itself the walk hints as it starts (on Linux, a utilization floor; no thread is bound to a CPU). A buffer longer than its service thread walks itself has the lane's idle thread woken as its turn is taken, before the rest of its begin, and that thread spins for the job for 50 µs at most, so its wake is made while the buffer is begun: no job, turn or order changes, only when the thread wakes (a_long_buffer_wakes_its_idle_lane_s_thread_as_it_is_begun). Tested through the device by a_queue_s_buffers_are_walked_at_once_and_committed_in_order, every_buffer_behind_a_held_walk_is_walked_beside_it_and_committed_in_turn, a_queue_s_buffers_past_its_lane_s_most_threads_wait_to_start_and_commit_in_turn, a_process_s_buffers_behind_its_held_answered_one_are_walked_and_committed_after_it, a_buffer_behind_one_that_waits_and_is_still_walked_is_answered_at_its_scheduling, a_video_buffer_is_walked_in_its_turn and a_lone_video_buffer_is_walked_on_its_queue_s_service_thread (graphics/tests.rs), and by the lane's a_turn_waits_for_every_turn_before_it, a_turn_is_next_once_every_turn_before_it_has_passed, many_waiting_turns_each_go_in_their_turn, a_lane_runs_its_jobs_at_once_on_the_budget_s_threads, a_lane_starts_its_next_jobs_while_its_jobs_wait, a_lane_of_waiting_jobs_holds_lane_most_threads_at_most, a_wait_off_the_lane_s_threads_or_inside_another_is_the_wait_alone, a_lane_with_no_budget_left_runs_its_jobs_on_its_own_thread_in_order, busy_lanes_hold_one_thread_each_and_the_budget_s, a_burst_s_threads_go_while_jobs_come_one_at_a_time, a_burst_after_the_threads_went_grows_the_lane_to_its_limit_again, each_thread_gives_itself_the_walk_hints_before_its_first_job, an_expected_job_starts_on_the_thread_woken_for_it, an_expected_job_that_comes_after_the_spin_wakes_its_thread_as_it_comes, a_withdrawn_expectation_or_the_close_ends_the_spin_at_once and an_expectation_wakes_only_an_idle_thread_and_one_at_a_time.

  • A command buffer in parts. Where the platform starts a command buffer's GPU work only at its commit (the Vulkan platform's runtime records it and submits it then), a long buffer's walk and its GPU work run in series: WindowServer's composite of a Liquid Glass desktop walked 2.6 to 3.5 ms and then ran 1.6 to 3.3 ms on an RTX 5080 Laptop GPU, each frame, against a refresh of 8.33 ms. So the walk commits such a buffer in parts (decode/split.rs): at an encoder's end that another encoder follows, once the part walked since the last took 250 µs, it hands the platform that part (CommandBuffer::split), which commits it on the buffer's queue and answers a command buffer of the queue that goes on from it, and the walk goes on in that one. While a command buffer its queue committed is not yet seen complete, it cuts a part only once the part's estimated GPU time reaches 16 ms, from the GPU time its parts seen complete took against their walk, or its walk 2 ms: each part is a job of the driver's scheduler, and one behind work adds a job and the GPU's boundary between jobs, about 0.1 ms on a Radeon 780M (decode/split.rs, "How many parts"). Where the GPU is far slower than the walk, every queue's work shares one VkQueue in submission order, so a buffer of another queue, a compositor's frame, committed after the walk's parts waits for all of them: a walk on its lane waits after a cut while two or more of its parts are out and their estimated GPU time is over 16 ms. It is not paced once it waited for or signalled an event by an op, nor once a buffer of its context waits for its last commit (at the split's gate, in the commit order, or for its tickets and range messages), which a paced walk would otherwise hold up (decode/split.rs, "How far ahead of the GPU"). On the M3 Max (MoltenVK) a frame of 60 passes then completed in 6.0 ms from its message's take, where it took 9.5 ms whole (decode/split.rs, "What it gains"). A part is committed only where the whole buffer could be committed then, waiting for nothing: its turn is next, every ticket and range message before its begin is done, and the buffers its COMMIT_ORDER names are committed. Every wait of the last commit is met at the first part, so the walk waits between parts for nothing but its own parts' completions where it is paced. The parts run in their order on the queue, as one buffer's encoders do. The buffer's handlers, records, ticket and commit marks are its last part's, and its outcome is all of them: the first failed part's error, and GPU times that start at the first part's start and span the parts' GPU time summed, never ending after the last part's end (decode/split.rs, "Its GPU times": the GPU's waits between parts are for the host's walk, which a Mac's GPU, handed the whole buffer at its commit, never has; one buffer on both x86 Macs spans its encoders' GPU time summed, and macOS's compositor reads a buffer's GPU times). The record's end so falls before the last part's own end by those waits (2.3 to 2.6 ms at the median in steady Launchpad on a Radeon 780M, 11-16), and the guest never reads it as a time: its GPUEndTime is when it took the record and its GPUStartTime the record's span before that ("Completion", below), so it sees the parts' GPU time summed as the run, ending after the last part's end by the record's delivery, as a whole buffer's does. While a buffer's parts are out, from its first part's commit to its last, no other command buffer of its context is committed (each waits at its commit, never at its walk), and the context's range messages that come are carried out after its last commit, so each other message comes wholly before the buffer's commit or wholly after it, as under the lock. A buffer splits only while no other commit or range message of its context is under way, and only where it waits for no event, is behind no buffer of its queue that does, is not a video buffer, and its queue holds room for another command buffer. A buffer whose walk faults after a part has its failure at its stand-in's completion, as one whose walk faults whole; the parts committed before the fault ran, as the encoders before a fault of Metal's GPU run. Each part but the last that waits for and signals no event is marked to join the next one's completion (CommandBuffer::set_completion_joins_next), so the platform may send several to its driver in one submission: nothing observes a marked part's completion but the note of its outcome for the last part's record, so the guest sees the buffer complete at its last part's own end, as before (decode/split.rs, "Its parts' completions"). The Vulkan platform keeps a buffer whole where a part would answer otherwise than the whole (gpu/command.rs, "A command buffer in parts"); a buffer of compute encoders alone is cut too, its unit of command predication going on in the next part, and a buffer shaped like Geekbench 7's Fluid Simulation's, of 2,600 one-dispatch encoders, then completed in 34.8 ms where it took 87.0 ms whole on the M3 Max (decode/split.rs, "What it gains"). Tested by a_buffer_walked_long_is_committed_in_parts_with_one_outcome, a_buffer_is_committed_whole_where_its_parts_would_wait, another_queue_s_commit_waits_for_a_buffer_s_last_part and a_walk_that_faults_after_a_part_fails_at_its_stand_in, a_split_after_a_mid_buffer_signal_keeps_the_signal_before_the_cut, a_split_after_a_skipped_encoder_answers_as_the_whole, a_buffer_s_parts_but_its_last_join_the_next_completion_unless_they_signal a_first_part_that_waits_from_its_begin_is_not_marked, a_walk_behind_incomplete_work_cuts_its_parts_by_their_estimated_gpu_time, a_paced_walk_waits_while_its_parts_run_far_ahead_of_the_gpu, a_paced_walk_s_wait_ends_at_a_reset_its_queue_s_end_a_fault_or_its_bound, a_walk_that_waits_for_or_signals_an_event_by_an_op_is_not_paced and a_paced_walk_goes_on_unpaced_once_a_buffer_of_its_context_waits_for_it (the decoder's cmdbuf tests), and the gate's and the estimate's own (decode/split.rs).

  • What still waits on ring 0's thread: a block named again, for that block's writers; a present's fill, for that block's users begun and not finished (not for the fill itself: the fill is committed there, and the present waits for it in the present queue, shown at the fill's completion); and the device's reset, for every message in flight. A context's close waits for no walk: reims_vgpu_graphics fences each of its queues, which waits only for a take of the queue's submission ring or a post onto its completion ring under way, and the close is answered once its buffers have finished (a_close_during_a_walk_holds_up_nothing_on_ring_0). A doorbell's take tries every lock it takes, and takes nothing it would have to let go of.

  • A landed download at ring 0's doorbell. A write of ring 0's doorbell through Device::mmio_write_taking takes ring 0's next message on the writing thread and answers it there where it is a SURFACE_DOWNLOAD the host has carried out already (Host::surface_downloaded: the block has no device cache, or one nothing wrote since its last copy, whose early copy has landed), the control thread sleeps with every answer of what it took posted, the block's lane has nothing left, and the control completion ring has room; each lock is tried, and nothing is allocated or freed. The COMPLETE is posted and the control vector raised before the write returns, so a CPU lock of a decoder's output whose copy has landed no longer waits for the control thread's wake. QEMU takes ring 0's doorbell with an ioeventfd, whose file the control thread polls, so under QEMU this applies only once reims-graphics-pci sends that write through _mmio_write_taking too.

  • The answer at the doorbell. A queue's doorbell write, on the guest's vCPU, may answer CB_SUBMITTED to the buffer at the head of the queue's ring before the queue's thread wakes to take it (reims_vgpu_graphics's Device::mmio_write_taking), where the buffer would get it at its take and nothing need be waited for or allocated: the vCPU copies the message onto its stack, reads its ops where they lie, and tries every lock it takes. It reads the ops only where the stream's last op is the buffer's SUBMITTED, where the bundle appends it at the commit, so a buffer that does not ask costs the vCPU no scan of its ops. A buffer that does not ask, or whose ask is not its last op, or that waits for a copy of a device cache it uses (a fill it needs or one not yet done, or a copy asked before it that it follows), waits for an event or another queue's buffer, sits behind a held buffer, or finds a lock busy is left to the queue's thread, as before. One that uses a device cache and waits for none of its copies is answered there: it was left to the queue's thread for using one at all. A copy asked between the answer and the buffer's begin (a fill a write of the host's devices over the pages asks, a present's fill, a download or a release) is followed at the begin all the same where the buffer must follow it ("Device caches" above), the buffer waiting for it on the GPU with its answer given: the two were concurrent, and the buffer is ordered after the copy, as one begun after it is. The answer takes the buffer's turn in its queue's lane and its ticket in the commit order together, with its mark (every ticket issued before its own), keeps them on the queue (cmdbuf's Answered), and posts the record. The queue's thread then takes the buffer without waiting for ring 0 again (the vCPU found ring 0 carried out as far as the buffer waits for), and its begin takes the turn, the mark and the ticket in place of its own, so its commit and every commit it orders come where they would had it been answered at its begin. Its later messages on ring 0 wait for nothing more of it than before. A buffer never begun after its answer (its queue gone, the device reset) lets them go with its queue's entry, and a buffer the platform refuses at its begin fails in its turn. The vCPU neither allocates nor frees, as the library's allocator may purge pages in either call: the platform's command buffer and every other allocation are made on the queue's thread. The answer is on the queue's completion ring before the doorbell write returns, so the bundle's post looks for it there as the write returns (RgfxReplyReader::holdsSubmitted, which takes no record): a buffer answered at its doorbell is submitted there, and commitAndWaitUntilSubmitted returns with no interrupt and no wake of the completion thread on its way. That thread takes the record later, in ring order, and finds the buffer submitted already. Tested by the bundle's test_submitted_at_the_doorbell_wakes_no_thread and test_reply_reader_holds_submitted (tests/shell_tests.mm). A buffer the doorbell leaves to the queue's thread because ring 0 is behind (a create of its process's not yet carried out) is offered the same way on the lane's thread whose carrying out ends the queue's thread's wait, before that thread is woken (reims_vgpu_graphics's queue gate, its offers), so its CB_SUBMITTED no longer waits for the queue's thread's wake (a_buffer_behind_its_process_s_create_is_answered_on_the_lane_s_thread). Tested by a_doorbell_s_answer_allocates_nothing and a_doorbell_write_answers_a_command_buffer_on_its_thread (graphics/tests.rs), the cmdbuf tests a_buffer_is_answered_at_the_doorbell_only_where_it_need_wait_for_nothing, a_buffer_answered_at_the_doorbell_is_carried_out_as_one_decoded, a_buffer_begun_after_an_answer_is_committed_after_the_answered_buffer, a_reset_between_an_answer_and_its_begin_lets_the_answer_go and a_refused_make_after_an_answer_fails_in_turn, the surface_cache test a_buffer_using_a_cache_is_answered_at_its_doorbell_where_it_waits_for_no_copy, the decoder's fuzz (an_answer_at_the_doorbell_keeps_the_order_of_a_take), and the device's an_answered_command_buffer_waits_for_no_later_ring_0_message. Under DOORBELL_ASKS only a write that carries RGFX_DOORBELL_ASKS is answered there; a plain write wakes the queue's thread alone (only_an_asking_doorbell_write_is_answered_at_the_doorbell, a_guest_without_doorbell_asks_is_answered_at_any_doorbell_and_not_routed).

  • Routed doorbells. A plain doorbell write needs nothing of the host but the wake of the queue's thread, so where the guest took DOORBELL_ASKS each queue's thread sleeps on an eventfd of its own as well as on its wake, and the device hands the host that eventfd with the ring's id at the queue's create (the C API's route_doorbell). QEMU registers it with KVM as an ioeventfd on DOORBELL matching the ring's id exactly, so KVM signals it inside the guest's write and the vCPU returns to the guest with no exit to QEMU; the asking write, the id with bit 0, matches no route and goes to QEMU and the library as before. Measured on the Radeon 780M host before the routes: a write QEMU takes as an ioeventfd (ring 0's) costs the guest 8.9 us, one it runs through the library 13.4 us. The thread drains the eventfd and walks the ring on each wake, so writes that coalesce into one wake are all taken, in ring order (a_routed_doorbell_wakes_its_queue_which_takes_every_buffer_published). The device routes at most 128 queues' doorbells (KVM holds 1000 devices on its MMIO bus, and QEMU ends the VM where KVM refuses one); a queue past them, or one whose route the host refuses, keeps its doorbell on the write, logged once per kind (full, refused) and then counted (a_queue_past_the_routes_or_refused_keeps_its_doorbell_on_the_write). A queue's route goes at its destroy, its context's close and the device's reset (a_reset_drops_the_queues_routes), and QEMU drops every route at its teardown. QEMU adds and drops a route under the BQL before the callback returns, so the device calls it holding no lock of its own: on the lane's thread after the queues' table is let go, and in a reset after its rings and table are; and no device function a host calls under the BQL waits for a lane (the_host_s_lock_held_around_its_calls_while_a_route_waits_for_it_holds_up_nothing). A route changes no order: the ring's records, its completions and interrupts are the thread's, as for a doorbell the host takes in the write. Where the guest took DOORBELL_PAGES, a queue of a context with a doorbell page is routed at the page's doorbell in BAR4 instead, and the page's routes count among the 128 ("BAR4: the doorbell pages").

  • A process rings at its doorbell page. Where the kext mapped the context's doorbell page (OpenContext's seventh output), the bundle rings a queue with one 32-bit store of the ring's id at the page's first byte, a DMB OSHST before it on arm64 and the store one STR of a W register, the one form a hypervisor decodes from its abort's syndrome (guest/bundle/src/RgfxDoorbellPage.hpp). The store exits to the hypervisor as the kext's register write does, so what it saves is the call into the kext: the Mach trap and IOUserClient's dispatch. The control ring's held messages still go first, as before any call of the process's into the kext. With no page the bundle calls Doorbell, as before.

  • Ring 0's doorbell rings out of its lock. The framebuffer publishes a post on ring 0 under its submit lock and reads whether the host's consumer sleeps there, and writes DOORBELL once it has let the lock go (rgfxControlPublishWantsBell, guest/kext/src/RgfxControlRing.hpp): the write exits to the host, and another CPU's post would wait that exit out under the lock. The ring's order is its producer's, which the lock keeps; a doorbell is a wake, and two posts that both find the consumer asleep ring twice, as they did under the lock.

Stage 3 guest stack (from the prior-art study)

How a Metal bundle plugs into macOS, in Apple's own terms (notes: stage3-apple-metal-iface.md):

  • Discovery/load. The bundle installs under /Library/GPUBundles/. Metal does not scan that directory; it loads the bundle from two properties on the accelerator service's registry entry — MetalPluginName (the path) and MetalPluginClassName (the Obj-C class Metal instantiates as the MTLDevice) — under IOMatchCategory IOAccelerator. So stage 3 needs a guest accelerator kext that matches our PCI device and publishes those two keys; the bundle ships beside it.
  • Trusted-bundle gate (with SIP on). Before it loads a GPU bundle from /Library/GPUBundles, Metal asks the system whether that path is trusted, and the answer is yes only for a path carrying the particular SIP "rootless" storage class the OS gives the bundles its own kext-staging writes there (or for a path sealed on the system volume). A bundle merely copied onto the data volume does not carry it, so with SIP on Metal declines to load it and WindowServer, finding the accelerator registered, crashes and restarts in a loop. Our install kext (guest/rgfxgate, a Graft client) therefore writes the bundle to the data volume and gives the whole tree that exact storage class and the matching restricted flag from kernel context, below the file-system MAC layer, so only our bundle's own paths are tagged and SIP is relaxed for nothing. The unsigned bundle's executable still has to pass library validation when WindowServer and the Metal helpers map it; the same kext answers the library-validation, mmap and signature MAC checks for our bundle by its code-directory hash, leaving every other binary's signing rules untouched. The signature check, the wall that gates the other two, also requires the executable's path to be under /Library/GPUBundles, so the exemption follows the installed bundle and a byte-identical copy of it placed elsewhere is not trusted — the same pinning the install writes carry. No boot-args and no SIP relaxation are involved — the guest boots with SIP fully enabled (measured on msi, x86-64 macOS 26.6.1: desktop composites on our Metal device and Safari WebGL renders, csrutil enabled). /Library/GPUBundles itself comes with every install: the data-volume template on the sealed system volume holds it, already restricted and of that storage class (measured: the x86-64 26.6.1 guest and a 27.0.1 host). The install kext waits for the data volume to mount (/Library/Preferences appears) and creates the container, with the same class, only where it is missing.
    • Checklist (per supported OS). The three load hooks and the three install hooks are Graft routes of six XNU MAC dispatchers (_mac_file_check_library_validation, _mac_file_check_mmap, _mac_vnode_check_signature, _mac_vnode_check_{create,open,truncate}), whose argument lists RgfxGateHooks.cpp hard-codes. Routing is by symbol, not by raw bytes, so a moved patch site is not the risk; a changed prototype is. RgfxGate has no kernel version range, so when a release joins the test matrix, re-verify each of the six prototypes against that release's kernel before shipping it, and confirm _csfg_get_cdhash and _csblob_get_cdhash still resolve (a miss on either now logs loudly and leaves the gate inert rather than bricking silently).
  • Bundle updates. The marker beside the executable (below, "Registration waits for the bundle") carries the kext's wire version, and the bundle is the kext's own payload, so a newer kext whose executable or wire version differs replaces the installed bundle. The replacement is atomic: the whole new tree is built and tagged in a sibling staging directory (NAME.bundle.new), then put in place with a single rename — an existing bundle is exchanged with it (VNOP_RENAMEX, VFS_RENAME_SWAP) and the old tree, swapped aside, dropped; where there is none the staged tree is moved in. A reader (WindowServer, a Metal helper) therefore sees either the whole old bundle or the whole new one, never a half-written one, so an upgrade that keeps the wire version cannot leave a torn executable mid-boot (the "RgfxGate rewrite race"). The container is never unlocked, so SIP is not widened around it even mid-upgrade. A bundle that is byte-current but untagged — staged by a tool under relaxed SIP and then first seen on a SIP-on boot — is detected and tagged in place without a rewrite. The test is the bundle directory's storage class and restricted flag together: a bundle copied into the restricted container is given the flag but not the class, and the class is what Metal reads. Userspace cannot remove the class even with SIP off, so only the kext writes or clears it. A current, tagged bundle is left as it is, and the boot writes nothing. The accelerator, in turn, registers only once RgfxGate has signalled that its install pass has ended, so it never registers against a tree mid-swap.
  • Device class. The bundle's device subclasses Apple's private IOAccel Metal base class and conforms to <MTLDevice, MTLDeviceSPI>; entry -initWithAcceleratorPort: (may return nil to decline). The base fills the limit tables (zero limits make CoreImage refuse), and the bundle implements the whole MTLDevice object graph plus enough of the GL/OpenCL private selectors. AIR arrives as .metallib through newLibraryWith*; the bundle takes the AIR slice, asks the host for it by its content key (LIBRARY_LOOKUP), and forwards the slice's bytes over the wire only where the host holds none (LIBRARY_CREATE), which the host compiles.
  • Core Image's link. Core Image makes its kernel libraries (file type 1, whose kernels are extern functions of functionType 4, left out of functionNames) through newLibraryWith*, takes each kernel and its own helpers with the private newExternFunctionWithName:, and links them on the CPU in Metal's base device class (newLibraryWithImageFilterFunctionsSPI:…, which calls newLibraryWithCIFilters:… on the device). The link reads Metal-internal library data from each function, which no function of ours holds. So each library of ours keeps the bytes it was made from and makes, on first use, a shadow: Metal's own library over them (the base class's newLibraryWithData:), whose extern functions ours hold. The device's link overrides hand Metal the shadows, and make the library Metal links (the bytes it answers as libraryDataContents: one kernel, ciKernelMain) the device's own through newLibraryWithData:, so the kernel's pipeline is made on the host like any other (measured: macOS 27, and 26.6.1 in the guest; tools/ci_probe.m renders through it).
  • Kernel family — the fork. The prior art builds its accelerator on the older IOAcceleratorFamily2, but our guest already runs the ported IOGPUFamily stack, and IOAccel2 cannot start in a kernel where IOGPU runs. So our accelerator aligns with IOGPU (owner's correction, 2026-10-30), and the IOAccel2 user-client selectors do not transfer; our accelerator exposes the alloc/map + submit + completion-stamp + IOSurface-sharing boundary over our own protocol, not Apple's IOGPU user client.
  • Compositor/present. WindowServer composites into IOSurfaces and presents through a display pipe. Our ported IOGPU stack already runs Metal compositing through its IOSurface display pipe (type-4 adapter), and we already have the framebuffer/display kext; stage 3's display work is making the accelerator and the framebuffer agree on the IOSurface scanout (flip, else copy).
  • Load policy. Loading our unsigned bundle into WindowServer, the Metal compiler helpers and sandboxed apps is done with SIP and library validation left on, by the install kext's two gates above — the rootless storage-class tag that makes the path trusted, and the code-directory-hash answer to the library-validation and signature MAC checks. It is a concern of our kext, not a boot-args relaxation.

Stage 3 accelerator kext (scaffold)

RgfxAccelerator (guest/kext/src/RgfxAccelerator.{hpp,cpp}) is a second IOService in the one kext, on the same PCI device as the Stage-2 framebuffer: the framebuffer matches in category IOFramebuffer, the accelerator in category IOAccelerator, both children of the one IOPCIDevice. Its Info.plist personality holds only what matches the provider and names the driver, as Graft takes a personality's other keys for the provider's matching ("Graft", above). The accelerator sets its driver keys on its registry entry at the start of start, before it registers (setDriverKeys), of the same types on x86-64 and arm64: MetalPluginName = reims-graphics (the bundle /Library/GPUBundles/reims-graphics.bundle) and MetalPluginClassName = RgfxMetalDevice, which is how Metal (IOServiceMatching("IOAccelerator")) finds and loads the bundle; IOGLBundleName (OpenGL, below); AcceleratorProperties, whose IOAccelDisplayPipeCapabilities say the display pipe and its transactions are supported; and DisplayPortCount 1. Where the host decodes video it also sets IODVDBundleName, IOVARendererID and IOGVACodec (hardware video, Decided 16), before it registers (publishVideoCodecs). The accelerator maps BAR 0 for the doorbell and holds BAR 2 to map each process's part of it in; it touches no pixels and no control ring (the framebuffer owns those).

OpenGL. The accelerator also carries IOGLBundleName = AppleMetalOpenGLRenderer, the GL renderer OpenGL loads for an accelerator: the system's own GL over Metal, which finds its Metal device among MTLCopyAllDevices() by the accelerator's registry entry ID (the device's registryID). The renderer hands the device each GL shader as GL IR and each variant as plugin data; Metal's own devices lower the two to AIR in their compiler service. The bundle has none, so it lowers a variant in the app's process, through the GL code generator the system ships beside the renderer (libGLDPlugin<V>.dylib, called in place), into a .metallib of one function, and makes an ordinary library of it (guest/bundle/src/RgfxGLFunction.h, RgfxGLLowering.hpp): the host compiles GL shaders as it compiles any library. A tessellated draw's vertex and control shaders are one kernel the renderer makes a compute pipeline of under a stage input descriptor; the kernel takes the draw's vertices as a patch control point input, which Metal compiles in no kernel, so its pipeline is made of the kernel made one without the input under that descriptor (RgfxGLStageInKernel), whose fetch reads what Metal's [[stage_in]] fetch reads (bit for bit on the M3 Max, every attribute format: guest/bundle/tests/gl_tests.mm). Measured on an x86 Mac (macOS 26.7.1, the Intel UHD 630): the renderer runs on a non-Apple Metal device, and the bundle's lowering draws what Metal's own does (guest/bundle/tools/gl_probe.m, gl_inject.mm). An on-screen context's drawable is the IOGPU base's, over the kext's GL drawable and window surface ("A GL window", below). OpenCL lists a GPU for every accelerator that names an IOGLBundleName, and runs its kernels through the same renderer.

The renderer's settings. The renderer picks a set of per-vendor settings for a device when it makes its first context, read from its code (macOS 27.0.1, both slices): by the device's vendorName, "AMD" or "ATI" (AMD's settings only where the device's class is the one of AMD's older Metal driver, NVIDIA's otherwise), "NVIDIA" or "Intel"; for any other vendor by supportsFamily: of Apple7, then Apple5; and it ends the process on a device that answers none ("Unknown GPU!!"). Among what the settings decide:

  • Whether the renderer sends GL's provoking vertex to the encoder (setProvokingVertexMode:, 1 for GL's default last-vertex convention, 0 for the first). The Apple and AMD settings do. Under NVIDIA's and Intel's, the renderer reorders each triangle's vertices itself, and a line keeps its first vertex's flat value: gl_cases' provoking-line-last fails. Measured: the M3 Max sends 1 and 0 to its encoder and passes every provoking case (macOS 27.0.1, job m3-max-26643); the Intel 630's Metal GL renderer fails that one case (macOS 26.7.1, commit 17b468160's measurement). The AMD Radeon Pro 5300M's Metal device is not of the older driver's class, so it takes NVIDIA's settings (its class read on macOS 26.7.1, job m3-max-26630).
  • Whether GL's GL_POINT polygon mode goes to the encoder as setTriangleFillMode: 2, which no public MTLTriangleFillMode names. The Apple, AMD and Intel settings send it. Measured with a triangle at mode 2: the M3 Max and the Intel 630 draw its three vertices' pixels, the 5300M fills it (jobs m3-max-26654 and m3-max-26650). The Vulkan platform draws them as the M3 Max does, as points of one pixel (the runtime's TriangleFillMode::Points, VK_POLYGON_MODE_POINT), where the device has fillModeNonSolid, and pointPolygons on a portability-subset device; elsewhere, MoltenVK among them, the runtime refuses the mode and the platform dies on the refusal (fill_mode_2_draws_a_triangles_vertices_as_points in crates/reims-vgpu-vulkan/src/gpu/encode_render.rs). A guest given Intel's settings sends it.
  • Whether texture uploads and mipmap generation take the renderer's other path (gldModifyTexSubImage, gldGenerateTexMipmaps): the Apple settings alone.
  • Whether it keeps supportsForceSeamsOnCubemaps' answer: the Apple settings alone; every other vendor's drop it.
  • The largest point the renderer draws (updateRenderPointSettings clamps GL's point size to it): 16 pixels under Apple5's settings, 64 under every other set.

Apple7's settings and Apple5's are the same but for that point size: both answer each of the settings above as Apple's (read from the five settings records and the code that copies them, macOS 27.0.1's arm64e slice). So the narrowest answers that give a device the Apple settings are a vendorName that holds none of "AMD", "ATI", "NVIDIA" and "Intel" and supportsFamily: of Apple5; "Apple" without Apple5 or Apple7 ends every process that makes a GL context.

Our device answers vendorName "AMD" on an x86-64 guest, on every host, the vendor of the name it answers there, which holds neither "Intel" nor "NVIDIA" (rgfxMetalVendorNameOf and rgfxMetalNameOf in guest/bundle/src/RgfxCaps.hpp, and the reason in guest/kext/src/RgfxDeviceName.hpp). On an arm64 guest it answers the host GPU's vendor, and "AMD" for any other (rgfxVendorNameOf). It answers no Apple family short of Apple7 (crates/reims-vgpu/src/graphics/device_info.rs). So its x86-64 guests get NVIDIA's settings on every host, as the 5300M does, an Intel host's among them, and its arm64 guests NVIDIA's, or Intel's on an Intel host. An arm64 guest on the M3 Max gets NVIDIA's settings where the M3 Max's own renderer takes the Apple ones: GL lines under the last-vertex convention take their first vertex's flat value there (arm64 macOS 27.0.1, a64walk2's walks), whatever the bundle and the host do with the setter. The device does not answer Apple5 for it: Apple4's and Apple5's rows hold tile shaders, imageblocks and nonsquare tile dispatch, which the device does not carry (no tile pipeline crosses the wire) and the Vulkan platform's runtime refuses on every device (its family audit, measured on an Iris Xe at metal2vulkan c796a88d6a: 26 rows of Apple5's block it, these four among them). Apple5 without Apple7 is also no Mac's answer, which is why the device claims no Apple family short of Apple7 (FIRST_MAC_APPLE_FAMILY in device_info.rs).

Registration waits for the bundle. Where the accelerator is registered and its bundle is not on disk, every WindowServer aborts in CoreDisplay as it brings the display up, and launchd starts another until it gives up: the screen stays black. That is every boot before the bundle is installed: the install boot, Recovery, the installer. Where no accelerator is registered, WindowServer composites in software on the framebuffer. Measured on msi (x86-64 macOS 26, no bundle): an accelerator that does not start leaves WindowServer up with a console session and the desktop drawn, the framebuffer still naming it in IOAccelTypes; a registered accelerator still aborts it, the framebuffer naming it or not. So the accelerator starts as before but registers only once its bundle is on disk:

  • From its start, a thread call checks every 100 ms for the bundle's executable, /Library/GPUBundles/NAME.bundle/Contents/MacOS/NAME, NAME its MetalPluginName, and for the marker of the kext's wire version beside it, Contents/Resources/wire-version-N ("The wire's version"): nothing before the root file system is mounted (vfs_rootvnode), then a vnode_lookup of each. An executable without that marker is a bundle of another version, and counts as none. /Library/GPUBundles is on the data volume, which launchd mounts early in boot, well before it starts WindowServer, so with the bundle installed the accelerator is registered before WindowServer looks for a GPU.
  • WindowServer's first server connection to the framebuffer settles it. ReimsGraphics::newUserClient has the accelerator check once more before IOFramebuffer makes the connection, with no lock held, and register at once where the bundle is there; WindowServer opens that connection before any of the accelerator's user clients. No check runs after it.
  • RgfxGate's install pass comes first. Where RgfxGate installs the bundle, nothing on disk counts while its install pass is under way: an update that keeps the wire version would find the old bundle and its marker before the pass drops the marker and rewrites the files, and WindowServer could then load a bundle mid-rewrite. RgfxGate publishes RgfxGateInstallDone on IOResources, false from the pass's start and true once the pass has ended, on every path (the installer and Recovery, a data volume that never mounts, a failed write). The check looks again while it is false. The settling connection waits up to 5 s for it, and leaves the accelerator unregistered for the boot where the pass is still under way. Without RgfxGate there is no property, and the check counts what it finds.
  • The framebuffer comes first too. A process's context reaches the device only through the framebuffer's rings, so the check registers the accelerator only once the framebuffer has started as well: its start has taken the device and brought its rings up (ReimsGraphics::hasStarted). The check says once in the kernel log when the bundle waits for it. A context opens only while the framebuffer is started (kIOReturnNotReady otherwise, taking no units), and a close that finds none started gives its context's units back at once: none has carried a message of the context since the device's last reset (a failed start's or the stop's), which dropped every context's objects ("Reset"). Seen on arm64 27.0.1, where an accelerator registered after ReimsGraphics' start failed had its contexts' messages and closes refused, and their units kept from use for good.
  • A bundle installed later takes effect at the next boot: a running WindowServer never sees a GPU appear under it. The guest's install puts the bundle in place and reboots.
  • x86-64's Recovery and installer composite in software. RgfxGate's x86-64 build installs nothing where /System/Installation exists, so the accelerator stays unregistered there and WindowServer draws Recovery's and the installer's windows on the framebuffer, at our mode. The bundle could not give them Metal anyway. Recovery's base system ships no IOGPU.framework, and our device subclasses that framework's IOGPUMetalDevice. Measured on the x86-64 15.4 and 26.6.2 recovery images: neither has the framework in /System/Library/PrivateFrameworks, and 26.6.2's dyld cache names no IOGPUMetalDevice. In 26.6.2's Recovery, /Library is a link to System/Volumes/Data/Library, a tmpfs that rc.temporaryDataVolume mounts. A probe build of RgfxGate wrote and tagged the bundle there and the accelerator registered. WindowServer then opened the bundle's executable and mapped it through RgfxGate's checks, but never opened the user client IOGPUMetalDevice opens (type 5), and it aborted at every launch with the screen black. In 15.4's Recovery, /Library is a directory on the read-only HFS root, /Library/GPUBundles stays on that root all boot (Recovery's RAM disks cover only other directories), and kernel_mount is not in the kernel symbol table Graft resolves. The installer's second stage, the boot after a Reinstall from 26.6.2's Recovery, is no full system either: it roots from the base system it copied into macOS Install Data (auth-root-dmg=file:///macOS%20Install%20Data/BaseSystem.dmg in its boot-args), a read-only APFS volume, with /Library on the same tmpfs. The probe build failed there as it did in 26.6.2's Recovery: registered, mapped by WindowServer, no type 5 user client, and WindowServer aborted at every launch with the screen black. With today's set, the accelerator stays unregistered there and the stage's progress screen draws. So the skip stays.
  • arm64's BaseSystem draws through Metal, so the bundle goes there too. On arm64 the kernel roots from the system volume and pivots onto the paired Recovery volume's arm64eBaseSystem.dmg on every boot (imageboot_pivot_image). launchd's select-boot-mode then leaves for the full system by a userspace reboot, which keeps the kernel and its kexts, or stays: for FileVault's unlock (fvunlock: every cold start of a FileVault guest, and every restart but fdesetup authrestart's), for Recovery, and for the obliteration boot (eacs). That BaseSystem ships IOGPU.framework and Apple's GPU bundles, and its WindowServer composites with Metal only: with no Metal device it aborts 30 s after it starts, in SkyLight's WSSystemCanCompositeWithMetal, and launchd starts another, the screen black (measured on 15.6.1 with no RgfxGate: four aborts in four minutes, each at 30 s). So RgfxGate's arm64e build installs there as well. In the BaseSystem /Library is a link to System/Volumes/Data/Library on the tmpfs rc.temporaryDataVolume mounts from /System/Library/Templates/Data, whose Library/GPUBundles carries the rootless class. The pass first checks that volume takes writes (vfs_isrdonly, as the writes go below the VFS), then writes and tags the bundle there (3.7 ms on 26.6.2), and the accelerator registers as on a full system's boot.
    • AMFI refuses all but platform code in the BaseSystem, with a fatal description ("The system only allows platform binaries"). RgfxGate's signature hook admits the embedded bundle's cdhashes under /Library/GPUBundles or, as a BaseSystem's vnode path names it, /System/Volumes/Data/Library/GPUBundles. Where it admits the bundle past AMFI's refusal it drops that description: XNU's dispatcher panics on an answer of 0 that leaves one set (measured on 26.6.2: mac_vnode_check_signature: MAC hook returned no error, but status is claimed to be fatal, then a reset at every boot).
    • macOS 27's BaseSystem does not trust the bundle on that tmpfs by itself. IOGPU loads a GPU bundle only from a trusted path, and with SIP on libsystem_sandbox's gpu_bundle_is_path_trusted asks the Sandbox policy, through mac_syscall(2) call 2, whether writing the path is rootless protected for the storage class KernelExtensionManagement. 14, 15 and 26 answer yes for the tagged bundle on the tmpfs; 27 answers no (measured on 27.2.1, m3-max-35795: the bundle written and tagged, the accelerator registered, WindowServer reading MetalPluginName, then aborting every 30 s with the unlock screen black). RgfxGate's arm64e build routes the Sandbox policy's policy_syscall through Graft (0.4.0 and later) and, while the root is the BaseSystem, answers yes for exactly that query on a path under the bundle; every other call, and every call on a full system, goes to the Sandbox policy's own handler (wrapSandboxPolicySyscall, rgfx_rootless_trust_ours). Each install pass clears the answer and only the BaseSystem's pass sets it, so the full system's pass after the unlock hands the query back to the Sandbox policy. With it, on Graft 0.4.0, the unlock screen draws on 27.0.1 and 27.2.1 and the password reaches a desktop drawn with Metal 3 on our device (m3-max-37114 and m3-max-37206).
    • After that pass RgfxGate watches the Data volume (the file system of /Library/Preferences, every 100 ms) and passes again on each one the boot moves to without restarting the kernel: the full system's, once the password unlocks it (rgfx_pass.h). The watch ends once the root is a full system whose Data volume has had its pass. A boot that starts in its full system has no watch: RgfxGate starts after its userspace reboot.
    • The accelerator stays registered across the userspace reboot, so the full system's WindowServer finds a GPU before that system's Data volume has had its pass, and that volume can hold another build's bundle, which RgfxGate's hooks do not admit. Metal reads the accelerator's MetalPluginName before it loads the bundle (IOGPU's +[IOGPUMetalDevice registerAcceleratorService:], from Metal's IOServicePublish notification on IOAccelerator), so that read is the order: while the watch runs, each of its passes publishes the id of the root file system it ended under as RgfxGatePassRoot on IOResources, false once the watch ends, and the accelerator holds a process's read of MetalPluginName, alone or with its other properties, made on any other root until the pass of that root has ended, up to 10 s (rgfxMetalNameWaits). A read in the kernel, and every read on a boot that starts in its full system, goes on at once.
    • Measured on clones of FileVault guests whose Data volume held an older build's bundle. On 26.6.2 (m3-max-35539) the unlock screen draws, the password unlocks, and the full system's pass replaces the bundle, ending 0.35 s after launchd commits the full system's boot; WindowServer starts after it, and the desktop comes up on our GPU. A second unlock cycle in the same VM finds the bundle current. On 15.6.1 (m3-max-35462, before the hold) the pass ends 0.42 s after that commit. With the full system's pass held back 8 s by a probe build (26.6.2, m3-max-35615), WindowServer read MetalPluginName before the pass ended, was held 5.1 s until it had, and then loaded the new bundle, with no abort.
    • Of the boots that stay in the BaseSystem, an arm64 guest on Ambrosia meets FileVault's unlock and the obliteration boot, not Recovery: Ambrosia boots no recoveryOS (its README and docs/internals/replacing-iboot.md), and the guest's nvram recovery-boot-mode=unused sets nothing (measured on 26.6.2, m3-max-35539: the variable reads back as absent, and the restart is FileVault's unlock again).
    • x86-64 is unchanged: its RgfxGate and ReimsGraphics binaries are byte-identical to the build without these.
  • Unregistered, the accelerator refuses every user client (kIOReturnNotReady): a task can still reach it by the framebuffer's IOAccelTypes path.
  • Neither the check nor its wait runs on the kext's start or the framebuffer's console path.

RgfxAcceleratorUserClient (guest/kext/src/RgfxAcceleratorUserClient.{hpp,cpp}) is our own transport, not Apple's IOGPU user-client ABI: the context's window ("Processes map only their own"), where the bundle's RgfxRegion / RgfxRingWriter write into real device memory, the device info (selector 0x10b), and externalMethod(kRgfxAccelMethodDoorbell), which writes a ring id to RGFX_REG_DOORBELL. These ids/selectors are defined in RgfxUserClientABI.hpp, which the kext and the bundle both include; the bundle's wire handshake opens them with IOServiceOpen / IOConnectCallStructMethod / IOConnectCallScalarMethod.

The accelerator's user client: its numbers. This table gives out every number of the 'RGFX' user client and of a shared event's port. A new selector takes the next free number here first, among the numbers below. A selector or a flag that a kext may lack gets a kext feature bit, which the kext sets in the second word Features answers once it carries it out, and the bundle uses it only where that word holds the bit. The numbers and the kext feature bits are in guest/kext/src/RgfxUserClientABI.hpp, which the kext and the bundle include.

Every number is one that every WebKit web-content sandbox lets its process call on an IOAccelerator connection, on every release from 11 to 26. WebKit's web-content profile (com.apple.WebProcess.sb, its IOAcceleratorMessageFilter) lists numbers on macOS 12 alone and refuses any other there before the kext sees it: from Safari 15.1 to 17.6 (WebKit 612.2 to 7618.3) every list holds 0-13, 15-18, 22-24, 28-31, 40, 42, 48, 256-265, 267, 268 and 512, the numbers Apple's own drivers take (17.6's adds 41, 43, 46, 49, 266, 269 and 513). On macOS 11 and from 13 on it lists none, and allows every number; its asynchronous methods (0 and 47 on 12) and traps the bundle makes none of. Read from WebKit's source at each release branch, and on 11.7.11, 12.7.6 and 13.7.8 guests. user_client_words_test holds the set, checks every number here against it, and checks that every IOConnectCall*Method in the bundle's sources names one of these selectors.

The numbers move only with the set: the bundle and the kext ship together. A move takes the next selector map number (kRgfxSelectorMap), which Features answers third, at a number it keeps in every map. A bundle whose map is not the kext's has no Metal device in its process, logged, rather than call a number that means another call there. Map 0, before the number, had SurfaceBlockRelease at 0x10a, SurfaceRetire at 0x10d, PagesBlock at 0x10e, Features at 0x10f, TakeAnswers at 0x112 and the port's selectors at 0x113 and 0x114, outside the numbers above: macOS 12's web content process could not call Features, took 64-id chunks where the kext granted 16, and had its textures past each chunk's first 16 ids refused (BadResourceId). A kext of map 1 gives none of those numbers a meaning, so a bundle of map 0 is refused at each.

Map 1:

number name kext feature bit what
0 Doorbell writes a ring's id to DOORBELL
1 Consumed 1 << 3 ConsumedDoorbell reserved: a completion ring's room doorbell (CONSUMED)
2 given to none: the IOGPU base's device-info call on its own client type, so a trace names one call per number
3 Features the device's feature word, the kext's and the selector map; at 3 in every map
4 PagesBlock 1 << 0 PagesBlock, 1 << 18 ImportAddresses (its third output, the GPU address the device gave the block's view, 0 for none), 1 << 19 UnchangingPages (its third input's kRgfxPagesUnchanging, kRgfxPagesCopyOnWrite and why), 1 << 20 SoleHolderPages (its third input's kRgfxPagesSoleHolder) a block of the runs of a process's own pages, wired, for its no-copy buffers; three inputs, the address, the length and how the memory is (kRgfxPagesWritable 1 << 0, kRgfxPagesUnchanging 1 << 1, kRgfxPagesCopyOnWrite 1 << 2, kRgfxPagesSoleHolder 1 << 3, and for read-only memory not unchanging why not in bits 8 to 11, kRgfxPagesWhyShift; none for read-only memory); two outputs, or three with its view's GPU address ("Import addresses")
5 SubmitBatch 1 << 1 SubmitBatch, 1 << 11 QueuePublish (three inputs and a second output: a queue's publish after them) a process's destroys, and its creates and writes no one waits for that name no block, onto ring 0 in one call ("Destroys and creates no one waits for go together"), and with three inputs a command buffer's publish on its queue's ring after them ("A commit behind held messages is one call")
6 WakeCompletions 1 << 2 WakeCompletions reserved: wakes the client's completion waiters
7 TakeAnswers 1 << 4 DeferredAnswers hands a process its held pipeline-create answers ("Known pipeline creates")
8 SurfaceBlockRelease lets go of a shared block
9 SurfaceRetire a queue's writes up to a seqno retire
10 Export, on a shared event's port ('RGSE') 1 << 6 SharedEvents names the caller's shared event for other processes ("Shared events across processes")
11 Import, on a shared event's port ('RGSE') 1 << 6 SharedEvents makes the caller's new shared event of the one the port names
12 PagesChunked 1 << 8 PagesChunked a block of the runs of 64 KiB chunks of the kext's own, mapped into the process, for its slabs
13 SurfaceSeeds 1 << 10 SurfaceSeeds an IOSurface's lock and unlock seeds, for a copy synced while a CPU held the surface locked for writing
15 CpuPats 1 << 13 CpuPats every online CPU's PAT, read on each CPU, for an administrator's process: the check that entry 2 is write-back everywhere ("The BAR is one host memory region"; the guest's guest/bundle/tools/pat_probe.c); x86-64 only
16 PoolTake 1 << 15 Pool, 1 << 16 PoolAddresses (its fourth output, the block's GPU address, 0 for none) a block of the Shared pool for the process's context, mapped into the process write-back once the host answers its POOL_TAKE, however long that takes ("The Shared pool"); three outputs, or four with its GPU address; kIOReturnUnsupported where the device offers no pool
17 PoolGive 1 << 15 Pool gives a pool block back: out of the process, then its POOL_GIVE
18 PrivateTake 1 << 17 PrivateBlocks a block of GPU addresses for the Private objects of the process's context, once the host answers its PRIVATE_TAKE, however long that takes ("Private blocks"); one input, the bytes, and two outputs, the block's GPU address and length
22 PrivateGive 1 << 17 PrivateBlocks gives a Private block back: its PRIVATE_GIVE, with the block's GPU address and length; 22 rather than 19, as macOS 12's web-content sandbox refuses 19 to 21
0x100 OpenContext 1 << 5 ContextSpan (its sixth output), 1 << 12 DoorbellPage (its seventh) the context and its window; five outputs, six with its GPU addresses' span, or seven with its doorbell page's address in the process, 0 for none ("BAR4: the doorbell pages")
0x101 Alloc 1 << 7 WriteCombined (its third input), 1 << 14 ZeroedBlocks (the block reads zero) a region block; 2 inputs, or 3 with the byte its write-combined part starts at
0x102 Free frees a block
0x103 QueueCreate a command queue; 6 inputs, or 7 with the flags wanted
0x104 QueueDestroy closes a queue
0x105 Submit 1 << 4 DeferredAnswers (its deferred flag), 1 << 9 SharedPipelines (its shared flag: the pipeline key in four more inputs, and a second output) one lifecycle message onto ring 0
0x106 ResourceIds a chunk of texture resource ids, and with a second output its size
0x107 WaitCompletions waits for the client's completions
0x108 SurfaceScanout the scanout an IOAccel surface is drawn into
0x109 SurfaceBlock an IOSurface plane's shared block
0x10b DeviceInfo the device info and video caps
0x10c SurfaceWrites the surfaces a command buffer writes

A shared event's port is a connection of a second type, 'RGSE' (0x52475345), on the accelerator, which the bundle opens for each event it hands out: 10 and 11 are its own selectors, numbered apart from the accelerator's own so that a call on a connection of another kind finds none of that number there.

The kext sets 1 << 0 PagesBlock, 1 << 1 SubmitBatch, 1 << 4 DeferredAnswers, 1 << 5 ContextSpan, 1 << 6 SharedEvents, 1 << 7 WriteCombined, 1 << 8 PagesChunked, 1 << 9 SharedPipelines, 1 << 10 SurfaceSeeds, 1 << 11 QueuePublish, 1 << 12 DoorbellPage, 1 << 13 CpuPats, 1 << 14 ZeroedBlocks, 1 << 15 Pool, 1 << 16 PoolAddresses, 1 << 17 PrivateBlocks, 1 << 18 ImportAddresses, 1 << 19 UnchangingPages and 1 << 20 SoleHolderPages, SurfaceSeeds only where the release's IOSurface exports its unlock seed, CpuPats only on x86-64, and Pool and PoolAddresses only where the device has a pool; no other bit yet.

Where the device offers no POOL (an arm64 guest on a Windows host), the kext sets no Pool bit, selector 16 answers kIOReturnUnsupported, and its processes keep the region's blocks and the kext's chunked pages. A take waits for the host's answer with no deadline, THREAD_UNINT, where the kext's other asks behind the host's work wait with none interruptibly (How a waiter waits): the host answers each take of an open context, and the context's close waits for its takes in flight. Where the host stops answering, each taking thread waits until it answers, holding one of the kext's 16 waiters for the device's own asks, and a kill of its process completes only then; other threads and processes go on, their asks ending at their processes' kills. A paused VM runs no guest thread. The device's reset ends a take unanswered, but the kext resets the device only at its start and its stop, when no process holds it open, and a VM's reset restarts the guest.

A GL window: the drawable (type 7) and the window surface (type 0x20). These are IOGPU's types, not ours. The bundle leaves newGLDrawable to its IOGPU base, which opens type 7. The kext serves both types (guest/kext/src/RgfxGLUserClients.{hpp,cpp}, with the rules in RgfxGLSurfaces.hpp and their native test). Measured on a macOS 26.6.1 guest, for window-backed and layer-backed NSOpenGLViews alike:

  • the app opens type 7, then its SLSBindSurface opens type 0x20 for the window's surface: SetIDMode(id, 0x4024), then SetShape with the view's size;
  • the drawable's set surface (selector 1) names that id. Its lookups (selector 5) of indexes 0 and 1 get two IOSurfaces, which the kext makes in the app's task;
  • the app draws into those IOSurfaces through the bundle, and WindowServer composites the window from them (screen dumps show the frames). It opens no user client of the accelerator for the window.

The rules are IOGPU's, read from IOGPUFamily's x86_64 code in the 26.7.1 KDK: the mode and shape checks, the request bits a drawable's mode gives, the eleven buffer slots and their formats, and when buffers are made again. Not served, each answering kIOReturnUnsupported:

  • surface modes of IOGPU's shared buffers (0x700000);

  • a drawable's scaled sources and shared events;

  • every surface method but SetIDMode and SetShape.

  • Boot-gated — base class / kernel family (notes UNKNOWN #1). The scaffold subclasses IOAccelerator, the base the macOS SDK and KDK expose (the IOGPU kernel family — IOGPU, its device/queue classes and its submission/ allocation user-client ABI — is Apple-private and in neither, so it cannot be subclassed or linked off the guest). On the guest the base very likely becomes the IOGPU family class per Decided 15; the Metal discovery keys, the PCI match and our region-map + doorbell user client are expected to carry over. The IOGPU user-client ABI is deliberately not invented here.

Stage 3 device control

RgfxDeviceControl (guest/kext/src/RgfxDeviceControl.{hpp,cpp}) is the third service on the PCI device, in a category of its own: an AppleGraphicsDeviceControl (AGDC), the System-KC library class AppleGraphicsControl.kext's plug-in defines. WindowServer's IOPresentment builds a display pipe only for a framebuffer whose PCI device has an AGDC, and AppleGPUWrangler pairs the AGDC with the GPU's record and sets its attribute 3 to its InitFlags. Without one, CoreDisplay logs "Unable to find display pipe for IOFB service" and WindowServer picks the software compositor. The kext names the library in OSBundleLibraries; the loader binds its base-class sites as it binds IOGraphicsFamily's. AppleGraphicsDeviceControl.hpp is our declaration of the base class, from the names and vtable order the KDK's x86_64 binary exports. The control answers attributes 1 (its description), 3 (what it makes), 0x301 (the wrangler's GPU index), 0x921 and 0x980 (which IOPresentment reads before it builds a pipe), and refuses the rest.

Open

  • Stage 3 bundle placement — RESOLVED: the bundle sits in /Library/GPUBundles and our accelerator's registry entry carries MetalPluginName/MetalPluginClassName. The library-validation boot state is settled: the install kext gives the bundle the rootless storage class so Metal trusts its path, and answers the library-validation, mmap and signature MAC checks for it by its code-directory hash, so WindowServer composites on our Metal device and Safari WebGL renders with SIP fully on and no boot-args ("Trusted-bundle gate", above; measured on msi, x86-64 macOS 26.6.1). Open: the exact IOGPU accelerator user-client ABI our kext exposes, settled by a guest experiment.
  • IOSurface details: whether the device-cache sync runs on every CPU access path and on unlock (window buffers wrapped no-copy are written without a lock); whether IOGPU accepts a device cache that holds a host handle and no guest pages; and which surfaces the guest CPU touches (probe on the Apple lane: KVM's dirty bits per mapped surface).
  • The PCI vendor:device ID the device ships with (owner call).
  • Owner calls, each with a recommendation once the evidence is in:
    • whether host device addresses are ever exposed.