iHD's decodes write their render target Y-tiled whatever the linear import
says (U30, measured on the Iris Xe), so its target check fails every kind and
its pictures reach the device's caches by its video processing alone, into
each cache's surface, whose planes lie as iHD's runs write them. The docs
said those pictures were copied by the runtime device's GPU on iHD, which the
Linux open never made; they now say which way each layout takes.
cutdel's newest tip deletes vaapi.rs's crop_extent with the old
platform's copier; the route's text named it as where the crop is
fitted. The crop is still the CPU copy's, so the sentence keeps that
and loses the name.
The cutdel branch deletes VulkanPlatform, metal2vulkan-runtime and the rt
feature, so RtPlatform over metal2vulkan-rt is the only platform. These
docs still described the old one: its answer policies, its exact
switches, MoltenVK on the Mac, its in-place guest memory, its records
cache, its device recovery and its Metal-answer tests.
- conventions.md: the guest-memory-in-place rule is replaced by the rt
rule (rt allocates GPU memory, the device maps its blocks into the
guest, textures sync at the guest's events, and there is one VkDevice
per process). The degradation codes are now rt-unbuilt and rt-refused,
and the deleted codes are dropped.
- accuracy-ledger.md: restated for rt, which has no switches. It keeps
the device's own arithmetic notes (tagged as measured before rt), the
19 unbuilt pieces and rt's refusal kinds, and device loss.
- api.md, README.md: REIMS_VGPU_EXACT, _CENSUS_DIR and _TRACE_DEGRADE
are gone, and STRICT now covers running out of memory only. The let-go
and the quiesce describe one platform.
- architecture.md, development.md, testing.md, qemu.md: KosmicKrisp in
place of MoltenVK; RtPlatform, rt_window and RtBlocks in place of
VulkanPlatform, the old window sink and HostBlocks; no Metal-answer
comparisons and no opt-in GPU-fault tests.
- lessons.md: the four lessons about deleted code only (the Metal
comparison after MoltenVK, the runtime's shadows, device recovery and
the in-place check) are dropped. The lessons that still bind mark
their deleted names.
- video/vaapi.md, graphics-kext/design.md: the GPU plane copy and the
compositor mirror are marked as gone.
- AGENTS.md: only the Vulkan platform's "Where things are" row changes.
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.
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.
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.
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.
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 session's end line now says how many surfaces' memory its decodes landed
in and the most of them live at once, told apart by the memory's identity
(the device cache's, else the mapping its pages lie in), and, where the CPU
copied pictures, the copies' mean and longest time. These size the exported
surfaces a session would need on rt and the CPU's cost of landing there
today. Log lines only: nothing the guest or host observes changes.
On the rt platform the VA-API arm now answers the guest: its decoders
land pictures in rt's exported blocks, which rt makes as dma-bufs
(new_dma_buf_buffer_of_length_padding_unobserved, export_dma_buf over
new_exported_block(DmaBuf), linear, the named byte on a multiple of 256).
rt's contract after an acquire is that the external side does not touch
the block until its next whole overwrite, and VA reads a reference from
the surface it was decoded into. So each codec's decoder now tells its
accelerator whether a later picture may predict from the picture it asks
storage for (PictureRole: H.264's nal_ref_idc, HEVC's sub-layer
non-reference picture of the highest sub-layer), and where the platform's
rules keep references apart (CachedReferences::Apart, rt's) a reference
is decoded into a surface of the decoder's own and lands in its cache by
video processing, while a picture no later one predicts from is decoded
straight into its cache. Each session counts its pictures by role and the
references it kept apart, and logs the counts at its end.
The rt arm answers no encoder: rt releases no encoder's sources to the
driver yet. The Vulkan platform's rules keep every picture in its cache
and its encoders, as before.
CUDA maps a buffer of an import made dedicated only from offset 0: from 224,
256, 4096 or 65536 bytes in, cuExternalMemoryGetMappedBuffer answers
CUDA_ERROR_INVALID_VALUE, while a mapping of any length from offset 0 maps
(measured on an RTX 2080, and at 224 on an RTX 3090). ImportedBuffer::import
mapped from the buffer's offset, so no buffer past the first byte of an
exporter's dedicated allocation was ever imported. Where a driver makes each
exportable buffer its own dedicated allocation (docs/video/devices.md says
metal2vulkan does on the RTX 5080, which no check here reaches), a device
cache whose first plane the platform places past its first byte would be
declined, and its pictures read back and copied by the CPU.
The import now maps from the allocation's first byte to the buffer's last and
gives the buffer's address as its offset into that mapping, so no exporter's
layout, on either platform or any driver, depends on CUDA taking an offset.
What the host sees changes only where the import failed before: there a
picture lands in the device cache by the GPU's copy. A test of the pattern
writes a buffer 224 bytes and one a page into a Vulkan device's dedicated
allocation through their own imports and reads where the writes landed.
On the UHD Graphics 630 host, QEMU ended in an access violation inside
Intel's Direct3D 12 video driver as a guest's 4K H.264 session ended beside
its next: a decoder let go while another lived on the display broke the
other's next vaEndPicture. A test of two threads' decoders, each let go
round after round while the other decodes, ends the same way under vaon12,
and keeps ending so with every call made alone, with no teardown inside
another context's picture, and with the other contexts' pictures done
first. Kept until no context lived, every teardown passed.
So on Windows a context's, a config's or a pool's destroy asked for while
another context lives on the display is held, and made in the order asked
once the last live context's teardown is asked for; the log says so once a
process. What changes for the host: the process no longer ends there, and an
ended session's surfaces stay allocated while another session lives. Linux
is unchanged: the same test passes on radeonsi with every teardown made at
once.
A guest encodes one frame at a time: AppleGVA submits a frame and waits for
it before the next, on a real Mac as in our guest, so a frame's encode time
is its rate, and NVENC's preset is the one lever on it. The middle quality,
which an x86 guest's encodes always ask and VideoToolbox's default sits at,
took P4. It now takes P1, and qualities above the middle spread over P1 to
P7, so an app that asks for the best still gets P7.
What the guest sees changes: its encodes' bitstreams differ, and they come
faster. Measured on the RTX 3090 against a MacBook Pro's Radeon Pro 5300M,
same source, matched bitrates (fps, PSNR Y):
- 3840x2160 30 Mbit/s: P4 41-42 fps 44.95 dB, P1 46 fps 44.73 dB; the Mac
72-76 fps 43.40 dB.
- 1920x1080 6 Mbit/s: P4 162 fps 43.61 dB, P1 168 fps 43.44 dB; the Mac
177-275 fps 41.91 dB.
P1 still beats the Mac's quality by 1.3 to 1.5 dB. NVENC's own single-frame
time at P1 for 4K, about 15 ms on the 3090, is itself above the Mac's whole
chain of about 13 ms a frame, so the 3090 cannot meet the Mac's 72-76 fps at
4K one frame at a time; what is left of the gap is in our chain.
The decode-back's failures were NVDEC's answers to decodes starved by the
device's own copies of caches into the guest's RAM, a case like U21's: say so
in U21 with the measured runs (the causal switch, the no-VM replay beside CUDA
copies, the paced boot), and keep the trap in lessons.md: failures clustered
at a workload's end or in bursts are lined up against the device's own GPU
work before the stream or the driver is suspected.
A guest's H.264 session on NVDEC got zeros for a picture NVDEC answered
failed (status 8 or 9), and every later picture refused until the next IDR:
AppleGVA's H.264 path reads no failure from the driver (D25), so each reached
the client as a decoded frame of zeros. A Mac's hardware H.264 decoder hands
such a picture on with no error, decoded as it could, and decodes on from it
until the next IDR (measured on the MacBook Pro of 2019, macOS 26.7.1, job
m3-max-38757: a P picture cut to half its slice, or with 64 bytes changed,
and those after it came back with status 0, 26.5 to 29.7 dB from the
undamaged stream, none all zeros).
What changes for the guest: on NVDEC, an H.264 picture whose decode NVDEC
answers failed now lands in its output as NVDEC left it, and the pictures
after it are decoded from it, where they were zeros. The host counts and logs
each such landing. HEVC's sessions still refuse such a picture, as their
guest path reports the failure to VideoToolbox. The pacing of the releases'
copies before this removed the cause of the failures seen in the decode-back.
vaapi.md: a Windows pool's surfaces are shared Direct3D 12 textures, the
stand-in for a lost frame is the GPU's copy there, and the GPU's landing
copies from a frame's texture. devices.md: Windows pictures land by the
runtime device's GPU, the CPU's copy where the device imports none.
devices.md says what a Windows host's video runs on (VA-API alone, through
libva-win32 and vaon12) and what the UHD 630's driver answers; vaapi.md how
the module loads libva there and what it leaves out without dma-bufs;
backends.md and AGENTS.md's map that the VA-API module builds for Windows.
On an NVIDIA host the device listed no VideoToolbox encoder, so an arm64
guest's apps found no hardware encoder and encoded in software. The NVIDIA
arm now answers one encoder for each codec NVENC encodes a profile of, each
session on an NVENC encoder of its own (NvGuestEncoder):
- the guest's settings map onto NVENC's as an x86 guest's do, and Quality
onto the same preset and tuning (speed_of), the middle where it is unset;
- a frame goes NVENC's two ways: copied by the GPU from the buffer over the
lent surface's pages into memory NVENC reads, else read by the CPU;
- key frames are placed by the codec module's KeyFrames, NVENC's parameter
sets go into the configuration record (Record), and no B-frames.
What changes for the guest: on an NVIDIA host, `encs` lists the H.264 and
HEVC encoders NVENC has, and VTCompressionSession's hardware encoders open
and encode there.
The VA-API arm's guest encoder kept its source checks, its view of the
source's planes, its encoder list and its Quality conversion to itself, and
the codec module's encoder kept its configuration record inside it. NVENC's
guest encoder, next, needs each of them, and also the NVIDIA arm's GPU fill
and preset choice of its host encodes, so they move where both arms reach
them, unchanged:
- the video crate's codec::encode::record::Record: the avcC or hvcC of the
parameter sets the hardware writes, and samples without them;
- reims-vgpu's graphics::vt_encode: the encoder list, Quality as a
percentage, and a source frame's planes, checked, in a buffer over the
surface's pages and in host bytes;
- the NVIDIA arm's speed_of (the preset and tuning of the device's quality)
and Fills::encode_filled (a frame copied by the GPU, else declined).
Nothing the guest or the host observes changes.
The NVIDIA arm read each encode source as host bytes and copied it with the
CPU into an NVENC input buffer; a source in a device cache went through a
staging copy first. The runtime device's GPU now copies the source's planes,
where they lie, into an exportable buffer that CUDA imports and NVENC
registers as input (nvEncRegisterResource, a CUDA device pointer, mapped for
each frame and unmapped once its bitstream is locked), as the VA-API arm
fills its input surfaces (cee727b5e). A frame whose copy is declined is
uploaded as before, with the reason logged once a session; a session whose
input CUDA or NVENC refuses uploads from then on.
NVENC codes the same bytes either way: the new hardware test
each_frame_filled_by_the_gpu_encodes_as_uploaded compares every access
unit of H.264 High and HEVC Main at 1080p, from pages and from a device
cache. The guest sees the same results sooner: on um870's RTX 3090,
VideoToolbox's H.264 encode of 300 frames went from 88.7 to 156.5 fps at
1080p (6 Mbit/s) and from 24.6 to 40.5 fps at 2160p (30 Mbit/s), each
stream byte-identical in size and in PSNR against the source.
An arm64 guest's VideoToolbox encoder read each source frame through the host's
view of the IOSurface's pages, and the VA crate's encoder uploaded it by the
CPU. The runtime device's GPU now copies the frame's two planes, in place, from
a Shared buffer over the surface's pages (LentViews::buffer_over, kept with the
session's view of the surface) into an input surface of the encoder's, as an
x86 guest's frames are filled (cee727b5e). Where the device makes no such
buffer, or the copy is declined, the frame is uploaded by the CPU as before,
said once a session; an input surface whose fill failed on the GPU stays out of
the encoder's pool.
What the guest sees: the same samples, byte for byte
(a_guest_encoders_frames_filled_by_the_gpu_code_as_read_by_the_cpu, on the
780M's radeonsi, m3-max-38046; in the boots below, the same bytes for each
stream), at a higher rate. A macOS 26.6.2 guest under TCG on the 780M, 120
frames at 1080p and 8 Mbit/s, two runs each: H.264 45.5 and 47.8 fps before,
49.6 and 49.0 after; HEVC 52.9 and 51.9 before, 57.9 and 57.2 after
(m3-max-38122, m3-max-38178). Each fill took 0.14 ms of GPU time.
An arm64 guest's VideoToolbox now finds a hardware encoder for each codec the
host's VA-API driver encodes a profile of: `encs` lists
reims-vgpu-video.videoencoder.avc and .hevc, which the guest registers as
paravirtualized and hardware-accelerated, and a create of one (by that ID, by
Apple's hardware encoder's, which the guest's own paravirtual encoders send,
or by none) starts an encoder session instead of being refused with
kVTCouldNotFindVideoEncoderErr.
Each session's encoder is the arm's GuestEncoder: on VA-API, the VA crate's
VideoEncoder, made from the settings the session's properties make, `Quality`
onto the driver's quality levels as the device's `quality` maps. Each source
frame is read from the host's view of the IOSurface the guest lent with its
`efrm` (vt.rs's VtEncoderBackend, through the decoders' kept views) and
uploaded; the session emits the samples and lets go of the surface. A change
of the bitrate, frame rate or key-frame interval reaches the encoder from the
next frame; one that makes a new sequence makes a new encoder before the first
frame and is refused after it.
The device's features are unchanged: VT_MESSAGES is still offered where a
decoder is listed, and the arm64e kext still serves macOS 26 and later alone.
Decided 14 and the feature bits now say what the device answers since
4cd77f6aa. A host whose GPU shares the CPU's memory offers SURFACE_CACHE
and SURFACE_DEFERRED, as a Mac on an Intel GPU keeps its own copy of each
IOSurface (the UHD 630's lock, fill and memory numbers, jobs m3-max-37817
and 37822), within the caches' budget. No host offers
SURFACE_CACHE_REFUSED now, and the decoder's module docs and the video
device doc say so.
The host's side of VideoToolbox's paravirtual protocol gains encoder sessions
(`+enc`), the half C2's VA-API backend encodes on:
- the properties a guest's compression session sets (`esup`, `ecop`, `eset`,
`emul`), in the shape Apple's hardware encoder answers them, made into the
codec's EncoderSettings on a 90 kHz clock;
- `esta`, which opens the backend's encoder at the frames' size, rounded down
to even, and asks for video-range source buffers (`Epba`);
- `efrm`, which encodes the frame's lent surface and holds it until the frame
is both encoded and emitted; `ecfr` and `einv`;
- emission: `Efds` for each new configuration record, then `Eemt` with a
sample buffer of the guest's own times, in 16 KiB fragments.
What the decoder and encoder sessions share (the session's handle, its thread
and queue, the host's requests) moves out of decoder.rs into session.rs.
SampleBuffer gains a writer that its reader reads back.
Nothing changes for the guest: the encoder list names encoders only for a host
given an encoder backend, the device gives none, so `encs` still lists none
and `+enc` is still refused with kVTCouldNotFindVideoEncoderErr.
The paravirtual route's second piece: the host's side of a guest decoder's
session, so that a backend over the host's video arm can serve VideoToolbox's
decodes next. reims_vgpu_video::paravirt gains:
- decoder: a `+dec` session on a thread of its own. dsta starts it once from
the format description's avcC or hvcC, refusing 3-byte NAL unit lengths and
H.264 field pictures, and sends Dpba first; dfrm asks the guest for a buffer
(Dbuf), has the backend decode the sample's access unit into the surface it
lends, emits the frame (Demt) and lets go of the surface (rels), Dfub
naming a buffer left unused; the guest's replies go straight to the request
that waits for them. dsup, dcop, dset, dcan, dinv and the rest are answered.
- image_description and sample_buffer: readers of the =fds and =sbf
parameters, with the serializer's known keys; plist reads binary property
lists within bounds of ours.
- Host::with_backend, under which a create of a listed codec opens a session,
and a close ends it.
Nothing changes for a guest: the device's host makes its Host without a
backend, so every create is still refused, and no host offers VT_MESSAGES.
The docs said an arm64 guest lists no hardware encoder and refuses a session
requiring one -12908, as measured on arm64 macOS 27.0.1. Arm64 macOS 26 under
TCG lists Apple's own AVE encoders (ave.avc, ave.hevc) as hardware and fails
such a session -12903, with the arm64e set before H.264 encode and after
(m3-max-37133, m3-max-36944): the OS's own answer, with no encoder behind them
in a VM. devices.md and design.md now say so.
AppleGVA's H.264 encoder now reaches the host's VA-API or NVENC encoder
through our video driver, the AMD vendor route it already drives for decode.
What the guest sees, where the host's caps list an H.264 encoder with a rate
control: the accelerator publishes IOGVAH264EncodeCapabilities (VTRating 350,
VTQualityRating 50, an AMD Mac's), the driver lists encode function 0x20,
sub-ID 0x800 (NV12 in, bitstream out), and VideoToolbox lists
com.apple.videotoolbox.videoencoder.h264.gva as hardware. A session that
requires hardware is made at 720p, 1080p and 2160p, and its frames are
encoded on the host: the driver sends each as an ENCODE_H264 op over the
source surface's planes, and puts the access unit in AppleGVA's bitstream
ring with its end cursor and length in bits. AppleGVA's own SPS, PPS, NAL
header and per-frame QP set the stream; the parameter sets in the format
description are the host encoder's.
HEVC encode stays unlisted, also on a host that encodes HEVC: no hevc.gva,
and a session that requires hardware fails -12908, as on a Mac without an
HEVC encoder. A host with no encoder, or one listed with no rate control,
publishes and lists nothing for encode, as before. An arm64 guest's arm64e kext
publishes no encode ratings on any host, as it names no video driver there
(kRgfxGuestVideoDriver), so an arm64 guest still lists no hardware encoder.
The driver's checks gain the encode listing (in a process of its own, since the
block is filled once a process), context creates, the pixel pools and frames
through the ring; the kext's gain rgfxH264Encode, in both architectures' rules.
On an arm64 guest on a host that decodes H.264 and HEVC, the arm64e kext
published AppleGVA's video-driver keys (IODVDBundleName, IOGVACodec,
IOVARendererID) and HEVC decode (IOGVAHEVCDecode and its capabilities), as the
x86-64 kext does. The vendor-driver route our bundle's video driver serves is
x86-64's, and on arm64 the keys brought no session to it: VideoToolbox answered
VTIsHardwareDecodeSupported true for HEVC, yet a session requiring a hardware
HEVC decoder failed -17692 and one requiring H.264 -12906, no encoder was
hardware while one requiring a hardware encoder failed -12903, and every other
session decoded in software, none reaching the host (arm64 macOS 14.6.1 on a
VA-API host, m3-max-36575).
The arm64e kext (RGFX_GUEST_ARM64) now publishes no video key on any host
(kRgfxGuestVideoDriver; rgfxDecodesVideo and rgfxHevcDecode answer false), and
logs once that it names none. The x86-64 kext is unchanged.
What an arm64 guest sees on every host: VTIsHardwareDecodeSupported false for
every codec, no hardware encoder listed, sessions requiring a hardware decoder
or encoder refused as on a Mac without one (-12906, -12908), and every other
session in software, as an arm64 guest on a host with no video arm already
answered (arm64 macOS 27.0.1 on the M3, m3-max-36519).
video_codecs_arm64_test checks the arm64e kext's rules: no video driver and no
HEVC decode for caps of H.264 and HEVC, H.264 alone or HEVC alone.
On a host with no video arm (the Windows mini's UHD 630), the accelerator
still named the bundle as AppleGVA's video driver (IODVDBundleName,
IOGVACodec, IOVARendererID). VideoToolbox then answered
VTIsHardwareDecodeSupported(avc1) true and listed AppleGVA's H.264 encoder as
hardware, yet a session requiring a hardware decoder failed -12913 and one
requiring a hardware encoder -12903: no session could have either.
The accelerator now sets the three keys in publishVideoCodecs, only where the
host's video caps list a decoder (rgfxDecodesVideo: a decode entry of H.264 or
HEVC with a profile), and logs once that it names none otherwise.
What the guest sees on a host with no video arm: VTIsHardwareDecodeSupported
false for every codec, no hardware encoder in VTCopyVideoEncoderList, and
sessions requiring hardware refused as on a Mac without it (-12906
kVTCouldNotFindVideoDecoderErr, -12908 kVTCouldNotFindVideoEncoderErr).
Sessions that allow or default to hardware decode and encode in software, as
before. A host with an arm is unchanged: its caps list a decoder, and the keys
are set as before, ahead of registerService.
Measured on a macOS 26.7.2 guest on the mini with a scratch kext without the
keys (m3-max-36420) against the tree's (m3-max-36369).
The NVIDIA crate's threads and waits run on the runtime it is first handed,
and only the Annex B decoder handed one. A QEMU whose first NVIDIA video was
an NVENC encode session, before any decode session, made its encoder's lock
thread and waits on the crate's fallback: std's threads, outside the
library's, and no exit gate, so a call in NVENC or CUDA could run beside
the driver's exit-time destructors as the process ended, the class of the
exit aborts the gate exists for.
NvidiaVideo::new now hands its runtime to the crate (nvidia::use_runtime,
public) before it opens the GPU, as a VA display takes its runtime as it
opens, so every session kind runs on the platform's threads and clock, and
the crate arms the platform's exit gate as CUDA loads.
A test on the NVIDIA host opens the arm in a child process of its own, makes
an NVENC encoder before any decoder and encodes a frame: NVENC's lock thread
is started by the runtime the arm was opened with. Nothing the guest sees
changes; an encode-first QEMU's NVENC threads are now the library's.
The VA-API hardware tests open their displays on GatedRuntime since
b52eea52f, whose exit gate closes before the drivers' exit-time destructors
run, after iHD aborted a test process that exited while a kept session was let
go on another thread. The NVIDIA arm's tests ran on std's runtime, which has
no gate: its waits fell back to StdRuntime::shared where no backend's opening
made a runtime, and the Annex B decoder's test handed it std's. Its call
threads and the sweep of work kept past a deadline call NVDEC, NVENC and CUDA
on threads of their own, so a test's process could exit beside them the same
way. No abort was seen on NVIDIA.
In a test the NVIDIA waits now fall back to GatedRuntime, which the first load
of a driver's library makes and arms (arm_exit, as Library::open and cuInit
call it), so its hook runs before what the library registered. The Annex B
decoder's test and the session-start probes hand the gated runtime too. One
gate serves the process, whichever arm's driver loads, so the NVIDIA tests use
VA-API's (vaapi::gated) rather than a second one.
A test of the pattern runs in a child process that registers an exit handler
as a driver's library would, then has the crate arm its gate: at exit the
crate's steps are refused by the time that handler runs. On std's runtime they
were still given. The product is unchanged: outside tests the fallback is
std's, as before.
NVDEC's decoder kept the capabilities it asked, once per GPU, codec, chroma
format and bit depth, but the graphics device's NVDEC arm asks the same
three as it opens (H.264 8-bit, HEVC 8- and 10-bit) through
decode_capabilities, which kept nothing. So the first session of each codec
and bit depth asked cuvidGetDecoderCaps again before making its decoder:
6-9 ms on an RTX 3090 at idle, 15-19 ms beside two running decoders or 16
busy CPUs (the session-start probe, job m3-max-30770).
decode_capabilities now keeps every answer itself, and the decoder asks
through it, so the arm's open fills what the sessions read. A failed query
is still asked again. The answers are the same, and the caps the guest reads
are unchanged; the first session of each codec and bit depth in a QEMU
process starts that much sooner. The decoder's module doc records the 3090's
cuvidCreateDecoder times beside the 5080's.
Two rows of the unfixed-bugs ledger said that a session's first picture costs
the guest a lot at every clip start: ~175 ms of CPU on radeonsi before the
first wait, and 34 ms to 2.13 s for NVDEC's first decode. Neither said where
the time went, and the first was taken from a debug build of a held test.
Two ignored probes, run by hand (probes::va_session_starts and
probes::nvdec_session_starts), now start sessions as the graphics device's
video does: a new decoder per session, then the first access unit and its
wait, then the second for comparison. A record of the driver calls
(probes::timeline), stamped by the VA-API and CUDA check functions in test
builds only, splits a session's first decode into its calls: config, pool,
context, buffers and the first vaEndPicture on VA-API; the capabilities query,
the decoder's make and the submission on NVDEC.
On um870's Radeon 780M (release, idle, job m3-max-30770), a new decoder's
config, surfaces and context took 0.04 ms at most, since radeonsi allocates
them at first use. The first vaEndPicture took 1.0 to 3.0 ms (the session's
create job, U24), so the ~175 ms was the debug build's. The module doc of
buffer.rs and bugs.md B92 record the numbers. Nothing changes for the guest
or the host.
Where the host's video decodes into device caches, a picture the driver's
check refused to decode into its cache (its codec and format), or whose planes
do not lie as a target's must, landed by the runtime device's GPU copy, which
imports the decode surface as images by their DRM format modifiers, and else
by the CPU through the session's staging. On an RX 550 both apply to HEVC Main
10: its radeonsi fails the check's second step for P010 (the first wrong byte,
0x40, is the low byte of the check's 0x5a5a scribble as a 10-bit sample, read
from the reference's overwritten target), and its RADV lists no
VK_EXT_image_drm_format_modifier, so every 10-bit picture was read back and
copied by the CPU. A 26.7.2 guest's walk there (m3-max-21989) played a
2160p30 HEVC Main 10 clip at 22.2 fps with 109 frames dropped.
The cache's memory is a dma-buf the arm already exports for its decodes
(CacheTargets). The arm's first landing, the driver's video processing into a
linear VA surface over a dma-buf of the planes' pages (Frame::write_to_guest),
now also takes such a cache: CacheBytes hands the cache's memory as the
device memory of the write, each range at its own byte of the one dma-buf, and
the write is acquired as a decode into the cache is
(Buffer::external_write_done). Its import goes as the cache does, by the
cache's identity. Where the driver's import check refuses the format or the
planes' alignment, the picture lands as before.
What the guest sees: the same pictures in its outputs, landed in the cache by
the driver's GPU work rather than by the CPU. The session counts such pictures
"in a device cache, by the hardware".
Tests: the ignored hardware test
a_picture_written_into_a_dma_buf_cache_by_video_processing_is_the_cpus_copy,
on a VA-API host with the conformance suite's streams.
A video op faulted its command buffer where its surface's device cache was not
filled, or its last picture not copied into its pages, within 2 s; and a VA-API
picture failed where the runtime device's GPU copy of it took over 2 s. The
fault was seen once, behind a 2 s GPU stall on a loaded host. A Mac's video work
waits for the GPU's earlier work on its surface however long it takes.
The op now waits until the fill and the copy are done. Each ends as the
platform sees its command buffer complete, which it does on every path, failed
where the device was lost; a reset of the device ends the wait, as it ends every
wait of the decoder's, so none holds a reset up. A wait past 2 s is named in the
log. The device caches' waits take what ends them in place of a timeout, and a
deferred fill's make is waited for in the same slices, so a reset ends that wait
too where it waited without end before. The plane copier waits on its fence with
the maximum timeout, which Vulkan returns from in finite time once the device is
lost.
For the guest: a decode or encode whose output's or source's device cache is
slow to fill, or slow to be copied out, no longer faults its command buffer
after 2 s, and a VA-API picture whose GPU copy is slow no longer fails its
decode; both wait, and only a reset of the device or a lost device fails them.
Where the host's video imports device caches (NVDEC), every device cache was
made exportable, whatever its surface. The video writes only two-plane surfaces
(NV12, P010), so a window's or a layer's cache gained nothing from it and paid
for it: metal2vulkan makes each exportable buffer a dedicated allocation, to
which it binds no image, so every texture over every cached surface was a
shadow, copied in before and back after each command buffer that used it.
On a GPU of its own memory the cache maker knew only the first plane's byte of
the layout a cached block's SURFACE_PAGES carries. CacheLayout now carries the
surface's plane count too, and only a cache whose layout gives two planes is
made exportable and gives the video its identity. A cache of one plane, or of
a surface whose pages carry no layout, is made as any other cache.
Measured with a macOS 26.7.2 guest at 3648x2038 on GPUs behind a Thunderbolt 3
link (PCIe x4 Gen3), each step Launchpad or Mission Control held open, ABBA on
one host, development 9e2f9e90f (A) against this change on it (B):
GPU run Launchpad held take-to-show Mission Control held
RTX 2080 A1 24.5/s 66.2 ms 52.1/s
B1 56.8/s 14.9 ms 59.9/s
B2 56.9/s 6.9 ms 60.0/s
A2 24.4/s 66.6 ms 52.1/s
RTX 3090 A1 23.1/s 70.7 ms 51.9/s
B1 55.7/s 20.1 ms 59.8/s
The 3090's B2 and A2 did not run: its Thunderbolt link failed during B2 (a
fatal PCIe error at the dock's bridge, Xid 79). A walk of this change with
video on that 3090 held Launchpad at 56.8/s, 6.9 ms. On the 3090 the shadow
copies went from 151M texels in and 165M back a present to 23M to 36M in and
next to none back. NVDEC still lands every picture in its output's exportable
cache, by the hardware.
What the host observes: timing alone; the guest sees nothing else change. The
exportable allocations and their exports are made for the video's caches
alone, and the caches' count line's "made exportable" counts those. No
degradation kind changes; the warning for a carried layout that does not lie
in its surface now says its cache is made, not placed, as with none.
The aligned byte puts a cache's first plane where an image over its memory
may start, but on the RTX 5080 metal2vulkan makes each exportable buffer its
own dedicated allocation, to which it binds no image, so the NV12 and P010
planes' textures over NVDEC's caches stay shadows wherever the byte lies.
Measured in a 4K60 bar boot: their shadows' cause moved from the texels
sharing a line to the exported memory's, and their count stayed (1424 at
development, 1586 with the byte). The docs said they lie in place; they now
say where that holds.
aligned_byte named a surface's first plane's byte only where it lay off a
multiple of 256 bytes, a figure of the runtime's that our code repeated
(ALIGNED_BYTE_MULTIPLE). It now names the byte wherever the plane starts
past the surface's first, and the platform places it on its own boundary:
on the Vulkan platform the runtime's multiple of 256 bytes
(BufferDescriptor::with_aligned_byte), the largest linear image alignment
measured (RADV's 256 on an RX 550, 128 on an RTX 5080 Laptop GPU). A plane
256 bytes in is now placed by the runtime rather than left to the buffer's
own start; where the buffer starts on that boundary the memory is the same.
For the guest nothing changes: the same answers and the same bytes in its
pages. The asked cache's test now has the platform place a plane 256 bytes
in (an_asked_cache_places_its_first_planes_byte).
NVDEC lands each 4K picture in an exportable device cache, and the guest's
decode names R8 and RG8 textures over its planes 32 bytes into the surface,
as CoreVideo lays them. NVIDIA's linear images need 128 bytes there and
RADV's 256, so every such texture was a metal2vulkan shadow, its plane
copied in before each command buffer's use (1114 of them in one boot of the
5080's 4K60 bar at development). The host now places the cache by the layout
a cached or deferred block's SURFACE_PAGES carries on a device that asks
nothing (CacheLayout::FirstPlaneAt): the surface's first plane's byte goes on
a multiple of 256 bytes of the cache's memory (BufferDescriptor::
with_aligned_byte), as an asked cache's already did, on the exportable route
(new_exportable_buffer_of_length takes the byte, made as BufferDescriptor::
exported_as OpaqueFd) and on a plain cache's (new_buffer_of_length_aligned,
declaring nothing else). A layout that does not lie in the surface's bytes
is logged and places nothing. The copies between a cache and its pages are
unchanged: only the ask's layout makes them take texels alone.
For the guest nothing changes: the same answers and the same bytes in its
pages. On the wire, CACHED and DEFERRED SURFACE_PAGES may carry the layout,
64 to 200 bytes, compatible both ways (the kext's commit before this).
The tests: on Linux, an exportable cache of a 4K NV12 frame made with the
byte takes both planes' textures in its memory (Buffer::
texture_placement_with_iosurface_plane answers NotHostPages; made without
it, both were shadows, printed); the NVDEC landing test lands its pictures
32 bytes into such a cache through CUDA's mapping at the export's offset; a
cached block's layout places its cache alone, a deferred block's alike, a
first plane at the first byte, a layout past the bytes and none place
nothing, and the copies stay whole; the graphics crate hands a cached
message's layout to the host.
VA-API's zero copy kept a guest buffer's import by the mapping's identity
and the frame's size and format alone. One mapping can hold several buffers
of one size: macOS 26.7.2's HEIC decodes (Preview opening a desktop picture,
Freeform's welcome) write each tile of a grid image into one surface at the
tile's own offset. Every tile after the first found the first tile's import,
so its frame was written over the first tile's planes, the check that
declines a luma plane off a page's start on iHD was skipped, and the guest
showed the other tiles as zero YUV (green) on the Iris Xe.
The import is now kept by the place and pitch of the buffer's planes as well:
core's DeviceImports takes a variant of the backend's own type, compared
whole. What changes for the guest: each tile's frame lands in its own planes,
or is copied by the CPU where the driver takes no import of them. The new
VA-API test writes two buffers of one memory, stacked and side by side, and
failed with the old key on the Iris Xe.
Every build, test, boot and copy on the shared machines has run as a
potluck job since 11-05, and the job's lease is the lock: --gpu holds a
GPU, --exclusive gives a timing run the whole machine. gpu-locks.sh and
metal2vulkan's maclock took lock files potluck never sees, so a run under
them could still share a GPU with a potluck job.
AGENTS.md, the boot section of docs/qemu.md, the video checks, the cost
benches' docs and the oracle README now name potluck's lease. The
conformance scripts take no lock of their own, and lane-gate runs its
tests under its job's lease. A build holds no GPU: it builds in a job
without --gpu, and the tests run in the same workspace holding one.
The documented VA-API check, `cargo nextest run -p reims-vgpu-video
--run-ignored only -E 'test(/^vaapi::/)'`, failed from a clean checkout:
the target probe's ignored test, in that set, needs RVG_VA_STREAMS, the
streams the conformance scripts write with x264, x265 and ffmpeg.
The probe becomes a tool rather than a test, since the target check's own
tests are the check. The probe prints how many pictures of each way came
out as the driver's own surfaces', and asserts only that it decoded
something; the target check's tests check every byte of their targets'
memory after each picture, and run in the set with no streams. Taking the
streams where the scripts leave them would still fail from a clean
checkout, and running the probe inside the scripts would add its decodes,
about 150 s on a 780M, with no verdict, to every conformance run.
The tool is an ignored test at the crate's root (`probes::`), outside the
`vaapi::` and `nvidia::` sets the hardware hosts' checks run, as the
fuzzers' long runs and reims-vgpu's RVG_VA_STREAMS tests sit outside them.
It is not an example: an example reaches only the public API, and the
probe's import hook (`surface::MAKE_SURFACE`), which has every surface a
decoder's pool makes imported over the probe's memory, exists only in a
test build. Its code and unsafe blocks stay in the `va` module. Without
RVG_VA_STREAMS it still fails, naming it. Nothing it compares changed.
Adds U28 to the video bugs: radeonsi's decodes write an imported surface only
within the bytes its declared planes span from the luma plane's first byte, and
what the targets do about it.
The cut of the VA arm's H.264 answer to 65,535 macroblocks kept the driver's
largest width and lowered the height. radeonsi answers 4096x4096, which came
out as 4096x4080, but iHD answers 8192x8192 in VAConfigAttribMaxPictureWidth
and Height, which came out as 8192x2032: the guest's video driver would then
refuse 3840x2160 and every H.264 stream taller than 2032 at its create, and
VideoToolbox would decode 4K H.264 in software on Intel hosts.
iHD decodes nothing wider than 4096: its surfaces' bound is 4096x4096, and
ffmpeg's VA-API decode refuses every size from 4112x2160 to 8192x1024 on an
Iris Xe (iHD 26.3.5). So where the driver's largest size holds more than the
bound, the answer is at most 4096 wide and as tall as the bound leaves there:
4096x4080 on both drivers, holding 3840x2160 and 4096x2160. The test now
feeds iHD's answer too, and the sizes users play.
For the guest: on an iHD host H.264's largest size is 4096x4080, where it was
8192x2032 since the bound came in.
A boot of the guest on a Radeon 780M decoded the item's 30 H.264 streams, on
the hardware decoder alone and as a player takes them, beside the MacBook Pro
16 2019's answers: interlaced streams, 4:2:2, 4:4:4, monochrome, lossless and
8192x4320 fail their session's create in the guest as on the Mac's 5300M, and
a 4096x4096 stream now fails it too, at the driver's size check, and decodes
right in software. High 10, FMO, data partitions and SP slices reach the host
only with a picture, and give the 5300M's frames.
T3 says what interlaced streams do now, D25 what is left of it, and devices.md
and design.md where an H.264 decode is checked.