An encode's frame at 1080p and 8 Mbit/s goes to the guest as two or more
16 KiB VT_MESSAGE events. Two of them do not fit the control completion
ring's 32 KiB at once, so an encode filled that ring about once a frame:
control-ring-full and control-ring-post-waited 592 times in an arm64 26.6.2
boot's encode bench (potluck job m3-max-38178). A full ring holds back the
display's VBLANKs and the presents' answers while the guest encodes.
Feature bit 54, VT_RING, which the device offers wherever its host offers
VT_MESSAGES and the arm64e kext takes with it, moves those messages into
the VideoToolbox ring: a 2 MiB ring at region offset 0x20000, in the room
between the control completion ring's span and the guest's allocations,
which the kexts already map with the control rings. It is the device's
memory, so the kext wires none of the guest's RAM for it and frees nothing
at the service's stop or its unload. Each message there is followed on the
control completion ring by a 24-byte VT_RING event (0x40f) carrying the
ring's count through it. The kext takes the ring through that count as it
takes the event, so the messages keep their place among the control
ring's events. A message that finds the ring full goes onto the control
completion ring as before, after the VT_RINGs of the messages ahead of it,
and the spell is counted as vt-ring-full. A guest or host without the bit
gets VT_MESSAGE events as before.
What the guest observes: the feature bit offered with VT_MESSAGES, and the
host's messages in the VideoToolbox ring with VT_RING events instead of
VT_MESSAGE events, in the same order.
The Mac mini's 11-15 outage during a recovery boot read as a hard hang
followed by a planned upgrade, from records filtered by time stamp. Those
records were the install night's, stamped from the firmware clock 8 hours
ahead before Windows first synced its time. In record order the log shows a
sleep, a wake and a power-button shutdown, and two recovery boots on today's
tree ran clean.
065432241 failed a command buffer at its begin where a record of its
UPLOADS_WRITTEN named no Managed buffer, or bytes past one. A buffer answered
CB_SUBMITTED at its doorbell has posted its CB_SUBMITTED and CB_SCHEDULED by
then, so it failed with them where a buffer its queue's thread took failed
without them: the fuzz caught it
(an_answer_at_the_doorbell_keeps_the_order_of_a_take, case 11 of the
default seed).
The record is dropped now, logged once, as the host drops a
BUFFER_DID_MODIFY_RANGE it refuses, and the buffer runs and completes as it
would behind that message, the same whether or not it was answered at its
doorbell. The records beside it are carried out. Only a guest that names an
object its bundle never made a chunk of sees the difference.
On a discrete GPU the bundle's set*Bytes chunks are Managed, and each
commit told the host the bytes written in each with a
BUFFER_DID_MODIFY_RANGE on ring 0 ahead of the buffer. That cost a
one-dispatch command buffer 41 to 44 us of commit-to-wait on the RX 7900
XTX and RTX 3090 hosts. Traced on the XTX, the held message's timer and the
kext call that posts it added 11 to 12 us each before the host took the
buffer, and the buffer then waited 18 to 26 us at the gate for the context
lane that carried the range out.
UPLOADS_WRITTEN (feature bit 53, FEATURES_HI bit 21) lets the buffer's own
stream carry them: op 0x000f, before the first encoder, as many
RgfxUploadWritten records (buffer, bytes from its start) as its length
holds. The host carries each out as the platform's didModifyRange: as it
begins the buffer, before its commit; a record that names no Managed
buffer, or bytes past one, fails the buffer, and none of its records is
carried out. Every host offers the bit and both kexts take it. The bundle
names the bytes there where its chunks are Managed, and sends the range
messages as before where the host did not offer it.
The guest sees the same results: the same bytes reach the GPU's copy before
the buffer's work. The host takes those ranges from the buffer, and ring 0
carries no range message for them.
On a Mac with a discrete GPU, Metal's driver copies setBytes: data into
the GPU's own memory: on the AMD Radeon Pro 5300M it read at 1.00x of a
Private buffer. A Shared buffer read over the bus came in at 1.05x at
4 KiB, and up to 1.5x at 64 KiB on a dependent chain (constant-read probe,
macOS 26.7.1). Our bundle put those bytes in Shared upload chunks in guest
RAM, so on a discrete host the GPU read every one of them over PCIe.
Where the device answers hasUnifiedMemory NO (the identity flag that also
makes the host keep two copies of a Managed buffer), a queue's upload
chunks are now Managed buffers. The arena notes how far each chunk's runs
filled it as the runs end. At each commit it sends a didModifyRange: of
each chunk's written extent, which goes on the control ring ahead of the
command buffer. The host's Managed path then copies that range into the
GPU's copy before the buffer's commands. A chunk still goes back to its
pool only once the host has completed its buffer, so a later buffer never
rewrites bytes an earlier one is still reading.
What changes for the host on such a device: the chunks' creates carry
Managed storage, and each commit that used set*Bytes is preceded by one
BUFFER_DID_MODIFY_RANGE per chunk it used. Hosts whose GPU shares the
CPU's memory see no change.
The NVIDIA arm read each encode source as host bytes and copied it with the
CPU into an NVENC input buffer; a source in a device cache went through a
staging copy first. The runtime device's GPU now copies the source's planes,
where they lie, into an exportable buffer that CUDA imports and NVENC
registers as input (nvEncRegisterResource, a CUDA device pointer, mapped for
each frame and unmapped once its bitstream is locked), as the VA-API arm
fills its input surfaces (cee727b5e). A frame whose copy is declined is
uploaded as before, with the reason logged once a session; a session whose
input CUDA or NVENC refuses uploads from then on.
NVENC codes the same bytes either way: the new hardware test
each_frame_filled_by_the_gpu_encodes_as_uploaded compares every access
unit of H.264 High and HEVC Main at 1080p, from pages and from a device
cache. The guest sees the same results sooner: on um870's RTX 3090,
VideoToolbox's H.264 encode of 300 frames went from 88.7 to 156.5 fps at
1080p (6 Mbit/s) and from 24.6 to 40.5 fps at 2160p (30 Mbit/s), each
stream byte-identical in size and in PSNR against the source.
An arm64 guest's VideoToolbox encoder read each source frame through the host's
view of the IOSurface's pages, and the VA crate's encoder uploaded it by the
CPU. The runtime device's GPU now copies the frame's two planes, in place, from
a Shared buffer over the surface's pages (LentViews::buffer_over, kept with the
session's view of the surface) into an input surface of the encoder's, as an
x86 guest's frames are filled (cee727b5e). Where the device makes no such
buffer, or the copy is declined, the frame is uploaded by the CPU as before,
said once a session; an input surface whose fill failed on the GPU stays out of
the encoder's pool.
What the guest sees: the same samples, byte for byte
(a_guest_encoders_frames_filled_by_the_gpu_code_as_read_by_the_cpu, on the
780M's radeonsi, m3-max-38046; in the boots below, the same bytes for each
stream), at a higher rate. A macOS 26.6.2 guest under TCG on the 780M, 120
frames at 1080p and 8 Mbit/s, two runs each: H.264 45.5 and 47.8 fps before,
49.6 and 49.0 after; HEVC 52.9 and 51.9 before, 57.9 and 57.2 after
(m3-max-38122, m3-max-38178). Each fill took 0.14 ms of GPU time.
The encoder list named this host's encoders by IDs of their own
(reims-vgpu-video.videoencoder.avc), which the guest registered as
paravirtualized:<ID> and never opened. On a macOS 26.6.2 guest on the 780M, a
compression session that requires a hardware encoder failed with
kVTInvalidSessionErr, one that allows one got a software encoder, and no +enc
reached the host (m3-max-37910).
The guest's own two paravirtual encoders, the hardware encoders its apps get
(VTVPParavirtualizedH264VideoEncoder and its HEVC twin), open the registered
encoder of Apple's AVE ID, com.apple.videotoolbox.videoencoder.ave.avc or
.ave.hevc, and send that ID as ,cid (read from VideoToolbox's code on macOS
27). The list now names each encoder by that ID, and a create takes that ID or
none, and refuses this host's former IDs.
What the guest sees: `encs` entries whose CMClassImplementationID is Apple's
AVE encoder's; nothing else in the entries changes.
An arm64 guest's VideoToolbox now finds a hardware encoder for each codec the
host's VA-API driver encodes a profile of: `encs` lists
reims-vgpu-video.videoencoder.avc and .hevc, which the guest registers as
paravirtualized and hardware-accelerated, and a create of one (by that ID, by
Apple's hardware encoder's, which the guest's own paravirtual encoders send,
or by none) starts an encoder session instead of being refused with
kVTCouldNotFindVideoEncoderErr.
Each session's encoder is the arm's GuestEncoder: on VA-API, the VA crate's
VideoEncoder, made from the settings the session's properties make, `Quality`
onto the driver's quality levels as the device's `quality` maps. Each source
frame is read from the host's view of the IOSurface the guest lent with its
`efrm` (vt.rs's VtEncoderBackend, through the decoders' kept views) and
uploaded; the session emits the samples and lets go of the surface. A change
of the bitrate, frame rate or key-frame interval reaches the encoder from the
next frame; one that makes a new sequence makes a new encoder before the first
frame and is refused after it.
The device's features are unchanged: VT_MESSAGES is still offered where a
decoder is listed, and the arm64e kext still serves macOS 26 and later alone.
A Windows user's folder can hold a space (C:\Users\First Last), and QEMU's
configure refuses a source or build directory with one ("main directory
cannot contain spaces nor colons"). With the library fixed, a user's install
would stop there next: install-ctl.sh builds QEMU in ~/.cache/reims-ctl, in
that folder. With the checkout in the folder too, as install.ps1 clones by
default, sdl3-sys stops first: it finds no SDL3, as a space splits the -L
path of the pkg-config file it reads. Both measured on the mini with a profile
named "Test User". No alias keeps the space out: meson takes realpath of its
directories, which turns an 8.3 short name back into the long one, and a volume
can have no short names (the mini's P: has none).
install.ps1 now clones into C:\reims-vgpu where the user's folder has a space,
saying so, and stops on a -Checkout with one. install-ctl.sh on Windows builds
and stages QEMU in the target directory where the cache directory has a space,
and stops before any download or build on a checkout or CARGO_TARGET_DIR with
one, naming the folder to use.
A user's install of development on Windows stopped in sdl3-sys's CMake build:
their environment's CC named Visual Studio's cl.exe, cc-rs gave the build
MSVC's C flags (and clang's C++ flags, CXX being unset), and CMake, which
reads CC itself where the cmake crate names no compiler, took cl.exe. Its test
compile failed once MSYS2 had turned /nologo into C:/msys64/nologo. Visual
Studio's install alone does not do it: cc-rs takes cl.exe from it for MSVC
targets only, and our hosts set no CC, so no run of ours met it.
install-ctl.sh on Windows now sets CC, CXX and AR, their per-target forms that
cc-rs takes first, and CMake's generator, to CLANG64's clang, clang++, llvm-ar
and MSYS Makefiles, for cargo's build scripts, CMake, QEMU's configure and
meson alike. The generator is the one the cmake crate chose with none set, and
CLANG64's ar is llvm-ar, so a host without those variables builds as before.
A checkout Git for Windows made before .gitattributes holds every text file
with CRLF line ends (its installer sets core.autocrlf=true), and git does not
write a file again where a later checkout leaves it unchanged: .gitattributes
has it compare the file as LF, so it finds nothing to do. A clone at
core.autocrlf=true moved to the commit that added .gitattributes kept all 1730
text files CRLF, and the build would have failed on the .metal sources' hashes
as before.
install-ctl.sh on Windows now writes each text file whose working copy differs
from its commit only in its line ends out again from the commit, after the
update and before any build, and keeps a file with changes of its own.
vendor/qemu moves from e8ae598e to f56d36ff: c3704402 and f56d36ff.
On an AMD host Hyper-V refuses WHvX64RegisterTscDeadline while its CPUID
offers the TSC deadline timer, and a macOS guest that arms that timer waited
for interrupts that never came: the VM booted only with -tsc-deadline added
to vm.toml's cpu_flags by hand, which 9db299bdb's docs/qemu.md said reims-ctl
did not do. From c3704402 WHPX asks Hyper-V for the register at its init,
of a vCPU made for the question, and where it is refused offers the guest no
TSC deadline timer: the CPU model's tsc-deadline is filtered out as any
feature the host lacks, with check's warning, and the guest arms the local
APIC's timer. It follows Hyper-V's answer, not the host's vendor. On such a
host the guest's CPUID loses the tsc-deadline bit; where Hyper-V takes the
register, as on the Mac mini 2018, nothing changes. The AMD side is read from
code and pull request #15's report, not run here.
f56d36ff corrects 40257041's comment on the SYSENTER MSRs: QEMU's copy of
their 64 bits answers only a read that faults as well, until the vCPU's next
full register read, and a read Hyper-V answers itself gives the low 32.
docs/qemu.md's table and its AMD host notes now say so, and that only each
vCPU's reset sets the TSC deadline register, where 9db299bdb said every
register sync logged its refusal.
A refused vkCreateSwapchainKHR, or a refused wrap of the new swapchain's
images, retires the old swapchain all the same, and the remake keeps it among
the retired until its last present is known complete. Vulkan keeps a retired
swapchain associated with its surface until it is destroyed, and refuses a
create with no oldSwapchain while the window has a swapchain
(VK_ERROR_NATIVE_WINDOW_IN_USE_KHR; read from the specification of
vkCreateSwapchainKHR and VkSwapchainCreateInfoKHR, not seen on a host). So
the next remake, with no current swapchain to hand over, was refused for as
long as the retired one lived; on a device without present fences, with
nothing new presented, nothing ever made its presents known complete, and
the window kept its last frame for good, as 245a1ebb6's refusal before the
create did. This is the other half of that class, found in review.
A remake with no current swapchain to hand over now destroys the retired
ones first, waiting for their presents as the swapchain's end does
(end_retired, which Drop now calls too). It runs only after a refused create,
since every other remake hands a current swapchain over.
a_make_after_a_refused_create_ends_the_retired_swapchains_first runs it in
the model window system. docs/lessons.md's entry for 245a1ebb6 says so.
Neither x86 Mac's Metal device responds to gpuCoreCount: the AMD Radeon
Pro 5300M's and the Intel UHD 630's answer respondsToSelector: NO under
macOS 26.7.1 (oracle_caps, m3-max-37201 and 37202). The bundle has
answered it on every guest since f692b4de0, from the M3 Max's answer,
the one device it was measured on then.
What the guest now sees: an x86-64 guest's device does not respond to
gpuCoreCount, and a call raises an unrecognized selector, as on the
x86 Macs, where it answered the host's count (a GPU's CUs or SMs, 0 on
Intel). An arm64 guest's device, an Apple GPU's, answers the host's
count as before.
On a GPU that shares the CPU's memory every IOSurface device cache fitted
the deferred blocks' budget, a quarter of the GPU's memory budget at the
device's start. On a Radeon 780M with an 8 GiB guest that is 1385 MiB, and
Safari's and a WebGL page's surfaces went past it (454 blocks): those late
surfaces lay in place in the guest's pages, and the WebGL page's frames
fell from 33.0 to 24.6 a second, below development's 32.6. With no bound
the caches held 1762 MiB at most and the frames ran at 33.0 (jobs
m3-max-38032, 38033 and 38034).
The caches now fit half of the budget, twice the deferred blocks', which
stay at a quarter, so the DEFERRED_BUDGET registers read as before. The
budget is read past the guest's RAM, which QEMU preallocates, so the caches
stay bounded on a small host.
Decided 14 and the feature bits now say what the device answers since
4cd77f6aa. A host whose GPU shares the CPU's memory offers SURFACE_CACHE
and SURFACE_DEFERRED, as a Mac on an Intel GPU keeps its own copy of each
IOSurface (the UHD 630's lock, fill and memory numbers, jobs m3-max-37817
and 37822), within the caches' budget. No host offers
SURFACE_CACHE_REFUSED now, and the decoder's module docs and the video
device doc say so.
On the desktop, the device's lanes walk WindowServer's command buffers at
about 120 us per render encoder on a Zen 4 host, and the walk is bound by
instruction fetch: the code it runs is spread over far more 4 KiB pages
than the L2 iTLB holds. Placing that code in the order lld's call-graph
clustering gives it, from a profile of the desktop, makes the walk faster.
Linux's dist now reads crates/reims-vgpu-c/link-order.txt, the library's
functions one a line as GNU nm -C prints them without crate
disambiguators, and in the objcopy call that localizes the archive's object
renames each listed function's section to .text.sorted.NNNNNN in the
list's order. GNU ld's default script sorts those by name ahead of the
rest of .text, so make qemu and install-ctl.sh's QEMU get the order with
the compiler's default linker; a linker that does not sort them keeps the
order it had. dist prints how many of the list's functions it placed: a
function no longer in the archive is skipped, so a stale list loses speed
and never fails the build. The list survives a metal2vulkan pin move,
whose crates change only their disambiguators.
cargo xtask link-order BINARY CALL_GRAPH (Linux) writes the list from a
QEMU lld linked with --call-graph-ordering-file, after this tree's dist;
docs/development.md, "The link order", says how to refresh it. With no
list the archive is as before.
An arm64 guest's VideoToolbox now decodes H.264 and HEVC on an NVIDIA host's
GPU, as it does on VA-API. The NVIDIA arm answers a GuestDecoder for each codec
NVDEC decodes: a decoder of whole access units of its own, whose picture lands
in the IOSurface the kext lent, laid out as the kext read it and checked
against its memory (GuestTarget). The GPU writes it there, one cuMemcpy2D a
plane into the view of the surface's pages registered with CUDA, as it writes
an x86-64 guest's output pages; where CUDA refuses the view, the picture is
read back and copied by the CPU, each reason logged once a decoder. NVIDIA's
errors reach VideoToolbox as bad data, unsupported or a malfunction.
What changes for the guest: on an NVIDIA host, where NVDEC decodes H.264 or
HEVC, the device offers VT_MESSAGES, and a macOS 26 or 27 arm64 guest's
VideoToolbox lists our decoders as hardware (VTIsHardwareDecodeSupported is
true for avc1, and for hvc1 where NVDEC decodes HEVC) and decodes on them.
Before, an NVIDIA host offered no bit 52 and listed no decoder, so they
decoded in software. An x86-64 guest takes no bit 52, as before.
Brings in pull request #159, for a Windows host on an AMD CPU: 245a1ebb6
keeps the window's swapchain when its remake refuses before the create, and
9db299bdb takes vendor/qemu's 40257041, which keeps an Intel guest's MSRs
that Hyper-V refuses on an AMD host. A merge commit by the owner's one-time
exception (2026-11-16).
vendor/qemu moves to e8ae598e, the merge of this branch's 500d30fb with
GitHub's steelbrain/reims-vgpu-rebase-2 (5970afb4, pull request #15), so it
holds both WHPX changes. swapchain.rs, docs/lessons.md and docs/qemu.md
merged without conflicts.
The host's side of VideoToolbox's paravirtual protocol gains encoder sessions
(`+enc`), the half C2's VA-API backend encodes on:
- the properties a guest's compression session sets (`esup`, `ecop`, `eset`,
`emul`), in the shape Apple's hardware encoder answers them, made into the
codec's EncoderSettings on a 90 kHz clock;
- `esta`, which opens the backend's encoder at the frames' size, rounded down
to even, and asks for video-range source buffers (`Epba`);
- `efrm`, which encodes the frame's lent surface and holds it until the frame
is both encoded and emitted; `ecfr` and `einv`;
- emission: `Efds` for each new configuration record, then `Eemt` with a
sample buffer of the guest's own times, in 16 KiB fragments.
What the decoder and encoder sessions share (the session's handle, its thread
and queue, the host's requests) moves out of decoder.rs into session.rs.
SampleBuffer gains a writer that its reader reads back.
Nothing changes for the guest: the encoder list names encoders only for a host
given an encoder backend, the device gives none, so `encs` still lists none
and `+enc` is still refused with kVTCouldNotFindVideoEncoderErr.
vendor/qemu moves to 500d30fb: QMP's and HMP's screendump copy the console's
surface under the BQL, then encode and write the copy on a thread of the
pool with the BQL let go. Encoded under the BQL, a PNG of 2880x1620 held it
about 120 ms on the Mac mini 2018 (a busy desktop's up to 1.7 s). A vCPU
that touched another device's MMIO, which takes the BQL, waited as long, and
an on-screen app's frames with it. That happened even with the device's
interrupts and doorbells off the BQL (the two commits before this): a
present_probe run lost 116.7-157.9 ms at its screendump in 4 of 5 runs, and
a build that logged the BQL's waits found a vCPU waiting 127 ms at another
device's register (0x806492b4) while the present loop stalled 133-283 ms.
For the host, a screendump's file is the same: the frame the console's
update left, now copied before the BQL is let go. reims-ctl's terminal
viewer, which takes PPM screendumps, no longer holds the guest's vCPUs while
each is written. docs/qemu.md says so and corrects the measured numbers of
the commit before this, which were 2 runs that missed the wait.
The commit before this sent the device's interrupts off QEMU's main loop on
WHPX. It left the gap: a QMP screendump in PNG still cost an on-screen app
116.6-133.7 ms of frames on the Mac mini 2018 (UHD 630), against 128-148 ms
before. The vCPUs were the ones waiting. WHPX's vCPU loop took the BQL
before each run of a vCPU, so a vCPU that exited to the device's lockless
BARs, to ring a doorbell, waited the 111-123 ms png_save held it. A build
that logged those waits measured them at every screendump, while 8191 of
8192 interrupts went out directly.
vendor/qemu 0fdbf381: with kernel-irqchip and no interrupt request pending,
whpx_vcpu_pre_run skips its locked section, as kvm_arch_pre_run does with
KVM's in-kernel irqchip. With both commits, the probe's gap max at the
screendump is 33.7-34.0 ms, 60.0 fps and 0 dropped, the same as KVM's on
ms01's Iris Xe (33.3-33.7 ms). What the guest sees is the same interrupts
and the same MMIO answers, with no wait while QEMU's main loop is held.
On Windows the device sent every interrupt through a BH in QEMU's main loop,
since WHPX has no irqfds. A QMP screendump in PNG of the 2880x1620 display
held the main loop about 120 ms in png_save. For that long the guest took no
completion and an on-screen app's nextDrawable blocked: a 117-145 ms gap
(7 refreshes) in all 6 present_probe runs on the Mac mini 2018 (winbench,
11-15). The same screendump under KVM, where the irqfd injects the
interrupt, cost no frame on ms01's Iris Xe (6 of 6 runs, gap max 33.3-33.7
ms, m3-max-37378).
vendor/qemu 243971f2: on WHPX with the hypervisor's APIC the raising thread
requests the vector's MSI from the hypervisor itself, with no BQL, keeping
the BH for a masked vector, disabled MSI-X and a refused request. What the
guest sees is the same interrupt, sent sooner when the main loop is held.
The remake retired the old swapchain whether or not the new one was made,
and the make can refuse before vkCreateSwapchainKHR, where the window's
surface has no pixels for now. Vulkan was never handed the old one, so it
stayed the window's, and each later remake, with no current swapchain to
pass as oldSwapchain, made one beside it, which Windows refuses while the
old one lives (VK_ERROR_NATIVE_WINDOW_IN_USE_KHR). On a Ryzen 5 5600G host
with an RTX 3060 the window kept the macOS installer's last frame from the
guest's reboot on, while QMP's screendumps followed the guest, and drew
nothing on a minimize and restore; the log held the one refusal a refusing
swapchain logs.
A make refused before the create now leaves the old swapchain the current
one, stale, so the next remake hands it over; one refused by the create or
the wrap of its images retires it, as before. No unit test reaches the
swapchain without a window system, and the fix is not yet checked on a
VM boot; docs/lessons.md records the trap.
A macOS guest under WHPX on a Ryzen 5 5600G stopped at the Apple logo with
no progress bar: Hyper-V on an AMD host answers with #GP the kernel's write
of a 64-bit address to IA32_SYSENTER_EIP and its read of IA32_MISC_ENABLE,
and the kernel panicked before its console was up. vendor/qemu's 40257041
intercepts such a #GP by default where the host is not Intel's and keeps
those MSRs as KVM does for an Intel guest on AMD. The guest then reached
Recovery, installed macOS 26 and reached Setup Assistant on that host.
docs/qemu.md records the commit, the panics, and the TSC deadline timer
Hyper-V gives such a guest no register for, which the VM's CPU flags drop
for now (-tsc-deadline).
An arm64 guest's VideoToolbox now decodes H.264 and HEVC on the host's GPU.
The host offers VT_MESSAGES where VideoToolbox's paravirtual path lists a
decoder: where the video arm lands decodes in the surfaces the guest lends,
on VA-API. Each decoder session decodes on a GuestDecoder of the arm, through
the VA crate's decoders, and lands its picture in the lent IOSurface through
a view of its guest RAM pages: written there by the driver's video
processing where its import check takes the surface's layout, else read back
and copied by the CPU. A session keeps the views of the last eight surfaces
it landed in.
What changes for the guest: on a VA-API host, a macOS 26 or 27 arm64 guest's
VideoToolbox lists our decoders as hardware (VTIsHardwareDecodeSupported is
true for avc1 and hvc1) and decodes on them. The arm64e kext publishes the
service on macOS 26 and later alone, so macOS 14 and 15 decode in software
as before. Before it lends a surface, the kext takes a read-write CPU lock of
it and lets it go, as a process would: the surface's seed moves, and a
device cache of it is filled from its pages again at its next use, once the
host's picture is there. An NVIDIA host, whose arm lands no such decode yet,
offers no bit 52 and lists no decoder; an x86-64 guest takes no bit 52.
macOS 12 and 13 guests' iconservicesagent and com.apple.dock.extra send
the device's private compileVisibleFunction:withDescriptor:error: at
start-up, from Metal's own link of Core Image's kernels, and the bundle
answered it unsupported while supportsFunctionPointers answers YES (17
boots of 11-15/16). Both x86 Macs answer each of its three forms with no
error for any function and descriptor, keep the function in the archive
of the archive form, and call the handler form's one-argument handler
with nil on the caller's thread (oracle_binfn, macOS 26.7.1, Q47).
What the guest now sees, where the host makes function pointers:
- the three compile forms answer as the Macs do and compile nothing,
as the host compiles a binary function where a pipeline links it;
the archive form keeps the function as addFunctionWithDescriptor:
keeps it, and the handler runs before the call returns;
- newComputePipelineStateWithAdditionalBinaryFunctions:error: answers
the pipeline itself, as the AMD 5300M's does (the Intel 630 makes
another; the Macs diverge), where it answered nil and an error;
- the device's functionHandleWithFunction: and its resource-index form
raise an unrecognized selector, as both Macs' devices do, where they
answered nil.
Where the host makes none, each answers the unsupported error as before.
A decoder session writes each picture into a buffer the guest's VideoToolbox
lends with its message. The arm64e kext's service now looks up each IOSurface
ID a send names in the client's task, holds the surface with its memory
wired, and carries it in the VT_MESSAGE as an RgfxVtSurface record (the
lend's name, the surface's ID, pixel format, size and two planes) and the
runs of its pages. It lets go of a lend when the host's rels names it, of a
message's lends at once where the message never reached the ring, and of
every lend at its stop.
The device reads each record with its runs and checks that the record's lend
is the one the message names. reims-vgpu hands the lent surfaces to the
paravirtual host, which lets go of them where no session takes the message,
and sends their rels itself where the message's runs lie outside guest RAM.
The host still offers no VT_MESSAGES, so no guest sends any: nothing changes
for a guest or the host until a backend lands in the lent pages.
Item 17 of the design pointed at an old doc at a tag for the list of
VideoToolbox's paravirtual messages. The doc now says what carries them and
what reads them on the host: the device's rings and reims_vgpu_video's
paravirt module.
The paravirtual route's second piece: the host's side of a guest decoder's
session, so that a backend over the host's video arm can serve VideoToolbox's
decodes next. reims_vgpu_video::paravirt gains:
- decoder: a `+dec` session on a thread of its own. dsta starts it once from
the format description's avcC or hvcC, refusing 3-byte NAL unit lengths and
H.264 field pictures, and sends Dpba first; dfrm asks the guest for a buffer
(Dbuf), has the backend decode the sample's access unit into the surface it
lends, emits the frame (Demt) and lets go of the surface (rels), Dfub
naming a buffer left unused; the guest's replies go straight to the request
that waits for them. dsup, dcop, dset, dcan, dinv and the rest are answered.
- image_description and sample_buffer: readers of the =fds and =sbf
parameters, with the serializer's known keys; plist reads binary property
lists within bounds of ours.
- Host::with_backend, under which a create of a listed codec opens a session,
and a close ends it.
Nothing changes for a guest: the device's host makes its Host without a
backend, so every create is still refused, and no host offers VT_MESSAGES.
An arm64 guest's VideoToolbox runs its codecs in a guest only where it finds
an AppleVideoToolboxParavirtualizationDriver service: it then sends the host
side `vtpv` messages, and lists and runs the host's decoders as hardware ones.
This is the first slice of that route (design.md, "Decided", 17).
The device gains feature bit 52, VT_MESSAGES: ring 0's VT_MESSAGE carries a
message in guest RAM runs to the host, and the control completion ring's
VT_STATUS answers it and VT_MESSAGE brings the host's messages back. The
arm64e kext publishes the service under display 0's framebuffer where the
guest took the bit and the host's caps list a decoder, with the user client
of Apple's kext's five selectors, read from its 15.0.0 build. The host's side
is reims_vgpu_video::paravirt: it answers the decoder list and each codec's
capabilities from the decoders the caps list, an empty encoder and motion
estimation list, and refuses session creates for now.
No host offers the bit yet: the host's caps code turns it on with decode
sessions, the next slice, so guests see nothing new. The x86 kext is
unchanged, and the option ROM's bytes too; its record takes the new header.
Every part a walk cuts is a submission to the driver and a job of its
scheduler, and a part cut while the queue still has work out starts no sooner
for it: on the RX 7900 XTX, Geekbench 7 cut 1,437 parts for Particle Physics'
111 buffers and 2,631 for Fluid Simulation's 882, 1,256 and 1,703 of those cuts
behind a part not yet seen complete, where the host's own Vulkan pass ran 111
and 882 jobs. On the Iris Xe, WindowServer's frames took 8.96 parts a buffer,
22,155 of 25,856 cuts behind incomplete work.
A queue now counts its command buffers committed and not seen complete
(QueueCounts::out; a place joins it at its commit and leaves it with its
completion handler). A walk cuts a part only while that count is 0, and goes
on into the part it is in otherwise; a buffer whose walk starts behind such
work is dealt in two chunks, one a thread, rather than a chunk each 4 KiB.
What the guest sees is unchanged: the same work in the same order on the
queue, the same events and read-backs in their parts, one CB_COMPLETE per
buffer after its last part. A buffer's parts are fewer and longer, so its
GPU span has fewer gaps. The cut tests keep their cuts through a test knob
(set_cut_behind_work); a_walk_cuts_no_part_while_work_its_queue_committed_is_out
tests the rule.
The docs said an arm64 guest lists no hardware encoder and refuses a session
requiring one -12908, as measured on arm64 macOS 27.0.1. Arm64 macOS 26 under
TCG lists Apple's own AVE encoders (ave.avc, ave.hevc) as hardware and fails
such a session -12903, with the arm64e set before H.264 encode and after
(m3-max-37133, m3-max-36944): the OS's own answer, with no encoder behind them
in a VM. devices.md and design.md now say so.
An H.264 stream the guest encoded on the host came out at about 83% of the
average bitrate asked: 6.6 Mbit/s for 8 Mbit/s at 1080p, 25.9 for 30 at 2160p.
AppleGVA's rate control reads a word of the length record the driver fills,
at +0x3c, whose name nothing states; the driver wrote only the access unit's
length in bits at +0x6c, so with 0 there AppleGVA kept one QP a session.
The driver now writes the access unit's bits at +0x3c too. What the guest
sees: AppleGVA moves its QP each frame toward the session's average bitrate,
as on an AMD Mac. On a macOS 26.7.2 guest on an Iris Xe host (m3-max-37343):
asked came out per second over 10 s
8 Mbit/s 1080p, 120 f 8.42
4 Mbit/s 1080p, 120 f 4.22
6 Mbit/s 1080p, 300 f 6.17 7.11, then 5.87 to 6.25
30 Mbit/s 2160p, 300 f 30.44 35.37, then 29.07 to 30.24
A Radeon Pro 5300M Mac's streams came out at 100% to 104% of the asked. Of
each word from +0x04 to +0x68 written alone, only +0x3c moved the QP; of the
values tried there (the bits, the bytes, the QP, 1), the bits came closest to
the asked bitrate (m3-max-36997, m3-max-37146).
The driver's checks gain +0x3c's bits on a published frame and 0 on a failed
one.
Each slab of the process's own pages is a pages block the host maps as a
view of its own and imports once, and RADV and ANV on i915 list every
live import in every kernel submission. A class's slabs stopped at 2 MiB
and every buffer past 1 MiB took a slab of its own, so a process with
many large buffers held as many imports. Where the kext gives chunks, a
class's slabs now grow, doubling, to 16 MiB (256 chunks, one dma-buf at
udmabuf's stock limits), each one heap, and a buffer of up to 4 MiB lies
in them; the region's slabs, and slabs of plain pages, keep their 2 MiB.
A class's slab past 2 MiB is never plain pages: where the kext gives no
chunks it is the region's, of 2 MiB at most.
A guest command buffer the walk cuts into parts went to the GPU as one
kernel submission a part: on the Iris Xe's animation page a waited buffer
took about 11.6 vkQueueSubmit calls of about 180 us each on ANV. Nothing
observes a part's completion but its own handler, which notes its GPU times
and error for the last part's record and lets its place among its queue's
command buffers go; the last part carries every record, ticket and signal
the guest sees.
So each part but the last is marked to join the next one's completion
(CommandBuffer::set_completion_joins_next), and the runtime may send up to
four of a queue's parts found ready together, and the part behind them, in
one submission. Never marked: the last part; a part that waits for or
signals an event, by an op or from the buffer's begin (a device cache's fill,
another queue's buffer in the surface order); and a part the platform keeps
whole, whose commit is the whole's. The guest still sees its command buffer
complete at its last part's own end, with the same GPU times and the first
failed part's error.
Tests: a_buffer_s_parts_but_its_last_join_the_next_completion_unless_they_
signal and a_first_part_that_waits_from_its_begin_is_not_marked; the dealt
and kept-whole tests check which parts are marked.
The window's doc of tell_pointer still said the device holds a crossing's
positions for up to 100 ms; it is a second since the hold became the arm64e
kext's longest crossing. The design now says what that means for a cursor
the guest keeps hidden: it never shows on the pointer's display, so its
crossing holds the positions the whole second, while a captured game, which
drives the guest's mouse, is not held.
A crossing held the pointer's positions over the new display back from the
guest's tablet until the guest's cursor showed there, for 100 ms at most.
An arm64 guest under TCG had not shown it on display 1 100 ms after the
POINTER_OVER while the pointer went on over display 1's window: the
positions handed on then were scaled over display 0, where the cursor was,
and left it at their mirror there for good (macOS 26.6.2 at two displays,
potluck job m3-max-37089). The arm64e kext's crossing takes up to four posts
250 ms apart.
What changes for the host: CROSSING_HOLD_NS is a second, so a crossing
holds the positions until the guest's cursor shows on the pointer's display,
for a second at most; a position whose buttons changed still goes on at
once. x86-64 crossings, under a millisecond, and arm64 ones under HVF, under
40 ms, end the hold as before. The kext keeps its 100 ms bound for a
landing that may show the tablet's move, which still holds for a position
whose buttons changed; its comments and the design say so. features.md's
crossing entry says a second.
The device told a crossing onto a display once, until the guest's cursor
showed there. A crossing the guest did not carry out stayed told, so later
crossings onto that display were never told. On 15.6.1 under TCG
(m3-max-36608), a crossing onto display 1 that the kext missed left the
next uncaptured crossings and the captured drag onto display 1 untold. The
tablet put the cursor at the pointer's spot on display 0. The window began
driving the guest's mouse 130 ms into the drag, because the stale crossing
was minutes old and the crossing's hide counted from it.
Now a pointer over the cursor's display ends a told crossing and drops one
still owed, so the next move over the other display is told anew. Each
re-entry gives the guest a fresh POINTER_OVER for display 1, and the hide's
second counts from that one.
A post near its display's edge can show the cursor's image on the display
beside it before its own landing. The crossing waited only 50 ms on that
image before it posted again. Under TCG the landing comes later than that.
On 15.6.1, a captured drag back onto display 0 posted at its right edge.
The image showed at display 1's first pixel 7 ms after the post. After the
50 ms wait the crossing posted again, beside display 1. Display 0's landing
came 139 ms after the first post and was taken for the second post's
(potluck job m3-max-36695). In job m3-max-36608 such a landing agreed with
the second post's placement. Display 0 was confirmed right of display 1 and
the host was told so; its log shows it then sent the pointer back onto
display 1.
A post held by the image now waits for its landing as long as any post
does, 250 ms after the post, and at least 50 ms after the image. A
rearrangement still teaches a new place on the first crossing whose post is
held at the old place's edge. The tests that held the 50 ms wait change
with it, and a new one holds the drag-back case.
The guest hides its cursor on the display it leaves before it shows it on
the next. A captured window takes a cursor hidden on every display for 50 ms
for a game's, and hands its motion to the guest's own mouse, which the guest
accelerates. An arm64 guest under TCG showed the cursor on the next display
up to 491 ms after the POINTER_OVER, so every captured drag across displays
switched to the guest's mouse mid-drag: the cursor flew to a display's
corner or stayed on the display it left, and each show let the pointer go
one pixel outside the edge's reach, where the next move left again (potluck
jobs m3-max-36283, m3-max-36434 and m3-max-36435; x86-64's crossings, under
a millisecond, never switched).
What changes for the host: while a POINTER_OVER has yet to show the cursor
on the pointer's display, PointerLink::cursor_hidden_for counts the hidden
cursor from one second after it at the earliest (CROSSING_HIDE_NS), the
arm64e kext's crossing being at most four posts 250 ms apart. A game that
hides its cursor with no crossing under way drives the guest's mouse as
before; one that hides it while a crossing never shows it, a second later.
The host holds its pointer's positions back from the tablet for 100 ms
after a POINTER_OVER (CROSSING_HOLD_NS), or until the cursor shows on the
pointer's display. Under TCG a post's landing can come after that, and the
cursor it shows may then be where the tablet moved it after the post. 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; taken for the post's
landing, it and the landing before it sized display 0 1005 by 628 points, a
later landing confirmed that, and the host was told it (potluck job
m3-max-36292).
What changes for the guest: a landing kRgfxCrossingHoldNs or more after
the POINTER_OVER its post is for, dated from the POINTER_OVER's arrival on
the work loop, confirms the placement it was posted by where it agrees with
it on both axes, and otherwise changes nothing: no corner, no size, and it
is not kept as the display's last landing. Landings inside the hold learn
as before.
At a post's deadline the arm64 kext looks at what each display shows to tell
whether the post was held at an edge, and posts again beside another display
where it was. A display's last MOVE_CURSOR from before the post said nothing
of it: on 15.6.1 under TCG a captured drag left the cursor at display 1's left
edge, the crossing onto display 0 posted there, and at the deadline, the post
not yet shown, display 1 still showed the cursor where that post's point is
held. The crossing took it for the post's outcome and posted beside display 1,
and the first post's late landing, taken for that one's, placed display 0
right of display 1 (potluck job m3-max-36173). Every later crossing went
wrong from there.
What changes for the guest: the kext numbers each MOVE_CURSOR it posts, and
only one numbered after the post counts as what the post did. A post with no
such evidence leaves the crossing unsure, which learns no place from a later
landing, as for a post that showed nothing at all.
On 27.0.1 the first post after the displays were rearranged showed nothing
in 250 ms (potluck job m3-max-35865); the next, beside display 1, held the
cursor at display 0's edge, and the learner took that placement on the axis
held at the edge, putting display 0 past display 1, so every later crossing
missed and the host was told no new place.
Two rules now: an axis where a landing is held at the display's edge keeps
the display's own place, since the post's point lay past the display there;
and a crossing whose post showed nothing, with no display showing the cursor
where its point lies or is held at, learns no place from a later landing,
which may be that post's, late, at the pixel every post aims at. The
crossing still ends on its display's landing. What the guest sees: such a
crossing leaves the places as they were instead of placing a display
wrongly; what the host sees: no DISPLAY_BOUNDS from such a landing.
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 at that edge (27.0.1, potluck job m3-max-35746). Its
MOVE_CURSOR, often the later of the two, made the device take that display
for the cursor's, so the next crossing onto it was never told, and the
tablet put the cursor at its mirror on the display it was on.
The device now takes such a MOVE_CURSOR, 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 and a crossing told the
guest the pointer is over this one.
What the host sees: the display the device takes as the cursor's follows
the hot spot, not a display showing only the image's part over an edge, so
a crossing's POINTER_OVER and its hold, and the window that draws the
cursor, stay with the display the cursor is on. features.md's crossing
entries say so and name the new test.
A post at the pixel the cursor is at shows no move, as nothing changed. The
crossing took that for a point held where the cursor was and posted again
beside another display, so a crossing the device told while the cursor was
on its display already (it took the image's part over the edge for the
cursor) moved the cursor off it. Now, where the crossing's display last
showed the cursor at the post's pixel, the crossing is over.
On arm64 14.6.1 under TCG, a guest shows a crossing's landing 18 to 153 ms
after the POINTER_OVER, past the host's 100 ms hold, so the tablet's
positions reach the guest first and move the cursor on the display it is
on. The kext took that move for the post's landing and placed the display
it showed on over the other (display 1 learned at 0,0), and later posts
went to display 0. On 27.0.1 the cursor's image over an edge also showed
its hot spot at the next display's first pixel, not past it, and was taken
for a landing.
Now only the display a post aims at learns from it, by the placement the
post was made with, which a landing that agrees with it confirms. On
another display only the pixel where the post's point lies, or is held at
its edge, counts: the crossing posts again, after 50 ms more where the
point lies within a cursor's reach of that edge. A post that shows no move
in 250 ms (held at the pixel the cursor was at) posts again. The crossing
is bounded by its four posts alone: cut off at the host's hold, a slow
guest's crossing learned nothing of a moved display and missed it on every
crossing after.
A cursor near one display's edge also shows on the display beside it,
where WindowServer shows the part of its image that reaches over the edge.
That display's MOVE_CURSOR puts the hot spot past its edge. On arm64
27.0.1, a crossing back onto display 0 at 1915,600 got display 1's
MOVE_CURSOR first, with its hot spot at x -5. The kext took it as the
landing and posted again beside display 1, which left the cursor at
display 0's right edge instead of at the pointer (job m3-max-35450).
A MOVE_CURSOR whose hot spot lies past its display is now no landing: the
crossing waits for the display that holds the hot spot.
The test's model of WindowServer now holds a point past every display at
the edge of the display the cursor is on, as measured in the same job,
rather than at the nearest display's edge.
An arm64 guest at two displays or more now takes POINTER_OVER and
DISPLAY_BOUNDS, as the x86-64 kext does. The host's pointer moving into
another display's window moves the guest's cursor onto that display, and a
captured drag on Linux goes on past an edge where the guest placed another
display. Before this, the arm64e kext took neither bit: its cursor stayed on
the display it was on, and a captured drag stayed at the edge (design.md A3).
The move is the x86-64 kext's own, IOHIDSystem::extPostEvent with
kIOHIDSetCursorPosition. Measured on arm64 27.0.1 under HVF and on 14.6.1,
WindowServer follows it as on x86-64. But WindowServer tells an arm64
guest's kernel nothing of where it placed each display: no screens
registered with IOHIDSystem, and no bounds on an IOMobileFramebuffer. So
the kext learns each display's rectangle from its own posts
(RgfxDisplayPlaces.hpp):
- Each landing, the first MOVE_CURSOR that shows the cursor after a post,
checks the rectangle held for the display it shows on. Rectangles start
from WindowServer's first-boot arrangement.
- A crossing posts again beside the other displays where the cursor landed
elsewhere: at most four posts, within the host's 100 ms hold, and
otherwise the cursor stays put, counted in RgfxCrossingsMissed.
- Only rectangles a landing confirmed are told the host.
The bits go with MULTI_DISPLAY: with fewer than two display nodes, or on a
device of one display, the feature word written is the same as before.