A released block's device cache was dropped on the surface worker under its
block's key, and so were the views and the SURFACE_PAGES and BUFFER_OVER_PAGES
jobs, on the worker's four threads. A video session's caches go together at its
end: on Windows each is a Direct3D 11 target pair whose drop flushes both
immediate contexts under the plane draws' lock, 6 ms at the median and up to
100 ms under that contention. On the UHD 630 the held pass's 240 pairs kept all
four threads busy, and the next session's first SURFACE_PAGES, taken 15-19 ms
after its open and done in 0.02 ms, waited 512-586 ms for a thread to post its
answer; the guest's first copy took 516-600 ms.
The caches now go on a worker of their own, reims-vgpu.graphics-let-go-<i>,
each block's in its order: at a BLOCK_RELEASE, and once a block is named again
without a cache, whose drop ran inline on its ring-0 lane before. Their drops
answer nothing and no job waits for them, so a pages job no longer waits behind
them. The Linux arms' caches, VA-API's dma-buf imports and NVDEC's, go the same
way through the same let-go. A view's drop stays on the surface worker under
its block's key, as its mapping may go back to the idle pool the block's next
SURFACE_PAGES takes.
The planner measured the copies on the M3's walk: while apps opened, from
24% to 152% of a 1080p frame's bytes; in steady animation, under 1%. On a
Mac the guest's pages reach the GPU by host pointer, and that kind of import
has no handover that keeps an image's bytes, so the platform copies them.
Linux hosts import through dma-bufs where the pages lie in one, and an
in-place form there is being built.
docs/known-issues.md's Mac section becomes "On a Mac", with the macOS 26
floor and this as its two parts. Windows is named as a fact of the code:
rt_platform/buffer.rs's import_pages takes the pages by pointer on every
host but Linux's dma-buf path (buffer.rs:1483-1491); the copy amounts are
measured on the Mac only.
docs/known-issues.md and install-ctl.sh's warnings said that on a Mac with
no KosmicKrisp, macOS 15 or earlier or a mesa without the driver, VMs get no
GPU. They do not start: the library's device has no GPU device to open
(reims-vgpu's GraphicsDevice::with_platform refuses with HostResources), so
rvg_graphics_device_create refuses, and QEMU's reims-graphics-pci fails its
realize, which ends QEMU before the guest runs. reims-ctl gives every arm64
VM that device, and arm64 VMs are what a Mac runs.
The doc's heading and paragraph and the installer's two warnings now say the
VMs do not start.
The cutover makes the rt platform the library's platform, and with it some
things a user meets that the README did not say: on a host of several GPUs
the VM takes a discrete GPU over an integrated one, untimed, so a host whose
integrated GPU is the faster one gets the slower card; three open bugs of 4K
H.264 video on a Windows host; the host memory the guest's Shared pool holds
beyond the VM's RAM, with its 64 MiB headroom and 5 s release delay; and on a
Mac, Mesa's KosmicKrisp, which Homebrew builds only on macOS 26 and later.
docs/known-issues.md says each in the user's voice, with how to pick the
other GPU through reims-ctl's --gpu or --env, and the README's Beta note
links it in one sentence.
The pool asked its source for 64 MiB pieces. metal2vulkan-rt's unit is 16 MiB:
a take of up to a unit lands in a unit rt's block maker made ahead, with no
Vulkan call, while a longer take makes an allocation of its own length on the
pool's thread and rt frees it as one call once it has been idle 250 ms. A
driver may hold the device's submissions for the whole of such a call, longer
the longer it is: on an RTX 3090 a free on rt's slow path held a submit 72 ms
for 64 MiB and 20.6 ms for 16 MiB, and rt's ALLOCATION_LEN records a 16 MiB
Shared allocation holding one 3.3 ms at the median and one of 256 MiB 51 ms
(measured).
A piece the pool asks for itself is now one unit, BLOCK_LEN, read from rt
(MemoryClass::Shared.block_len()). The headroom keeps the bytes it kept, 64 MiB
(HEADROOM), as four empty pieces: the pool asks a unit for each piece the
headroom is short, counting the asks its thread has yet to serve and the one it
serves, and gives back only the empty pieces above the lowest 64 MiB of them. A
take longer than a unit still has a piece of its own length.
What the host sees: pool_add and pool_remove carry 16 MiB pieces where they
carried 64 MiB ones, four adds at the guest driver's take of POOL where there
was one, and, as the guest's use grows and shrinks, up to four times the adds
and removes for the same bytes, each piece a mapping of its own (QEMU: an
unmergeable RAM region, a KVM memory slot in each address space).
What the guest sees: a block's offset in the pool, and its GPU address where
the guest took POOL_ADDRESSES, follow the 16 MiB pieces. Blocks that shared a
64 MiB piece now lie in up to four, and a take longer than 16 MiB, which fitted
the old piece, has a piece of its own past the headroom's.
The tests that held the one 64 MiB piece count the headroom's pieces, and
a_piece_is_one_rt_unit pins the unit, the headroom's bytes and the long take's
own piece.
The owner ordered the cutover: the library's platform is RtPlatform, over
metal2vulkan-rt, from this commit on. The rt feature of reims-vgpu-vulkan,
reims-vgpu and reims-vgpu-c is now on by default, so `cargo xtask dist`,
`make`, the installers' builds and QEMU's link all make every handle on
RtPlatform. Every test set that builds those crates with their default
features now runs rt's tests where it ran the old platform's.
For the guest everything the device answers and draws now comes from rt:
pipelines through rt's translator, memory from rt's pool, surfaces and imports
through rt's paths, on the host's Vulkan driver on Linux and Windows and on
Mesa's KosmicKrisp on a Mac. The old platform, VulkanPlatform over
metal2vulkan-runtime, still builds without the feature until its code is
deleted, which comes next. Anything wrong on rt is fixed forward.
fce2381013 tells the guest of a drawn picture's decode before its draw, so a
player that holds each 4K picture no longer waits for the draw between its
decodes. Measured on the Intel UHD 630 (Vulkan driver 101.2145, Mesa 26.2.7's
vaon12), 2026-11-20, in two exclusive boots of a macOS guest with it and two
of the same tree without it, four held passes of each file a boot:
- held 4K HEVC played at 57.5 to 69.8 fps with it, against 27.9 to 44.3;
- held 4K H.264 at 89.1 to 127.6 fps, against 62.8 to 121.7.
check.js matched 240 of 240 frames in each of its four checks a boot on both
trees. What is left of a held picture's time is the driver's decode, which
the entry said the device cannot shorten.
docs/video/bugs.md gave U28 to two upstream bugs. The first, iHD and
radeonsi decoding nothing of a 4096x4096 H.264 picture, keeps U28: D25,
devices.md, vaapi.md, lessons.md and h264.rs cite it. The second, radeonsi's
decodes writing an imported surface only within the bytes its planes as
declared span from the luma plane's first byte, becomes U29, with the two
comments that cite it (the VA crate's target.rs and the arm's tests).
Comments and docs only.
On the rt platform on Windows, a picture whose output's planes lie in a
cache's surface over Direct3D 11 textures lands by a draw from the texture
the driver decoded it into. The landing waited for the decode, drew, and only
then did the guest hear of the frame: a command buffer of the decode alone
posted its CB_COMPLETE at its platform end, behind the session's signal. A
player that holds each picture keeps one decode in flight, so each picture
took the decode, the draw (4.4 to 5.2 ms of a 4K HEVC picture on a UHD 630)
and the guest's own work in turn (docs/video/bugs.md, B96).
The landing now tells of the decode done between its wait for the decode and
its draw, as the VA-API arm's video processing on Linux does as it issues its
copy. What changes for the guest: such a command buffer's CB_COMPLETE goes as
the decode is done, in its queue's order, with GPU times of 0, while the draw
runs. Nothing else moves. The session signals the decode once the draw is
done and the platform holds what it wrote, and the buffer's end, its surface
timeline and every read of the output wait for that signal: a command buffer
of another queue that uses the output (a blit or copy from its texture or its
buffer among them), a decode into it, a lock's download and a present. No
reader sees the picture half drawn. A draw that fails falls back to the CPU's
copy, still before the signal; a picture that fails to land after its
CB_COMPLETE fails the session's next decode in its stead, counted as
video-landing-failure-carried, as on Linux.
No test held the old order: the drawn landing needs vaon12 and a decode. New
tests: a session posts a picture's completion at its decode-done tell and
signals the decode only once the rest of its landing is done; and a blit of
another queue from the output, its texture's texels and its buffer's bytes,
copies only behind its wait for the decode's buffer's end, which that buffer
signals only behind its wait for its session's value. The tests of a reader
on another queue, a decode, a download and a present after a completion at
the decode hold for the draw as for the copy.
A large surface's whole-extent shape had its block taken ahead, on a worker
pool of its own after its SURFACE_PAGES answer, so that the ring could place
the shape's image in it instead of taking a block at the make. On a 3090 walk
(the desktop, a browser and a 3D benchmark), no placement into a block taken
ahead saved a make: 33 images placed so at 2648x1618 took 1.47 ms each,
against 1.21 ms for the 8 of that shape made with a block taken at the make;
2 at 3648x2038 took 1.64 ms against 1.67 ms; and the two shapes whose makes
took longest were never placed so. 54 blocks were taken ahead (1755 MiB), and
19 of them went back unused (1141 MiB).
The take ahead, its worker pool (reims-vgpu.graphics-shape-blocks-<i>),
ApiPlatform's shape_block and placed_shape_image_in, rt's ImageBlock, and
their codes (rt-shape-blocks-ahead*, rt-shape-image-makes*) are removed. A
new shape's image is made on the thread that asks for it: it is placed in a
block taken at its make where its fill copies more than zeros, and is the
platform's own otherwise, as before the take ahead. The guest sees the same
values.
The device choice now passes over a device a display's window cannot present
on, so with KosmicKrisp's manifest where Homebrew's mesa puts it the default
platform opens MoltenVK. docs/qemu.md and install-ctl.sh's comment said it
timed KosmicKrisp as the faster and took it; they now say it passes it over,
with the M3 Max boot that shows it (m3-max-57194: 16 of 16 checks, the
full-screen Metal app at 60 fps with 600 frames and none dropped), and keep
the earlier numbers as what it did before. mesa stays out of what the script
installs, as the default platform does not use it.
metal2vulkan's development b676eda182 refused a colour render target made with
no texture index. The blit seam's tests made theirs directly with the runtime and
failed on every rt device, but they are ignored on macOS, so only the Linux and
Windows legs of the pin's batch could see it. The lesson says how to find such
tests before a pin's batch.
install-ctl.sh's comment said the default platform takes the first GPU of
its kind the loader lists. It times each GPU the loader lists and takes the
fastest (device_choice.rs), and a boot measured what that does when Homebrew's
mesa puts KosmicKrisp's manifest where the loader reads it: on the M3 Max the
default platform took KosmicKrisp, on which a display's window cannot present,
and check-boot's full-screen Metal app ran at 30 fps with dropped frames and
failed, where on MoltenVK it runs at 60 fps with none dropped.
The comment now says so, and docs/qemu.md records the boot beside the rt
build's, which passed all 16 checks on the KosmicKrisp the install links.
The rt platform loads the Vulkan loader and Mesa's KosmicKrisp only from
beside QEMU's binary or from ../lib (rt_driver.rs), and nothing put them
there: lanes linked them beside QEMU by hand.
On a Mac, install-ctl.sh now links both into the lib directory of the QEMU
it installs, and make qemu (or make vulkan-links) into build/lib, which is
../lib from build/qemu and from the arm64 build directory docs/qemu.md
configures beside it. Each link points into its Homebrew formula's opt
directory, so brew upgrade reaches it: the loader to vulkan-loader's, the
driver to mesa's. Homebrew's mesa formula is Mesa's release built unpatched
(26.3.1, the release the M3 boots on rt used), and its macOS 26 and later
bottles build KosmicKrisp, so no Mesa build of our own is needed.
Neither installs mesa: with its manifest in Homebrew's share, the system
loader lists KosmicKrisp ahead of MoltenVK (measured on the M3 Max), and the
default platform would take it in MoltenVK's place before the cutover.
Where Homebrew has no KosmicKrisp, no link to it is made and rt makes its
own instance, as before. Linux and Windows installs are unchanged: the new
code runs only where uname says Darwin.
The staged copies' spare pieces were topped up on a thread of their own
after each copy. One 780M walk made 72 scratch pieces beside 27 spares
topped up, and on the 780M a buffer make holds the process's submits
through the driver's lock (6 submits, median 6.50 ms, max 9.76 ms), so a
make on any thread holds up the guest's work.
The two kept pieces now circulate instead. The first two pieces made are
whole 16 MiB pieces, kept; a copy takes an idle kept piece and gives it
back to the kept ones when its command buffer completes. Nothing is made
after a copy, and the top-up thread
(reims-vgpu.graphics-staging-spares-<i>) is gone. A copy that finds no
kept piece idle makes a scratch piece of the length it needs on its own
thread and lets it go once its copy is done, counted as before. Scratch
pieces given back under the caches' lock are let go of after it.
What changes for the guest: its copies make no staging buffers but the
first two kept pieces and the scratch pieces of copies that find none
idle, and nothing makes buffers between copies; the first two copies
make a whole 16 MiB piece where they made the length they needed.
Counters: rt-staging-spares-unused is gone; rt-staging-spares-dropped
(-kib) counts kept pieces let go of without coming back, and
rt-staging-piece-get-ns and -max-ns time each copy's getting a piece.
Held 4K HEVC played at 35.3 fps with the spares made ahead (m3-max-56925).
B96 records where a picture's time goes: the wait for the driver's decode,
7.7 to 11.9 ms a pass, which the host alone shows is the driver's
(18.9 to 19.4 ms with one in flight, m3-max-56739), and our draw into the
output's textures, 4.4 to 5.2 ms, with the fix that would take the draw
off the frame's chain.
A drawn cache's ask that found no spare made its own surface on the ring
while the spares' thread could be making the very spare it asked for. Two
makes at once contend in the driver: in held 4K H.264 on the UHD 630
(m3-max-56925, round 1 pass 2), 78 makes on the ring took 29.2 ms each and
the spares' thread's 162 took 21.0 ms, where the same pass made each on
the ring at 9.8 ms before the spares (m3-max-56661), and the pass fell
from 76.1 to 44.3 fps.
So an ask whose make is running waits for it and takes its spare, bounded
at ten slices of 10 ms, past which it makes its own as before. Counted:
video-drawn-spares-waited, the asks that waited, with
video-drawn-spares-wait-ns their wait and video-drawn-spares-wait-max-ns
the longest, so a boot shows each take waits about one make.
On Windows a video cache's surface over two Direct3D 11 textures is made at the
guest's first texture over one of its planes, on the ring-0 thread that carries
that texture make out, and the guest's next messages wait for it. A player that
holds every picture it decoded takes a new IOSurface, and so a new surface, for
each picture. Measured on the UHD 630 (2026-11-19, a macOS guest's 4K playback,
pictures held): the targets' make took 9.3 to 9.8 ms on the ring and their
import about 0.7 ms a picture between the HEVC stream's decodes, of a 26 to 33
ms gap from one decode op to the next, as the guest keeps one HEVC decode in
flight; the H.264 stream's first round made them in 14.7 to 18.2 ms.
Each ask now takes a spare made ahead for the same plane shapes, formats and
device recoveries, where one is kept, and hands the makes that bring its spares
back up to the depth to a thread of their own
(reims-vgpu.graphics-drawn-spares-<i>), which nothing waits for; an ask that
finds none makes its own as before. The depth is the guest's decodes in flight
at its last decode (the session's value less its event's signalled value), at
least one and at most 8 spares in all, which bounds their memory; the makes run
one at a time under the device's reset gate held shared. The guest sees the
same surfaces: only the thread and the time of their make change. Counted as
video-drawn-spares-used, -missed, -made and -dropped.
A carve passed over the zeroer's claimed chunk to the next fit past it, so where
a take's first fit held some of that chunk, the block's offset and GPU address,
which reach the guest, depended on how far the zeroer had got. The 3090 leg
caught it: a_block_of_a_source_with_no_addresses_takes_the_hosts_next_pick
found the freed block's bytes carved at 0x10000, not 0, the zeroer writing the
lower half of them as the take came.
Such a take now waits for the chunk's write, as a take only the chunk kept out
of every piece already did, and is carved at its first fit: one chunk's write
at most, counted with the other claim waits, and blocks lie where they would
with no zeroer. The wait's count goes down from there to the take's carve with
the pool's lock held, so the zeroer claims no new chunk under the waiting take.
With 64 MiB pieces, most of a take's bytes lie in a piece no block held
before, which the take's worker zeroed while the guest waited: on a 3090
walk the take path zeroed 3794 MiB (928 MiB with 256 MiB pieces), and the
takes' zeroing waits rose from 41.5 to 120.6 ms. The pool's zeroer only
zeroed a freed block's bytes in a piece another block still held.
The zeroer now zeroes, ahead of the takes, every byte no block holds and
no zeroing reached in each piece a block lies in and in the headroom, the
lowest empty piece, from its place on, before the host maps it. It
zeroes no other empty piece: one above the headroom goes back whole past
its delay, untouched. It takes the lowest such run first, the one a
take's first fit meets, from the run's top down.
It no longer writes with the pool's lock held: it claims a 64 KiB chunk
and holds its piece under the lock, writes it with the lock let go of,
and marks it zeroed under the lock again. A carve passes over the
claimed chunk, so no byte is zeroed twice and the chunk's piece goes back
only once the write is done. Where the claimed chunk alone keeps a take
out of every piece, its worker waits for that one write instead of
asking for a piece, counted (pool-take-claim-waits, -wait-ns).
The zeroer's bytes are counted as pool-zeroed-ahead-bytes (was
pool-zeroed-after-free-bytes), its writes' time as pool-zero-write-ns and
-write-max-ns, and its holds now cover the pick and the mark alone.
A refused pipeline's AIR alone does not reproduce its refusal when the guest's
call adds what refuses it: a kernel that compiles with default function
constants can be refused for the values or descriptor fields the guest passed.
Under the same off-by-default switch, REIMS_VGPU_REFUSED_AIR_DIR, each refused
compute or render state now also writes a record into records.txt next to
refused.txt, once per distinct record. The record holds the creator and the
refusal; for each stage, its function, whether it was made specialized, each
function-constant value with its index, declared name, type and bytes, and each
declared constant left undefined; the same for each linked function; and each
field of the descriptor rt was given. The records are the guest's data: they
are written only to that directory on the host, never to stderr or the log.
The rt-diag refused-air line now also counts the records.
On rt, a cache's first shape over rt's 16 MiB unit makes its image in a
Private block of its own, taken on the decoding thread: a 34.5 MiB image's take
took 24.6 ms on a ring on a Radeon 780M, and the longest of rt's takes in a boot
45.7 ms, each a stall on the guest's path. A cache's surface pages give its
whole-extent shape before a draw needs it, so after the SURFACE_PAGES answer the
device asks a worker pool of its own (four threads, keyed by the block) to take
that shape's block, holding the reset gate shared. The ring places the shape's
image in the block when the take has landed, and makes its own as before when it
has not: it never waits for the take. A block no image takes is given back.
New codes count the shape images the ring makes (all, over rt's unit, and in a
block taken ahead: count, ns and longest), the blocks taken ahead (count, ns,
longest and KiB), and those that came late, did not fit, were refused or went
unused.
The arm64 macOS 26 boot on rt refused 5685 draws, the first of them as
reading a colour attachment through its texture (FetchedAttachment), and
nothing said which attachments those were: rt refuses one that is no 2D
texture, renders another level or slice, has no index, shares its image
with another target, or that the device reads no attachment through. The
boot diagnostics now count each such draw by each colour target's class
(how its texture was made, type, samples, level and slice, index, whether
its image's usage reads and writes, its usages, a shared image), with a
first line per pipeline state, as they do the attachment reads.
They also count rt's refusals of Metal's and its limits by variant, where
the counts line has one rt-refused-metal and one rt-refused-limit, and
the sampler states made, with those that clamp to their border colour by
the colour.
And a diagnostic switch, off by default: REIMS_VGPU_REFUSED_AIR_DIR keeps
the metallib of each function of a pipeline state the translator refused,
once per library, with a line per refusal, in air-<pid> in the directory
it names, so the refusal can be read on the host that met it. It is the
guest's code: it stays on that host, and nothing commits or copies it.
rt writes nothing when its VkDevice is lost, and the platform answered the
lost work with codes alone, so a run that lost its device left no trace on
the host but the guest's own silence: two walks froze that way with nothing
in their logs to say why.
The first command buffer that fails with the device lost now writes one
line on stderr, once for the device, beside the platform's other
degradation lines: it names the GPU (name, PCI vendor and device IDs) and
how many command buffers were committed and not complete at that moment.
Each command buffer that fails so is counted under rt-device-lost, so the
boot's degradation counts say how much work the loss ended. The ledger's
rt device-loss row says so in place of "nothing logs or counts the loss".
The row named what the guest ran in the two rt walks that lost their device.
The ledger keeps walk facts generic, so it now says only that the guest's
running app logged nothing for its last ~3 minutes, until the walk stopped it.
The rt device-loss row said no rt boot had lost its device. Two had, while
every command buffer the loss ended still answered 11: m3-max-53777 on the
3090 and m3-max-54078 on the XTX. In each, the running benchmark stopped
making progress for its last three minutes. The row now says that, and that
what the guest does with 2 and 1 is not measured.
Each many-passes test submits 706 passes, each after a 1x1 encoder, as
one vkQueueSubmit of 1413 command buffers. Beside the rest of the Windows
tests on the UHD Graphics 630 that submit lost the device in 7 of 90 tests
over five runs, and the suite's longest test lost its own device in 4 of
the 5, once with no loss of theirs. Neither a 28 GiB commit limit nor
anything in the System log changed or explained it, and the new runtime's
path for the same passes lost nothing in 117 tests beside the same tests.
Alone the tests passed 18 of 18, so on Windows they now run with nothing
else in flight, as the Mac's GPU-faulting test did. The lesson records how
to tell such a loss from paging.
The process's rt platform keeps its device until a host releases its last
graphics device, which no unit test does, so every rt test process reached
the C library's exit with the device live, which rt does not support. On an
RTX 3090 two tiled-texture tests printed ok and then died of SIGSEGV, rt's
memory thread in vkDestroyBuffer while the main thread ran the driver's EGL
exit handler (2 of 2067 tests of one run).
In a test process run as nextest runs it (--exact), the test's thread now
keeps the process's platform and each platform a test makes of its own
(rt_test_end::platform) in a thread-local whose destructor, run after the
test's function and before libtest's join, lets go of each device as a
host's release does, on a thread of its own. A device still held after 30 s
fails the test with _exit(101), running no exit handler. Unix only: Windows
runs thread destructors under the loader lock.
on_vulkan_a_test_s_rt_device_goes_before_its_process_exits runs a child that
takes the device, runs a blit and returns, and checks from the child's exit
handler that rt tore the device down; it fails on the tree before this on
any GPU.
Test infrastructure only: nothing the guest or the host observes changes.
The owner ruled that the cutover ships with no recovery after a GPU device
loss. The ledger listed only the default platform's recovery, so this adds a
row for rt beside it. On rt the device is never made again. The lost work
fails 2 then 1, and every later commit fails at once with 1. A new object is
made only where the driver's Vulkan calls still make one. The window presents
nothing more, while the guest's presents are still answered at each refresh.
The process runs on until the VM ends. What the guest's apps do after that is
not measured.
The pass that zeroes the scanout's room for a new WindowServer was described
from the code, without a measured frequency. A walk on the 3090 under KVM
(job m3-max-50552) read the guest's kernel buffer before and after each step,
and checked that each read continued the one before it. A logout with
autologin off made one pass, and was given the VRAM range once. The login typed
at the login window kept the same WindowServer and made no pass. The boot's
count was not read, because the 128 KiB buffer had dropped the boot's lines.
metal2vulkan development bf55e38ee3 enables VK_EXT_zero_initialize_device_memory
on no device and drops BlockInfo::zeroed: the runtime writes every zero itself,
where new_buffer's zero_from asks for them. So every block counts as unzeroed.
- The pool's take workers zero each carve whole, but for the bytes the zeroer
zeroed after an earlier free (pool-take-zero-skipped-prezeroed-bytes stays).
- A buffer or heap in a block of its own is zeroed: zero_from Some(0), a Shared
heap and a Managed buffer's bytes through the mapping, a Private heap by rt's
fill. A buffer pinned in a known block passes its zero_from as asked.
Gone with the fact: the pool's BlockInfo::zeroed, the codes
pool-take-zero-skipped-bytes, rt-zero-skipped-private-bytes and
rt-zero-skipped-shared-bytes, and the Placed mark, its module and the known
blocks' marks, which only the skip read. The tests that held the skip now hold
the zeros: a take over a given-back carve and past it zeroes all of it, a pinned
Private buffer reads zero at each placement, and the scratch test counts rt's
zeros alone. The guest's bytes read zero as before.
This builds only against bf55e38ee3 or later, so it lands with that pin.
Each zero-copy import made a video-processing context of its own, on its
strips' surfaces, and a driver's first run on a new context costs it a few
milliseconds its later runs do not. A guest's decoder makes a new pool of
buffers for each stream, so each stream's start paid that on the decode
thread once a buffer: on the Radeon 780M (radeonsi, Mesa 26.2.6), 43 new
imports over three streams in Safari issued their first run in 5.3 ms at
the median, against 94 us on a context of their size that another import
had already run on.
The imports of a frame size now share one context, made on no surface with
the size's first import and destroyed with its last: the table of contexts
holds weak references only, so a context holds no memory past the imports
that use it. One import's runs are issued on it at a time. The import check
keeps a context of its own.
The new ignored test checks that two imports of a size share a context, that
another size gets another, that each run writes what its frame decoded, and
that the context goes with the size's last import and a new one is made for
the next.
A picture whose copy into its output's caches fails after its command buffer
completed at the decode can no longer fail that command buffer: the guest
was told it landed. The session's next decode now fails in its stead, its
command buffer completing as one whose picture did not land, so the guest
sees the decode error one picture late (an HEVC picture's schedule gets
kVTVideoDecoderMalfunctionErr) instead of never. The decode after it is not
affected.
It is counted as the degradation video-landing-failure-carried and logged
once per process.
A command buffer that holds only a video decode whose output lies in device
caches, where the VA-API arm copies the picture into the caches by its video
processing on the GPU, now posts its CB_COMPLETE as the session says the
decode is done and the copy is issued, instead of at its platform end after
the copy. The guest's decoder hands the picture on while the copy runs: the
start of a 4K stream decodes one picture at a time into new surfaces, and
each picture's chain waited for its copy.
What changed for the guest:
- such a CB_COMPLETE comes before the copy into the output's caches ends,
in its queue's order of records (a queue's turns of completion posts), and
carries GPU times of 0;
- the guest's writer slots, which it empties at the CB_COMPLETE, then name
the decode no more, so the host keeps each such decode by its blocks until
its platform end: a later command buffer of another queue that uses the
output waits for that end, on the GPU, or on the CPU for a video op; a
present waits for it as for a writer named; a lock's download waits on the
end value as before. Counted as buffers and presents held;
- the buffer's later work, its surface timeline, its caches' copy into the
pages, its context's drain and its place among its queue's buffers in
flight all stay at its platform end, so a reset, a close and a quiesce see
the decode in flight as before.
What changed for the host: raise_interrupt may now be called on a video
session's picture landing thread, reims-vgpu.graphics-video-land, inside the
landing's video processing run (reims_vgpu.h, docs/api.md section 5). QEMU's
reims-graphics-pci raises its interrupt from any thread, and is unchanged.
On Windows on the rt platform, a video cache's two planes can lie in a surface
over two shared Direct3D 11 textures that the VA-API arm draws each picture
into (PlaneDraw), in place of the CPU's copy. The platform imports the textures
through GpuDevice::import_d3d11_surface, which rt_platform answers through a
stub of rt's provisional Device::import_d3d11_surface, the signature of m2v's
42993be0bc: it refuses every surface, counted (rt-refused-d3d11-surface), so
each picture still lands by the CPU's copy until the pin carries the import.
Swapping the stub for rt's call is one function and its plane type.
The draws are made at the arm's open (RtCopies::new), so no picture waits for
their devices and pipelines. A drawn picture holds the textures' keyed mutexes
across the draw, waits on the landing's thread, releases them, and then says
the writes are done (external_writes_done). Each draw is counted by picture
and KiB (video-pictures-drawn, video-drawn-kib): one GPU pass per picture that
a Mac does not make. A plane not drawn falls to the CPU's copy into its image.
The bundle asked the kext for Private blocks of 256 MiB. On metal2vulkan-rt each
was an allocation of the driver's in the take: on NVIDIA's driver about 0.08 ms
a MiB with the device's other calls held, 21 ms for 256 MiB. It now asks for
16 MiB (kPrivateBlockBytes), rt's allocation unit, which rt's block maker makes
ahead of need, so a take is a range of an allocation already made.
A pick whose span and alignment are more than 16 MiB takes a block of its own:
their length rounded up to 64 KiB, holding that pick alone, at the block's first
aligned byte. It goes back to the host with the pick's free. On a 780M desktop
boot, 4 of 77 Private objects were longer than 16 MiB (32 MiB each), 250 MiB in
all.
What the host observes: PRIVATE_TAKE asks for 16 MiB or one object's span rather
than 256 MiB, and a context holds more, shorter blocks, an own block given back
at its object's free. What the guest observes: its Private objects' gpuAddress
values lie in those blocks. Picks, refusals and gives are otherwise as before.
The tests that held 256 MiB blocks now hold 16 MiB ones and the own block.
docs/graphics-kext/design.md says so.
The guest's Metal bundle is to ask for Private blocks of 16 MiB, metal2vulkan-rt's
allocation unit (MemoryClass::block_len), which rt's block maker makes ahead of
need, so the host answers such a take with no allocation of the driver's in it.
An object whose span is longer takes a block of its own, which rt allocates in
the take, on the context's take worker.
Those takes are now counted apart among the sourced ones: private-take-span, and
private-take-span-us, the source's time for them, with the first one's line in
each boot's log. UNIT_LEN names the unit, from rt's block_len. Nothing the guest
or the host observes changes: the counts and the log line are diagnostics.
A staged copy that found no spare made its piece on its own thread, and on a
Radeon 780M 55 first copies of caches did, 124 ms in all, the longest 17.1 ms
(rpstage2's walk). Making the pieces at each cache's make instead moved that
wait into the guest's SURFACE_PAGES answer. Now a copy whose takes leave no
whole piece among the spares hands a top-up to a worker of the spares' own,
which nothing waits for: it makes whole pieces until the spares hold their cap
of two, under the device's reset gate, letting go of shorter ones to fit. A
copy that still finds no spare makes its piece as before, counted as before.
The trigger is a drained spare set, not every take: a take that leaves a whole
piece kept is served again once its own piece comes back, and a top-up after
it would make one piece and let one go per copy (2209 takes on that walk).
The top-ups are counted: pieces made, their time and KiB, pieces let go of,
those a top-up made and no copy took, and the most the spares held. A test's
spares hold their top-ups until it lets them run, so the copies' tests keep
what a copy does with no top-up ahead of it.
Where the guest took MANAGED_AT_COPY and the platform makes the Managed
buffer at an address other than its CPU copy's (a copy in no block the
platform knows, such as one over the region), the host refused the
create, so the guest's id stood for a refused object: nil where bound,
its uses dropped. Metal makes that buffer, so the host must not refuse
it.
The host now keeps the buffer the platform made. It is the buffer the
same create makes from a guest that did not take the bit: the same
platform call, the same pin left unkept and counted, the same binding.
Each such create is counted as managed-at-copy-unkept, the first logged.
What changes for the guest on a unified rt host: such a create is a live
buffer, bound and used as without the bit, rather than a refused object.
Its gpuAddress is the address the guest posted, which the buffer is not
at, as a guest's own pick is not on that host today. Nothing changes
where the copy lies in a block the platform knows, nor on a host that
does not offer the bit.
The wire header's doc for the bit says so. The prebuilt sets and the
option ROM's record are rebuilt from it in their own commit.
The tests compare the answers with the same create's without the bit:
the decoder test its result, the platform's calls, the binding, the GPU
address, the unkept pin's count, a didModifyRange and a synchronize; the
rt GPU test its result, the binding and rt's address over the region.
What changes for the guest: on a host whose GPU shares the CPU's memory, on
metal2vulkan-rt's platform, with the Shared pool, the device offers feature
bit 63. A guest that takes it makes each Managed buffer at its CPU copy's
GPU address, so the gpuAddress its argument buffers and pointers hold is the
buffer's bytes, and it takes no Private block for it. Before, the guest held
its own pick in a Private block, rt made the buffer at the copy's address
instead, and a kernel reaching the buffer through its gpuAddress read the
Private block; each pick also held a Private take (1308 such picks and four
256 MiB Private blocks on a 780M desktop walk).
Where the guest took the bit and the platform does not make the buffer at
the copy's address (a copy in no block it knows), the host refuses the
create, as Metal answers nil, counted managed-at-copy-refused; it never
makes the buffer at an address of its own. A GPU of its own memory keeps two
copies, the Vulkan platform pins each buffer at the guest's pick, and a
device with no pool keeps the slabs' copies in region heaps: none offers
the bit, and their guests see no change.
On development the Private blocks' takes run on a worker per context, and
their release waits until no worker holds the ledger (ce64175ac). The pool's
zeroer met both rules badly:
- a take worker whose carve covered the chunk the zeroer was zeroing waited
for that chunk, so a take waited on the zeroer;
- the release waited for the pool's take workers and its zeroer to leave
their loops, but not for their threads to let go of the pool. The pool's
clock holds the platform, so a thread whose handle was the last could drop
rt's device past the release, the bug ce64175ac fixed for the ledger.
The zeroer now zeroes each chunk, 16 KiB, with the pool's lock held, and lets
the lock go between chunks. A carve is made under the same lock, so it never
meets a chunk half zeroed: no claim and no wait on either side. A holder of
the lock waits at most one chunk's zeroing, as for any other holder. The
zeroer shares no ledger, lock or thread with the Private blocks' workers.
The Private blocks' thread count (Threads, Live) moves to the pool's module.
The pool's take workers and zeroer are counted in it from their spawn until
they let go of the pool, and the release waits for that count. A new test
pins it: after the release, the pool's only handle is the caller's.
Zeroing was 91% of a take's wait on the 3090's desktop walk (220.0 ms of
242.0 ms in all, m3-max-53890): each take zeroed the bytes an earlier block
of its piece had held, on its own worker, before its answer.
A free now hands the freed block's bytes to the pool's zeroer
(reims-vgpu.graphics-pool-zero), when another block still holds the piece.
The zeroer zeroes them 64 KiB at a time, with the pool's lock let go of, and
records them as reading zero. A later take over them leaves them as zeroed.
An emptied piece is never zeroed, because it may go back whole. A release
never waits on queued bytes: they are dropped.
A take over bytes still queued zeroes them itself, as before, and the
zeroer's job skips them. A take over the 64 KiB the zeroer is zeroing at
that moment leaves those bytes to it, zeroes the rest, then answers once
they are done: the zeroer's writes to them may still land. Every take still
reads zero.
Two counts are new: pool-zeroed-after-free-bytes and
pool-take-zero-skipped-prezeroed-bytes.
Since zero copy's runs are issued right behind their decode, a reference on
the rt platform that fails lands as the driver left it, as a picture
decoded into its cache already did and as an H.264 picture NVDEC fails
does. The guest sees those bytes only for H.264, whose failed pictures
AppleGVA hands on as decoded (guest/bundle/src/RgfxVideoStatus.hpp), and
the device's documented answer for those is what the hardware left. Where
the GPU or the CPU copies a picture, it waits for the decode, so a failed
one is not copied, and that is said too.
A frame written into a guest buffer by video processing waited for its
decode on the CPU, then issued the runs and waited again, so the GPU sat
idle between the two for as long as the CPU took to hear of the decode and
issue the runs. On the rt platform every reference picture lands so
(docs/video/bugs.md, B95, added here), and at a 4K start the guest decodes
10 frames one at a time behind those landings. The runs are now issued
right behind the decode, and the decode is waited for between their issue
and their wait: one wait for both.
runs_issued_right_behind_a_decode_write_what_it_decoded, ignored as the
other VA-API tests are, writes each picture of a 4K stream as soon as its
decode is issued and compares the buffer with the picture's read back. It
counts the pictures whose decode was still running as their runs were
issued, and fails where none was.
What the guest can see: a frame whose decode fails still fails as before,
but its buffer now holds what the runs copied from the decode surface,
where it held its earlier bytes, as the runs are issued before the decode
is known to have failed and run whatever it answers. No test holds a
failed decode's earlier bytes in a buffer zero copy writes: the VA tests
that write into a guest buffer check decodes that succeed, and
a_failed_landing_into_a_new_output_leaves_zeros_and_no_host_bytes drives a
landing of the test platform's own, not this one.
The rebase onto development put the contexts' Private takes after the
Vulkan platform's command predication in the conventions' list of counted
codes, which left two "and"s in one list. Drop the first. [ci skip]
On the rt platform, a Windows host answered the guest no hardware video. It
now opens the VA-API arm there, on Mesa's VA-on-D3D12 driver, at the DXGI
adapter whose LUID Vulkan answers for rt's device (HostGpu::luid). The guest
sees H.264 and HEVC decodes where the driver has them, and no encoder, as on
Linux's rt arm.
rt imports no image of the shared Direct3D 12 texture a picture decodes into:
the UHD 630's driver faults binding a two-plane image imported from its D3D11
handle, and refuses single-plane images from the D3D12 resource. So the
session's copier declines each picture at the GPU's copy, counted as
rt-video-gpu-copy-declined, and each lands by vaGetImage and the CPU's copy.
On the old platform on that GPU the CPU's copy took 18.77, 68.35 and 79.28 ms
a picture (1080p NV12, 4K NV12, 4K P010) against the GPU copy's 1.47, 4.18
and 10.36 ms; bugs.md B94 records it and the measured way out.
A lane's release loop removed 30 potluck workspaces that were not its own on
2026-11-19: its lookup filter compared None with None for every record with no
branch. The lesson says how a release is checked so the next one cannot.
PRIVATE_TAKE was carried out on the context's lane. On metal2vulkan-rt each
take is one of rt's Private blocks, a driver allocation, and NVIDIA's driver
holds the device's other calls while it allocates. On an RTX 3090 a boot took 7
blocks of 256 MiB, 52.7 ms in all and 11.5 ms at most, each on the control
ring's lane, which held every context's next messages behind it.
A take of the source's now goes to its context's worker
(reims-vgpu.graphics-private-take), as POOL_TAKE's does. The worker takes the
block from the source and answers. A context's takes are answered in its own
order, so a take waits only behind its own context's earlier takes. A take that
its context's close, the device's reset or its release ended is never answered,
and the block its worker was taking goes back to the source. The device's
release waits for the workers, so none calls the source past it; a worker that
the exit gate parks counts as gone. Where the platform gives no Private blocks,
the host's pick is still answered at once on the lane. The source decides this,
never the driver or the device.
What the guest observes: only when PRIVATE_BLOCK comes. It may now come after
the answers to messages the context posted after the take. Its status, address
and length are unchanged. The kext waits for PRIVATE_BLOCK with no deadline, on
the thread whose create found no room, so no other wait changes.
The degradation counts carry the takes by cause:
- private-take-queued: a take that waited behind its context's earlier take;
- private-take-sourced: a take its worker took from the source, with
private-take-sourced-us, the source's time for those takes;
- private-take-lane-us-most: the longest a take held the thread that carried
it out.
No block is made ahead: a 256 MiB Private make holds an NVIDIA device for
6.5 ms (RTX 3090) to 8 ms (RTX 2080) on any thread, while 16 MiB units stay at
the baseline (a no-boot probe). Smaller blocks are the guest's change, in its
own commit.
rt's BlockInfo::zeroed (metal2vulkan dd4193cab3) says a block reads zero as
rt hands it out: the driver zeroed its allocation and no block held a byte at
or past it before. The owner's rule: zero unless the block says zeroed and
these bytes were never handed out. A block's mark of the bytes ever handed out
(Placed) rises past each placement, and only bytes below it are zeroed:
- own() and own_managed(): a Shared or Private buffer in a block of its own
skips rt's zero or the platform's memset where the block is zeroed;
- heap zeroed(): a heap's block of its own likewise;
- in_known(): a Private buffer pinned in a known block skips rt's GPU fill
where none of its bytes is below the block's mark, which every lookup in
the block raises (buffers, heaps and Managed device copies pinned there);
- the Shared take worker zeroes only the first bytes of a carve below its
piece's mark, raised as the carve is carved.
Skipped bytes are counted by class: rt-zero-skipped-private-bytes,
rt-zero-skipped-shared-bytes and pool-take-zero-skipped-bytes. Every byte
still reads zero to the guest; on a device without zeroInitializeDeviceMemory
nothing changes.
On the Vulkan platform (metal2vulkan's old runtime) rvg_quiesce_for_exit
answered true once the release's let-go took the GPU devices, so QEMU called
exit(). The let-go does not end the runtime's work: a pipeline making of the
warm pass can stay in the driver past the device's last drop, and the
runtime's exit hook, registered as the device was made, then waits for it and
on Linux ends the process at once with _exit. QEMU's exit notifiers never ran:
on an RTX 2080 (620.70.06) a quit 24 s into a boot, its let-go 315 ms after
the quit, ended 9.6 s after it with QEMU's pidfile left (job m3-max-53092).
Now the quiesce answers false once the platform asked the runtime for a device
in the process, kept or let go of since: each of the platform's makes (the
default device, a window's device, MTLCopyAllDevices's, the device choice's
timed devices) and each adoption mark it (let_go::asked_the_runtime_for_devices).
What changes for the host: on the Vulkan platform, a quit after the release
that let go of the device now gets false, and QEMU runs its own exit work (its
exit notifiers, the terminal's restore, the streams' flush) and ends with
_exit and the cleanup's status, as it did with a device kept. The runtime's
exit hook and the driver's exit handlers no longer run then, and the library
writes its degradation counts in the quiesce. A process that never opened a
GPU device still answers true. The platform over metal2vulkan-rt is unchanged.
The let-go's child-process test now expects false after the let-go, then
_exit with status 0; a new one holds true and exit() for a process that asked
for no device. The C harness ends as QEMU does on the answer, and its test
expects false on the Vulkan platform and true over metal2vulkan-rt. The API
docs, the header, docs/api.md and docs/lessons.md say the same.