Commit Graph
58 Commits
Author SHA1 Message Date
Anees Iqbal 7d153fc6f2 🆕 Write a picture into its dma-buf cache by the driver's VPP
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.
2026-11-12 11:53:16 -08:00
Anees Iqbal 2208a41716 🐛 Wait for a video op's cache and GPU copy as long as they take
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.
2026-11-12 11:53:03 -08:00
Anees Iqbal 94f599643a 🐎 Make exportable caches of two-plane surfaces alone
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.
2026-11-11 06:22:13 -08:00
Anees Iqbal 7c4d36f0c1 📝 Say the 5080's exportable caches keep their planes' shadows [ci skip]
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.
2026-11-11 03:27:14 -08:00
Anees Iqbal ee763eb3b4 🎨 Leave the boundary of a cache's placed byte to the platform
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).
2026-11-11 03:27:14 -08:00
Anees Iqbal 377aa5f3f4 🐎 Place a dGPU device cache's first plane where textures lie in place
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.
2026-11-11 03:27:14 -08:00
Anees Iqbal 9289b2f37f 🐛 Keep a zero-copy import for each buffer's planes in a mapping
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.
2026-11-11 02:27:46 -08:00
Anees Iqbal 7e264b6dbd 🔥 Hold GPUs through potluck alone and remove gpu-locks.sh
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.
2026-11-10 23:17:59 -08:00
Anees Iqbal f77c620de6 ✅ Run the VA target probe by hand, outside the VA check
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.
2026-11-08 18:20:43 -08:00
Anees Iqbal 460474ce1a 📝 Record radeonsi's write bound of imported decode targets [ci skip]
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.
2026-11-08 18:20:43 -08:00
Anees Iqbal 822ff54fc7 🐛 Answer H.264's largest size at most 4096 wide under the macroblock bound
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.
2026-11-08 16:51:38 -08:00
Anees Iqbal 2702dfb579 📝 Record where H.264's refusals reach the guest [ci skip]
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.
2026-11-08 16:37:43 -08:00
Anees Iqbal 2d5d6a4003 🐛 Keep H.264 pictures under the macroblocks VA's drivers decode
iHD and radeonsi answer 4096x4096 as their largest H.264 decode, yet give
every frame of a 4096x4096 stream back with its luma all zeros, every call
succeeding: ffmpeg's VA-API decode as ours, on an Iris Xe, an RX 7900 XTX
and a Radeon 780M. 4096x4080, 4080x4096 and 15 other sizes decode right.
4096x4096 is the one size within the drivers' bound of 65,536 macroblocks.

So the VA decoder refuses a picture of more than 65,535 macroblocks at its
SPS, and the graphics device answers H.264's largest size under the bound,
4096x4096 as 4096x4080: the guest's video driver then refuses such a stream
at its create, and VideoToolbox decodes it in software, where before every
frame reached the guest black. Recorded as bugs.md U28.
2026-11-08 16:37:43 -08:00
Anees Iqbal 020efddfc1 🐛 Decode H.264's Extended profile where its slices use only Main's tools
The codec module refused every SPS of profile_idc 88, at the first picture,
which through the graphics device reaches the guest as undecoded frames:
AppleGVA's H.264 decoder hears of no failure. Apple's AVC decoder on an x86-64
Mac decodes such a stream in hardware (measured on a Radeon Pro 5300M's
AppleGVA flow and an Intel UHD 630's, macOS 26.7.1: JM 19's Extended stream of
CAVLC B slices decoded as JM's reconstruction). Its pictures are Main's where
they use none of Extended's own tools, so the SPS is taken, the VA-API arm
asks for VA's Main profile, else High, and data partitioning and SP and SI
slices stay refused at the slices that use them.

For the guest: an Extended stream now decodes on the host where it reached the
client as undecoded frames.
2026-11-08 16:37:43 -08:00
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 cbf4187e24 🆕 Give the guest the narrowest HEVC tile column the host decodes
The host refuses an HEVC picture whose PPS has a tile column under 128 luma
samples (MIN_TILE_COLUMN_WIDTH), and nothing on the wire said so. The guest
could learn it only after it had scheduled the picture, which AppleGVA takes,
with the picture after it, for decoded.

RgfxVideoCaps gains decode (at 0x510), an RgfxVideoDecodeCaps for each entry.
Its min_tile_width is 128 for HEVC decode on both arms, and 0, no bound, for
every other entry. The kext copies the device info and the caps by their
sizes, so the kext set is built again with the header. The option ROM's
record names the header, so the record is written again too.
2026-11-08 12:47:31 -08:00
Anees Iqbal 5dfba088f8 🐛 Decode HEVC tile columns from 128 samples and rows of any height
The HEVC decoder refused a PPS with a tile column under 256 luma samples or a
row under 64, the Main profiles' bounds (A.3.2 to A.3.4), after the guest had
scheduled the picture. kvazaar writes such streams without a warning. The
hardware decodes them: columns of 128 and 192 samples and rows of 16 and 64
matched kvazaar's MD5 SEI and reconstruction on every frame on radeonsi (a
Radeon 780M), on iHD (an Iris Xe), on NVDEC (an RTX 5080 Laptop GPU), and on an
x86-64 Mac's Apple decoders (Intel UHD 630, and AMD's driver on a Radeon Pro
5300M). A column of 64 samples, one CTB of 64, came out wrong on every frame,
with no error, on radeonsi and on the Mac's AMD driver, and right on NVDEC and
the Intel ones.

The decoder now refuses only tile columns under MIN_TILE_COLUMN_WIDTH, 128.
No driver reports the bound, so it is the same on every host. For the guest,
kvz-720p-tiles-narrow (a 192-sample column) and a stream with a row of 16
decode on every frame. A stream with columns of 64 is still refused.
hevc-check.sh decodes kvz-720p-tiles-narrow and kvz-720p-tiles-short, and
expects kvz-720p-tiles-col64 to be refused at its PPS.
2026-11-08 12:47:31 -08:00
Anees Iqbal 6d6d1b994e 🐛 Answer the 8 current HEVC references every picture decodes with
The HEVC decode entries said 15 for max_references on both arms: the size of
VA's ReferenceFrames, and the DPB bound on NVDEC. Neither host decodes a
picture with more than 8 pictures in its current reference sets. VA-API's
decoder refuses it (va.h: NumPocTotalCurr "should be equal to or smaller than
8"), and radeonsi decodes one wrongly when it is sent. NVDEC's
CUVIDHEVCPICPARAMS holds 8 a set, so 8 in all is the most with which every
picture decodes there. kvz-720p-ref15 is refused from its tenth picture, with
9 current references.

The guest now reads 8 for max_references in its HEVC decode entry on both
arms. H.264's 16 stays: the hosts take a reference list of 16 frames
(ReferenceFrames[16], NVDEC's dpb[16]), which is the standard's bound.
2026-11-08 12:47:31 -08:00
Anees Iqbal 4d76e9b642 🐎 Land VA-API pictures in device caches where memory is shared
What changes for the guest: on a host whose GPU shares the CPU's memory
(RGFX_FEATURE_SURFACE_CACHE_REFUSED), with VA-API's hardware video (the
Radeon 780M's radeonsi, the Iris Xe's iHD), the video caps now say
RGFX_VIDEO_CAPS_OUTPUT_CACHED, with no output layouts, as a host of a GPU
of its own memory says them where its video lands pictures in caches. The
guest's video driver then asks its output surfaces cached, with their
layout, as any other surface (RgfxAskUncachedScope no longer covers them),
and the device keeps a cache of those it answers RGFX_STATUS_CACHE: an
output whose textures would not lie in place in its pages, or whose view
has no room for its mappings. A picture lands in such a cache by the
runtime device's copy of the decode surface (or the CPU's, through the
session's staging, where that copy is refused), and a CPU read of a decoded
frame has the cache copied out into its pages first. An output that lies
in place stays in its pages, as before.

For the host: VaapiVideo::lands_in_device_caches is true, and the device
offers cached outputs wherever the kext makes caches (video_caps, out of
GraphicsDevice::with_platform). The caches lay the first plane on 256
bytes of their memory (the commit before), so textures over the decoded
planes lie in them rather than in the runtime's shadows.

Measured on guest boots of macOS 26.7.2, Safari playing 4K60 HEVC clips
(8-bit, then 10-bit; then two and three at once), against development
81f187735 on the same host, vm.max_map_count 1048576, before this change
was rebased onto development's df50639ea (a laid-out cache's bytes between
rows declared unobserved), which the boots did not include:

- Radeon 780M (radeonsi and RADV, Mesa 26.2.6): the runtime's shadow
  texels copied in per presented frame fell from 10.2-15.6 M to 0.00-0.03 M.
  18 of 85 sessions landed in caches (4K outputs whose planes exceed
  udmabuf's 1024 pieces), the rest in place; 148 caches were made aligned.
  Presented fps 55.8/55.5 single, 53.9/57.0 two, 52.1/51.9/54.0 three
  (development 57.0/57.2, 56.0/57.5, 53.9/53.3/52.6), drops 14/14/6 at
  three (13/15/5). Mappings 5.7-6.6 k both.
- Iris Xe (iHD, ANV Mesa 26.2.6), where ANV answers a cache for every
  surface: all 85 sessions landed in caches, and the process's mappings
  peaked at 13.3 k (311 k on development). Shadow texels 0.07-0.32 M per
  frame both. Presented fps 53.3/54.0 single, 54.4/53.6 two,
  54.5/55.2/55.0 three (development 57.1/56.6, 55.4/53.9, 54.0/51.8/54.0),
  at most 2 drops a clip; a second pair of boots, development's first,
  gave 56.5/55.4 single (development 54.1/55.7): the single clips' spread
  is the boots', not the change's.
- Both: 0 pictures copied by the CPU, 0 fatal lines. A guest process
  reading every decoded frame on the CPU (decode_md5 against ffmpeg's
  framemd5) matched on 63 of 75 streams both ways, the same 12 failing on
  development, the three 4K streams (in caches) among those matching. The
  byte-exact test lands every third of 4951 pictures of the conformance
  streams in a cache made as the device makes one, equal to the CPU's copy.
- RTX 5080 Laptop GPU (NVDEC): its caps and caches are as before (no cache
  made aligned); the boot's playback swung as development's does there.
2026-11-08 10:33:54 -08:00
Anees Iqbal 24fa54079b 🐎 Copy VA-API pictures into the guest's planes on the GPU
On VA-API every picture the reims-graphics device decoded was read back and
copied into the guest's output planes by the CPU (B93): CoreVideo lays each
plane 32 bytes into its page, and neither radeonsi's nor iHD's video
processing writes that layout, so the in-place write declined every picture.

Where the in-place write declines, the arm now exports the decode surface as
dma-bufs (vaExportSurfaceHandle, each plane a layer of its own, kept with the
surface's pool), imports each plane once into the runtime device as an image
of its DRM format modifier, and copies it with vkCmdCopyImageToBuffer into the
buffer the output plane lies in, the surface's pages or its device cache, at
the plane's offset and rows: the Vulkan platform's PlaneCopier, one a session
on a runtime queue of its own, which waits for the copy on a fence. The copy
writes the crop the CPU's copy writes and nothing past it, after the decode is
done, and the session signals the decode once the copy is done on the GPU.

Which way each host's pictures take, in order, each where those before it
refuse:
- radeonsi (Radeon 780M, Mesa 26.2.6): the in-place write declines
  CoreVideo's planes (it imports planes 256 bytes apart alone); every picture
  lands by the GPU's copy: radeonsi exports one object of modifier
  0x200000010401b04, and RADV imports each plane.
- iHD (Iris Xe, intel-media-driver 26.3.5): the in-place write declines them
  (iHD writes a plane only at its dma-buf's first byte, U26); every picture
  lands by the GPU's copy: iHD exports one Y-tiled object (0x100000000000002),
  and ANV imports each plane.
- A host whose driver exports a surface other than as a layer a plane, whose
  runtime device lists none of the dma-buf image extensions or refuses the
  modifier for the plane's format, or whose plane lies in a buffer the GPU's
  writes do not reach (pages the runtime copies, a detached buffer): the CPU's
  copy, as before. The session logs each reason once at that point, as `a
  picture copied by the CPU: <the in-place write's refusal>; and the GPU's
  copy: <its refusal>`, or `; and no GPU copy: <why>` where the device made
  the session no copier.
The in-place write stays first wherever the import check passes for the
planes' layout.

For the guest nothing changes: the planes hold the same bytes, padding
included, and the decode's event and completion come as before. For the
host, the pictures land by the hardware instead of the CPU, the session's
counts say so, and each session logs its GPU copies and their GPU time at its
end.

Checked on the Radeon 780M and the Iris Xe: the conformance suites
(h264-check.sh 62 and hevc-check.sh 156 checks pass on each), the video
crate's ignored VA tests (15 on each), and a new ignored test,
a_picture_copied_by_the_gpu_is_the_cpus_copy_byte_for_byte, which lands every
picture of the suites' Annex B streams by the GPU's copy and by the CPU's into
the same CoreVideo-like layout at two pitches and compares every byte: 4849
pictures of 79 streams equal on the 780M, 4951 on the Iris (the latter going
on past the leading pictures random access skips). The workspace's Linux
tests pass on the radeonsi host (1862).

In cold boots of a macOS 26.7.2 guest playing 4K 60 fps HEVC in Safari,
against the arm before it on the same GPU: on the 780M no picture was copied
by the CPU (9979 before), 10000 by the GPU at 1.01 ms of GPU time each, and
three clips at once played at 53.2, 53.7 and 52.5 fps with 3, 2 and 0 frames
dropped (50.0, 50.3, 52.0 and 10, 11, 5 before); on the Iris none (9899
before), 10040 at 0.52 ms each, 53.8, 54.2 and 56.4 fps with 4, 3 and 0
dropped (52.3, 51.7, 53.5 and 71, 74, 1 before).
2026-11-08 06:52:46 -08:00
Anees Iqbal 5a4418c894 📝 Say that core is the Vulkan crate's module [ci skip]
reims-vgpu-core is folded into reims-vgpu-vulkan, so the docs, the
manifests' comments and the crate descriptions that named the crate name
its module now: the crate lists and graph, seven crates, core's files under
crates/reims-vgpu-vulkan/src/core, the testkit feature, and what the x86-64
leg runs. The design note that put the decoder in core says where it is,
reims-vgpu's graphics::decode, and the path of a deleted file goes. The
kache measurement keeps the crate's name, as it was measured then.
2026-11-08 01:55:07 -08:00
Anees Iqbal 6fb33ecd27 🎨 Rename the reims-graphics crate to reims-vgpu-graphics
The crate that holds the reims-graphics device's wire and transport now
carries the library's prefix, as reims-vgpu-video does: its directory is
crates/reims-vgpu-graphics, its package reims-vgpu-graphics, and its Rust
path and log target reims_vgpu_graphics. The guest's, the option ROM's and
Ambrosia's Makefiles include the wire header from the new directory, and the
prebuilt records name it there.

Nothing changes for the guest or the host. The device keeps its name
(reims-graphics, QEMU's reims-graphics-pci, PCI 1234:5247), and the wire
header keeps its file name and RGFX_ symbols. The C API header is unchanged,
and the prebuilt kexts and option ROM are byte-identical; only the records'
paths and source hashes move. A log filter names the crate's lines by its
new target (REIMS_VGPU_LOG=info,reims_vgpu_graphics=trace), a diagnostic.
2026-11-08 01:37:50 -08:00
Anees Iqbal f3b120ad16 🎨 Collapse the video crates into reims-vgpu-video
The host's video was five crates: core, codec, conformance, and the VA-API
and NVIDIA backends, with the examples and tools split between two of them.
One device uses them, from one library. They become one crate,
crates/reims-vgpu-video, with the modules core, codec, vaapi and nvidia, the
last two built on Linux alone. The conformance readers and writers, which only
the examples use, stay a crate of their own beside it, at
crates/reims-vgpu-video/conformance (reims-vgpu-video-conformance). The files
move with git mv, their paths rewritten, with no re-exports left behind. The
NVIDIA examples build on every host, as a stub off Linux.

Dead code goes with them: NVDEC's VP9 path and the codecs nothing asks it for
(NvdecCodec is H.264 and HEVC), and the Vulkan platform's listing of the
host's GPUs (host_gpus::hardware_gpus and gpu_device_gpu), which nothing
called, with its serde_json dependency.

AGENTS.md, development.md, docs/video and the nextest filter name the one
crate.
2026-11-07 21:32:05 -08:00
Anees Iqbal 8c0895c403 📝 Describe the graphics device's encode [ci skip]
devices.md and backends.md described decode alone. They now say what an
encode entry answers (its rate controls and B pictures, and a zero layout,
since both arms read every source by a copy), what an encode op does from its
check to its result and event, how each arm encodes, and the host encode
session's traits and thread. The guest's video driver sends no encode op yet.
2026-11-07 21:32:05 -08:00
Anees Iqbal cad05a22d4 🐎 Decode NVDEC's next picture while one is copied out
A picture's copy out waited for its decode holding the decoder's handle, so
the decoder's next picture reached NVDEC only once the copy was done: each
picture's decode and copy ran one after the other. The status of the decode
is now asked with the handle held for each ask alone, and the map, copies and
unmap hold it as before, so a session that decodes while it copies (the
reims-graphics device's) has the next picture decoding on NVDEC meanwhile.
Sessions that copy each frame before the next decode see no change.

Measured on the RTX 5080 (potluck 6864, decode_md5 over our device, two boots
of each build in both orders, every frame's md5 matching): 1080p H.264 1443 to
2118 frames a second (+47%), 1080p HEVC 1499 to 2053 (+37%), 4K H.264 614 to
635 (+3%), 4K HEVC 604 to 615 (+2%).
2026-11-07 21:09:01 -08:00
Anees Iqbal db2dea4b39 🐛 Keep a dropped VA-API encoder's session open until the next codes
On radeonsi, an encode session begun after the process's last one was closed,
with none open in between, hangs the VCN at its first picture. The kernel
resets the VCN ring, or the whole GPU where that fails. A libva program of our
own does this within 2 to 4 sessions on a Radeon 780M of Phoenix and one of
Hawk Point (Mesa 26.2.6). Neither a 3 s pause nor a display per session
avoids it while the process holds another display of the GPU. Sessions closed
only once the next one has coded its first picture do not hang.

So a dropped encoder's session that coded a picture is kept open. Once a later
session on the same render node is about to code a picture after its first,
the kept session is destroyed, and that picture follows its close on the VCN.
An ignored test makes 24 encoders in a row from one display, the profiles in
turn, and checks that every frame is coded. bugs.md gains U27.
2026-11-07 21:03:12 -08:00
Anees Iqbal 3b3a5a7fa4 📝 Keep docs/video to the graphics device's video [ci skip]
The paravirt video devices, their JPEG engine and scaler, and Vulkan Video
are gone, so docs/video says only what is left: the reims-graphics device's
video on NVDEC or VA-API, and the crates under it.

- devices.md: what the device answers the guest (the caps, the layouts,
  OUTPUT_CACHED where NVDEC lands pictures in device caches) and what a
  decode does, on each arm.
- backends.md: the two arms, their crates and traits, and the conformance
  suite, which is VA-API's h264-check.sh and hevc-check.sh.
- core.md, vaapi.md and nvidia.md: the crates as they stand; vaapi.md adds
  the 2026-11-07 runs of both scripts on the Iris Xe and a Radeon 780M.
- bugs.md keeps the entries the code and the other docs cite that still
  hold, rewritten without the deleted devices; B26 is condensed.
- scaler.md, videotoolbox.md, hardening.md and vulkan.md go.
- AGENTS.md's video rows name the arms, the docs and the two scripts.
2026-11-07 19:55:37 -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 6383a2128f 🆕 Land NVDEC's pictures in the outputs' device caches
A picture landed in the output's pages, by DMA, or else by the CPU. Where
CUDA imports the runtime device's exportable buffers, which the arm learns
once as the video opens, it now lands in device caches instead. The caps say
RGFX_VIDEO_CAPS_OUTPUT_CACHED, the device makes its caches exportable as it
makes them, and each picture is one copy within the GPU into the cache's
memory, imported into CUDA once a cache and let go of as the cache goes.
Where the import is refused, a picture lands as before.

On the RTX 5080 Laptop GPU (job m3-max-5974, built with the overlap of the
NVIDIA crate's decode and copy beneath it), HEVC 4K decoded at 616 fps
against 30 into the pages, and the 300-frame soak streams at 2059 to 2247
against 42 to 56.
2026-11-07 19:32:51 -08:00
Anees Iqbal 71347e5947 🔥 Trim the NVIDIA crate to what the graphics device's video calls
The deletion of the paravirt devices left the NVIDIA crate code that
nothing calls, under a crate-wide expect(dead_code): NVDEC's VP9 and AV1
picture parameters and their bit-fields, CUDA's device memory
(DeviceMemory, cuMemAlloc), the paravirt decoders' error mapping
(backend_error), AV1's tile offsets (Slices::Tiles), the decoder's
check_not_stalled, PictureReadBack::copy_to, Picture::set_size and
usize_of, and the spinning kernel that only the deleted tests of the waits
ran (cuda/spin.rs). They go, and so does the expect, so that the lint
holds the crate to its callers again.

CuvidCodecSpecific keeps its size, as its CodecReserved member is the
largest (4096 bytes). NVDEC's codec IDs for VP9 and AV1 stay:
decode_capabilities still answers them. cuMemFree stays, with an
expectation of its own: the NVDEC arm's writes into memory another API
imports free their mappings through it.
2026-11-07 19:03:06 -08:00
Anees Iqbal e7b22b2318 📝 Document the VA-API import check and graphics arm [ci skip]
The VA-API doc still named a list of drivers trusted with imports, which
the import check replaced, and imports of a dma-buf a plane, now one of
both planes. It said nothing of the reims-graphics device's arm. bugs.md
said Intel's drivers were not measured.

vaapi.md gains "The import check" (what it tries, the drivers' answers,
its cost, the sweep) and "The reims-graphics device" (the chooser, the
two landings, the boots' results). The staged copy back's whole-rows
layout and zero copy's one dma-buf are described as they now are.
bugs.md gains U26, iHD's writes into an import, and B93: on VA-API the
device's pictures are all copied by the CPU, since CoreVideo's layout
of the guest's frames is one neither driver's video processing writes.
2026-11-07 19:03:06 -08:00
Anees Iqbal ec9fd1bac9 📝 Say how the reims-graphics device's video runs on NVDEC [ci skip]
The access unit in place, the picture by one GPU copy, a picture that
does not land as a decode error, and the surfaces it holds.
2026-11-07 19:03:06 -08:00
Anees Iqbal 517a79d5cb 📝 Record the Vulkan decode checks on RADV and ANV [ci skip]
The decode checks ran on a Radeon 780M and an Iris Xe for the first time:
RADV passes both, ANV fails H.265 (in-place reads end the device, dependent
slices decode wrong). The boot checks also count an apple-gfx guest's exec
faults without Metal's error mode key as their known class.
2026-11-07 12:58:38 -08:00
Anees Iqbal 912d72dfd5 📝 Record the RX 550's UVD faults on grey JPEG decodes [ci skip]
The day's journal on the RX 550's host names the processes behind every UVD
fault and ring timeout: each was one decoding jpeg-check.sh's grey cases,
development's engine or a diagnostic build. 10 faults, and 3 ring hangs the
kernel ended by resetting the GPU with VRAM lost, so a guest's grey JPEG on
development could reset the host's GPU. The engine that refuses grey made
none in 792 starts, each decoding the trial's 32x32 grey image. The module
doc and U25 say so.
2026-11-07 10:57:33 -08:00
Anees Iqbal e3efaaf736 🐛 Make each JPEG decode's vaEndPicture by its deadline
The JPEG engine made every decode's vaEndPicture on the decoding thread.
Each decode is its context's first picture, in which radeonsi may wait for
the GPU (U24): on an RX 550 (Polaris 12's UVD, Mesa 26.2.6), with the
compute rings that take the process's work held by the tests' spins, the
call waited 1.22 s in drmSyncobjWait, until the GPU was done, and the
decode then returned as decoded, past its 50 ms deadline, with the
driver's lock held all along (jobs 4555, 4562). So the held tests of the
compute rings failed there (job 4534).

The decode now ends its picture through render_decode, as a new H.264
decoder's first picture is: on the display's call thread, by the decode's
deadline. Past it the decode fails as stalled, and the engine stalls with
its context and surface kept until the GPU is done, as for its other waits.
The conversion's held test takes the display's other calls as the decode
stalled: they fail by their deadline while its first picture holds the
call thread, and go on where it waits on the memory's dma-buf.

For the guest: where the driver waits for the GPU in a JPEG decode's
vaEndPicture, as on Polaris's UVD with the GPU busy, the decode fails by
its deadline (kIOReturnDeviceError) instead of blocking past it, and the
display's other calls each fail by their own deadline meanwhile instead of
waiting inside the driver. Elsewhere nothing changes but that the call is
made on the display's call thread.
2026-11-07 10:57:33 -08:00
Anees Iqbal 6ec443c256 🐛 Refuse what the JPEG engine's trial at start decodes wrong
The JPEG engine took every sampling its VA driver lists as decoded right.
On an RX 550 (radeonsi on Polaris 12's UVD, Mesa 26.2.6) the driver lists
grey, and its decode of grey into a Y800 surface writes a luma none of
whose samples are the stream's, so the guest got a wrong picture for every
grey JPEG: the 14 grey cases of jpeg-check.sh failed (job 4315), and
ffmpeg's VA-API decode of grey on that GPU is wrong too (job 4318).

At start the engine now decodes a flat 32x32 JPEG of each listed sampling,
as a guest's decode would be made, and checks its samples. A sampling
whose trial decodes wrong is refused as unsupported, as one the driver
does not list, and left out of the backend's answer of what it decodes.

No other route decodes grey right there. Into NV12 surfaces of the
driver's, copied out by a run, grey decoded right for some streams and
wrong for others (jobs 4470, 4496): 3 of jpeg-check.sh's 14 grey cases
wrong, 15 more grey streams of cjpeg's and jpegtran's all wrong, and the
trial's luma not written at all. So that route is not taken.

For the guest: on a driver whose trial decodes a sampling wrong, its
JPEGs are refused as unsupported streams (kIOReturnBadMedia), where they
decoded wrong before. Where every trial passes, as on the RX 7900 XTX and
the Radeon 780M, nothing changes.
2026-11-07 10:57:33 -08:00
Anees Iqbal e0208b1571 ✅ Pass a JPEG refusal outside what the backend answers
Core's JpegDecoder now answers what its backend decodes at all
(JpegDecodes: the samplings and the largest picture): VA-API's the
samplings its driver lists and its largest size, NVIDIA's the four it
measures at any size. The guest hears of it only through the refusals it
already got, so nothing it sees changes.

The conformance suite's jpeg-check reads it. A stream outside the answer
that a case asked to decode now passes when refused as UnsupportedStream
("refused as answered"), and fails when it decodes; inside the answer every
refusal fails, as before. jpeg-check.sh's last line counts the passes, the
refused as answered among them, and the failures.

On an RX 550 (radeonsi, Polaris 12) the driver lists 4:2:0, 4:2:2 and grey
up to 4096x4096, so 19 cases failed on development (job 4315): every 4:4:4
one, and the 16384-wide 4:2:2 case. Each was the engine refusing a stream
by the driver's own answer.
2026-11-07 10:57:33 -08:00
Anees Iqbal 1e2d621c47 📝 Record B90's banded vaGetImage as tried and slower [ci skip]
B90's fix named vaGetImage of bands, small enough that each hold of the
display's lock would be short. Measured on the Radeon 780M and the RX 7900
XTX (jobs 4279, 4284), the bands held the lock longer than the derived map,
in all and at most. The engine keeps the derived map, and the fix left is
Mesa's (U22).
2026-11-07 10:28:30 -08:00
Anees Iqbal 82aee1e5c0 🐎 Give both planes of a 4:2:0 window a kernel of their own
The kernels' cut to one place a pixel is worked out ran a 4:2:0 window's
both planes through write_word's loop over the word's block, inside
scaler_transform. On the Radeon 780M that made 720p BGRA to 720p 420v
slower (docs/video/scaler.md recorded 0.26 to 0.31 ms). The old
both_planes, whose loop over a chroma row's two luma rows has a constant
count, is unrolled by the driver into two copies of a pixel's work that
run side by side. Put back inside scaler_transform, it was as fast as
before, but it grew that kernel from 21,524 to 31,216 bytes of code,
which every transform's making would pay for.

So both_planes gets a kernel of its own, scaler_transform_both_planes,
which non-adaptive dispatches of both planes take (Biplanar8,
Biplanar16). scaler_transform keeps its code. The making ahead
dispatches eight kernels, and the probe of first transforms has a 4:2:0
destination.

On the 780M, six alternated processes of each build: GPU time 0.230 to
0.206 ms at the median, the other benches within their spread. The
making ahead went from 274 ms to 298 cold, and the new kernel's own
making takes 27 ms. Its outputs are the same arithmetic in the same
order; the whole suite passes (113 of 113).
2026-11-07 08:54:06 -08:00
Anees Iqbal 2cb33d2c89 🐎 Run decodes beside the copies out where layouts are unified
On the RTX 5080 the decode engine sat idle 10-24% of each stream's time
(measured: 104-280 us p50 between decodes against 406-1680 us of decode):
every decode waited for the copy out of the picture before it, on the
reserved queue, and so did the event's signal batch on the decode queue,
since a copy without unified layouts moves a DPB picture's layout that the
next decode reads.

Where the device has VK_KHR_unified_image_layouts' unifiedImageLayoutsVideo
(now an optional extension of the platform's device; the 5080's 615.71
driver has it) and the copies run on the reserved queue, a decode now waits
only for the last copy out of the image it writes, sets up the free slot
copied out of longest ago, in a session of one more slot where the device
has it, and the event's signal goes on the reserved queue behind the copy.
A decode's value is signalled by a batch of no work after it that also
waits for the copy before it, so the shared timeline is still signalled in
order when a decode ends before the copy before it.

Devices without the feature, or with copies on the decode queue or a lent
queue, keep the old order. Unit tests run the order on a fake GPU: overlap
leaves the decode queue no idle tick, and a decode signalling its own value
would put the timeline out of order.
2026-11-05 21:59:28 -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 72a5fe6788 🐎 Copy decoded pictures out on a queue the runtime reserves
On a GPU of its own memory a decoded picture is copied into the runtime's
buffer that holds the surface's device cache, which only a queue of the
runtime's families reaches. Until now that was a runtime command queue's
VkQueue, lent per submission, which logical queues share with the guest's
work: a copy that waited for its decode on the GPU would hold that work
behind it, so a thread waited for each decode on the host and only then
submitted its copy.

metal2vulkan now reserves queues of its own families for the caller, which
none of its work ever runs on. The platform asks every device for one, and
the hardware video copies on it as on a queue of its own: each copy is
submitted with its decode and waits for it on the GPU, with no host
round trip between them. A device with no queue to spare (MoltenVK,
lavapipe, a Radeon's single graphics queue) reserves none, says so once at
info level, and keeps the lent queue and its host wait.

The options are one set for every device the process makes, so a device
with a queue to spare and no video-decode family reserves one it never
uses; on an RTX 5080's 16 graphics queues the round robin goes from 14 to
13.
2026-11-05 21:59:22 -08:00
Anees Iqbal e994560cf8 📝 Describe the Vulkan Video encoders and their check [ci skip]
The encoders need their contract written where the decoders' is: how a
device gets its encode queue, the RTX 5080's encode capabilities, where
sources and bitstreams lie and what is copied, how pictures, references
and rate control are planned, the NVIDIA 615.71.09 bugs worked around
and why, what the encode check checks, its results and GPU time a
picture at 1080p and 4K on the 5080, and what is not done.
2026-11-05 21:59:22 -08:00
Anees Iqbal 46c5860edc 📝 Describe the copies on a lent queue and their check [ci skip]
The video crate's doc names lent.rs and from_raw_copying_on, says why a
copy on a lent queue is submitted from a thread once the host sees its
decode done (a GPU wait there would hold the owner's work behind the
decode), and counts the H.264 check's two lent runs: all 68 of its
verdicts pass on the RTX 5080 Laptop GPU.
2026-11-05 21:59:22 -08:00
Anees Iqbal 58a661460f 📝 Describe the Vulkan H.265 decoder and its check [ci skip]
docs/video/vulkan.md now covers H.265 beside H.264: the 5080's H.265
answers, P010 pictures and buffer landings, each decode's plan (references
and their slots, the current sets, the 8-picture limit, IsReference), the
parameter sets as std structures, in-place reads, the GPU-less tests and the
check's 191 verdicts on the 5080.
2026-11-05 21:59:22 -08:00
Anees Iqbal 0021f9c41c 📝 Describe the Vulkan Video H.264 decoder [ci skip]
What the crate is and is not yet, the device it takes, its own DPB
pictures and the outputs it lands pictures in (images and buffer
planes), how the bitstream, parameters and frame numbers reach the driver,
including the shift past a frame number wrap that NVIDIA's initial lists
need, the timeline it signals, and what the H.264 check measured on the
RTX 5080.
2026-11-05 21:59:21 -08:00
Anees Iqbal aaec87ae4f ⬆️ Build on metal2vulkan a759d0e88f's runtime
Move the runtime from f6a96b7da8 to a759d0e88f, the tip of metal2vulkan's
development (runtime version 1643 to 1648; its runtime sources pinned as
abac6049).

metal2vulkan's gate on a759d0e88f was still running when this was committed;
the owner chose not to wait for it.

What changes for the guest:

- A 2D texture over host pages whose usage only samples or reads it is a linear
  image over the pages, with no shadow and no copy in at each command buffer's
  first use, on a device whose startup check passes: on that device, an image's
  first move keeps every byte while the CPU writes beside it, checked for
  pointer imports, fresh pages and dma-bufs each, and kept in the shader cache
  by driver and runtime version. Vulkan does not promise that move (an image
  over imported memory starts UNDEFINED), so this relies on the driver, by the
  owner's ruling of 2026-10-26. REIMS_VGPU_EXACT gains `host_page_textures`,
  which keeps every such texture a shadow, as before, and `all` names it; the
  accuracy ledger and docs/api.md say so. Render targets, written textures and
  two-plane YCbCr surfaces keep their shadows.
- A memoryless texture bound at a texture slot is taken, as plain Metal takes
  it, where the runtime refused the setter and this platform died there (an RX
  580 user's guest, at setFragmentTextures:withRange:). A command whose function
  uses the slot, a useResource of it or a blit of it fails the command buffer
  with MTLCommandBufferErrorInvalidResource (9) from the Metal submission that
  holds it, as Metal's GPU does (measured by metal2vulkan on the M3 Max). This
  platform passes the new CommandBufferError::InvalidResource to core as one of
  Metal's failures: the fourteenth it lists. A memoryless texture's CPU reads
  and writes move nothing, and its views are nil, as on Metal.
- new_texture_with_vk_image takes IdPlacement::Outside; nothing here passes it
  yet, so the window's swapchain images still take texture IDs.
- Nothing else in the span moves what a guest computes or observes: the
  in-place check's dma-buf pages come from cached memory, and the rest is
  counts, docs, tests and the sources pins.

The public surface gains CommandBufferError::InvalidResource,
DevicePolicy::host_page_textures and its HostPageTexturePolicy, and WorkCounts'
in-place and shadow-cause counts. No Degradation, RuntimeGap, refusal or notice
kind moved, so DIES and the relayed kinds stand. Device info, GPU families and
feature queries answer as before. The Vulkan platform ends the process at one
site fewer: the memoryless binding.

docs/video/bugs.md says what the pin carries for B73: the in-place textures and
the counts that tell them from the shadows that stay.

New tests, of the memoryless binding, on every platform:
a_memoryless_texture_at_a_fragment_slot_fails_only_a_draw_that_uses_it; and on
the Mac, memoryless_slots_fail_as_metals, which measured Metal's lines
(macOS 27.0.1): a draw whose function ignores the slot completes; one that
samples it fails the command buffer with code 9, the blit before its pass run
and neither its clear nor the blit after it, the signal after them not firing.

Checked, every test passing in its full run:
- on the M3 Max (macOS 27.0.1): rustfmt, the three clippy passes cargo xtask
  check makes (the Mac's, its tested features', and x86_64-unknown-linux-gnu's),
  and the 900 tests of reims-vgpu-vulkan and reims-vgpu on MoltenVK;
- the Vulkan crate's 434 tests and reims-vgpu's and the C API's 50 video and
  scaler tests on gem10's RX 7900 XTX and Radeon 780M, with no amdgpu reset.
The RTX 5080 Laptop GPU's run was skipped at the owner's word: the GPU was busy
with the owner's VM.
Only those crates link the runtime, so the rest of cargo xtask check (core's
tests, under Rosetta too, the Metal, window and video crates, and the header)
and the suite, which drives the C API on the Metal platform, do not
reach the change and were not run.
2026-10-26 21:45:46 +02:00
Anees Iqbal 054ac2080e 🆕 Give reims-ctl's VMs the VideoToolbox and M2 scaler devices
QEMU has had apple-videotoolbox-pci and apple-m2scaler-pci since the video
devices landed, but reims-ctl never put them on a VM's command line, so no VM
it starts had them, and the drivers reims-util 381f913 puts in x86-64 images
had nothing to drive.

Every VM on reims-vgpu now gets both. An x86-64 VM has them at slots 8 and 9,
after the IOSurface mapper their ported drivers link; one on vmware-svga, which
has no mapper, gets neither. A vmapple VM gets them too: arm64 macOS ships the
drivers, which link the mapper vmapple builds in. A guest without the drivers
leaves the devices without one. docs/video/bugs.md's D6, the images without
the kexts, goes.

Both devices realize on the installed QEMU (paused, on an arm64 machine's
PCIe bus). No guest has booted with them from reims-ctl's command yet, and no
arm64 guest has run against them at all (bugs.md T9).
2026-10-26 14:18:08 +02:00
Anees Iqbal 28aecd0f04 🎨 Move the development scripts to scripts/internal
scripts/ mixed the one script a person installing reims-ctl runs,
install-ctl.sh, with eight that only developing the project runs: the worktree
and build environment, the GPU locks, the VM boot and tour drivers, the window
walk and the IOSurface qtest. Those move to scripts/internal, so scripts/ holds
what users run. run_vmapple.sh, walk_window_macos.sh and vm_drive.py find the
repository from their own path, one level deeper now; every reference in the
docs, the Makefile, the video crates' tools and the code's comments follows.
2026-10-26 14:08:39 +02:00