A 1080p H.264 session in an x86 guest, at 8 Mbit/s with a limit of
1,000,000 bytes a second, runs 18.3% to 19.4% over the limit in its
busiest second on all three vendors. On the XTX the stream is the same,
byte for byte, as the stream without the limit. The guest's H.264
encoder is driven by macOS's AMD path: that path counts the limit but
codes no frame over again, and on our device its planning changes no
frame. The 2019 MacBook Pro's 2.3% is from macOS's Intel path, which
does code frames over again. No AMD-only Mac has been measured, so the
known issue keeps the Mac's number scoped, and B101 records the trigger,
the first step and the unfilled third length-record word as a lead only.
B100 had two claims the same rows now disprove. It said the real Mac ran
at another keyframe interval, but m3-max-77623 ran HEVC at the guest's
interval and stayed under the limit in every second. Its "the plug-in's
default" interval was the probe's 60. The HEVC paragraph in known-issues
said the runs don't compare; they now do, both on macOS's Intel path.
An x86-64 guest's hardware HEVC encoding never reached our GPU: macOS's HEVC
encoder plug-in drives only an Intel GPU's driver, found by name, so an app that
required hardware failed at its create (-12908) and others encoded in software
(m3-max-77632, development's set on this host). What the guest sees now, where
the host's video arm lists an HEVC encoder of Main and Main 10 with a constant
QP that codes a frame in place of the last (Linux hosts' VA-API, and NVENC where
its driver codes a frame without advancing its state):
- the accelerator publishes an IntelAccelerator child of its own with
IOGVAHEVCEncode and IOGVAHEVCEncodeCapabilities (Main and Main 10, up to
the encoder's level), so VideoToolbox lists a hardware HEVC encoder
(hevc.gva);
- RgfxGate keeps the Intel driver path the plug-in loads from
/Library/GPUBundles a hard link to the bundle's executable, at every boot;
- the bundle's video driver takes the plug-in's encode commands (function
0x20, sub-ID 0x1000), codes each frame on the host (ENCODE_H265) at the QP
the plug-in's rate control chose, an IRAP picture as a keyframe, Main from
an 8-bit source and Main 10 from a 10-bit one, and hands back the access
unit with 4-byte start codes, whose VPS, SPS and PPS make the session's
format description;
- a frame the plug-in codes again over its data rate limit, at a higher QP,
is sent in place of the last one (RGFX_VIDEO_ENCODE_IN_PLACE): a P
picture of the last frame's order count and source surface; a keyframe
coded again is sent as a new IDR picture;
- a session of a size the host does not encode is refused at its create,
so an app that allows software encodes in software as before.
A host whose encoder has Main alone gets no nub: VideoToolbox hands the
plug-in a Main 10 session whatever profiles the nub lists, and the driver
learns a session's profile only from its first frame. Nor does one that
codes no frame in place, where a retry would predict from the frame it
replaces. H.264 encode and both decodes are as before on either. The
plug-in's per-CTU QP map (its pool 27) is not applied, and its frame
statistics record is not supplied. The route is macOS 26.7.1's plug-in's,
booted on 26.7.2. Windows hosts list no encoder, so encode in software as
before.
Rows (macOS 26.7.2 guest, 1080p, 300 frames at 8 Mbit/s, decoded back by
VideoToolbox; the rate band is vboot's RATE_BAND_PCT, 6%, both codecs), the
same with the frames in place (m3-max-77615, m3-max-77613, m3-max-77614),
byte for byte but for 205 bytes of the Iris Xe's Main stream:
- RX 7900 XTX (m3-max-77475): Main 105.1%, 45.02 dB; Main 10 104.8%, 45.17 dB
- Iris Xe (m3-max-77476): Main 103.5%, 48.04 dB; Main 10 98.1%, 48.86 dB
- RTX 3090 (m3-max-77477): Main 100.7%, 44.81 dB; Main 10 106.1%, 45.06 dB,
where NVENC's own lands 104.6%: known-issues and video/bugs.md B97
At a data rate limit of 1 Mbyte a second, the plug-in coded 2 to 30 frames
of a session again, each sent in place: no gap in the order counts, all 300
frames decoded back, and the most bytes in a second 1.7% to 3.0% over the
limit (RX 7900 XTX m3-max-77611, RTX 3090 m3-max-77609, Iris Xe
m3-max-77627; video/bugs.md B100, to be read on a user's report). With a
keyframe every frame the stream comes to 4.1 to 5.0 times the asked rate, as
a real Intel Mac's comes to 5.7 times with the same QPs frame for frame
(m3-max-77635; design.md, known-issues); every frame decodes back.
Main 10 from a retained pool and from the app's own 8-bit buffers decodes as
from the pool taken per frame on all three. A real Intel Mac's hevc.gva
(macOS 26.7.1, m3-max-77481) replaces the session's pool at the third Main 10
frame, as ours does. Speed (Iris Xe, m3-max-77497): 94 to 118 fps at 1080p
against software's 3.3; 10.3 to 10.8 at 8K against 0.5 (B98, B99).
Tests: the kext's publish condition and its pairing with a host that codes
no frame in place (video_codecs_test: the caps of both decoders and encoders
without the flag publish no HEVC encode and the rest as before), the link's
update on real files (rgfxgate alias_test), and the driver's listing, create
refusals, settings, keyframes, write-back, failures, refused sources and the
frames it sends in place, and those it does not: never a keyframe, so a
session of keyframes from one reused surface sends none (video_driver_tests;
m3-max-77590). Development's set on this host (m3-max-77632) encodes H.264 to
the same bytes as this one and decodes as before. Docs: design.md and
devices.md, video/bugs.md B97 to B100, and known-issues.md's HEVC encoding
line, which now says which GPUs encode HEVC for an Intel Mac guest, and its
section on HEVC over the bitrate asked.
The host now takes VP9's profiles 1 and 3 and profile 2 at 12 bits where the
driver decodes them. devices.md gets a section on which hosts take which, how
the pictures land, the Iris Xe's boots and the 1080p rate; vaapi.md the
surfaces, iHD's lists and its 4:2:2 failure, and the new streams' card runs;
nvidia.md, backends.md and design.md drop the refusal of profiles 1 and 3 they
stated; known-issues.md names the formats each tested GPU decodes.
NVDEC's HEVC 4:2:2 decode landed on a proof run on an RTX 5080 Laptop GPU
from the host alone: no arm64 guest has run on that card. bugs.md's untested
list now says so, and when the guest's side is to run: a user's report of
HEVC 4:2:2 on an NVIDIA 50-series host, or an arm64 guest's disk reaching
such a card for another reason.
A boot of an arm64 macOS 26 guest on the RTX 3090 at the change that takes
HEVC 4:2:2 where NVDEC's caps list it (potluck job m3-max-77572) refused
each 4:2:2 session by the caps' answer and decoded the card's other range
extensions in hardware as before, every picture the same as the guest's
software decode. devices.md quoted the refusal's old wording.
What the guest sees: on an arm64 guest of an NVIDIA host whose NVDEC lists
HEVC 4:2:2 at the stream's depth and size, as the RTX 5080 Laptop GPU's
does at 8, 10 and 12 bits, a VideoToolbox session of an HEVC 4:2:2 stream
now decodes on the GPU, each picture copied into the surface's 422v, x422
or tv22 (or full-range twin) with no conversion by the CPU. Its dsta was
refused before, and the guest decoded the stream in software. On a card
whose caps lack it, as the RTX 3090's do, the session is still refused at
its start, and its warning now names the caps ("NVDEC does not decode HEVC
4:2:2 at 10 bits") where it said "NVDEC's decoders here land no HEVC 4:2:2
pictures".
declines_range_extensions takes the caps' answer for 4:2:2 as it does for
4:2:0 and 4:4:4, the decoder's output being NV16 at 8 bits and P216
deeper, and the VideoToolbox decoder checks a picture's chroma format
against the surface's from the picture itself.
Shown on the host, not from a guest on that card: the card test
(an_hevc_picture_lands_in_its_guest_format_as_the_software_decode_has_it)
on the RTX 5080 Laptop GPU decoded our x265 streams of 4:2:2 at 8, 10 and
12 bits through the arm's VideoToolbox decoder into pool-laid surfaces,
every picture byte for byte as ffmpeg's software decode, beside 4:2:0 and
4:4:4 at each depth, and landed 1920x1080 4:2:2 pictures at 344 to 384 a
second (potluck job m3-max-77563). The seam test holds the session-start
decision on the 5080's and the 3090's recorded caps.
NVDEC lists HEVC 4:2:2 on newer cards: the RTX 5080 Laptop GPU decodes it
at 8 bits into NV16 and at 10 and 12 bits into P216 (nvidia-probe). The
HEVC accelerator refused every 4:2:2 SPS, as no output of it was mapped.
Make a 4:2:2 decoder for an SPS of chroma_format_idc 2, into NV16 at 8 bits
and P216 deeper, laid out as NV12 and P016 with the chroma as tall as the
luma: a mapped frame's chroma rows start at the crop's first row and are as
many as the luma's (Mapped::of), a decode surface counts twice the luma's
samples, and AnnexBPicture::chroma names a picture's chroma format for its
callers. A card whose caps lack HEVC 4:2:2 still refuses the decoder at
its make.
No guest sees this yet: the graphics arm still refuses HEVC 4:2:2
sessions at their start, and a host video session's decoders refuse the
range extensions.
The AV1 route had only been checked on arm64 macOS 26.6.2. An arm64 macOS
14.6.1 guest on an RTX 3090 now decodes our svt-main8 stream to its
reference frame by frame, in a session that requires hardware (potluck job
m3-max-77531, at the tree this commit follows). The same boot decoded VP9,
HEVC and H.264 there with no errors. Docs only: nothing changes for the
guest.
An arm64 guest's VideoToolbox session of a 4:2:0 H.264, HEVC Main or Main 10
stream whose coded size lies outside the host decoder's own, as HEVC under
NVDEC's least size of 144x144, was started, and its pictures failed in the
host's decoder: NVDEC refuses to make a decoder of that size, and VA-API's
surfaces or context refuse it. A client that allowed software decoding got
failed frames rather than pictures.
For the guest: such a session's dsta is now refused with
kVTVideoDecoderUnsupportedDataFormatErr, its warning naming the stream and the
decoder's sizes, as the x86-64 route refuses it at create (5dfe92be1), and the
guest's VideoToolbox decodes the stream in software. That covers an H.264
stream wider than 4096 on iHD, as 4112x2160: iHD's H.264 config lists
8192x8192 but its surfaces take 4096x4096 at most, so such a session started
and its pictures failed. Streams inside the sizes start as before.
The sizes are each arm's own. On NVDEC, its caps of the codec at 4:2:0 and the
stream's depth: nMinWidth and nMinHeight up to nMaxWidth, nMaxHeight and
nMaxMBCount, the checks its decoder's make runs. On VA-API, the decoder the VA
crate's decoder picks for the stream, whose profile choice the video crate now
exports (h264_decoder_profiles, hevc_main_decoder): from its surfaces' least
size, none where they list none, up to the least of its config's and its
surfaces' largest, and H.264's 65,535 blocks. The range extensions' check takes
that bound too.
The hosts' drivers list VP9 decode at profiles 0 and 2, and an arm64 macOS
26 guest has no VP9 decoder of its own: every VP9 session fails -12906
without one from the host. The previous commit gave the host VA-API
and NVDEC decoders; this one offers them to the guest.
What the guest sees: the device's video caps gain a VP9 entry, codec 3
(RGFX_VIDEO_CODEC_VP9), where the host's arm decodes VP9, listing profile 0
into NV12 and profile 2 into P010 as the driver answers them, at the arm's
sizes up to 16384 a side, and level 62 (6.2, as vpcC numbers it). On the
paravirtual route (RGFX_FEATURE_VT_MESSAGES) the host then lists a vp09
decoder, reims-vgpu-video.videodecoder.vp9, with those profiles; once a
process registers VP9 (VTRegisterSupplementalVideoDecoderIfAvailable, as on
a Mac) the guest's VideoToolbox decodes VP9 on the host's hardware. A sample
is a frame or a superframe whole, which the host splits. A stream the host
does not decode (profiles 1 and 3, 12 bits) is refused at its session's
start, as an HEVC format the arm lacks is, and the guest has no VP9 decoder
of its own to fall back on: known-issues.md says so. No encoder of VP9 is
listed.
The guest's pictures of the two libvpx streams equal vpxdec's, frame by
frame, on an RX 7900 XTX, an Iris Xe and an RTX 3090 under macOS 26.6.2 and
on the 3090 under macOS 14.6.1, and VP9 decodes as fast as HEVC on the same
route at 1080p and at 8192x4352 (devices.md, with the guest's CPU emulated).
The wire change is additive. An x86-64 guest's kexts read no caps entry past
HEVC's, and the device takes no session of codec 3. An older host's caps
have no VP9 entry, so a newer guest's VideoToolbox lists no vp09; a newer
host's caps list H.264's and HEVC's entries as before, beside VP9's
(vt_decoders_list_vp9_beside_the_others_where_the_caps_decode_it). The
header's hash moves in the option ROM's and both kext sets' source records;
their bytes are unchanged.
The hosts' drivers list VP9 decode (radeonsi, iHD and NVDEC at profiles 0
and 2), and the owner's order is to offer the guest what the host lists. This
is the host's half: the decoders. Nothing offers them to a guest yet, so no
guest sees a change.
The codec module (codec/vp9) does on the host what VP9's hardware APIs leave
to the caller: it splits a superframe into its frames, reads each frame's
uncompressed header and keeps what persists between frames (the colour
configuration, the loop filter's deltas, the segmentation's features and the
eight reference slots), derives the quantizer scales and filter levels, and
hands each frame whole to an accelerator that decodes the compressed header
and the tiles. It refuses profiles 1 and 3 and 12 bits before anything
reaches a driver, and a frame that predicts from an empty slot is a picture's
error, after which a key frame decodes. Every field is checked against the
bytes before it is used: the CPU tests feed it truncated and hostile streams
and superframe indexes (the fuzz targets vp9-streams and vp9-samples).
VA-API's arm (vaapi::va::vp9) fills VADecPictureParameterBufferVP9 and the
slice parameters per frame, with a context per run of one format and size.
NVDEC's (nvidia::nvdec::vp9) fills CUVIDVP9PICPARAMS, whose bit-fields are
held in words of our own naming and checked against NVIDIA's header with the
rest of the layout. NVDEC makes a decoder at a frame's exact size, and a
frame that predicts from one of another decoder, a resized stream's, is
refused as a picture's error (bugs.md B96).
Two streams libvpx made from a synthetic source (640x360, profile 0 and
profile 2 at 10 bits, three superframes each) and vpxdec's per-frame MD5s
are committed; the ignored card tests decode them bit-exact on the RX 7900
XTX's radeonsi, the Iris Xe's iHD and the RTX 3090's NVDEC.
What changes for the guest: an arm64 guest's VideoToolbox now lists an av01
decoder, profile 0 at level 19 as Apple's own lists, wherever the arm's
capability query lists AV1 Main (VA-API's AV1Profile0, NVDEC's AV1 at
4:2:0), and decodes AV1 sessions on the host's GPU. Before, it had no AV1
decoder at all, and a session asking for one failed -12906.
A session of another profile, or past the depths or sizes the arm lists
(NVDEC's caps, VA-API's AV1 surfaces), is refused at its start with a
warning that names why. A picture the hardware reports failed reaches the
guest as a decode error, as H.264's and HEVC's do on this route.
AV1's codec number is the host's own: the device's caps, its wire and the
option ROM are unchanged, and x86-64 guests get no AV1, as AppleGVA decodes
none. Measured on a Radeon 780M, AV1 decodes at 0.87 of HEVC's rate at
1920x1080 and 1.02 at 8192x4352 (medians, emulated guest CPUs).
VA-API's AV1Profile0 decoder and NVDEC's cudaVideoCodec_AV1 decode the codec
module's frames, at 8 and 10 bits into NV12 and P010 (NVDEC's P016, which
holds samples as P010 does). The hardware applies
film grain into a second surface, which is what the caller gets, while the
frame without grain stays the reference.
NVDEC takes its references by surface: ref_frame_map, each ref_frame[] and
primary_ref_frame name the surface a slot holds. A slot's number in
primary_ref_frame, with ref_frame[] left zero on key frames, faulted
libnvcuvid inside cuvidDecodePicture on the RTX 3090; a frame naming a slot
that holds no frame is now refused before NVDEC sees it.
The ignored card tests decode the committed streams on the hardware, frame
by frame against libdav1d's MD5s. A frame the hardware reports failed is
allowed and counted; a wrong frame delivered as decoded fails, on any card.
Grain of the driver's own synthesis, iHD's, is held to the specification's
by its residual's mean, deviation and block variances, with grain of other
parameters shown to fail the same check. On the RTX 3090 NVDEC reports a
superres stream's inter frames failed (bugs.md U36).
An arm64 guest's VideoToolbox asks for AV1, and both arms decode it in
hardware, but the hardware takes only a frame's tile data: the syntax above
it is ours to read, as H.264's and HEVC's is. The codec module now reads
AV1's OBUs, av1C records, sequence and frame headers and tile groups, keeps
the eight reference slots, works out the frames each temporal unit shows,
and hands an Accelerator each frame's tile data with its parameters.
It refuses at a sequence header what no arm decodes or what the arm's
limits exclude: profiles other than Main, monochrome, spatial layers, and
frames larger or smaller than the arm's capability query lists. A record
without a sequence header is read from its first sample.
Eleven small streams of ours (aomenc, SVT-AV1 and rav1e from ffmpeg's
synthetic sources, and an AVIF still's item) are committed with the MD5 of
each shown frame from libdav1d's decode, and the CPU tests decode, truncate
and fuzz them through a recording accelerator. The card tests' judgement,
film grain's by its residual's statistics, lives here too.
An arm64 guest's VideoToolbox paravirtual decoders now take HEVC's range
extensions, 4:2:0, 4:2:2 and 4:4:4 at 8, 10 and 12 bits, wherever the host
arm's own query lists a decoder of the stream. Until now they took 4:4:4 at
8 bits alone and refused the rest at the session's start.
What changes for the guest:
- dsta and dsts take a range extensions stream where VA-API lists the
decoder of its profile with the render targets and surfaces it needs.
iHD on an Iris Xe lists all six profiles, but its Main 12 has P012 and
P016 surfaces alone, so 4:2:0 at 8 and 10 bits stays refused there.
- They also take it where NVDEC's caps list its chroma format, depth and
size: 4:2:0 and 4:4:4 on an RTX 3090.
- Where nothing lists the stream, the refusal stays as before and names
the stream and the arm's reason. radeonsi lists no decoder of them.
- Each picture lands in the format the guest's own software decoder gives
the stream, which Dpba names: 420v/x420/tv20, 422v/x422/tv22,
444v/x444/tv44 and their full-range forms.
- NVDEC's 4:2:2 is not built: the 3090 lists none, and those streams stay
refused there.
- The x86-64 caps are unchanged.
The codec takes the range extensions at 4:2:0, 4:2:2 and 4:4:4 and at 8,
10 and 12 bits, with their tools. It still refuses extended precision and
high precision weighted prediction offsets past 8 bits. Its CPU tests
decode streams of each chroma format and depth, and an SPS cut at every
length or with any bit flipped is refused or decoded whole, with no panic.
VA-API decodes on the stream's range extensions profile into P012, YUY2,
Y210, Y212, XYUV, Y410 or Y412 surfaces. The CPU splits the packed ones
into the guest's two planes; the GPU still splits XYUV where its import
check passed. NVDEC's 4:2:0 lands as Main 10's, and the CPU interleaves
its 10 and 12-bit 4:4:4 planes. Each picture the CPU converts is counted
as video-pictures-cpu-converted.
CoreVideo has no format with the layout of Y210, Y212, Y410 or Y412, and
the Mac's decoders answer 422v, not yuvs, for 4:2:2 at 8 bits, so the
conversions stay. Under TCG on the Iris Xe, hardware sessions took 0.36
to 0.66 s for 30 pictures at 1080p of every listed profile, against 1.88
to 5.32 s for the guest's software decode (docs/video/devices.md). The
conformance suite decodes x265's streams of every listed profile.
docs/video/devices.md said an arm64 guest is offered no codec on any host:
true of AppleGVA's route alone, and stale since 2d7ce10ea, after which the
arm64e kext serves the guest's VideoToolbox its paravirtual path, which
decodes H.264 and HEVC, and on Linux hosts encodes H.264 and HEVC Main and
Main 10, on the host's video arm. The paragraph now says so, keeping the
measured no-decoder case. video_choice.rs said VA-API decodes alone, stale
since ad8ef4392, which answers the driver's encoders on Linux; Windows still
decodes alone. A listing of the hosts' video formats read both as written.
[ci skip]
The module table in docs/video/backends.md labelled vaapi as Linux only.
lib.rs builds it on Linux and Windows (cfg(any(target_os = "linux",
windows))), where its pool surfaces are Direct3D 12 textures, as vaapi.md
says.
Say the measure, not the absolute: the charge an open of a texture's NT
handle on its own device adds to the GPU Process Memory counters never
comes down, even past the device's last release, and available physical
memory, the commit charge and DXGI's usage did not move with it (over 1440
MiB of charge, the lab's UHD 630 and WARP, potluck job m3-max-75692). The
lesson turns over: such a figure is not a leak until one of those moves
with it, which the first job reads. d3d11_surface.rs keeps its own figures
for rt's import, and gains only what was measured on the open.
On Windows an open of a texture's NT handle on the device that made it
stays charged to the process's GPU memory once the open, the texture and
the handle are all released. vaon12's import by NT handle is such an open,
and so was the plane draws' OpenSharedHandle: each pool stayed charged
twice, 72 MiB each time for six 3840x2160 NV12 textures, in the GPU Process
Memory counters (what Task Manager shows), which DXGI's usage does not
count. Measured on the lab's Intel UHD 630 under Windows (driver
31.0.101.2145, Mesa 26.2.7) with a program on Direct3D 12 and libva alone;
the opens alone did the same on WARP.
The pools now hand each texture to vaon12 as its ID3D12Resource
(VA_SURFACE_ATTRIB_MEM_TYPE_D3D12_RESOURCE), and the draws wrap the same
resource on D3D11On12: Direct3D 12 makes one device a process and adapter,
so the three are one. Nothing opens a pool texture by a handle any more, so
the textures are made in no shared heap and get no handle. A display whose
driver lists no resource memory type for its H.264 or HEVC decode surfaces
is refused at its open, as one is where libva does not load.
For the host: a decode session's pool no longer stays charged to the
process after it ends, which removes the same two opens the VM makes.
Verified on the lab's Intel card under Windows; expected on NVIDIA under
Windows. pools_let_go_give_back_their_memory is new and reads the process's
charge, and pool_textures_let_go_give_back_their_memory now reads it too.
README.md and docs/video/devices.md said the guest encodes in software on an
Intel UHD 630, as if another GPU could encode on Windows. The Windows arm opens
with encodes off on every GPU (open_on_rt in graphics/vaapi.rs), since rt imports
no shared Direct3D 12 texture, so no Windows host lists an encoder today.
A Mac's hardware decoder answers the pictures after an H.264 picture that
does not decode with no error and an image, concealed, until the next IDR
picture (held85's damage run, potluck job m3-max-60715). Ours refused each
of them with h264::Error::Unrecovered until an I picture decoded, so the
device landed nothing in their outputs, which kept their earlier bytes.
What changes for the guest: in an H.264 stream, the pictures after one that
does not decode now decode and land in their outputs as any, predicting
from what the DPB holds, a frame the failed sample lost stood in for by a
copy of the last reference. The picture that did not decode still lands
nothing; it is still the session's warn line and is still counted in the
session's end line. On NVIDIA, an H.264 picture NVDEC fails no longer
fails the pictures after it either. HEVC is unchanged: its pictures after
one that does not decode are refused until an IRAP picture.
The codec decoder's damaged state, mark_failed and Error::Unrecovered go;
its tests now hold that the pictures after a failure come out, in decode
and in display order. Ignored hardware tests on both arms (vaapi:: and
nvidia::) decode a stream whose fourth sample is damaged and read back
every other picture. docs/video/devices.md gains what a Mac's picture holds
for a stream started at a P picture (m3-max-74665: decoded against zeros,
green), which ours leaves as the output's earlier bytes or zeros.
The Windows run is owed on the mini.
On Windows a video cache's planes are rt's imports of the Direct3D 11 textures
the host's video draws its pictures into, and since metal2vulkan b68b31b54a rt
imports each with no view format but the texture's element format, the plane
image's and that one's sRGB sibling. A guest texture over such a plane in any
other format of the texel's size (an R8Uint over the luma plane, say) asked rt
for a view it refuses.
Such a texture now takes the storage shape of its extent, an image of its own
that rule 1 and the fills keep current with the plane, as a texture over a
plain shape in another format already does, so rt is never asked that view. A
texture in the plane's format or its sRGB sibling is a view of the plane, as
before. The guest sees the same pixels: the other-format case is a counted
copy where rt would refuse the view, counted in the degradation counts line as
rt-shape-drawn-format-storage-<plane format>-as-<texture format>, the first of
each pair logged, and in the shapes line. Hosts other than Windows make no
drawn planes and see no change.
The plane shapes a surface over Direct3D 11 textures adds are marked drawn
(ShapeTable::insert_drawn_plane), which the decoder asks of the shape it found
(Caches::drawn_plane). docs/video/bugs.md D26 records the copy as a known gap.
The Iris Xe run of the route's ignored test (m3-max-71683) answered what the
docs left open: iHD passes the XYUV trial at 64 bytes in whole rows, as it
does NV12 and P010, so a 1366-wide picture's rows of 5464 bytes go to the
CPU, and over 40 pictures, each byte-equal to the CPU's split, the GPU's
way took 0.57 ms of the calling thread's CPU time a picture (median)
against 12.1 ms for the read back and split.
The import check now tries XYUV beside NV12 and P010, and where it passes,
the graphics arm has the driver write a 4:4:4 picture into a scratch of its
device's and the device's GPU split it into the guest's surface; the CPU's
split through vaGetImage stays where it does not. The VA-API doc and the
device's design said the CPU split it always. They now say what the check
tries, what the arm does with its answer, and radeonsi's measured answer:
none, since its vaCreateImage refuses an XYUV image.
NVDEC's 4:4:4 pictures were read back to the host and interleaved by the
CPU into the guest's surface. Now, where CUDA imports the device's
exportable buffers, CUDA copies each plane within the GPU into a scratch of
the decoder's. videoGather444 then writes them into a Shared buffer over
the surface's pages, and the pass is waited for. This is the route NVDEC's
4:2:0 pictures already take, which writes the surface in place.
The guest's surface holds the same bytes as before. Each picture written
this way is counted as video-pictures-gpu-gathered, and a session logs how
many at its end. A refusal before anything is written (no exportable
scratch, a plane off a 32-bit word, a plane past the surface or the
scratch, a failed pass) falls back to the CPU's interleave, and its reason
is logged once per decoder.
What the guest sees now: where the driver lists HEVCMain444 VLD with 4:4:4
render targets (iHD on Intel's Iris Xe), VideoToolbox's paravirtual
sessions of HEVC 4:4:4 at 8 bits are made, as on NVDEC. Where it lists none
(radeonsi), they are refused at their start with "VA-API: the driver has no
HEVC Main 4:4:4 decoder" in the refusal line.
The accelerator sends the range extensions' picture and slice parameters,
the base and Rext structures in the usual buffer types, and decodes into
XYUV surfaces. A frame is read back through vaGetImage and split on the
CPU into the surface's luma and Cb/Cr planes. The import check has no XYUV
answer, so no GPU route lands these pictures yet. hevc-check.sh decodes
x265's Main 4:4:4 streams where the driver lists the profile, and expects
the driver's refusal elsewhere.
VideoToolbox's paravirtual decoders refused every HEVC stream outside Main,
Main 10 and Main Still Picture. At login, an arm64 macOS 26 guest opens a
tile session of an HEVC 4:4:4 stream at 8 bits (a HEIC image's), which was
refused.
What the guest sees now: where NVDEC lists HEVC 4:4:4 at 8 bits
(cuvidGetDecoderCaps, Yuv444 output), such a session is made and its
pictures land in '444v' or '444f' surfaces, by their range. Where the arm
declines it, the session is still refused at its start, and the refusal
names the arm's reason. 4:2:2, monochrome, 12-bit and deeper 4:4:4 streams
stay refused.
The codec crate parses the range extensions of the SPS, the PPS and the
slice header, each held to its range, and splits its check: the codec's own
refusals, then the arm's. NVDEC's pictures take the range extensions' pic
params, and its decoder writes three planes. The CPU interleaves them into
the surface's two planes. The tests that held the old refusal now hold the
new answer, and hevc-check.sh expects each refusal's own reason.
The ignored VA test now copies every picture of the 1366x768, 854x480,
642x362 and 426x240 streams on the RX 550 and the 780M, equal to the CPU's
copy, where the copier before this branch declined them. Cold boots playing
such clips show the pictures land by the hardware in their caches' exported
surfaces on both GPUs, so no walk on these cards reaches the copier.
The GPU's copier declined a picture whose planes' rows are not whole 32-bit
words, an NV12 picture 1366, 854, 642 or 426 wide, its rows 2 bytes past a
word, and those pictures took the CPU's copy: the frame read back, copied
into staging and blitted row by row. On an RX 550, whose radeonsi imports
no CoreVideo layout in place, that is every picture of such a stream.
The copier now hands the kernel each plane with no margin (unit 0): a row's
last word takes the row's bytes and keeps the cache's others, by an atomic
AND and OR, so the cache holds the bytes the CPU's copy writes, as before.
It still declines a plane whose first byte or pitch is off a word, and now
a plane whose last row's last word would end past its buffer. Rows of whole
words, 1080p's among them, copy as they did.
A picture whose landing in its output's device caches ran past the
hardware's deadline (a stall) was signalled with the caches never acquired:
the backend kept the work, which may still write them, and the device's
reads of the caches came after the signal with no acquire of what the
hardware wrote, then or later. The guest's next command buffer read them
regardless.
Each arm now takes a mark on the landing's thread before the hardware call
that may stall (VA-API's sync of a decode into a cache, and its video
processing's write into one; NVDEC's copies into CUDA's imports of the
caches), and a stalled landing (Landing::failed_in_caches) waits for the
work its thread kept since the mark to be let go, the device done with it,
then acquires the caches and signals the failure. The VA-API arm drops the
frame first, which keeps its target where its pool stalled. The wait is
bounded: STALL_HOLD, 10 s on the session's clock, past the hardware's own
5 s; past it the process dies at a fault of the decode, since the caches can
be neither read before their acquire nor waited for unbounded.
For the guest: a stalled decode's command buffer completes failed, as before,
once the hardware is done with the caches rather than at once, with the
caches acquired, so its reads and the next picture's see what the hardware
left; a hardware that is not done 15 s after the frame's first wait ends the
process. A stall that kept nothing (a decoder stalled on an earlier frame,
which writes nothing more) is acquired at once. Tests:
a_failed_landing_in_a_cache_says_it_written_before_its_signal (its stall now
acquired before the signal),
a_stalled_landing_in_a_cache_says_it_written_once_its_kept_work_is_let_go,
a_stalled_landing_whose_kept_work_is_not_let_go_ends_the_process.
Since rt copies a texture over an exported block in only at a change of the
block's bytes (the pin's bef2ec1df4), a cache's acquire (external_write_done)
is the one change a write by the host's video makes. A picture that failed
to land in its cache returned before the acquire, so the device kept reading
the cache's bytes from before the hardware's write. The paths: VA-API's
frame.sync() error for a picture decoded into its cache, and the video
processing's write_in_place error into a cache; NVDEC's write_into_device
outer error.
Each now ends through video_host::failed_in_caches, which says the planes
written as the landing would have, then fails with the landing's own error,
so it is logged and counted as any failure and its signal follows the
acquire. Where the error is a stall, the work may still write past its
deadline, so no acquire is said. A refused acquire is logged. A test pins
the pattern: a stopped failure acquires once before its value is signalled,
a stalled one acquires nothing, and both count as failed with their command
buffers completing failed.
The session's end line also counted a picture that the VA-API arm's GPU
copier landed from its scratch as "in a device cache, by the hardware". It
now counts it as "staged by the hardware and copied" (Landing::copied_by_gpu,
Way::Staged), with a test.
What the guest observes changes only where a landing fails: its texture reads
what the hardware left in the cache, as it would on a Mac, rather than the
cache's last picture. The rest is diagnostics.
A video cache's planes took their fill at their make: a clear of each on the
transfer queue, which the first decode op into each new surface then waited
for on its thread before the hardware could write. A macOS guest's walk of
1080p H.264 and HEVC and 4K 10-bit HEVC measured that wait at every new 4K
10-bit surface's first op on a Radeon 780M over VA-API, 14 of 14, 1.9 ms at
the median and 2.6 ms at most (26.1 ms in all), and on 12 of 14 on an RTX
3090 over NVDEC (0.23 ms, 0.32 ms at most); 4 of 21 and 7 of 28 of the 1080p
surfaces' first ops waited, up to 0.9 ms.
The planes now owe their fill as any new shape does. A decode that takes a
new cache's first fill as met takes the planes' fills as met too, on every
host (on Windows it did already), so its begin fills nothing and its op
waits for no fill. The guest reads the same zeros wherever no picture
lands:
- a picture short of the planes has the host's video zero the rest
(the commit before this one);
- a picture that fails to land in planes whose fill its decode took has
them cleared whole by the session, on its queue, before its value is
signalled (SurfaceTarget::zeros);
- a decode op that fails, at any step after its command buffer's begin,
makes the cache's fill from its pages, as one that answers no picture
does (Caches::decode_failed);
- planes that a video command buffer landed no picture in owe a fill from
the buffer, which a use makes by clearing them where the buffer holds no
memory, from the surface's own clear passes, rather than making the
buffer's memory to copy its zeros: SurfaceCaches::fill_shapes now clears
wherever the fill at the planes' make did.
What changes for the guest: a decode's first picture into a new surface
starts without that wait. A picture that fails to land in a new surface
now leaves its planes all zeros, where the hardware's partial write over
the make's zeros showed before. The counts line names the plane fills a
decode took ("taken as met by a decode over zeros"); its "filled at their
make" and "owing theirs past their make" counts are gone.
Tests: the tests that held the fill at the make now hold the planes owing
it and the decode taking it, with no wait (surface_shapes); new tests hold
the clears of planes no picture landed in, and a failed landing's clears
(video_host).
A decoded picture smaller than its output's planes (its crop, or its coded
size, short of the guest's surface) left the texels past it as they were: the
staging buffer's earlier bytes where a plane in a device cache took the CPU's
copy, and whatever the plane held where NVDEC or VA-API's video processing
wrote the crop alone, or VA-API decoded a smaller coded picture straight into
a cache. Every way now lands zeros there, as a new IOSurface reads:
- the CPU's copy zeros past what it copies, in the pages and in staging;
- a backend whose hardware writes the picture says first what the write
covers (`Landing::writes_only`), and the session zeros the rest of each
plane in host bytes, and clears a plane in a device cache whole on its
queue before the write: a render pass of a surface plane's image, a fill
of a buffer cache's bytes;
- VA-API decodes straight into a cache only a coded picture that covers the
planes' crop; a shorter one decodes elsewhere and lands as above;
- on Windows, a draw into textures larger than its crop clears them first.
For the guest: the texels of a decode's output surface past the picture's
crop read zeros, where they could read an earlier picture's bytes or the
staging buffer's. The bytes past each row, and a plane's rows of room below
its crop, keep what they held. No walk has shown a short picture yet (a
780M VA-API walk checked 1436 pictures, a 3090 NVDEC walk 1184, none short);
the tests pin each way the unit tests reach.
The example of the line a session logs for its GPU copies left its times
as ellipses. It now carries what an RX 550 (radeonsi) logged in a cold
boot's Safari video beside the guest's 3D work: 303 HEVC 1080p pictures,
5.087 ms each from the driver's write to the copy's end and 8.387 ms at
most, and 591 H.264 1080p pictures, 2.145 ms each and 30.980 ms at most
(walk job m3-max-66397).
On the rt platform on Linux a decode's picture lands in its output's device
cache by the driver's video processing writing the cache in place, and where
the driver's import refuses the cache's layout, by the CPU: the frame read
back into host memory, copied into the session's staging and from there into
the cache. The guest's decoder asks its outputs of CoreVideo, which lays them
out itself (measured: at 1920x1080, rows of 1920 bytes, the luma plane at
byte 32 and the chroma at byte 2088992), and radeonsi's import refuses that
on the AMD GPUs we have: the RX 550's refuses rows below its pitch of 2048
bytes, the 780M's rows off a multiple of 256. On the RX 550 a walk's 1080p
H.264 and HEVC clips took that way for each of their 894 pictures (walk b1,
m3-max-66052).
Now the session's copier, gpu_copy's ScratchCopier, takes such a picture at
that refusal: the driver's video processing writes the picture into a
scratch of the session's, laid out as the driver's imports must be (each
plane at its dma-buf's first byte or whole rows after it, the even width's
rows at a pitch on 256), and fill's videoEncodeFill kernel copies each
plane's crop from it into the cache at the cache's own offset and pitch, as
plain words; the copy is waited for before the picture counts as landed, as
the CPU's copy is. The copier is reached only where the in-place write was
refused, for a plane in a device cache outside its surface, whatever the
GPU or its driver: every host whose import refuses the guest's rows takes it
(the RX 550 and the 780M), and none is chosen by name. It declines, so that
the CPU copies as before, a plane in the guest's pages or in a surface, a
crop that does not fill its rows in whole 32-bit words (rows of 1366 or 642
bytes), and an offset or pitch off a word.
Where the platform "makes no GPU copies" on Linux: f716a52d2a opened VA-API
on rt with no copier, and 13fb154934 kept it ("the copies make no copier,
for the same reason as before"), the reason f716a52d2a gave being only "as
no GPU copier is given". Neither, nor docs/conventions.md or lessons.md,
records a measured cost, a driver trap or a rule for it: the copier was not
built yet. This crosses no rule of the Vulkan platform's.
GPU memory stays the runtime's: the scratch is rt's, a dma-buf buffer made
through rt and exported through rt's API, one per session, zeroed by a blit
at its make. It is host-only: the guest never maps it, nothing read from it
decides anything, and the kernel's bounds come from the planes' layouts the
host computed. The driver writes it as it writes an in-place cache, the
runtime acquires it after (external_write_done), and the kernel reads only
bytes the driver wrote.
Guest-invisible: each plane's crop rows are the bytes the CPU's copy writes
and every other byte of the cache is as its fill left it, the layout the
device answers is unchanged, and the picture lands at the same point of its
decode. The ignored test
a_picture_copied_by_the_gpu_from_its_scratch_is_the_cpus_copy
compares every byte of the cache with the CPU's copy: 32 pictures of 8
streams (H.264, HEVC and HEVC Main10, 640x360 to 3840x2160) equal on the
RX 550 (m3-max-66105) and the 780M (m3-max-66127), the 1366x768 and 642x362
streams declined.
Each picture so copied counts video-pictures-gpu-copied and its crop's KiB
video-gpu-copied-kib, and a session logs its copies at its end. The fills'
test that held "the platform makes no GPU copies" now holds that the
device's fills make a copier each decode session.
The guest driver's comment said AppleGVA makes its frames' IOSurfaces as
GetPixelBufferInfo answers. A walk on an x86-64 macOS 26.7.2 guest over an
RX 550 measured otherwise: an H.264 decoder's 1080p request was answered
pitches of 2048 at an alignment of 256, and its outputs' rows stayed 1920
bytes, the first plane 32 bytes in; HEVC decoders never asked. The comment
and docs/video/devices.md now say the outputs are CoreVideo's own layout.
In the per-shape form a cache made for the host's video is now a deferred
exportable buffer (an exported block for NVDEC, a dma-buf for VA-API) whose
memory is made where something first reaches it: a decode or an encode whose
buffer is the cache's, or a copy of the caches' through it. Its make on the
guest's SURFACE_PAGES call makes no memory and records no zeros.
The zeros the video's memory needs ahead of a write of the host's video,
which waits for no work of the platform's, are recorded as the video first
uses the memory, on the transfer queue, and the decode's op waits for them as
for the cache's last fill. A cache's planes, whose fill at their make read the
buffer's zeros, copy them from a 1 MiB buffer of zeros made with the surface
for that fill alone. A fill of the pages into a video cache whose memory is
not made goes straight into its shapes, as any deferred cache's does, and a
decode into the buffer then takes the pages into it over the zeros.
What changes for the guest: nothing it reads. Each plane, shape and buffer
holds the same bytes at the same points; a video cache whose pictures all
land in its surface holds no memory of its buffer.
A VA-API decode session made its surface pool up front, its DPB, the picture
and two spare, at the stream's coded size, and gave them to its context as
render targets. A session whose pictures land in the device's caches decodes
only its references into surfaces of its own, so it held surfaces no picture
used.
The pool now starts empty and the context is made with no render targets. The
pool makes a surface when a picture is to be decoded into one of its own and
none is free, up to 48, and lends the one freed last first. A kept context's
shape no longer holds a surface count. Mesa's vlVaCreateContext reads no
render target (read from code, Mesa 26.2.4), and surface::lazy's tests check
the decision off the GPU and, on it, that streams of the driver's own encoder
decode to the same pictures with surfaces made as needed as made up front.
Measured with the process's DRM fdinfo, 8 surfaces at 1080p NV12, 4K NV12 and
4K P010:
- radeonsi (Mesa 26.2.6; Radeon 780M, m3-max-64940; RX 7900 XTX, -64945) makes
no buffer until a surface's first use: +0.0 MiB once made, then 31, 108 and
203 MiB on the 780M (41, 144, 279 on the XTX) once each held an image. Nothing
changes there.
- iHD 26.3.5 (Iris Xe, m3-max-64988) makes each surface's buffer object at its
full size when the surface is made, +28, +96 and +192 MiB drm-total, and
backs none of it until first use (drm-resident +0.0). A session no longer
holds the objects of surfaces it never decodes into.
- On Windows each surface made is a committed D3D12 resource
(CreateCommittedResource in d3d12.rs's shared_texture, read from code), which
allocates when it is made: a session whose pictures land in caches no longer
holds its spare surfaces' memory there. Not measured.
A make takes 0.001 ms or less on radeonsi and 0.004 ms on iHD. The first
access unit, which holds the config, context and first surfaces, took the same
time either way within the runs' spread on all three GPUs (H.264 1080p on the
XTX 12.95 ms as needed, 13.18 up front), with two or three surfaces made as
needed against five up front.
Nothing changes for the guest: the device's answers, the pictures and their
order are the same.
What changes for the host on a GPU with memory of its own (a discrete
card): the IOSurface device caches now fit one budget together, two thirds
of the GPU's own memory's budget as the platform answers it at the device's
start. Past it, in the per-shape form the Vulkan platform takes, the shapes
no texture references are trimmed, least recently used first (never a dirty
or plane one), and a texture that takes one again has it made again and
filled from its cache's buffer. The guest reads the same bytes; only the
GPU's work and time change. Before, only a GPU that shares the CPU's
memory had a budget; its half stays as it was. The device's info line now
names the budget and the GPU's memory on both kinds.
Why: on a 4 GiB Radeon RX 550 (RADV) with no budget, QEMU asked the card
for more than it has in a browser's 3D page (by 201-270 MiB) and in a video
(by up to 1283 MiB, most of it the host's video decoder's). What did not fit
stayed in GTT after the card had room, and where long-lived allocations
stayed there a later benchmark scene ran at 17.2-17.5 frames a second
against 29.4-32.6 (jobs m3-max-63976 and 64138). The caches were the most
of what QEMU asked; of them the budget can trim only the unreferenced
shapes, 353-670 MiB at each over-asking moment, more than the 3D page's
over-ask, above a floor (buffers and referenced shapes) of 2912-3634 MiB.
Two thirds of the card is under every such floor, so it trims all it may
there, and in those walks would have trimmed elsewhere only where QEMU
asked within 415 MiB of the card's room; half would also have trimmed a
scroll that asked 2.2 GB of it.
The test that held the budget for unified memory alone takes both kinds,
and a new one checks a device on a GPU of its own memory sets it.
The guest now gets right pictures from concurrent decode sessions on a
Windows host. Intel's Direct3D 12 video driver for the UHD Graphics 630
(igd12dxva64.dll 31.0.101.2145) decodes wrong pictures on a device's later
video decode queue while an earlier one lives, and Mesa's vaon12 makes a
queue for each VA context, all on the process's one device. Of two guest
sessions decoding at once, one got wrong pictures.
While a device of ours is held, its ID3D12Device::CreateCommandQueue (the
vtable's slot 8) answers every ask for a video decode queue with one queue
it keeps, a reference added for each asker. Other queue types, and devices
no hold holds, go to the slot's own method. No vendor decides: every device
gets the one queue. The slot gets its own method back when the last hold on
a device with that vtable goes, and the kept queues go with the last hold on
their device.
Measured on the UHD 630, 4K H.264, frames per second in all: one session
25.4-27.4, two 53.2-56.1, four 113.6-116.0 with one queue, against 22.9-26.9,
49.7-52.2 and 101.8-111.9 with a queue each, where the sessions decoding
wrong ran fastest. The new test of two decoders at once passes 3 of 3 with
the one queue and fails without it; the churn test decodes none wrong in 3
runs. docs/video/bugs.md U33 records the driver's bug and the split.
On Windows the kept-context change held only a context's teardown and
destroyed a pool's surfaces and its config at once, beside the display's
live contexts. That passed the two-thread test, but rounds of 2 and 4
decoders each decoding the stream at once, each picture waited for and not
read back, had a decoder's vaEndPicture fail in every run of 6 on vaon12 on
the UHD Graphics 630 (potluck jobs m3-max-61922, 61930, 61939), where
development, which holds every teardown, passed 4 of 4, and holding the
surfaces' teardown too passed 2 of 2 (m3-max-61948).
So every teardown is held again while a context lives, and a decoder's
context is kept with its config and its pool: Context::new_decoder makes
the three, or takes the three back for a decoder of the same shape (now
with the surface format and count), so beside a live context nothing is
made or destroyed for a shape kept. A kept pool lets go of its
video-processing context first, which as a live context would keep the
held teardowns from ever being made, and a stalled pool is neither kept
nor taken back. The release_teardown doc's measured claim that destroying
a pool's surfaces at once passed is corrected with these runs, and the
full-pace test runs their shape.
On Windows every teardown asked for while another VA context lived was
held until none did, which stopped Intel's Direct3D 12 video driver
faulting, and kept each short 4K decoder's memory (about 211 MB of DXGI's
local count) until the long decoder beside it ended.
Measured on the UHD Graphics 630 (job m3-max-61642): holding the
context's destroy alone passes the two-thread test, with the pool's
surfaces, or the surfaces and the config, destroyed at once. Held
contexts still grew DXGI's local count by 34,905,201 bytes each. So a
config's and a pool's surfaces' teardowns are now made at once, and a
decoder's context let go while another lives is kept with its config
and taken back by the next decoder of the same config, size, render
targets and DPB, instead of one made beside it. Kept contexts are
destroyed with the held teardowns once no context lives. Linux is
unchanged, and so is what the guest sees.
The churn test makes ten short decoders beside a long one, compares their
pictures with the long one's, and on Windows asserts DXGI's local count
grows by less than one held context over the last nine.
iHD codes a frame from a linear import other than as from a surface of its own, and
the encoder's imported inputs are laid out in its Y tiles for that: the row says what
was measured on the Iris and where our code lays them out.
On an Intel GPU under iHD, a guest's encode session got other bytes from a
frame the rt GPU wrote into the encoder's input than from the same frame
uploaded. The input was imported linear, and iHD codes a linear import
differently from a surface of its own:
- H.264's P pictures differed at 640x360 and smaller;
- every HEVC Main 10 picture differed, intra ones too, at about ten times
the bits.
iHD's own inputs are Y-tiled (I915_FORMAT_MOD_Y_TILED). Their pitch is the
coded row's bytes rounded up to 128, and their chroma plane sits at the pitch
times the coded height rounded up to 32 rows. An import declared and written
in that layout coded as the upload did, byte for byte, in every profile at
five sizes up to 1080p. The one exception is where iHD differs from one
upload to the next anyway (HEVC Main at 640x360 and 1080p). Measured on an
Iris Xe, iHD 26.3.5.
What changed for the guest: on iHD, the GPU-filled path's samples are the
ones the upload path would give. Nothing changes on radeonsi: its own inputs
are in AMD's 64 KiB swizzle, so its inputs stay linear at rows of 256, which
it codes as the upload.
The changes:
- `VideoEncoder::input_layout` makes one surface as the encoder's pool does
and exports it. Where that surface is in Y tiles in this layout, the input
takes its pitch, chroma offset and size. Otherwise the input is linear, as
before.
- `import_input` takes the tiling, and `Target::import_as` declares Y tiles
in the DRM PRIME descriptor.
- The fill asks the layout once per shape, sizes the input from it, and
passes the kernel its tiling word.
- `TargetTiling::byte_at` is the Y-tile address the tests write and check
by.
Tests:
- The VA crate's import test now writes its input in the encoder's own
layout, so on iHD it writes Y tiles.
- The rt kernel test fills every case into a linear input and a Y-tiled
one, and compares the whole input byte for byte.
- New unit tests cover the Y-tiled layouts iHD gave, the misfits that are
refused, the tile address, the linear layout and the fill's declines.
On Linux the rt platform's VA-API arm made no GPU filler, so an encode
session's frames could only be uploaded by the CPU, and the arm answered no
encoder (f716a52d2a: "rt releases no encoder's sources to the driver yet").
The arm's GPU copies on rt (`fill::DeviceFills`) now give each encode session
a filler. Its input is a dma-buf block of the device's, made when no input of
the shape is free and imported on the encoder's display; a frame's two planes
are read where they lie, in the surface's pages or its device caches, and
written into it by videoEncodeFill, margin included, so the encoder codes the
bytes the upload would have given it. A blit hands the block to the driver
(`release_to_external`) behind the kernel, and the frame is coded once the
GPU's write is waited for; no B pictures are coded, so the driver has read the
input before the next frame's write. An input the driver still holds is not
written; a plane in its cache's surface, or one the input cannot hold, is
declined and that frame uploaded, said once a session. A write that fails on
the GPU keeps its filler and input for the session's life, and the session's
later frames are uploaded. Decodes are unchanged: the copies make no copier,
for the same reason as before.
The session's end logs how many frames went each way. The arm still answers no
encoder here; the next commit turns them on.
New tests: the input's planes and the kernel's arguments on the testkit; the
kernel on the rt device writes frames of NV12 and P010, with and without
margins, at odd offsets and pitches, as the upload writes them, and nothing
past the coded rows; on the VA-API host, frames written by the GPU code byte
for byte as the uploaded ones, an x86 guest's session's and an arm64 guest's
paravirtual encoder's.
The VA crate's encoder read its frames only from host bytes, which it uploaded
into a surface of its own pool. The rt platform can make the encoder's input
itself: a dma-buf block the encoder's display imports, which the device's GPU
writes the frame into where its planes lie, with no upload and no staging
copy.
`VideoEncoder::input_shape` names the input such an import must be: NV12 or
P010 at the encoder's coded size. `import_input` (Unix) imports a dma-buf as a
linear surface of that shape through DRM PRIME, as a decode's targets are
imported, keeping the caller's memory while it lives. `encode_target` codes
the frame written there, margin included, and reads none of the frame's
planes; an import of another shape is refused. A stalled frame's import is
kept with its session, as the driver may read it still.
Two ignored tests on the VA-API host: frames written into an import code byte
for byte as the same frames uploaded, for each profile the driver encodes, and
an import of another shape is refused.
The two vaon12 tests of the adapter's device after a display's let-go fail
on Mesa 26.2.7's vaon12 over the UHD 630: the driver leaves one Direct3D 12
object of every decode session past vaTerminate, whatever our surfaces, and
nothing in our order of calls reaches it. Their ignore reasons and docs now
say so, and docs/video/bugs.md's new U31 records the measurements, so a run
of the ignored tests on the Windows host reads as the driver's and passes
once a driver frees what it made.
What changes for the guest: an HEVC picture NVDEC answers failed once it ran
(its slice data damaged past what the parsers read) lands as NVDEC left it, its
command buffer completing as any, and the pictures after it decode from it, as
an H.264 picture NVDEC failed has. Before, its landing failed its command
buffer, which AppleGVA's HEVC path answers with kVTVideoDecoderMalfunctionErr
for that picture and every later one of the session.
Why: a Mac's hardware HEVC decoder hands such a picture on, as its H.264 one
does (measured with VideoToolbox on a MacBook Pro of 2019, macOS 26.7.1, on
the UHD 630: an HEVC P picture at 1080p whose last slice segment was cut to
half, and each picture after it until the IDR picture, came back with status
0 and an image). AnnexBDecoder::copy_failed_pictures now asks this for both
codecs, and its NVIDIA test cuts an HEVC P picture as it cut an H.264 one.
What changes for the guest: a host session's decode whose picture is one of
the stream's that does not decode no longer faults its command buffer. Such a
picture is one whose bytes do not read as H.264 or HEVC reads them, one that
predicts from a picture the decoder does not hold (a session or a seek that
starts at a P picture), or one after a picture that did not decode, before the
next I or IRAP picture. It now lands nothing: its command buffer completes as
any, its output keeps its bytes, and the session decodes again from the next I
or IRAP picture. This holds on VA-API and NVDEC, for H.264 and HEVC, and on
VA-API also covers a RASL picture the stream's random access skips, which
faulted there while NVDEC already landed nothing for it. A stream the decoder
does not take, an avcC or hvcC record's error, and the hardware's or the host
API's errors still fault.
Why: a Mac's hardware decoders answer each such picture alone and decode on
(measured with VideoToolbox on a MacBook Pro of 2019, macOS 26.7.1: H.264 with
no error, HEVC with kVTVideoDecoderBadDataErr or ReferenceMissingErr and no
image). Before, a guest boot on a Radeon 780M counted 85 decode faults
("a reference frame is missing", "PPS 4 has not been received", "no I picture
has decoded since a picture that did not decode") for H.264 streams started at
a P picture or with a damaged header, and an HEVC picture that faulted would
end AppleGVA's session with kVTVideoDecoderMalfunctionErr from that picture
on. The codec errors say which are one picture's (is_picture_error), and NVDEC's
error keeps them apart (Error::Picture), still reported as bad data.
What the guest observes changes. Before, where the host's video landing found
no blit encoder for its copy of a picture's staged planes into the output's
device caches (on the rt platform, an encoder metal2vulkan-runtime refuses),
the landing failed: the decode's value was signalled, and the command buffer
that waits for it completed failed, with Metal's internal error, which the
guest's video driver answers as a decode error (HEVC:
kVTVideoDecoderMalfunctionErr).
Now the copy is skipped, as the decoder skips whole a pass the platform makes
no encoder of (4b7975b882, decode::cmdbuf's unmade): the caches keep their
bytes, the picture lands with them, its value is signalled and its command
buffer completes as any landed picture's, not counted as a failure to land. rt
counts the refusal under rt-refused-<kind>, as before; the process's first
skip has a line. No new degradation code.
An encode's copy of its source out of the caches keeps its answer: no blit
encoder fails the frame (RGFX_VIDEO_ENCODE_FAILED), since a skipped copy would
hand the encoder the staging buffer's earlier bytes, another frame's or what
the buffer held when it was made.
No test held the old failure. The new tests:
a_copy_into_caches_the_platform_makes_no_blit_encoder_for_is_skipped (no copy,
signalled, completes as landed, the next picture copied as any) and
a_source_whose_copy_out_has_no_blit_encoder_fails_its_frame, which pins the
encode's answer.