Commit Graph
5 Commits
Author SHA1 Message Date
Anees Iqbal be06c54d3e 🐛 Fail an HEVC picture's schedule when the host fails its decode
AppleGVA's decode flow takes every query of a decode for its completion
and reads no status or error from it (read from its code on macOS
26.7.1); the one failure it reports to VideoToolbox is a failed
schedule. The driver answered a query of a decode the host was still
running as running and never looked at its token again, so a host
failure that came after the query was lost: the guest got the untouched
surface as a decoded frame and no error. Only a failure the host had
already reported at the query failed the session's next schedule, two
pictures late.

Now the schedule of an HEVC picture waits for the host's verdict on it,
out of the lock that orders the sessions' pictures, and fails where the
host failed it. What changes for the guest: an HEVC decode's
ScheduleCommands returns once the host has decoded the picture, and a
picture the host fails gets kVTVideoDecoderMalfunctionErr itself, from
that frame on, instead of two frames later or never. H.264 is unchanged:
AppleGVA's H.264 pipelines keep no decode's result, so its schedule waits
for no verdict (docs/video/bugs.md D25, now H.264's alone).

The tests that held the deferred failure (failsLaterSchedule,
queryReport) change with it, and checkHostVerdict drives the schedule
through a host that fails one picture.
2026-11-08 14:51:12 -08:00
Anees Iqbal 812b68c62b 🐛 Fail the schedule of an HEVC picture the host's caps refuse
An HEVC picture that the host refuses was sent anyway, and the refusal came
back only at the host. AppleGVA takes such a picture, and the one after it,
for decoded (D25), so VideoToolbox delivered two wrong frames before
-12911. The refused pictures were: one whose coded size was outside the
caps; one whose PPS had a tile column narrower than the host decodes; and one
whose current reference sets held more pictures than the caps'
max_references, as kvz-720p-ref15's tenth picture does.

The driver now checks each picture against its HEVC decode entry and the
entry's decode caps before it sends it (hevcTaken). It reads NumPicTotalCurr
from the first slice segment's header (h265::currentReferences): its own
short-term set or the SPS's, with prediction, and its long-term pictures.
It works out the PPS's narrowest tile column with 6.5.1's layout
(h265::narrowestTileColumn). A picture that fails the check fails its
schedule. VideoToolbox reports kVTVideoDecoderMalfunctionErr for that frame
and every one after it, where it used to deliver two wrong frames. A bound
of 0 refuses nothing, and a header the driver cannot read leaves the verdict
to the host. kvz-720p-ref15 now decodes 9 frames and then fails, as it does
on an M3's VideoToolbox. H.264 gets no such check: AppleGVA's H.264 decoder
delivers a picture whose schedule failed.

The kext set is built again with the bundle.
2026-11-08 12:51:01 -08:00
Anees Iqbal 533e26d043 🐛 Fail no H.264 schedule for a picture the host failed
AppleGVA's H.264 decoder reports no failure a driver can answer. Measured on
the guest with the RTX 5080 host, every picture failed on the host: a failed
schedule (answered 5, 1 or 7, once or for every schedule after), the query's
status 0, 3 or 4, its field_08 or field_14 set, and a failed query call each
left all 60 frames decoded for VideoToolbox. A picture whose schedule failed was
never decoded. So failing an H.264 session's next schedule for a failure on the
host reported nothing and dropped the picture after the failed one. Now only an
HEVC session's next schedule fails, as AppleGVA's HEVC decoder reports it.

The docs said the failure came one picture late. For HEVC it comes two pictures
late, as AppleGVA schedules a picture before it queries the one before (58
errors of 60 where every picture failed). For H.264 it never comes.

The guest's kext set is built again with it on m3-max (25G241 KDK, Xcode 27.2):
RgfxGate, which carries the bundle, changes.
2026-11-07 19:33:24 -08:00
Anees Iqbal caf9ae1120 🐛 Fail the schedule of a decode the driver cannot complete
A decode the driver could not send (no output surface, refused parameter
sets, no command buffer) was answered done at its status query, and
VideoToolbox took the untouched surface for a decoded frame. AppleGVA
reports a decode error only when the schedule fails: a schedule answering 5
reaches the client as kVTVideoDecoderMalfunctionErr (-12911), and it ignores
every failure a status query can answer, a detail word, a failed query and
the statuses 0 and 3 alike (measured on the guest with the RTX 5080).

So the schedule of a command the driver cannot send now fails, for H.264 as
for HEVC, and logs one line. A failure the host reports for a picture it was
sent shows only at the query: the driver marks the picture's session, and
the session's next schedule fails, one picture late. A context's deletion
clears it from the tokens, so a later context at its address is never
failed for it.
2026-11-05 21:59:24 -08:00
Anees Iqbal ae30f6891a 🆕 Decode HEVC in the guest's video driver
The video driver now offers AppleGVA HEVC decode where the host's video
caps list it: Main into NV12 ('420v', '420f') and Main 10 into P010
('x420', 'xf20'), in the profiles the host lists. Each picture goes to the
host as H.264's do, its slice segments copied out of AppleGVA's bitstream
buffer and the SPS and PPS written from AppleGVA's parsed form where they
changed (RgfxVideoH265.cpp, sharing the bit writer with H.264).

An HEVC decode command carries no output surface and no transfer command,
unlike H.264's: AppleGVA names the output frame in its decoded-picture
record, whose frame holds the surface's global IOSurface id, and the driver
looks it up there. AppleGVA holds each short-term set of the SPS by its
pictures, a predicted set's already derived, and the writer writes every set
by them. Both measured on the guest with the RTX 5080; the sets' layout
against hevc-main-720p-sets-sps, whose 25 sets AppleGVA held as 7-61 and
7-62 derive them, and whose SPS written from AppleGVA's struct decodes as
the stream's own.
2026-11-05 21:59:24 -08:00