Core Animation draws an HEIF grid through VideoToolbox's tile decoder, which
has AppleGVA decode every HEVC tile straight into one canvas surface. The
driver landed each tile at the canvas's origin, so a grid showed its last
tile's pixels top left and the rest of the canvas empty (Freeform's welcome
view; ca.heic.grid's mean 108 against the oracles' 5.3).
AppleGVA names the tile's place at P+0x58 and P+0x5c of the picture's
parameters (measured on the RTX 5080 host for grids of 2, 12 and 32 tiles;
0 for frames of their own). The driver now sends the place and the
picture's crop, and the channel lands the picture through textures over
each plane from that place, which RgfxIOSurfaceTexture makes at an offset
in the plane's view. A tile of the last column or row of a canvas of no
whole number of tiles goes with an SPS whose conformance window crops it to
the canvas, as the canvas's planes, and the device's copy of them, hold the
canvas alone.
The tile parameter now answers the place's alignment across from the
device's plane alignment, and H.264 a canvas row of 0: its pictures name no
place the driver knows, so AppleGVA starts no tile decoder for it.
GetContextParameter answered success for AppleGVA's tile parameter (0xb)
whenever it could not fill it, and wrote nothing. That happened with no
decoder of the codec on the host, which covers a process with no device
of ours and caps without the codec. It also happened for a codec or
function the driver has no decoder for, and for a list entry with no
record. AppleGVA then handed up whatever the caller's buffer held, and
CMPhoto divides by its alignments. The sweep's imageio.heic died that
way, of SIGFPE in CMPhotoDecompressionContainerCreateImageForIndex: a
divq by the width alignment, 0, at CMPhoto+0xc88eb, on the msi 5080
host's 5d7e04c6c image, from before the parameter was filled.
The tile parameter is now written whole or refused with kUnsupported, as
GetDriverParameter refuses what it cannot answer. A parameter the driver
does not know is still success with its record as it came, as AMD's
driver answers it. Every other getter already writes its whole answer or
returns an error.
video_driver_tests checks the refusals and that each record stays as it
came. On the driver before, it fails at the first case, H.264 with no host
decoder.
The tile parameter, the bitstream alignments and the pixel layouts the video
driver answered were AMD's driver's values, or a pick between the two dGPU
oracles' (725bd2bb0). The oracles answer for their own hardware, so each answer
is now what the host's decoder needs and does, from what the guest reads of it:
its video caps on the wire and the device's linear texture alignments.
- Tile parameter: a tile is a picture the host decodes, of the coded sizes its
caps take (min_size, max_size), and it lands in a frame of its own, cropped
to that frame's origin, which VideoToolbox lays in the canvas (measured on
the RTX 5080 host: a 4096x4096 image's 64 tiles of 512 went through four
512x512 frames). So a tile's place in the canvas needs whole chroma samples
alone, 2 by 2 in 4:2:0 (was 32 by 2), and the canvas row is at most the
widest the host writes, its largest width in samples of its widest format
(was 4096 bytes). The least and largest tile are the caps' sizes (were AMD's
and Intel's).
- Bitstream alignments: the decoder's own (bitstream_alignment, from its
minBitstreamBufferOffsetAlignment and size alignment), was 256.
- Pixel layouts: as the host's copy lands a picture, its crop at each plane's
origin: luma of the frame's size and chroma of half in whole pairs, with no
padding (heights were padded to 16, an odd frame's chroma short a column),
each plane's first byte and one pitch for both at the larger of the device's
linear texture alignment for the planes' formats and the 4 bytes the copy
takes (was 256).
video_driver_tests checks each answer against a stand-in host's caps and
device alignment.
CreateDriver answered every call with the same handle, and the bitstream
pools were the process's, by AppleGVA's pool type. AMD's driver keeps them per
driver, each CreateDriver a context of its own, and frees a pool allocated
again in that driver alone. Here a second decoder in a process, as an HEVC
stream with alpha decodes in VTDecoderXPCService, or a session made while
another's is still out, freed the buffers the first was still writing access
units in; mmap could then hand the same pages to the second. The sweep's
video.hevcalpha.generator failed at frame 15 with -11821, beside a
VTDecoderXPCService crash in AppleGVA's HEVC decoder zeroing memory at an
unmapped address (lane-gate's boot of 5d7e04c6c).
Each CreateDriver now makes a driver with pools of its own, which a context
names its pictures' buffers in, and DeleteDriver frees them; a handle no
CreateDriver made is refused. video_driver_tests checks that two drivers' pools
of one type stay apart and mapped, through a reallocation and a delete, and
fails on the driver before (two drivers shared a handle).
An HEIC decode reaches the HEVC decoder through VideoToolbox's tile decoder
session, which AppleGVA starts from the decoder's tile parameter
(GetContextParameter, entry 13, parameter 0xb). The driver answered entry 13
success with nothing written, so the tile alignments AppleGVA hands up stayed
0, and CMPhoto, above it, divided by them: ImageIO's HEIC decode died of SIGFPE
in CMPhotoDecompressionContainerCreateImageForIndex (measured on the RTX 5080
host), and the sweep stopped at imageio.heic.
Entry 13 now answers the tile parameter of each decoder. The two dGPU oracles
answer it differently (macOS 26.7.1):
AMD Radeon Pro 5300M, HEVC: 32, 2, 4096, 64, 64, 4096, 4320
AMD Radeon Pro 5300M, H.264: 32, 2, 4096, 64, 64, 4096, 2304
Intel UHD 630, HEVC: 128, 64, 131072, 16, 16, 8192, 8192
(width and height alignment, largest canvas row in bytes, least tile width and
height, largest tile width and height). Each field is the bound both allow,
held to the pictures the host's decoder takes: the alignments, canvas and
largest tile AMD's, the least tile Intel's 16 or the host's least, the largest
no more than the host's. A tile decodes into a frame of its own, of its size,
which VideoToolbox lays in the canvas (measured: a 4096x4096 image's 64 tiles
went through four 512x512 frames), so the canvas asks nothing of the host. A
parameter the driver does not know is answered as AMD's driver answers it:
success, the record as it came.
The other answers AppleGVA may divide by are made whole too: all six
bitstream alignments (five were 0), and a pixel layout refused, its record
untouched, for a frame under 2 samples a side, rather than a chroma plane of
none. video_driver_tests checks that none of these is 0 and fails on the
driver before.
Measured on the RTX 5080 host with the fixed bundle: HEIC images of 512,
1024 and 4096 square (gridded), made in the guest and on a Mac, decode within
4 of their source in every 64x64 block; a 6016x6016 desktop picture decodes;
the sweep's imageio.heic and imageio.heic.alpha pass, and h264.reader too.
Where CreateContexts could not open a later context's host session, it
deleted the contexts it had made before it without closing their sessions or
taking them out of the live ones. The sessions leaked on the host, and the
next FreePixelBufferPool walked the deleted contexts. Both paths now delete
a context the same way: its session closed and out of the live ones, and no
token naming it.
video_driver_tests drives the driver's entry points as AppleGVA calls them,
over a stand-in for the host's sessions: a create whose second session is
refused, DeleteContexts, and a decode the driver cannot send, which fails its
schedule. The first check fails on the old cleanup.