Files
reims-vgpu/guest/bundle
Anees Iqbal 319f54dabb 🆕 Encode an x86-64 guest's HEVC on the host's encoder
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.
2026-11-27 16:26:01 -08:00
..