At a device's loss the table walk (fault_walk) upgrades each decoder's
Weak<Shared> on the thread that read the first failed command buffer, rt's
completion thread among them. Where the decoder went during the walk, the
walk's hold was the last one, and the decoder's objects were dropped there: a
drop that waited for a command buffer's completion would hang the thread that
completes it.
TableWalk::each now hands a last hold to a thread of its own,
reims-vgpu.graphics-tables-let-go, through the platform's threads, so a
refused spawn ends the process as theirs do. The test drops the decoder in
the walk's callback and checks that its state went on that thread, and that a
walk of a decoder that outlives it spawns nothing. The host sees only a new
library thread name; nothing the guest sees changes.
WindowServer died while QuickTime Player played a 4K video full screen: a
user's 780M host, and measured here on a 780M (macOS 26.7.2 and 15.8.2) and on
an Iris Xe (26.7.2), each time on a walk's second clip. Read from their code,
SkyLight's compositor takes a Metal device whose name holds "Intel" for an
Intel GPU, and scales a full-screen video's YUV layer through Intel's video
pixel processor (AppleGVACore). That keeps only plugins of Intel's renderer
IDs, so with ours it has none and asserts. The naming rule gave integrated
hosts "Intel - ", and an Intel host's own name holds "Intel" under any prefix.
What an x86-64 guest sees now, on every host (the owner's rule):
- MTLDevice.name, and the GPU's `model` that System Information shows as its
Chipset Model, are "AMD - " and the host's name with "Intel" and "NVIDIA"
taken out, in any case, each with a mark directly after it ("(R)", "(TM)",
"®", "™") and one space:
- 780M: "AMD - AMD Radeon 780M Graphics (RADV PHOENIX)" (was "Intel - ...")
- Iris Xe: "AMD - Iris(R) Xe Graphics (RPL-P)" (was "Intel - Intel(R) ...")
- UHD 630: "AMD - UHD Graphics 630 (CFL GT2)", on Windows "AMD - UHD
Graphics 630"
- Arc A770: "AMD - Arc(tm) A770 Graphics (DG2)"
- RTX 3090: "AMD - GeForce RTX 3090" (was "AMD - NVIDIA GeForce RTX 3090")
- 7900 XTX and llvmpipe: unchanged, "AMD - " and the host's name
The kext's `model` was the host's name whole, and none for no name; it is
now the same name as Metal's, "AMD - reims-graphics" for no name.
- vendorName is "AMD" on every host (was "NVIDIA" or "Intel(R)" by the host
name's first word), so the GL renderer takes NVIDIA's settings on every
host, as on a 5300M, where an Intel host's guest took Intel's
(design.md, "The renderer's settings").
- SkyLight's NVIDIA name test finds nothing on an NVIDIA host either: it takes
an AMD GPU's path there (MetalTiledBacking's +0x71 now set).
The device info's `integrated` byte stays on the wire and the host still
writes it; nothing in the guest reads it now, as its docs say. arm64 guests
see what they saw. The ROM's bytes are unchanged: its record changes for the
wire header's comment alone.
Tests: serializer_tests' test_metal_names, test_vendor_names and
test_metal_answers_hold_no_vendor_word; the kext's device_name_test, now built
for the x86-64 kext's rules and, as device_name_arm64_test, the arm64e kext's.
A Shared or Managed newBuffer in the guest could answer nil while the process's
own memory was on its way back to the region. A create that found no room let
the process's empty, cached and doomed slabs go, waited for the slabs other
threads were giving back at that moment, and asked once more. Under CPU load the
slabs' background thread, at utility QoS, falls behind on its drops: the slabs
other threads let go while the wait lasted stayed doomed, their memory out of
the source, and the second ask was refused while 26 to 52 of them held it.
A create now goes round again for as long as a round gave memory back, so its
answer is nil only where the region, or the pool, is full. A round after the
first asks again only where it gave something back, so a create in a quiet
process does what it did.
test_slab_take_gives_back_slabs_let_go_while_it_waited holds the slabs' releases
at the test source's gate while a create waits, so the slabs let go meanwhile
stay doomed: it failed in 20 of 20 runs on the old code and passes in 20 of 20.
test_slab_thread, which saw it once under Rosetta beside a 16-job cargo build,
refused a 3 MiB take in 6 of 3,828 runs beside 48 busy loops and 8 dd copies on
the M3 Max's 16 CPUs before, and in none of 3,144 after.
Both prebuilt sets are rebuilt from the change.
Moves the runtime pin from 8ca94bca19 to 03a7e267ff, on metal2vulkan's
development, for heavy kernels that need less driver memory to compile and
the indirect offset refusal split by its basis.
For the guest:
- A variable a loop carries that no later trip reads is ended at each trip's
top, so the driver carries nothing for it: heavy kernels compile in less
memory and time (metal2vulkan's clean cold creates: a heavy kernel on a
Radeon 780M 10,269 -> 7,773 MiB and 73.5 -> 56.0 s, one on an RTX 3090
1,770 -> 1,376 MiB, one on an Iris Xe 444 -> 411 MiB). What they compute
is unchanged.
- An indirect draw or dispatch at an offset off a multiple of 4 is Metal's
documented refusal (Refusal::IndirectOffset), counted as Metal's; one that
leaves the buffer fewer bytes than its arguments is rt's own
(Refusal::IndirectArgumentsPastEnd), counted rt-refused-ours. Each still
draws or dispatches nothing; indirect_draws_on_vulkan's counts move one
from ours to Metal's for each pair.
- rt's floor takes maintenance4 (core in Vulkan 1.3): a device without it is
refused at creation.
For the host: the translator's SEMANTICS goes 2263 -> 2264, so a first boot
translates its kernels again; the pipeline cache's blob is kept.
A user's x86-64 VM hung at boot on Linux 6.12 (Debian 13) with amdgpu, on
both an RX 9070 XT and the Granite Ridge iGPU. QEMU logged "kvm run failed
Bad address" at the guest's first write to Shared memory. The guest's Shared
memory is the runtime's blocks: host-cached memory the driver allocates,
which QEMU maps into the guest. Before 6.13, KVM's hva_to_pfn_remapped maps a
page of a VM_PFNMAP mapping only where it can take a reference on the page.
TTM's ttm_pool_alloc_page makes its higher-order pages without __GFP_COMP, so
their tail pages have no reference to take, and KVM returns EFAULT. 6.13
resolves the pfn without a reference. Our hosts run 7.3, so no boot of ours
met it.
The owner's ruling (11-21): require Linux 6.13 or later, with no fallback.
For the host: reims-ctl refuses to start a VM on reims-vgpu's GPU under KVM
on a Linux older than 6.13, and says why and what to do, where the guest
used to hang at boot. reims-ctl doctor gains a kernel line, a failure below
6.13. The README states the requirement, and design.md no longer says that
Shared memory is anonymous memory KVM maps on any kernel.
The basis commit's list of the counts that move from rt-refused-metal to
rt-refused-ours missed one test, which its GPU run on a Radeon 780M failed:
- states_on_vulkan: a sampler state the guest places at an index it did not
reserve (Refusal::IndicesNotGranted, whose basis metal2vulkan-runtime's
error/basis.rs marks Ours), 1; its Metal's refusals go from 2 to 1, the
address mode rt has no value of.
The test now checks each count after its own refusal, and the module doc and
the accuracy ledger name the refusal among rt's own. Nothing changes for the
guest: the kind feeds only the host's counts and log.
metal2vulkan-runtime now declares where each refusal's rule comes from
(Error::basis): Metal's, documented or measured, or rt's own. The degradation
counts put every Error::Refused under rt-refused-metal but one,
TextureBufferNotOverBuffer, under rt-refused-ours, so a walk's counts mixed
Metal's refusals with rt's own rules.
RtRefusal::of now takes the kind from the refusal's basis (of_basis): rt's own
under rt-refused-ours, Metal's under rt-refused-metal. The device's basis,
which no refusal declares at the pin, and any later one stay under
rt-refused-metal, where they counted before. A heap texture's place that
Metal's own rule refuses too stays Metal's; one Metal places keeps its own
code, its kind now rt's own. rt's limits and gaps, and the loader and
below-floor codes, keep their own codes. A test pins each basis arm.
What moves from rt-refused-metal to rt-refused-ours, by the tests that held
it as Metal's:
- indirect_draws_on_vulkan: an indirect argument offset off a multiple of 4,
or without the arguments' bytes after it (Refusal::IndirectOffset), 2.
- a_layered_pass_renders_each_slice_on_vulkan: a layered pass's slices past
its texture's last (Refusal::AttachmentPlace), 1.
- compute_encoders_on_vulkan: a buffer offset set on an empty slot
(Refusal::NoBufferAtIndex), 1; its Metal's refusals go from 8 to 7.
- command_buffers_on_vulkan: waitUntilCompleted in a scheduled handler
(Refusal::InScheduledHandler), 1.
- shared_events_on_vulkan: waitUntilSignaledValue: in a notification on rt's
thread (Refusal::WaitOnOwnThread), 1.
- buffers_on_vulkan: a Managed buffer's didModifyRange: past its end
(Refusal::ModifiedRange), 1; its Metal's refusals go from 4 to 3.
Every other refusal of rt's whose basis is its own moves too (the variants
metal2vulkan-runtime's error/basis.rs marks Ours).
Nothing changes for the guest: the kind feeds only the counts, the stderr
lines, and the text of an NSError or a raise's detail, which reach the host's
log alone.
The accuracy ledger said rt-unbuilt-icb counts indirect command buffers
themselves, answered nil. Since 16eee4db90 rt makes them, of GPU-encoded indexed
draws, and executes and resets them on the GPU. The code now counts only the
pieces rt has no form of at 0429ff1bd4: commands the CPU encodes, a CPU
resetWithRange:, a blit copy between buffers, a descriptor of a resource index,
and the type-5 index reservation (rt_platform/icb.rs, device.rs). The row now
names those.
Re-read at 0429ff1bd4 by lane unbuiltsweep: every other Unbuilt piece is one
rt still lacks, so nothing else moves to rt.
A VA-API decode session made its surface pool up front, its DPB, the picture
and two spare, at the stream's coded size, and gave them to its context as
render targets. A session whose pictures land in the device's caches decodes
only its references into surfaces of its own, so it held surfaces no picture
used.
The pool now starts empty and the context is made with no render targets. The
pool makes a surface when a picture is to be decoded into one of its own and
none is free, up to 48, and lends the one freed last first. A kept context's
shape no longer holds a surface count. Mesa's vlVaCreateContext reads no
render target (read from code, Mesa 26.2.4), and surface::lazy's tests check
the decision off the GPU and, on it, that streams of the driver's own encoder
decode to the same pictures with surfaces made as needed as made up front.
Measured with the process's DRM fdinfo, 8 surfaces at 1080p NV12, 4K NV12 and
4K P010:
- radeonsi (Mesa 26.2.6; Radeon 780M, m3-max-64940; RX 7900 XTX, -64945) makes
no buffer until a surface's first use: +0.0 MiB once made, then 31, 108 and
203 MiB on the 780M (41, 144, 279 on the XTX) once each held an image. Nothing
changes there.
- iHD 26.3.5 (Iris Xe, m3-max-64988) makes each surface's buffer object at its
full size when the surface is made, +28, +96 and +192 MiB drm-total, and
backs none of it until first use (drm-resident +0.0). A session no longer
holds the objects of surfaces it never decodes into.
- On Windows each surface made is a committed D3D12 resource
(CreateCommittedResource in d3d12.rs's shared_texture, read from code), which
allocates when it is made: a session whose pictures land in caches no longer
holds its spare surfaces' memory there. Not measured.
A make takes 0.001 ms or less on radeonsi and 0.004 ms on iHD. The first
access unit, which holds the config, context and first surfaces, took the same
time either way within the runs' spread on all three GPUs (H.264 1080p on the
XTX 12.95 ms as needed, 13.18 up front), with two or three surfaces made as
needed against five up front.
Nothing changes for the guest: the device's answers, the pictures and their
order are the same.
On Linux with glibc, a pipeline make's translation frees nearly all it used
as the make returns. glibc, though, keeps the free chunks below its heaps' tops
resident, so the VM's process stayed at its largest make's level, up to about
450 MiB. Now each compile-pool make of 250 ms or more asks a thread of its own,
reims-vgpu.heap-trim, to run malloc_trim(0). One trim runs at a time, and the
asks made while it runs become one more trim.
For the host, resident memory falls after heavy creates (the ledger's kernel:
158 MiB to 32 MiB). The first trim is logged at info and later ones at debug,
each with resident bytes before and after and the trim's time. The counts line
carries heap-trims, heap-trim-us and heap-trim-returned-kib.
Nothing changes for the guest. No reply, value or order it sees moves, and the
compile's thread only asks for the trim. macOS, Windows and musl do nothing.
What is left: a trim takes each glibc arena's lock in turn, so a thread the
guest waits on (a make's or the ring's) that allocates meanwhile can wait up to
the trim's own time. That was 5.04 ms at most in a cold launch of the modelling
app on a 780M, and the contention itself was not measured.
The kext let a dormant deferred block go past half the device's deferred
budget, a quarter of the host GPU's memory budget, and that half is sized
by the host's GPU, not the guest's memory: on an M3 Max it is about
5.3 GiB for an 8 GiB guest, so only the count of 1024 dormant blocks bound
them. Only the host's device cache holds a dormant deferred block's bytes,
and after the browser closed the dormant blocks' caches held 3,862 MiB of
images on the host (arm64 macOS 27.0.1 walk m3-max-63600).
trimDormant() now passes the smaller of half the deferred budget and the
dormant bytes' cap, an eighth of the guest's memory, through
rgfxSurfaceDormantDeferredCap(), with its test in surface_blocks_test.
What the guest observes: no change in contents. A deferred block let go
past the new cap is released as one past the count is today: where the GPU
wrote it and another process holds the surface, its release names its
pages and the host copies the cache into them first, and op 6 still
answers the old state volatile, the contents kept. The cost is time: a
surface asked again after its block went makes a new block (SURFACE_PAGES
and a fill) instead of reviving the old one. Volatile surfaces' blocks go
first, then the oldest, so quick revivals are kept. The dormancy line's
"past the deferred bytes" count rises.
What the host observes: fewer host-only textures and texture-block bytes
held for dormant blocks after the guest's scenes end, about 1 GiB of
dormant deferred caches at most on an 8 GiB guest beside the 1 GiB of
dormant wired blocks, and more BLOCK_RELEASE copies, which it already
paces one at a time.
What changes for the host on a GPU with memory of its own (a discrete
card): the IOSurface device caches now fit one budget together, two thirds
of the GPU's own memory's budget as the platform answers it at the device's
start. Past it, in the per-shape form the Vulkan platform takes, the shapes
no texture references are trimmed, least recently used first (never a dirty
or plane one), and a texture that takes one again has it made again and
filled from its cache's buffer. The guest reads the same bytes; only the
GPU's work and time change. Before, only a GPU that shares the CPU's
memory had a budget; its half stays as it was. The device's info line now
names the budget and the GPU's memory on both kinds.
Why: on a 4 GiB Radeon RX 550 (RADV) with no budget, QEMU asked the card
for more than it has in a browser's 3D page (by 201-270 MiB) and in a video
(by up to 1283 MiB, most of it the host's video decoder's). What did not fit
stayed in GTT after the card had room, and where long-lived allocations
stayed there a later benchmark scene ran at 17.2-17.5 frames a second
against 29.4-32.6 (jobs m3-max-63976 and 64138). The caches were the most
of what QEMU asked; of them the budget can trim only the unreferenced
shapes, 353-670 MiB at each over-asking moment, more than the 3D page's
over-ask, above a floor (buffers and referenced shapes) of 2912-3634 MiB.
Two thirds of the card is under every such floor, so it trims all it may
there, and in those walks would have trimmed elsewhere only where QEMU
asked within 415 MiB of the card's room; half would also have trimmed a
scroll that asked 2.2 GB of it.
The test that held the budget for unified memory alone takes both kinds,
and a new one checks a device on a GPU of its own memory sets it.
A window draw held the answers of the presents after the one whose surface
it may read until the draw finished on the GPU. Behind a GPU-bound guest the
draw queues behind the guest's own work, so each answer waited for that work
too: on an Iris Xe under a 3D benchmark's scene, presents were answered
47.5 ms after their show at the median, and the scene presented 10.2 frames
a second against its own 26.4 (m3-max-63530).
A draw of a surface whose every write is the platform's work now lets go of
the answers as it is scheduled on rt: the present's texture lies over its
block's device cache, or a shape of it, and the cache was not made for the
host's video. The guest commits its next write of the surface only after the
answer, and rt submits every queue's work to its one VkQueue in commit order,
each segment ending in a full memory barrier, so that write runs after the
draw however long the draw waits on the GPU. A surface the guest's CPU or the
host's video may write (pages with no cache, a texture over the pages' view,
a video cache) still waits for the draw to finish, and the surface's block
hold still ends at the finish either way.
What the guest sees: a present of a device-cached surface is answered as soon
as the window's draw of it is scheduled, up to that draw's wait on the GPU
earlier, so a GPU-bound app gets its surfaces back sooner and presents more
often. The answers keep their order, and no write of the guest's reaches a
surface ahead of a draw that reads it. The timing line says "its draw
scheduled" or "its draw done", and "its draw under way" for "its draw
running".
Tests: a_later_answer_waits_for_the_scheduling_of_a_draw_of_an_earlier_surface
and the_guest_never_writes_a_surface_ahead_of_a_window_draw_that_reads_it
replace the two tests of the finish rule; sink's block test checks that the
hold waits for the finish, queued or not; a decoder test pins which presents
are queued; and rt_platform::command's
work_committed_after_a_scheduling_runs_after_it_on_vulkan fails if work
committed after a scheduling stops running after it on rt.
rt makes a texture buffer (a VkBufferView) only over a buffer its consumer
places, through Buffer::new_texture, and refuses one its device places
(Refusal::TextureBufferNotOverBuffer, a rule of rt's own), so a guest's
newTextureWithDescriptor: of MTLTextureTypeTextureBuffer was nil, counted
under rt-refused-ours.
The device now composes Metal's call from two of rt's: a buffer of the
texture's bytes, its row of width texels rounded up to rt's texture-buffer
alignment of the format, of the descriptor's resource options and so its
storage mode; then the texture over it from offset 0, rows that rounded row
apart, at the index the device's make would give it (the guest's, where it
places one). The texture holds the buffer, which goes with the texture and
its views. The buffer takes no object ID, GPU address or resource index the
guest sees and shifts no numbering: the decoder names only the texture, rt
gives a buffer no resource index, and the buffer lies at rt's own address. A
recording keeps the device's call, which plays back through the same make.
What the guest sees: such a texture buffer is made, of the descriptor's
storage mode, where it was nil. One of a format rt makes no texture buffer of
is still nil, now counted under that format's code. A heap's texture buffer
is still rt's own refusal, nil, which rt-refused-ours keeps counting.
The five decoder tests that started from the refused texture buffer now
start from the made one, the guest's texture ids kept as a graphics device
keeps them; what they pin about the host's ranges covers its buffer. A test
on the GPU checks the composition, Shared and Private, and a refused format.
reims-ctl gave an x86-64 VM `x-avx512-xstate=on` only where the host's
XSAVE layout was not Intel's, which meant Zen 4 and Zen 5: on Intel's, no
gain had been measured. The owner asked for it on every host with AVX-512
(2026-11-21), so a Linux KVM host whose OS keeps the AVX-512 state now
qualifies whatever its layout. On Intel's, XNU's own copy of the state is
right, and the gain stays unmeasured: no host here has that layout.
For the guest on an Intel host with AVX-512: CPUID leaf 0xD lists the
AVX-512 state components, RgfxGate promotes each user thread to them, and
hw.optional.avx512f still reads 0. Every other host's command is unchanged
byte for byte. The test that held Intel's layout out now holds it in.
A dispatch whose stage's fill ended failed or breached was skipped and its
command buffer still completed with no error, so the guest read a finished
buffer whose work was never done. Such a buffer now completes with Metal's
MTLCommandBufferErrorInternal (1): the guest sees RGFX_CB_INTERNAL with error
code 1 instead of a success. The first error a command buffer is failed with
is kept, so a later out-of-memory mark does not replace it.
Only that case changes. A dispatch refused while its fill is pending, or after
a cancelled fill, keeps today's skip and count (rt-refused-gap). The skip is
counted under codes of its own, stage-skipped-failed and
stage-skipped-breached, with one stderr line per code per process.
held() now returns the fill's end with its refusal (Refused), which the rt
platform's dispatch reads. The testkit's fake command buffer carries the same
failure, so the graphics tests pin the guest's completion for both ends.
Q16 measured another process's access to an IOSurface behind one long pass.
It left open whether a read waits out the writing process's whole queue of
work ahead of the write, whether it also waits for what that queue commits
after the write, and whether a writer committed by a plain commit is ordered
at all.
oracle_backlog asks those three, as arms 1 to 3, each against control rounds
in which the read has nothing to wait for. Job m3-max-64081 ran it on the
MacBookPro16,1 oracle's AMD Radeon Pro 5300M and Intel UHD Graphics 630
under macOS 26.7.1, and dgpu-oracle.md's Q48 records the answers. On both
GPUs the read waits out the writer's queue ahead of the write, as our surface
order makes it. The 5300M orders the read by the surface alone and lets it
pass buffers the writer committed after the write; the 630 runs both
processes' work first in, first out, as our one VkQueue does. On the 5300M a
read after a plain-commit writer ran ahead of the write in 1 of 3 rounds;
our order, which never lets it, matches the 630 and is kept.
design.md's "Surface order" and surface_order.rs's module doc cite Q48 beside
Q16, the oracle README lists the probe, and build.sh builds it with the
others.
Docs, a doc comment and the source of a probe built only for the oracle Mac:
no check reaches it ("docs and comments" in AGENTS.md), and nothing was built
or run for this commit.
The pin moves from 5a04298008 to 5ccd158e6d, metal2vulkan's development.
For the guest:
- Every compute pipeline a command buffer binds now goes through one bind
that binds rt's descriptor set 1 first (rt 70dfe08320). The guest's
dispatches after rt's own count kernel of an
executeCommandsInBuffer:indirectBuffer:indirectBufferOffset: over a
range the GPU writes found that set unbound, which lost the device in
the rendering sample's indirect path on the RTX 3090 and the RX 7900 XTX.
- Texture buffers are made: a texture buffer over a buffer
(newTextureWithDescriptor:offset:bytesPerRow: of a buffer) reads and
writes the buffer's bytes through a Vulkan buffer view (rt 817463704e).
Before, it was rt's gap (rt-refused-gap). rt refuses an offset off the
device's texture-buffer alignment (TextureBufferAlignment) and rows or
texels that do not fit the buffer (BufferTextureLayout), counted under
rt-refused-metal. A blit copy to or from a texture buffer is rt's gap
(Gap::TextureCopy).
- A texture buffer the device places (newTextureWithDescriptor: of
MTLTextureTypeTextureBuffer on the device) is rt's own refusal, not
Metal's (TextureBufferNotOverBuffer: rt makes a texture buffer only over
a buffer its consumer places, and the host places none for it yet): nil,
counted under a new code for rt's own refusals, rt-refused-ours, apart
from rt-refused-metal.
- A copy between textures whose bytes share memory is cut into ordered
slabs; where rt cannot cut it so, it is rt's gap (Gap::OverlappingCopy),
and nothing is encoded.
- rt's floor adds six texel-buffer features of Vulkan 1.2 (uniform and
storage texel buffers: update-after-bind, dynamic and non-uniform array
indexing) and counts texel-buffer arrays against the descriptor limits.
- SEMANTICS_VERSION 2257 -> 2258: the translation caches are made again,
so the first boot after this pin is cold.
The pin-range tests' texture buffer, a device-placed one, was rt's gap and
is now rt's TextureBufferNotOverBuffer, counted under rt-refused-ours
(RtRefusal::Ours); decoder_with_a_texture_buffer checks that, and
docs/accuracy-ledger.md names the code, the refusal and the two gaps. No
lock change: metal2vulkan's manifests did not change.
qemu.md's CPU model section now says why a Zen 4 host runs a macOS guest's
code without its op cache, what QEMU's x-avx512-xstate property and
RgfxGate's xstate route do about it, the four conditions under which
reims-ctl adds the property, how a VM's cpu_flags turn it off for a KDK
kernel, and what was measured: op-cache shares, the route on six releases,
and the timed pairs on the 8745H.
lessons.md records the trap the route had to fix: XNU copies a thread's
AVX-512 state at Intel's XSAVE offsets, which on a Zen 4 core are not
where XSAVE put it, and nothing logs the loss.
known-issues.md tells users that a DEVELOPMENT or DEBUG kernel stops on
such a host, and how to start one.
cargo xtask dist builds reims-vgpu-compile with reims-vgpu-c selected beside
its package, so the crates the two share resolve with the library's features
and build once, and installs it in the tree's bin on Linux, macOS and Windows.
The library starts the helper from beside the host's executable, so make qemu
copies it into build/qemu and install-ctl.sh into each QEMU install, with the
CLANG64 DLLs it loads on Windows. A QEMU without it refuses the pipelines past
rt's stage bound as before; --skip-qemu warns about such a kept install.
vendor/qemu c3e40185 adds the x86 CPU's x-avx512-xstate property, off by
default: on, CPUID leaf 0xD lists the AVX-512 state components (opmask,
ZMM_Hi256, Hi16_ZMM) while leaf 7's AVX-512 bits stay as the model sets them,
so a guest may turn the components on in XCR0 while it is told it has no
AVX-512. A Zen 4 core runs a thread's code from its decoders, not its op
cache, while the thread's XCR0 leaves them off.
For the guest: nothing changes until something sets the property; reims-ctl
does not yet.
The display's passes (the present shaders' conversion and the colour's) sampled
a presented IOSurface's texture through the texture's own resource index, which
is the guest's. The guest's indices belong to its processes: when one ends (a
logout, a window server restart), its indices go back to the guest's kext, and
the next process's texture made at one of them takes that index's element at
once. The display can still show the old texture and draws it again at each
refresh, so a refresh drew the new texture's pixels into the window, or
undefined ones once that texture had gone and emptied the element, until the
guest presented again.
The display now samples the texture through a view of its own: the whole
texture in its own pixel format, at one of the platform's own indices, made at
the texture's first such draw and kept with the decoder's entry and with each
of the display's holds of it, so a later present or refresh of that texture
makes no Vulkan call. The copy path reads the image through no index and is
unchanged. Where the platform refuses the view, the draw answers nothing: the
window keeps its last frame and the host's read of the display answers black,
counted as display-view-refused. No draw falls back to the guest's index.
For the host: a refresh after the guest reuses the shown texture's index still
shows that texture. a_color_draws_a_presented_surface_through_its_tables and
a_surface_takes_the_table_at_its_own_size_in_unorm now expect the view, not the
surface, in the fragment binds.
The host's runtime keeps a destroyed object for the command buffers
committed before its destroy, but a new object made with the old one's
resource id or at its GPU address takes them at once. A buffer still running
there then read the new object in place of the old one.
What a destroy gives back now waits until the host has completed every
command buffer the process committed before the object was let go, a failed
buffer included: its resource id and GPU address, its heap's bytes, its
region and pool blocks, its pages and its ICB slots
(RgfxRetireGate in RgfxSerializer.hpp). Every RgfxSerializer::destroy
`after` goes through the gate, stamped at the call. A command buffer takes a
serial at its commit and gives it back at its completion, or at its dealloc
where no completion came. makeAliasable still gives a heap range back at
once.
What the guest sees: ids and ranges are reused later than before. A texture
made while a buffer committed before another texture's release is in flight
takes a different resource id. A new buffer's address and a heap's usedSize
can differ the same way. With nothing in flight, everything goes back at once
as before. Under the game step's -r, no id is reused before frame f+3.
The serialiser's end, the context's, runs whatever still waits and logs once
the most that waited at once. A guest context ends only with its process, so
a new peak is also logged at each power of two from 64.
guest/prebuilt and guest/prebuilt-arm64e are rebuilt from these sources.
setVisibilityResultMode:offset: of Boolean or Counting and
setAlphaTestReferenceValue: were counted rt-unbuilt-render-command, though rt
has both calls at the pinned 8a36a49453. They now reach rt: Boolean and
Counting are rt's gap (Draw-VisibilityResults), counted rt-refused-gap, and the
reference is kept for rt's private alpha test, which no state of ours has.
Nothing the guest observes changes: the draws after an enabled mode still
write no result, and no draw reads the reference. Only the counts move. A
mode no Metal enumeration has is now Metal's refusal.
A line width other than 1 stays unbuilt, and the docs now say why: rt keeps
the width but refuses every draw of lines under it, which would draw lines
not at all where they draw 1 pixel wide now.
render_encoders_on_vulkan and the sub-encoders' counting-mode test count
rt-refused-gap where they counted rt-unbuilt-render-command.
Copies between a buffer and a texture with a blit option were counted
rt-unbuilt-blit and copied nothing. rt copies one aspect of a depth and
stencil format at the pinned 8a36a49453 (copy_from_buffer_with_options,
copy_from_texture_to_buffer_with_options), so the two plane options go there.
For the guest: a copy of MTLBlitOptionDepthFromDepthStencil or
MTLBlitOptionStencilFromDepthStencil now moves that plane, 4 bytes a texel of
Depth32Float_Stencil8's depth and 1 of a stencil. rt refuses a copy into a
32-bit float depth, and a plane option of a format without the plane, each
counted rt-refused-gap. PVRTC rows, more than one option, and copies between
textures with options stay unbuilt.
plane_copies_on_vulkan clears both planes in a pass and reads each back,
then writes a stencil and reads it back.
A render pass of renderTargetArrayLength 2 or more was counted
rt-unbuilt-render-pass and rendered its attachments' own slice alone: its load
and store actions reached no other slice. rt's pass takes the length at the
pinned 8a36a49453 (render_target_array_length), so the descriptor now keeps it
and hands it to rt.
For the guest: such a pass loads, stores and resolves that many slices of each
attachment from its own slice, and, as rt documents, a vertex function's
[[render_target_array_index]] picks the slice it draws into. An attachment
with fewer slices than the length is rt's refusal, the encoder nil and counted
rt-refused-metal; a length past the device's layers is rt's gap.
a_layered_pass_renders_each_slice_on_vulkan checks both slices' texels; the
descriptor test no longer counts the length unbuilt.
The Vulkan platform answered drawPrimitives:indirectBuffer:, the indexed
indirect draw and the indirect patch draw as unbuilt: each encoded nothing and
counted rt-unbuilt-render-command, so the guest's indirect draws drew nothing.
metal2vulkan's runtime builds them at the pinned 8a36a49453 (aed460e0da): each
is one vkCmdDraw*Indirect that reads the guest's MTLDraw*IndirectArguments
from its buffer as the draw runs.
For the guest: indirect draws of primitives, indexed primitives and patches
now draw what their arguments say. An offset rt refuses (off a multiple of 4,
or without the arguments' bytes after it) is counted rt-refused-metal, and a
patch index buffer rt-refused-gap, as the direct patch draw's is. Indexed
patch draws stay unbuilt: rt refuses every state of a control point index
type.
indirect_draws_on_vulkan fills the arguments buffer and checks the pixels;
render_encoders_on_vulkan no longer counts an indirect draw unbuilt.
A command buffer's completion reached the bundle's completion thread only
after the framebuffer's work loop thread was woken and had taken the control
ring: on msi's RTX 5080 (v5, compute commits with a copy-in, n 9782) the
handler to the thread's take was 47.8 / 16.3 / 177.6 us mean / p50 / p90.
The vector's source is now an IOFilterInterruptEventSource whose filter, at
primary interrupt context, has the accelerator look at the watched rings and
wake each client with untaken records (queueFilter); the work loop's look
(queueInterrupt) then skips a producer the filter looked at
(RgfxQueueWakes.hpp, queue_wakes_test).
The filter returns true for every interrupt, so the work loop's pass runs as
before and in the same order: takeCompletions, the room wake, queueInterrupt,
rgfxSurfaceLocksWake, each display's service and the refreshes. The wake count
now rises once where both looks saw one completion; the bundle only waits on
its value. The count moves under a spin lock taken with interrupts disabled,
and the waiter asserts its wait under it and blocks after, as IOWorkLoop's
thread does.
Every call is in the SDK's Kernel.framework headers and defined by every
release's kernel collection we ship (kc-check: x86-64 11.7.11 to 26.7.2,
arm64 14.6.1 to 27.0.1). The kernel's own MSI path calls
thread_wakeup_thread at primary interrupt level with interrupts masked under
a spin lock (IOWorkLoop::signalWorkAvailable on 11.7.11, 26.7.2, 14.6.1 and
27.0.1), and thread_wakeup_prim enters the same waitq wakeup, which masks
interrupts itself (26.7.2); IOWorkLoop::threadMain asserts its wait under a
spin lock with interrupts disabled (11.7.11, 26.7.2): read from code.
A compute buffer longer than the service thread walks itself (2 KiB) went to
its queue's lane, whose thread was woken for it as it was begun. Over the
Metal compute pass on the RTX 5080 Laptop host, those 4127 buffers waited
73.7 us at the mean (90.3 at the median) from the begin to their walk's start,
nearly all of it the lane thread's wake, where one walked on the service
thread started 3.0 us after its begin; their guest commit to rt commit took
204 us at the mean against 80. The lane is there so the queue's next buffers
are taken beside a long walk, but most of these had nothing behind them: the
guest published the next one after the walk in 7085 of 10690 cases.
A buffer of up to 8 KiB whose commit would wait for nothing is now walked
and committed on the service thread when the guest has published nothing
behind it on its ring as it is taken (QueueClaim::nothing_published), and no
lane thread is woken for it. A walk of 2 to 8 KiB took 51 to 72 us at the
median there, about one wake: what a buffer published during it waits for its
take. Its commit comes after this one's in its turn either way. The claim is
let go through the walk as for a short buffer, so a buffer that asks for its
CB_SUBMITTED behind it is answered at its doorbell.
Ring messages, events and their order are unchanged; only which library
thread walks such a buffer changes.
The two race tests of 21e637db25 passed against the two-hold code they guard:
on libpthread's default mutex policy the committing thread took the held
messages' mutex again before the thread waiting on it, so the window between
the holds was never met. Each now runs in a child of its binary on the
fair-share policy (PTHREAD_MUTEX_DEFAULT_POLICY=1, rgfxRunFairShare), where an
unlocked mutex goes to its waiter, and checks that the child has it. The
protocol test's kext now refuses a held destroy, as a post that took every
held message leaves the old check a lock-free answer that waits for nothing.
Against the sources before the fix both fail, the serializer's at
postHeldCreates and the protocol's at the buffer missing from its ring; on
the fixed tree `make -C guest test` passes. The trap is in docs/lessons.md.
The bundle's tests are not among the sets' sources, so the sets stay as built.
A lost device's line named the Vulkan call that met the loss and nothing of
the fault behind it, so a loss on the host left no trace of what the GPU read
or ran when it faulted. rt reads the driver's report (VK_EXT_device_fault) at
the loss and places none of its addresses: that is the platform's to do, as it
holds the guest's objects and the blocks they lie in.
On the host, a lost device's line is now followed by the fault's lines on
stderr: the driver's description and vendor records; each access it names,
rounded to its precision and placed among the decoders' live objects (buffers,
heaps, textures over a buffer, Managed textures' CPU-copy buffers) and the
mapped blocks the host sees (rt's pool allocations, the device's known blocks
and dma-buf imports, the blocks of live objects), with the offset in each that
holds it; where none does, the nearest live object and the nearest mapped
block below and above the address, each with its id or class and its distance
in bytes; each instruction pointer, placed the same way, with the note that no
range the host sees holds shader code; and what the placement saw and did not.
A loss that rt read no report for says so on one line.
The device gives rt a BlockMappings that maps nothing and refuses nothing, to
keep its pool allocations' ranges, and each import's range is kept beside the
record of where it was imported. The decoders' tables are walked only at the
loss, each walk waiting 500 ms in all for its locks, as the lines are written
on rt's completion thread. Nothing the guest sees changes.
A pipeline create waited 60 s for its reflection. On a slow host or a cold
compile the app got nil, and the destroy posted behind the create cancelled a
compile that would have succeeded. Other waits for host answers had the same
problem. A queue's create (30 s), SURFACE_PAGES (30 s), shared events (60 s),
a CPU lock's wait for its surface's writes and the host's copies (2 s), a new
block's wait for a write-back (10 s) and the bundle's library chunk acks
(10 s) all sit behind the context's earlier work on the host, a compile among
it. At their bounds a lock read whatever bytes the pages held.
Each of those waits now has no deadline, as Metal's own calls wait for the
GPU's driver (RgfxAnswerWait.hpp). It sleeps THREAD_INTERRUPTIBLE, so a caught
signal never ends it, and it ends only:
- at the answer;
- at the device's stop: quiesce wakes every waiter, and the waiter finds the
device stopped;
- at the thread's abort (SIGKILL, a fatal signal, exit), returning
kIOReturnAborted.
An aborted create still gets its destroy posted behind it. A CPU lock waits
with no deadline for the device to complete its writes' buffers. Its 2 s bound
now counts only from that completion to the bundle's retire, so a process
that locks a surface on the thread that would retire it still goes on.
The 64 lifecycle waiters are split by kind: 32 for the processes' creates and
shared events, 16 for surface pages and downloads, and 16 for the device's
own asks (queue create, close, pool takes, kept answers, video). Creates
waiting on compiles can no longer take the waiters WindowServer's surface,
queue and close asks need. A waiter take that ends unanswered returns
kIOReturnBusy, so a caller never mistakes an unposted message for a posted
one.
The waits that do not depend on host work keep their deadlines, each with its
reason in a comment: ring room, display commands, the start's kept answers,
a context's close, the display pipe, arm64 video sends and the region-room
wait.
What the guest now sees: a lock or present behind a slow compile waits for
it, and a create returns its pipeline however long the compile takes.
The fix boot of the start refusals measured what the guest gets: sips's decodes
of a 4:4:4 thumbnail and of a monochrome alpha item now come out, decoded in
software and within 2/255 of the M3's decode, where today's tree left sips no
picture.
An arm64 guest's HEIC images hold items the host's arms cannot decode: Apple's
desktop thumbnails include HEVC Rext 4:4:4 streams, and its alpha items are
Rext monochrome. Every arm's decode of a picture runs the codec's
check_supported, which takes 4:2:0 alone, at 8 bits, or HEVC's at 10 too.
The paravirtual decoder still started tile sessions on such streams. dsts
named a 4:2:0 format in TDrs, CMPhoto lent a 444f buffer for the 4:4:4
stream, and every dtil failed at vt.rs's region_layout ("tiles in '444f'",
seen four times in an arm64 26 boot on a 780M host).
read_record now runs check_supported on the record's SPS, so these streams
are refused when their session starts instead of at each tile or frame:
- dsts answers kVTUnimplementedErr with no TDrs. That is the answer on which
the guest's VideoToolbox decodes the image in software, as for a backend
that decodes no tiles. Rext 4:4:4 thumbnails and monochrome alpha items
now fall back to software decode at the session's start, where today each
tile fails at region_layout.
- dsta answers kVTVideoDecoderUnsupportedDataFormatErr with no Dpba.
Every session that opens is then of 4:2:0 pictures, whose format TDrs and
Dpba name (420v, 420f, x420 or xf20), and region_layout lays out all four.
This also refuses HEVC streams deeper than 10 bits at their start. Before,
nothing refused them, although read_record's doc said it did. An H.264
stream deeper than 8 bits is now answered kVTUnimplementedErr at dsts
instead of kVTVideoDecoderUnsupportedDataFormatErr, so its tiles fall back
to software in the same way. The tests have a table of formats for each
codec: 4:2:0, 4:2:2, 4:4:4 and 4:0:0 at 8, 10 and 12 bits, in video and
full range, Main, Main 10, Main Still Picture and Rext. Each row lands in
its 4:2:0 format or is refused at the start of both kinds of session.
The guest now gets right pictures from concurrent decode sessions on a
Windows host. Intel's Direct3D 12 video driver for the UHD Graphics 630
(igd12dxva64.dll 31.0.101.2145) decodes wrong pictures on a device's later
video decode queue while an earlier one lives, and Mesa's vaon12 makes a
queue for each VA context, all on the process's one device. Of two guest
sessions decoding at once, one got wrong pictures.
While a device of ours is held, its ID3D12Device::CreateCommandQueue (the
vtable's slot 8) answers every ask for a video decode queue with one queue
it keeps, a reference added for each asker. Other queue types, and devices
no hold holds, go to the slot's own method. No vendor decides: every device
gets the one queue. The slot gets its own method back when the last hold on
a device with that vtable goes, and the kept queues go with the last hold on
their device.
Measured on the UHD 630, 4K H.264, frames per second in all: one session
25.4-27.4, two 53.2-56.1, four 113.6-116.0 with one queue, against 22.9-26.9,
49.7-52.2 and 101.8-111.9 with a queue each, where the sessions decoding
wrong ran fastest. The new test of two decoders at once passes 3 of 3 with
the one queue and fails without it; the churn test decodes none wrong in 3
runs. docs/video/bugs.md U33 records the driver's bug and the split.
On Windows the kept-context change held only a context's teardown and
destroyed a pool's surfaces and its config at once, beside the display's
live contexts. That passed the two-thread test, but rounds of 2 and 4
decoders each decoding the stream at once, each picture waited for and not
read back, had a decoder's vaEndPicture fail in every run of 6 on vaon12 on
the UHD Graphics 630 (potluck jobs m3-max-61922, 61930, 61939), where
development, which holds every teardown, passed 4 of 4, and holding the
surfaces' teardown too passed 2 of 2 (m3-max-61948).
So every teardown is held again while a context lives, and a decoder's
context is kept with its config and its pool: Context::new_decoder makes
the three, or takes the three back for a decoder of the same shape (now
with the surface format and count), so beside a live context nothing is
made or destroyed for a shape kept. A kept pool lets go of its
video-processing context first, which as a live context would keep the
held teardowns from ever being made, and a stalled pool is neither kept
nor taken back. The release_teardown doc's measured claim that destroying
a pool's surfaces at once passed is corrected with these runs, and the
full-pace test runs their shape.
On Windows every teardown asked for while another VA context lived was
held until none did, which stopped Intel's Direct3D 12 video driver
faulting, and kept each short 4K decoder's memory (about 211 MB of DXGI's
local count) until the long decoder beside it ended.
Measured on the UHD Graphics 630 (job m3-max-61642): holding the
context's destroy alone passes the two-thread test, with the pool's
surfaces, or the surfaces and the config, destroyed at once. Held
contexts still grew DXGI's local count by 34,905,201 bytes each. So a
config's and a pool's surfaces' teardowns are now made at once, and a
decoder's context let go while another lives is kept with its config
and taken back by the next decoder of the same config, size, render
targets and DPB, instead of one made beside it. Kept contexts are
destroyed with the held teardowns once no context lives. Linux is
unchanged, and so is what the guest sees.
The churn test makes ten short decoders beside a long one, compares their
pictures with the long one's, and on Windows asserts DXGI's local count
grows by less than one held context over the last nine.
rt makes no rasterization rate map: its newRasterizationRateMapWithDescriptor:
refuses (Unbuilt::RateMap, rt-unbuilt-rate-map), yet the Vulkan platform
answered the M3's layer count, 2, and every host offered RATE_MAPS. A guest
asked supportsRasterizationRateMapWithLayerCount:1, heard yes, and its map's
create was refused at the host.
The Vulkan platform now answers max_rasterization_rate_layer_count 0, and so
the identity's largest_rasterization_rate_map_layer_count 0, and the device
offers RATE_MAPS only where that count is one or more (makes_rate_maps). What
the guest sees on rt: supportsRasterizationRateMapWithLayerCount: answers NO
for every count, the device info's largest rate map layer count is 0, and
newRasterizationRateMapWithDescriptor: returns nil in the bundle with no
message to the host. A platform that makes rate maps (the testkit's fake)
offers them as before. No GPU family's answer moves: Mac2 stands, and no
Apple family stood before or after.
The tests that held rt's answer of 2 now hold 0, and a new test pins the
feature bit to the platform's layer count.
iHD codes a frame from a linear import other than as from a surface of its own, and
the encoder's imported inputs are laid out in its Y tiles for that: the row says what
was measured on the Iris and where our code lays them out.
On an Intel GPU under iHD, a guest's encode session got other bytes from a
frame the rt GPU wrote into the encoder's input than from the same frame
uploaded. The input was imported linear, and iHD codes a linear import
differently from a surface of its own:
- H.264's P pictures differed at 640x360 and smaller;
- every HEVC Main 10 picture differed, intra ones too, at about ten times
the bits.
iHD's own inputs are Y-tiled (I915_FORMAT_MOD_Y_TILED). Their pitch is the
coded row's bytes rounded up to 128, and their chroma plane sits at the pitch
times the coded height rounded up to 32 rows. An import declared and written
in that layout coded as the upload did, byte for byte, in every profile at
five sizes up to 1080p. The one exception is where iHD differs from one
upload to the next anyway (HEVC Main at 640x360 and 1080p). Measured on an
Iris Xe, iHD 26.3.5.
What changed for the guest: on iHD, the GPU-filled path's samples are the
ones the upload path would give. Nothing changes on radeonsi: its own inputs
are in AMD's 64 KiB swizzle, so its inputs stay linear at rows of 256, which
it codes as the upload.
The changes:
- `VideoEncoder::input_layout` makes one surface as the encoder's pool does
and exports it. Where that surface is in Y tiles in this layout, the input
takes its pitch, chroma offset and size. Otherwise the input is linear, as
before.
- `import_input` takes the tiling, and `Target::import_as` declares Y tiles
in the DRM PRIME descriptor.
- The fill asks the layout once per shape, sizes the input from it, and
passes the kernel its tiling word.
- `TargetTiling::byte_at` is the Y-tile address the tests write and check
by.
Tests:
- The VA crate's import test now writes its input in the encoder's own
layout, so on iHD it writes Y tiles.
- The rt kernel test fills every case into a linear input and a Y-tiled
one, and compares the whole input byte for byte.
- New unit tests cover the Y-tiled layouts iHD gave, the misfits that are
refused, the tile address, the linear layout and the fill's declines.
On Linux the rt platform's VA-API arm made no GPU filler, so an encode
session's frames could only be uploaded by the CPU, and the arm answered no
encoder (f716a52d2a: "rt releases no encoder's sources to the driver yet").
The arm's GPU copies on rt (`fill::DeviceFills`) now give each encode session
a filler. Its input is a dma-buf block of the device's, made when no input of
the shape is free and imported on the encoder's display; a frame's two planes
are read where they lie, in the surface's pages or its device caches, and
written into it by videoEncodeFill, margin included, so the encoder codes the
bytes the upload would have given it. A blit hands the block to the driver
(`release_to_external`) behind the kernel, and the frame is coded once the
GPU's write is waited for; no B pictures are coded, so the driver has read the
input before the next frame's write. An input the driver still holds is not
written; a plane in its cache's surface, or one the input cannot hold, is
declined and that frame uploaded, said once a session. A write that fails on
the GPU keeps its filler and input for the session's life, and the session's
later frames are uploaded. Decodes are unchanged: the copies make no copier,
for the same reason as before.
The session's end logs how many frames went each way. The arm still answers no
encoder here; the next commit turns them on.
New tests: the input's planes and the kernel's arguments on the testkit; the
kernel on the rt device writes frames of NV12 and P010, with and without
margins, at odd offsets and pitches, as the upload writes them, and nothing
past the coded rows; on the VA-API host, frames written by the GPU code byte
for byte as the uploaded ones, an x86 guest's session's and an arm64 guest's
paravirtual encoder's.
The VA crate's encoder read its frames only from host bytes, which it uploaded
into a surface of its own pool. The rt platform can make the encoder's input
itself: a dma-buf block the encoder's display imports, which the device's GPU
writes the frame into where its planes lie, with no upload and no staging
copy.
`VideoEncoder::input_shape` names the input such an import must be: NV12 or
P010 at the encoder's coded size. `import_input` (Unix) imports a dma-buf as a
linear surface of that shape through DRM PRIME, as a decode's targets are
imported, keeping the caller's memory while it lives. `encode_target` codes
the frame written there, margin included, and reads none of the frame's
planes; an import of another shape is refused. A stalled frame's import is
kept with its session, as the driver may read it still.
Two ignored tests on the VA-API host: frames written into an import code byte
for byte as the same frames uploaded, for each profile the driver encodes, and
an import of another shape is refused.
The two vaon12 tests of the adapter's device after a display's let-go fail
on Mesa 26.2.7's vaon12 over the UHD 630: the driver leaves one Direct3D 12
object of every decode session past vaTerminate, whatever our surfaces, and
nothing in our order of calls reaches it. Their ignore reasons and docs now
say so, and docs/video/bugs.md's new U31 records the measurements, so a run
of the ignored tests on the Windows host reads as the driver's and passes
once a driver frees what it made.
The pin's range refuses a render pipeline state that fetches or blends an
extended-range colour attachment on every device (Translation-Format), and makes
a fragment function whose SIMD-group operations read other lanes where the
device reports shaderQuadControl, refusing it elsewhere
(Translation-SubgroupOperations). The ledger's list of the translator's
refusals names both. It named no argument buffer sampling refusal, which the
range translates, so no row goes.
The 3090's fault at job 60124 left no named cause: at a loss, the rt
platform wrote one line naming the GPU, the Vulkan call and its result,
and nothing of the work that was on the GPU.
Each command buffer rt ends as in flight at its device's loss now writes a
line after the device's, naming the guest's command buffer by its object
id and the object ids of the first compute and the first render pipeline
state its encoders set, or none; a command buffer of the host's own says
so. A command buffer cut in parts writes one line however many of its parts
are lost. The first 8 write theirs, the next one that the rest are counted
only, and each is counted, rt-device-lost-in-flight.
The record is the cheapest that holds them. The decoder makes the guest's
names for a command buffer's work once, at its begin, and hands them to the
platform before any encoder (CommandBuffer::names_work, a no-op by default
that makes no Metal call), which keeps them on the command buffer and each
part cut from it. A walk keeps its first pipeline state of each kind in a
cell, read at each set, and notes them in the names with relaxed stores
before each commit of what it walked: a cut, a dealt chunk's commit, which
notes its chunks' firsts in their order, and the last commit. Nothing per
draw, and nothing reaches the guest: the line is a diagnostic.
What changes for the guest: an HEVC picture NVDEC answers failed once it ran
(its slice data damaged past what the parsers read) lands as NVDEC left it, its
command buffer completing as any, and the pictures after it decode from it, as
an H.264 picture NVDEC failed has. Before, its landing failed its command
buffer, which AppleGVA's HEVC path answers with kVTVideoDecoderMalfunctionErr
for that picture and every later one of the session.
Why: a Mac's hardware HEVC decoder hands such a picture on, as its H.264 one
does (measured with VideoToolbox on a MacBook Pro of 2019, macOS 26.7.1, on
the UHD 630: an HEVC P picture at 1080p whose last slice segment was cut to
half, and each picture after it until the IDR picture, came back with status
0 and an image). AnnexBDecoder::copy_failed_pictures now asks this for both
codecs, and its NVIDIA test cuts an HEVC P picture as it cut an H.264 one.
What changes for the guest: a host session's decode whose picture is one of
the stream's that does not decode no longer faults its command buffer. Such a
picture is one whose bytes do not read as H.264 or HEVC reads them, one that
predicts from a picture the decoder does not hold (a session or a seek that
starts at a P picture), or one after a picture that did not decode, before the
next I or IRAP picture. It now lands nothing: its command buffer completes as
any, its output keeps its bytes, and the session decodes again from the next I
or IRAP picture. This holds on VA-API and NVDEC, for H.264 and HEVC, and on
VA-API also covers a RASL picture the stream's random access skips, which
faulted there while NVDEC already landed nothing for it. A stream the decoder
does not take, an avcC or hvcC record's error, and the hardware's or the host
API's errors still fault.
Why: a Mac's hardware decoders answer each such picture alone and decode on
(measured with VideoToolbox on a MacBook Pro of 2019, macOS 26.7.1: H.264 with
no error, HEVC with kVTVideoDecoderBadDataErr or ReferenceMissingErr and no
image). Before, a guest boot on a Radeon 780M counted 85 decode faults
("a reference frame is missing", "PPS 4 has not been received", "no I picture
has decoded since a picture that did not decode") for H.264 streams started at
a P picture or with a damaged header, and an HEVC picture that faulted would
end AppleGVA's session with kVTVideoDecoderMalfunctionErr from that picture
on. The codec errors say which are one picture's (is_picture_error), and NVDEC's
error keeps them apart (Error::Picture), still reported as bad data.
The device's imports of the guest's pages into the host GPU can outlive its
release: rt frees them on a thread of its own once no GPU work uses them, and
the release of the last device keeps the GPU device for the process when its
wait runs out. So the memory map's host memory stays mapped, and is not
unmapped, mapped anew or discarded, until the process exits (the header's
RvgMemoryRange and memory_map, docs/api.md, and reims-vgpu's MemoryMap).
QEMU's side does not change: the machine holds its RAM backend until QEMU
exits (hw/core/machine.c:1216), and the VMs reims-ctl makes discard no guest
RAM: no balloon, free page reporting, virtio-mem or memory hot-unplug, and
their RAM is a shared mapping, which KSM does not merge.
A cached surface's device cache could hold the pages as they were mid-write
with no refill ever asked: the bundle recorded the surface's unlock seed only
as a commit first named a generation, so a fill the bundle never saw (a
present's, the first fill a block owes, a block named again) made while the
CPU held its read-write lock stood until the next lock. Such a present also
left the record to be made after the unlock, which then never asked.
The kext now writes each generation's refill record into the block's header
itself, as it caches the block and at each read-write lock, before the
generation, with the surface's unlock seed then (RgfxSurfaceRefill.hpp,
which the bundle shares). The first commit, in any process, once the unlock
seed has moved past the record's carries RGFX_SURFACE_USE_REFILL and settles
it; a commit while the lock is held or being taken asks nothing and leaves it
owed. For the host: a use after each read-write lock's unlock now carries the
flag, including the first use of that generation; the host ignores it where
the cache holds an older generation, as before, so a generation never filled
mid-write costs no extra fill. The record is one 64-bit word written by
compare-and-swap, so a holder never writes over a newer generation's record.
The bundle now names read-only anonymous memory unchanging where its maximum
protection has no write, the kernel answers it SM_PRIVATE at a shadow depth of
0, and mach_vm_page_info's VM_PAGE_INFO_BASIC answers its object's count as 1
at depth 0 with the region's object id (kRgfxAnonymousPrivate). The kext takes
such a block (kRgfxPagesSoleHolder, 1 << 3, where it sets
kRgfxKextFeatureSoleHolderPages, 1 << 20) and marks its SURFACE_PAGES
RGFX_SURFACE_PAGES_UNCHANGING without COPY_ON_WRITE, so the host reads its
pages once, as the view is imported. On P2's guest (macOS 26.7.2, the Windows
mini) the 4K block over such memory was copied whole at each commit that used
it.
A wire holds no reference, so the count leaves out wires for writing taken
while the memory was writable. The kext knows its own: it refuses the block
(kIOReturnNotPermitted) where, once its pages are wired, a writable block of
its own in the table or an in-place surface block covers a page of them, or a
block of writable memory is being made (writableMakes), and the bundle then
asks a read-only block, why RGFX_PAGES_WHY_REFUSED. The check sorts the
block's runs and walks every writable wire's segments under contextLock, once
per such make. What is left is a write another driver started before the app
removed write for good, still landing after the make.
The clause is on for every guest kernel, with no release gate. The facts it
rests on, read in xnu's published source at each tag from macOS 11.0.1 to
26.5, osfmk/vm/ lines:
xnu- cnt pid rid fake prot upl clamp iopl walk id
7195.50.7.100.1 19154 19264 14459 19126 6172 6459 17037 9030 14915 1209
7195.60.75 19074 19184 14406 19046 6156 6459 16984 9030 14862 1209
7195.81.3 19074 19184 14413 19046 6157 6459 16984 9030 14869 1209
7195.101.1 19119 19229 14290 19091 5915 6457 17020 9010 14749 1190
7195.121.3 19158 19268 14329 19130 5916 6457 17059 9010 14788 1190
7195.141.2 19158 19268 14329 19130 5916 6517 17059 9070 14788 1190
8019.41.5 19330 19440 14493 19302 6007 6551 17227 9137 14952 1190
8019.61.5 19330 19440 14493 19302 6007 6551 17227 9137 14952 1190
8019.80.24 19330 19440 14493 19302 6007 6551 17227 9137 14952 1190
8020.101.4 19330 19440 14501 19302 6003 6543 17247 9143 14960 1188
8020.121.3 18885 18995 14245 18857 5918 6541 16960 9131 14704 1168
8020.140.41 18945 19055 14305 18917 5909 6542 17019 9135 14771 1168
8792.41.9 19527 19637 14780 19499 5939 6701 17519 9294 15246 1166
8792.61.2 19538 19648 14791 19510 5939 6753 17530 9346 15257 1167
8792.81.2 19538 19648 14791 19510 5939 6753 17530 9346 15257 1167
8796.101.5 19669 19779 14872 19641 5926 6750 17650 9273 15338 1164
8796.121.2 19669 19779 14872 19641 5926 6750 17650 9273 15338 1164
8796.141.3 19738 19848 14911 19710 5940 6774 17695 9297 15377 1164
10002.1.13 19897 20007 15074 19869 6032 6791 17854 9316 15540 1163
10002.41.9 19910 20020 15087 19882 6032 6771 17867 9296 15553 1165
10002.61.3 19910 20020 15087 19882 6032 6771 17867 9296 15553 1167
10002.81.5 20023 20133 15121 19995 6041 6771 17980 9296 15587 1167
10063.101.15 20254 20364 15180 20226 6098 6774 18210 9299 15646 1355
10063.121.3 20357 20467 15247 20329 6123 6774 18308 9299 15714 1355
10063.141.1 20359 20469 15249 20331 6125 6774 18310 9299 15716 1355
11215.1.10 20139 20249 14984 20111 5692 6843 18096 8188 15442 771i
11215.41.3 20139 20249 14984 20111 5692 6843 18096 8188 15442 771i
11215.61.5 20501 20611 15230 20472 5759 6817 18384 8162 15693 765i
11215.81.4 20507 20617 15236 20478 5765 6817 18390 8162 15699 765i
11417.101.15 20646 20756 15393 20617 5804 6766 18487 8111 15856 765i
11417.121.6 20694 20804 15441 20665 5843 6781 18535 8129 15904 766i
11417.140.69 20703 20813 15449 20674 5841 6777 18546 8124 15913 766i
12377.1.9 20960 21070 15518 20931 5974 6988 18734 8331 16004 776i
12377.41.6 22004 22114 16433 21975 6174 7198 19709 8562 16933 807i
12377.61.12 22037 22147 16463 22008 6204 7203 19742 8567 16963 808i
12377.81.4 22109 22219 16534 22080 6275 7209 19813 8573 17034 808i
12377.101.15 18688 18805 13571 18677 5743 7659 16128 8765 14068 824i
12377.121.6 18686 18803 13569 18675 5722 7659 16126 8765 14066 824i
cnt vm_map.c, vm_map_page_range_info_internal: the top object's count,
less the query's own reference to 12377.81.4, read before it after
pid there: the id, VM_KERNEL_ADDRPERM to 10063.101.15, ADDRHASH after
rid vm_map.c, vm_map_region_recurse_64: the region's id, VM_OBJECT_ID
id vm_object.h (i: vm_object_internal.h): VM_OBJECT_ID, the low 32 bits
of pid's macro in each tag
fake vm_map_page_range_info_internal: a footprint query's count of 1 and
an id of no object (task_self_region_footprint)
prot vm_map.c, vm_map_protect (its preflight from 12377.101.15): no
protection the maximum lacks
upl vm_pageout.c, vm_map_create_upl: no write UPL where the entry's
protection lacks write; from 12377.1.9 through vme_allows_upl_write,
whose test is at 6786, 6986, 6991, 6997, 7413 and 7413
clamp vm_map.c, vm_map_remap_extract: a share's maximum is the source's at
most, which memory entries take through vm_map_copy_extract
iopl vm_pageout.c, vm_object_iopl_request: the UPL keeps the object with
no reference of its own
walk vm_map.c, vm_map_region_walk: the count less one while paging, so
the share mode alone leaves it in doubt
Later releases are checked by test: guest/bundle/tools/sole_holder_probe.c,
which the lane gate's info phase (item sole-holder) and Ambrosia's
check-boot.sh (check sole-holder) run on each guest they boot, reads the count
as 2 with a memory entry or a second mapping holding the memory and 1 once it
goes, sees a footprint query answered otherwise, the kext's writable wire of
memory whose maximum lacks write refused, a sole holder's block made, and
refused while a writable block of the kext's covers it. A release where it
fails is a red leg. The kext's tests cover the wiring and the runs' sort and
search, and the bundle's a sole holder's block named and refused.