Files
reims-vgpu/docs/video/bugs.md
T
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

149 lines
46 KiB
Markdown

# Bugs and deferred work
Everything known to be wrong, untested or put off in the reims-graphics device's video on the host, so it can be picked up later without being rediscovered.
**Each entry says:**
- what is wrong;
- the evidence: a run, a test or a source line, tagged **measured** or **read** as [testing.md](../testing.md), "Tags", says;
- why it waits;
- what would fix it;
- who has it, where anyone does.
**Keeping it current:**
- An entry is added in the commit that defers the work.
- It is deleted in the commit that fixes it. An ID is not used again, since other docs and the code cite entries by it.
## Open bugs
### B14. A guest's video sessions have no VRAM budget
- **What:** each decode session holds a pool of surfaces at its stream's coded size, as many as its DPB asks plus a few, and the host bounds neither how many sessions a guest opens nor the bytes their pools take: about 480 MB for one 4096x4096 H.264 session with 16 frames, so a few sessions of large streams can take a shared GPU's memory.
- **Evidence:** **read**: the VA-API H.264 decoder's `configure` (`crates/reims-vgpu-video/src/vaapi/va/h264.rs`) makes `dpb_frames + 1 + SPARE_SURFACES` surfaces at the SPS's size. **Measured** on an RTX 5080 Laptop GPU (16,303 MiB, driver 615.71.09), 2026-10-24: one decoder of a 7680x4320 HEVC Main 10 stream held 1,020 MiB of VRAM, with the DPB its SPS asks for; one process with one held 1,216 MiB, with two 2,236 MiB. NVDEC's surfaces are the DPB plus 3 at the stream's size.
- **Why it waits:** the host puts no limit of its own on how much of its hardware one VM holds, as a native GPU's driver puts none on its apps.
- **Fix, if that changes:** a budget of surface bytes per process's sessions, or a bound on its sessions.
### B26. Some guest command buffers ran for seconds on an RTX 5080 Laptop GPU, over guest memory
- **What:** in boots of an x86_64 guest on an RTX 5080 Laptop GPU, a few of the guest's command buffers ran on the GPU for seconds, and the command buffers committed behind them waited: a VideoToolbox pixel transfer kernel, one dispatch, 2.4 to 2.7 s, and, in the boots where mediaanalysisd ran its analysis, one command buffer of 452 dispatches 2.4 to 3.0 s and one of 794 dispatches 23.1 to 29.2 s. 31 boots on a Radeon 780M showed none.
- **Evidence:** **measured**, driver 615.71.09, 2026-10-25 and 26. The seconds were metal2vulkan's runtime's stores into the guest's pages, in shapes that leave gaps, which the RTX 5080 Laptop GPU stores into host memory hundreds of times slower than the same bytes without them: 609 ms per 8 MiB with an invocation's four words consecutive, 0.85 ms with them a workgroup apart. At metal2vulkan 27935d575e, which lays the stores so, the three took 9 to 10 ms, 309 to 359 ms and 565 to 591 ms, as the two Radeon GPUs take them (0.23 to 0.69 s). Not measured since on the reims-graphics device.
- **Device copies, tried and dropped** (2026-10-25): the guest resources those command buffers use, copied into the GPU's own memory and back. In the first boot with them, the guest's WindowServer aborted 26 s after it started, on a corrupted malloc free list, and the session never logged in (**measured**): the guest reaches those pages itself. Guest memory stays in place ([conventions.md](../conventions.md)).
- **Why it waits:** what is left is metal2vulkan's: a vector stored through a pointer as one store where the pointer's type's alignment holds, and a command queue that does not wait behind another queue's long command buffer, as Metal's does not. It is not the video code's, and is here for B37.
### B37. NVDEC fails valid decodes in every process while one of our VMs boots on its GPU
- **What:** while a VM boots through reims-vgpu on an RTX 5080 Laptop GPU, NVDEC reports valid pictures' decodes failed (`cuvidDecodeStatus_Error`, status 8) in other processes, and gives other pictures wrong with no failed status, H.264's and HEVC's alike; every picture predicted from such a picture is wrong too.
- **Evidence:** **measured** on that GPU (driver 615.71.09), 2026-10-24 and 25, with workers decoding through the `nvidia` module beside boots of a VM:
- beside the boots, 8 to 12 of 432 runs failed, in bursts that fell in the seconds a guest command buffer of 200 ms or more was in flight (B26); with no VM of ours on the GPU, 4,968 runs passed, and none failed;
- NVDEC's own status, read by `cuvidGetDecodeStatus` (`check_status`, `crates/reims-vgpu-video/src/nvidia/nvdec/decoder.rs`), failed the runs; the kernel logged no Xid;
- most wrong pictures came with no failed status, and a picture's two copies never differed, so the samples are wrong in NVDEC's surface; a failed picture decoded again at once answered status 2 and stayed wrong, so the crate makes no retry;
- a load that does it without a guest: 16 workgroups of 64 invocations adding to one 32-bit word with `atomicAdd`, in host memory imported with `VK_EXT_external_memory_host` (U21). The same atomics in device-local memory, spread over words, or in one workgroup failed none. Whether the guest's own work contends on atomics in its memory is **not known**.
- **Not seen** beside a boot at metal2vulkan 6c9cad047a (2026-10-26): 432 of 432 runs passed in two boots.
- **Not ours to change.** The load is a guest's own work on its own memory, which the Vulkan platform keeps in place, in host memory ([conventions.md](../conventions.md)). Moving that memory to the device to avoid this would copy guest memory.
- **Why it waits:** NVIDIA's driver: U21. A failed picture fails its decode's command buffer ([devices.md](devices.md), "A decode").
- **Fix:** NVIDIA's. Once a driver fixes U21, run the workers beside a boot again.
### B41. A truncated H.264 or HEVC slice is decoded on VA-API, and in a picture NVIDIA does not copy
- **What:** on VA-API a slice whose data ends early goes to the GPU, and its picture lands with whatever the GPU made, with no error, and the pictures after it too: our parsers stop at the slice header, and radeonsi reports nothing. On NVIDIA, NVDEC's status of the decode, read at the picture's copy, fails the picture, and sets the codec module's damaged state (`mark_failed`, `h264/decoder.rs` and `hevc/decoder.rs`) before the next sample (`Failures`, `crates/reims-vgpu-video/src/nvidia/decode.rs`), so the pictures after it are refused until an I picture (H.264) or an IRAP picture (HEVC). But the status is read only by a picture's copy, so an HEVC picture with `pic_output_flag` 0, which is not output, starts nothing.
- **Evidence:** **measured**, 2026-10-25, on main-gapsrc-720p with frame 20's slice cut to 10, 50 and 95% (`h264-craft --truncate`), and x265's `idr`, `radl`, `cra`, `cra7` and `bla` with frame 20 cut to half its slice (`hevc-cut truncate`):
- radeonsi, on an RX 7900 XTX and a Radeon 780M (Mesa 26.2.4, libva 2.24.1), with a scratch build that asked the driver after each wait for a decode: for each of the 5,396 waits on each GPU, `vaSyncSurface2` and `vaSyncSurface` answered `VA_STATUS_SUCCESS`, `vaQuerySurfaceStatus` `VASurfaceReady`, and `vaQuerySurfaceError` `VA_STATUS_ERROR_UNIMPLEMENTED`; no `vaEndPicture` failed. H.264's frames 20 to 29 came out unlike the undamaged stream's, HEVC's frame 20 alone (a TRAIL_N picture).
- NVIDIA, on an RTX 5080 Laptop GPU (driver 615.71.09): NVDEC reported each truncated frame failed with status 9 (`cuvidDecodeStatus_Error_Concealed`). With the damaged state set from it, every frame that came out equalled the undamaged stream's.
- **Why it waits:** radeonsi reports no decode error, so on VA-API only a walk of the slice data on the CPU finds where it ends early: H.264's CAVLC and CABAC macroblock layers, and HEVC's CABAC coding trees, as a software decoder's entropy decoding without its reconstruction. By our estimate that is a parser of guest data about as large as the codec module's H.264 and HEVC parsing together (about 8,500 lines beside their tests), and a share of a CPU core for every stream, neither measured; whether to build it is the owner's decision.
- **Fix:** a walk of each slice's data on the CPU beside the GPU's decode, which sets the damaged state where the data ends before `end_of_slice_flag` (H.264) or `end_of_slice_segment_flag` (HEVC); or keep the difference.
### B61. The first decode after an RX 7900 XTX has idled 5 s takes 0.88 s
- **What:** on an RX 7900 XTX, a decode that comes after 5 s or more with none took 880 to 890 ms on the host, where the same decode a second later took 1 to 5 ms. It is the slowest frame measured on any of the hosts' GPUs, and what sets the crates' bound on a frame's waits, `DEVICE_WAIT`, 5 s ([core.md](core.md), "Bounded waits").
- **Evidence:** **measured**, 2026-10-24. In an x86_64 guest, a guest's first H.264 frame took 0.88 s. The RX 7900 XTX's PCI device has runtime power management on, `power/control` `auto` with `autosuspend_delay_ms` 5000, so the GPU sleeps 5 s after its last use; the Radeon 780M beside it has it `on`. A process's decode started 7 s after the last, with `runtime_status` `suspended`, took 915 and 918 ms in all; at once after, `active`, 34 and 37 ms; the decode itself 1.6 to 2.8 ms in all four. So the wake is the cost; that `power/control` `on` removes it is not measured.
- **Why it waits:** every frame fits within the bound, and the fix is a setting of the host's.
- **Fix:** keep the GPU awake while a VM uses it: `power/control` `on` for the render node's device while QEMU runs, a host setting; or a cheap GPU call every few seconds while a session is open, at some power.
### B78. On a driver other than radeonsi, a VA-API call measured not to wait can hold its caller's thread
- **What:** the `vaapi` module's driver calls that wait for the GPU inside radeonsi (`vaGetImage`, `vaMapBuffer` of a derived image, `vaSyncSurface` where a driver has no `vaSyncSurface2`, and a decoder's first `vaEndPicture`) are made on the display's call thread by the frame's deadline, and every other call waits for them by its own ([vaapi.md](vaapi.md), "The display's calls"). The rest are made on the caller's thread with no bound of their own: the submissions (`vaBeginPicture`, `vaRenderPicture`, and `vaEndPicture` but a decoder's first), `vaPutImage`, `vaDeriveImage`, the map of an image `vaCreateImage` made, exports, creates and destroys. A driver whose call among them waits for a GPU that never finishes holds the caller's thread there, a decoding thread of the graphics device's session. The `mapped` way back, for comparison only, waits in `DMA_BUF_IOCTL_SYNC` with no bound.
- **Evidence:** **measured** on radeonsi (Mesa 26.2.4, libva 2.24.1, an RX 7900 XTX and a Radeon 780M, 2026-10-26), each call timed with the graphics ring or 16 compute queues held by a spin of the tests' own (`crates/reims-vgpu-video/src/vaapi/va/spin.rs`): none of those calls waited, and each that did is bounded now, its frame failing by its deadline while the GPU was still held (`src/va/wait/held.rs`). A decoder's first `vaEndPicture` was not timed so then: it waits for the job that begins the decoder's session (U24), which after an unmap waits for the held ring (B92), and is bounded so too now. iHD and the other drivers the arm opens on were not timed so.
- **Why it waits:** no run has shown such a call waiting.
- **Fix:** time each call so, with a ring held, on the driver that shows one, and make that call through `Display::wait_call` (`crates/reims-vgpu-video/src/vaapi/va/display.rs`).
### B92. After memory of the process's GPU is freed, its next VA-API work waits for every job then on the GPU
- **What:** a surface or buffer destroyed unmaps its memory from the process's GPU VM, and amdgpu has every later submission of the VM, on any ring, wait for every job the VM had in flight at the unmap (U23). RADV's jobs in the process are of that VM, a guest's command buffers among them, so a VA-API frame submitted after an unmap waits for the work the GPU had then, and fails by its deadline as stalled where that work runs past it. Every unmap of the process, another session's or metal2vulkan's runtime's, has the next VA-API work wait.
- **A new decoder's first picture waits on the CPU.** radeonsi submits the job that begins a decoder's session in the decoder's first `vaEndPicture`, and waits there for it, with the display's lock held (U24). After an unmap that job waits for every job then on the GPU, and the call waits as long. The crate makes a decoder's first `vaEndPicture` on the display's call thread, by the frame's deadline (`render_decode`, `crates/reims-vgpu-video/src/vaapi/va/buffer.rs`), so past it the frame fails as stalled, and the display's other calls wait behind it for the gate, each by its own deadline.
- **Evidence:** **measured** on the RX 7900 XTX and the Radeon 780M (Linux 7.2.9, Mesa 26.2.4, 2026-10-26), with the graphics ring held by a spin of the tests' own (`crates/reims-vgpu-video/src/vaapi/va/spin.rs`) and the GPU scheduler's tracepoints of a job's dependencies (`gpu_scheduler:drm_sched_job_add_dep`, `drm_sched_job_unschedulable`):
- destroying a 256x256 host surface the GPU was done with queued a page-table update on an SDMA ring that depended on the spin's job; the next decode's job depended on that update and ran only once the spin ended, 59 and 60 ms on, and the decode failed by its deadline. With nothing destroyed, each decode ran beside the spin. The spin's jobs and radeonsi's were of one DRM client.
- A macOS guest booting on the Radeon 780M unmapped 36 and 586 buffers in traces of 3.5 and 4.1 s, 21 and 515 of them on metal2vulkan's threads; in boots at metal2vulkan 6c9cad047a the process made 9,984 `vkFreeMemory` calls on the Radeon 780M and 9,778 on the RX 7900 XTX, about four in five of them dma-buf chunks no longer live, outside the runtime's own allocator.
- A program on libva alone (U24): a new 128x128 H.264 context's first `vaEndPicture`, beside 40 queued processing runs of 7680x4320, took 1.31 ms at the median on the RX 7900 XTX and 5.91 ms on the Radeon 780M, and 14.34 and 142.66 ms with an idle 256x256 surface destroyed just before it; on a context used before, 0.03 to 0.11 ms at the median either way. Another thread's `vaSyncSurface2` of an idle surface, timeout 0, made meanwhile, took as long.
- 30 of the `vaapi` module's H.264 decoders made and let go in turn, 10 frames of 4K each, each frame waited for: beside a session decoding the same stream over and over on a thread of its own, 5 of their first `vaEndPicture`s took over 5 ms on the RX 7900 XTX, 9.0 ms at most, and 16 on the Radeon 780M, 21.8 ms at most. Beside the graphics ring held 8 ms in every 16 by the tests' spin, as a display's work holds it, and alone, none took over 5 ms on either GPU.
- `a_new_decoders_first_picture_after_a_free_on_a_held_gpu_fails_by_its_deadline` (`src/va/wait/held.rs`), with the graphics ring held and a decoder let go: made on the call thread, the new decoder's first decode fails by its deadline, 57 and 58 ms on (50 ms in the test), and the display's other calls by theirs.
- **Why it waits:** the waits are amdgpu's (U23), and a process cannot keep its VA-API jobs out of RADV's VM. The ring is busy that long only under a guest command buffer that runs for seconds (B26). A new decoder's first picture would wait no longer than the job that begins its session, on an idle VCN 1.3 ms on the RX 7900 XTX and 5.9 ms on the Radeon 780M, if radeonsi did not wait for that job on the CPU (U24). Keeping decoders for later sessions of the same shape would spare only a session of a shape seen before, at the VRAM of each kept decoder's pool and context; beside a playing session the wait measured 9 and 22 ms at most, once a session, so it is not done.
- **Fix:** amdgpu's (U23), and for a decoder's first picture radeonsi's (U24). Short of it, nothing of the process unmaps while a guest's work runs, metal2vulkan's runtime's frees among it.
## Upstream bugs
Bugs in drivers, libraries and tools that our code or our checks work around.
- **U1. ffmpeg's native HEVC decoder** is wrong on `--ctu 16` streams with SAO and deblocking. Our HEVC check uses x265's reconstruction as a second reference because of it ([vaapi.md](vaapi.md), "Testing HEVC").
- **U2. libva's header.** `VAIQMatrixBufferHEVC`'s documentation gives two orders for the scaling lists; radeonsi needs raster, which ours sends (`crates/reims-vgpu-video/src/vaapi/va/hevc.rs`).
- **U3. radeonsi rewrites the packed parameter sets an encoder gives it.** With packed SPS, PPS (and VPS) and slice headers, the coded buffer holds parameter sets of the driver's own: H.264 High's `transform_8x8_mode_flag` goes from 1 to 0 and its VUI restriction fields change; HEVC's height goes from 1080 to 1088 with a conformance window, its transform depths from 0 to 4 against the 0..0 the driver reports, and its bitstream restriction is dropped. The VPS and HEVC PPS come out as packed. With no packed slice header the coded buffer holds no parameter set at all. So our configuration record is read from what the hardware emits ([vaapi.md](vaapi.md), "The encoders"). **Measured** with a libva program of our own, which encodes one frame and compares, on an RX 7900 XTX and a Radeon 780M alike (Mesa 26.2.4, libva 2.24.1, 2026-10-24).
- **U5. libva-nvidia-driver 0.0.18** answers `VAConfigAttribMaxPictureWidth` and `Height` with 0 on any thread but the one that opened the display (**measured** with a libva program of our own, 2026-10-24: 8192x8192 on the opening thread, 0x0 on a second one, and 8192x8192 again on the first; radeonsi the same on both). The `vaapi` module asks every query on the opening thread and keeps the answers (`crates/reims-vgpu-video/src/vaapi/va/caps.rs`), so it does not depend on it.
- **U6. NVENC with lookahead.** In synchronous mode with lookahead on (P6 and P7 at high quality), after `NV_ENC_SUCCESS` only the oldest pending output locks, though the header says all of them do, and frames are lost. The `nvidia` module's encoder turns lookahead off (D12).
- **U8. ffmpeg's H.264 decoder leaves frames out after a frame number gap that wraps.** On a stream whose SPS allows gaps, with order count type 2 and an I picture just after a gap of 5, ffmpeg n9.0.2 output 50 of 60 frames, missing 30 to 39; with a gap of 9 and four references, 54, missing 30 to 35 (**measured**, 2026-10-24). Apple's AVD, our VA-API decoder and the source's own decode agree on all 60. Streams written from scratch found the condition: the skipped frame numbers wrap past MaxFrameNum (16 here, from frame_num 13), and 15 - G frames are lost for a gap of G, while the same gaps from frame_num 0 lose none. The cause, read in ffmpeg's `h264_slice.c`, is that the gap code moves `prev_frame_num` past the wrap without adding MaxFrameNum to `prev_frame_num_offset`, so the pictures after the gap get order counts one MaxFrameNum low and are dropped as out of order; with it added, all 52 of the streams' decodes gave 60 frames. The gap streams' reference is therefore their source's (`crates/reims-vgpu-video/tools/h264-check.sh`).
- **U13. kvazaar writes no first access unit when it codes fields with a GOP of 8 or 16.** With `--source-scan-type tff` or `bff` and `--gop 8` (`--preset fast`'s) or `--gop 16` (the default), kvazaar 2.3.2 (CachyOS's 2.3.2-2.1) wrote 59 field pictures for 30 frames and no VPS, SPS, PPS or IDR picture: the stream starts with a TRAIL_R picture, and ffmpeg and our parser cannot open it ("PPS 0 has not been received"). With `--gop 0` or a low-delay GOP it wrote all 60, starting with the parameter sets and an IDR picture, and those decode. `--debug` with fields aborted on `recon_buffer_size == 0` (`encmain.c:747`) with `--gop 8`, crashed with `--gop 0` on a plain `testsrc2`, and with `lp-g4d3t1` wrote pictures that are not the decoded fields (10.8 dB against the decode, which is 36.8 dB against the source). `hevc-check.sh`'s kvz-720p-fields uses `lp-g4d3t1`, and checks it against ffmpeg's decode with kvazaar's MD5 SEI instead of `--debug`.
- **U14. radeonsi's VBR and CBR pass the HRD buffer they are given.** With an HRD buffer of 0.5 Mbit and VBR or CBR at 1 Mbit/s, the key frames of a picture whose key frames cost most came out 2.09 to 2.44 times the buffer (**measured** with a libva program of our own on an RX 7900 XTX and a Radeon 780M, Mesa 26.2.4, libva 2.24.1, 2026-10-24). Mesa sends the firmware the buffer and `enforce_hrd` 1, and `VAEncMiscParameterTypeMaxFrameSize` at the buffer left the first key frame where it was. Our VA-API streams under a hard limit do not depend on it: the driver runs a constant QP, and ours picks each picture's ([vaapi.md](vaapi.md), "Rate control under a hard limit").
- **U16. libva-nvidia-driver lists video processing and does nothing for it.** Its README says "Hardware decoding only", yet it lists `VAEntrypointVideoProc` for `VAProfileNone`, and every call of a processing run answers `VA_STATUS_SUCCESS` with nothing written: into a linear NV12 surface imported from a dma-buf, every byte stayed as it was, where radeonsi wrote the source's samples (**measured** with a libva program of our own, libva-nvidia-driver 0.0.18, libva 2.24.1, an RTX 5080 Laptop GPU with driver 615.71.09; radeonsi on the Radeon GPUs; 2026-10-25). Ours does not depend on it: a driver gets such writes only where its display's import check passed (`Display::writes_imports`, `crates/reims-vgpu-video/src/vaapi/va/display.rs`; [vaapi.md](vaapi.md), "The import check"). The driver answers `vaQueryVideoProcPipelineCaps` with `VA_STATUS_ERROR_UNIMPLEMENTED` (**measured**, same driver and GPU, 2026-10-25). VA-API is the graphics device's arm on an NVIDIA GPU only where NVDEC's does not open.
- **U17. Mesa's VA frontend holds its display's lock while `vaSyncSurface` waits for a processing run.** `_vlVaSyncSurface` waits for the output surface's `pipe_fence`, which a video-processing run leaves, with `drv->mutex` held, where it waits for a decode's fence under the context's lock alone; `vaBeginPicture`, `vaRenderPicture` and `vaEndPicture` take `drv->mutex` too, so while one thread waits for a run, every other thread's calls on the display wait behind it (**read** in Mesa 26.2.4, `src/gallium/frontends/va/surface.c` and `picture.c`). **Measured** on an RX 7900 XTX and a Radeon 780M, 2026-10-25: with the copy of one frame on a thread of its own, the next frame's decode calls took 0.9 to 5.0 ms at 4K, against 0.3 to 1.0 ms with nothing beside them. Ours waits for a run by `poll` on the dma-bufs it writes before `vaSyncSurface` (`crates/reims-vgpu-video/src/vaapi/va/fence.rs`), and the decode calls then took 0.3 to 0.9 ms. Not reported upstream yet.
- **U18. metal2vulkan's runtime lists only the GPUs of its own loader environment.** Its instance loads the drivers the loader's environment names (`VK_DRIVER_FILES`, as reims-ctl pins a VM to lavapipe), and it lists and identifies the physical devices of that instance alone (`Device::system_default_identity_with`, `Device::registry_ids_with`; **read** in the runtime's source at the pinned commit, 2026-10-25). The graphics device's video arms open on the runtime device's own GPU, which it identifies with its PCI address and DRM render node, so a VM pinned to lavapipe has no video arm.
- **U19. NVENC's `doNotWait` lock waits in synchronous mode and gives an IDR picture wrongly, and a second lock of a buffer never returns.** Synchronous mode is the only one on Linux. **Measured** on an RTX 5080 Laptop GPU, driver 615.71.09, NVENC API 13.1, 2026-10-25, 4K HEVC Main with no B pictures and IDR pictures forced, `nvEncLockBitstream` made as soon as `nvEncEncodePicture` returned, with the `nvidia` module's probe (`nvenc::encoder::tests::what_each_lock_returns`) and a program of our own written from scratch, which compared each picture's lock with the same picture of a second, identical session locked 40 ms later:
- A lock with `NV_ENC_LOCK_BITSTREAM::doNotWait` returned only once its picture was encoded, 6.0 to 16.4 ms later, as a waiting lock does, and never answered `NV_ENC_ERR_LOCK_BUSY`, which the header says it may in synchronous mode.
- Without split-frame encoding (P4 with the high-quality tuning at 4K, or `splitEncodeMode` disabled), it answered `NV_ENC_SUCCESS` with an IDR picture's `bitstreamSizeInBytes` 200 to 400 times the picture's: 391,140,259 to 398,125,977 where a later lock answered 1,031,535 to 1,032,383, and 408,745,268 and 521,579,237 for pictures of 1,031,228 and 2,347,367 bytes. The bytes were right. Reading that size crashed a probe.
- With split-frame encoding (P4 with the low-latency tuning at 4K, which turns it on, or two strips forced), the size was right and about half the bytes were not: after the picture's VPS, SPS and PPS came a second VPS, SPS and PPS and 165 zero bytes, then the first strip's slice, 1,518,722 of an IDR picture's 3,039,958 bytes differing from byte 94. ffmpeg decoded it, with no error, to another picture. In some runs a P picture's second strip differed too. The bytes were the same 40 ms later with the buffer still locked, so they were not bytes still being written.
- A waiting lock made at the same moment, or either lock made once the picture was encoded, gave the right size and bytes.
- A second lock of a buffer already locked and unlocked, with no picture submitted into it since, never returned, with `doNotWait` or without it: one left running spun a CPU core inside `nvEncLockBitstream` for 14 minutes. The header does not say whether a buffer may be locked twice.
Ours does not depend on any of it: the `nvidia` module's encoder makes only waiting locks, on a thread of each session's own, and waits for the answer until the deadline (`crates/reims-vgpu-video/src/nvidia/nvenc/locks.rs`), and a session locks a buffer only while a picture submitted into it waits for its lock, once, and submits a picture into a buffer only once the last one's lock is made (`Submitted`, `crates/reims-vgpu-video/src/nvidia/nvenc.rs`).
- **U21. NVDEC decodes wrongly in one process while another process's Vulkan compute contends on an atomic in imported host memory.**
- The load: 16 workgroups of 64 invocations `atomicAdd` one 32-bit word of host memory imported with `VK_EXT_external_memory_host`, in dispatches of 190 to 280 ms.
- Beside it, NVDEC answers `cuvidDecodeStatus_Error` for some pictures of valid H.264 and HEVC streams in other processes, and gives many more wrong with status 2. The kernel logs no Xid, and every call succeeds.
- The same atomics in device-local memory, spread over words, or in one workgroup leave the decodes right.
- **Measured** on an RTX 5080 Laptop GPU, driver 615.71.09, 2026-10-25 (B37).
- The decoding process gets no sign of which frames are wrong, so nothing of ours works around it.
- A report, with a program written from scratch, is written and not filed yet.
- **U22. Mesa's VA frontend holds its display's lock while `vaGetImage` and `vaMapBuffer` of a derived image wait for the GPU.** `vlVaGetImage` maps each plane of the surface with `texture_map(PIPE_MAP_READ)` and copies it out, and `vlVaMapBuffer2` maps a derived image's surface with `texture_map`, both with `drv->mutex` held (**read** in Mesa 26.2.4, `src/gallium/frontends/va/image.c` and `buffer.c`). For a tiled surface radeonsi's map copies it on the GPU and waits for the copy, so while the GPU is busy, every other thread's calls on the display wait behind the map. **Measured** on an RX 7900 XTX and a Radeon 780M, 2026-10-26: with the graphics ring held, another thread's `vaSyncSurface2` of an idle surface, with a timeout of 0, returned only once `vaGetImage` had, 380 ms on; Ours makes those calls on the display's call thread and bounds the others by their deadlines ([vaapi.md](vaapi.md), "The display's calls"). Not reported upstream yet.
- **U23. amdgpu has every submission after an unmap wait for every job its VM had in flight at the unmap.** The page-table update of an unmap waits for every job of the VM (`amdgpu_vm_clear_freed` syncs to the VM's root reservation, `AMDGPU_SYNC_EQ_OWNER`), `amdgpu_gem_va_update_vm` leaves that update's fence as `vm->last_update`, and `amdgpu_cs_vm_handling` has each submission wait for `vm->last_update`, so a job that uses none of the memory unmapped waits for every job then queued or running, on any ring (**read** in Linux 7.2.9, `drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c`, `amdgpu_gem.c` and `amdgpu_cs.c`, and the same on `master` at 21a7f44fd076, 2026-10-25). libdrm_amdgpu opens a GPU once a process (`amdgpu_device_initialize` gives each caller with a descriptor of the same GPU the device the first made, which submits through a duplicate of the first descriptor), and Mesa 26.2.4's RADV and radeonsi both open it so, so a process using both has one DRM client and one VM on each GPU. **Measured** with a program on libva alone, 2026-10-26: a small decode submitted beside 40 queued processing runs of 7680x4320 was done in 0.46 ms at the median on the RX 7900 XTX and 4.47 ms on the Radeon 780M, and in 12.98 and 140.66 ms, as the runs ended 13.37 and 144.97 ms on, when an idle 256x256 surface was destroyed just before it (B92). A report, with that program, is written and not filed yet.
- **U24. radeonsi's decoders wait on the CPU in their first `vaEndPicture` for the job that begins their session, with the display's lock held.** radeonsi begins a VCN decoder's session in its first `end_frame`: `si_dec_init_decoder` writes the create command's message into the embedded buffer of the decoder's current slot (`emb_buffers[cur_buffer]`, one of four) and submits it, and `decode_cmd_build` then maps the same slot's buffer for write, without `PIPE_MAP_UNSYNCHRONIZED`, so `amdgpu_bo_map` waits with no timeout until the create job is done; `vlVaEndPicture` holds `drv->mutex` throughout. Every VCN video decoder has a create command, H.264's and HEVC's among them (**read** in Mesa 26.2.4, `src/gallium/drivers/radeonsi/mm/si_video_dec.c`, `src/gallium/winsys/amdgpu/drm/amdgpu_bo.c`, `src/amd/common/ac_vcn_dec.c` and `src/gallium/frontends/va/picture.c`, and the same on `main` at ab1502fd, read 2026-10-26). **Measured** with a program on libva alone, 2026-10-26: a new 128x128 H.264 context's first `vaEndPicture` took 1.31 ms at the median on the RX 7900 XTX and 5.91 ms on the Radeon 780M with VCN idle, against 0.03 and 0.08 ms on a context used before; with an unmap just before it, behind 40 queued processing runs (U23), 14.34 and 142.66 ms, until the runs were done, where a used context's took 0.03 and 0.11 ms at the median and its decode waited on the GPU instead. Another thread's `vaSyncSurface2` of an idle surface, timeout 0, took as long as each (B92). Ours makes a decoder's first `vaEndPicture` on the display's call thread (`crates/reims-vgpu-video/src/vaapi/va/buffer.rs`). A report, with that program, is written and not filed yet.
- **U26. iHD's video processing writes an imported surface's planes where the descriptor does not put them.** Into an NV12 or P010 surface imported from a dma-buf (`VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2`, one object, one layer of two planes, linear), a processing run answers success and writes the luma plane at the dma-buf's first byte whatever its offset, and the chroma plane `(chroma - luma) / pitch` whole rows after it, the rest of the offset dropped (**measured**, an Iris Xe of an i9-13900H, intel-media-driver 26.3.5, libva 2.24.1, Linux 7.3.1, 2026-11-07, with the import check's sweep and a libva program written from scratch: a luma plane given 256 bytes or two whole rows in landed at the first byte; a chroma plane given at the page past the luma's 360 rows of 640 bytes landed at row 364, 512 bytes before it). A luma plane 64 or 128 bytes in fails the run (`VA_STATUS_ERROR_OPERATION_FAILED`), an object a plane is refused or written wrong, and rows of samples not a multiple of 64 bytes are written out to the next 64, the padding zeroed. Ours: the import check's second trial is of that shape, rows of whole alignments, the luma plane at the dma-buf's first byte and the chroma whole rows after it, which iHD passes at 64 bytes (`ImportWrite::whole_rows`, `crates/reims-vgpu-video/src/vaapi/va/import_check.rs`); the staged copy back lays its planes so on every driver (`HostFormat`'s layout, `readback.rs`), and zero copy lends such a driver only a buffer whose luma plane starts a page and whose chroma plane is whole rows after it (`zero_copy.rs`). The reims-graphics device's decode outputs, each plane 32 bytes into its page as CoreVideo lays them out, are therefore copied there by the runtime device's GPU on iHD ([vaapi.md](vaapi.md), "The reims-graphics device"). A report, with that program, is written (the upstream folder's 105) and not filed yet.
- **U27. radeonsi hangs the VCN at the first picture of an encode session begun after the last one closed.** An H.264 or HEVC encode session begun on the VCN after the process's last one was closed (`vaDestroyContext`), with none open between, never finishes its first picture: the VCN faults on a write to an address not mapped, the kernel times out the VCN ring and resets it, or the whole GPU where the ring's reset fails, and the process's later calls fail with its context lost. It happens within 2 to 4 sessions made one after another, after a pause of 3 s as without one, and with a display of each session's own while the process holds another display of the GPU, whose address space they share. Sessions never closed, or each closed once the next has coded its first picture, do not hang; neither do sessions one a process (ffmpeg's encoders) or a display each with no other display open (**measured** with a libva program of our own, `va-enc-sessions.c`, and with the VA crate's encoder, on a Radeon 780M of Phoenix and one of Hawk Point, Mesa 26.2.6, libva 2.24.1, Linux 7.3.1, linux-firmware 20261019, 2026-11-07; iHD on an Iris Xe codes 90 sessions in a row, each closed before the next). So a dropped encoder's session is kept open until a later session on the render node is about to code its second picture (`crates/reims-vgpu-video/src/vaapi/va/encoder/accelerator.rs`).
- **U28. iHD and radeonsi decode nothing of an H.264 picture of 4096x4096, and answer success.** Both take 4096x4096 as their largest H.264 decode (radeonsi's `VAConfigAttribMaxPictureWidth` and `Height`, iHD's surface bounds), and every frame of a 4096x4096 stream comes back all zeros, luma and chroma, from ffmpeg's VA-API decode as from ours, every call succeeding, while ffmpeg's software decode of it is right. 4096x4080, 4080x4096, 4000x4000, 4096x2304 and 12 other sizes up to 4096x4096 decode right on iHD, and 4096x2304 on radeonsi (**measured**, 2026-11-08, libva 2.24.1, streams of x264: ffmpeg 9.0.2's decode on an Iris Xe of an i9-13900H, intel-media-driver 26.3.5, and on an RX 7900 XTX, Mesa 26.2.6; ours on the Iris Xe and on a Radeon 780M of Hawk Point, Mesa 26.2.6). 4096x4096 is the one size within 4096x4096 of 65,536 macroblocks. NVDEC decodes the same streams right, and 8192x4320 (RTX 5080 Laptop GPU, driver 615.71.09). Ours refuses an H.264 picture of more than 65,535 macroblocks before it reaches the driver (`H264_MAX_MACROBLOCKS`, `crates/reims-vgpu-video/src/vaapi/va/h264.rs`), and the graphics device answers H.264's largest size under that bound, at most 4096 wide: radeonsi's 4096x4096 and iHD's 8192x8192 (its `VAConfigAttribMaxPictureWidth`; its surfaces' bound is 4096x4096) as 4096x4080, so the guest's video driver refuses a 4096x4096 stream at its create and VideoToolbox decodes it in software ([devices.md](devices.md), "The caps"). Not reported upstream yet.
- **U28. radeonsi's decodes write an imported surface only within the bytes its planes as declared span from the luma plane's first byte.** Into an NV12 surface imported from a dma-buf (`VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2`, one object, one layer of two planes, linear) whose chroma plane lies past the end of the luma's rows, a decode answers success and writes nothing past the luma's pitch times the import's height and the chroma's times half of it, from the luma plane's first byte: the chroma plane's last rows are never written, and the luma plane's first row is overwritten (**measured**, a Radeon 780M of Hawk Point and an RX 7900 XTX, Mesa 26.2.6, libva 2.24.1, Linux 7.3.1, 2026-11-08, with the target check's streams and a libva program written from scratch: a 240x144 picture at 256-byte rows lost the chroma's last row at a 256-byte gap, its last two at 512 and its last 16 at 4096, and every byte outside the planes' rows was left as it was; the same with HEVC Main into NV12 and Main 10 into P010). The same surfaces imported taller, so that the declared planes span the chroma plane's rows, the luma plane declared over the gap and into the chroma plane, were written whole; the driver refuses an import whose declared planes run past the dma-buf. Its video processing writes such surfaces at their offsets (the upstream folder's 105). Ours: a target is imported as tall as its planes need to be declared to span its chroma plane's rows (`declared_rows`, `crates/reims-vgpu-video/src/vaapi/va/target.rs`), and the target check's layout has a gap before the chroma plane, as CoreVideo's outputs do. A report, with that program, is written (the upstream folder's 109) and not filed yet.
## Untested, or tested by unit tests only
- **T1. HEVC.** kvazaar 2.3.2's streams cover what x265 does not write, each checked with `hevc-info` for what it holds ([vaapi.md](vaapi.md), "Testing HEVC"): tiles uniform (3x3) and explicit (4x3), tiles in slices of their own at 1080p, at 1366x766 and at 4K (4x4), WPP rows in dependent slice segments, with an open GOP's CRA and RASL pictures, cut and spliced there too, slice headers that code their own short-term sets, 8 current references, low-delay B, and field pictures (`field_seq_flag`), which ours decodes as pictures of half the frame's height. Every frame equalled kvazaar's reconstruction and ffmpeg's decode, whose MD5 of every picture kvazaar's own SEI confirmed (**measured**, 2026-10-24): on an RX 7900 XTX and a Radeon 780M, 108 of 108 `hevc-check.sh` checks each, and on an RTX 5080 Laptop GPU's NVDEC, 62 of 62.
What neither encoder writes, `hevc-craft` writes into copies of their streams, every picture decoding as the source's ([vaapi.md](vaapi.md), "Crafted HEVC streams"): list modification in P and B slices, identities and, where long-term pictures moved to the end of `RefPicListTemp0`, list 0 put back in another order; short-term sets predicted from one another in the SPS, named by the headers or predicting the headers' own (`delta_idx_minus1`); and long-term pictures, predicted from and not, in P and in B slices, naming the SPS's `lt_ref_pic_poc_lsb_sps` and coding their own LSBs, with an MSB cycle and without. Fourteen such streams from x265's and kvazaar's, at 720p and 1080p, Main and Main 10, with B-frames and open GOPs and without, decoded with every frame their source's, as ffmpeg's and libde265's decodes of them did (**measured**, 2026-10-25): on an RX 7900 XTX and a Radeon 780M, 42 of 42 `hevc-check.sh` checks each, and on an RTX 5080 Laptop GPU's NVDEC, 28 of 28. Not reached by them, so unit tests only:
- a long-term picture's MSB cycle other than 0: every stream is shorter than its `MaxPicOrderCntLsb` of 256;
- a long-term picture in a list beside other pictures, which no rewrite can make without changing the decode (the motion vectors' prediction between a long-term and a short-term reference, 8.5.3.2.7 to 8.5.3.2.9), and so a modification that reorders list 1;
- PCM: its SPS fields are parsed and passed on, but no stream with PCM blocks reached a decoder;
- Main 10 from kvazaar, which CachyOS builds for 8 bits alone, and tiles with WPP, which kvazaar says no profile allows.
Field-coded HEVC with kvazaar needs `--gop 0` or a low-delay GOP, since its GOPs of 8 and 16 write no first access unit then (U13).
kvz-720p-ref15, kvz-720p-tiles-narrow, kvz-720p-tiles-short and kvz-720p-tiles-col64 break Main's limits. kvz-720p-tiles-narrow's tile column of 192 samples and kvz-720p-tiles-short's row of 16 decode on every frame; columns of 64 samples, one CTB, decode wrongly on radeonsi with no error, so the decoder refuses kvz-720p-tiles-col64 at its PPS (`MIN_TILE_COLUMN_WIDTH`, 128, `codec/hevc/decoder.rs`). The VA-API decoder refuses kvz-720p-ref15 at its tenth picture, which names more than the 8 current references VA-API takes, after its first 9 pictures match (`hevc-check.sh`). The guest's video driver fails the schedule of both before they reach the host ([devices.md](devices.md), "The caps").
- **T3. H.264.**
- Interlaced video, any SPS with `frame_mbs_only_flag` 0, does not reach the host from the guest. AppleGVA's AMD flow, which the guest's video driver is under (docs/graphics-kext/design.md, "Routing"), refuses every such stream at its session's create (-12913), as on a MacBook Pro 16 2019's Radeon Pro 5300M, and VideoToolbox then decodes it in software where its client allows. The Intel flow of the same Mac's UHD 630 decodes them all in hardware, every frame right. **Measured** 2026-11-08, on that Mac on macOS 26.7.1 and in the guest on 26.7.2 on a Radeon 780M, with streams of JM 19.0 (fields of P, B and High pictures, PAFF, fields then frames, MBAFF, PAFF with MBAFF) and of x264 (MBAFF, top and bottom field first, and `--fake-interlaced`). VideoToolbox's software decoder then decodes JM's streams right, and x264's MBAFF streams wrongly after their first two frames, on that Mac and an M3 as in the guest, and x264's `--fake-interlaced` streams wrongly in the guest. The host still refuses interlaced streams (`h264::Error::Interlaced`), so fields and MBAFF on VA-API and NVDEC are untested.
- Long-term references, MMCO 2 to 6 and frame number gaps are covered on an RX 7900 XTX and a Radeon 780M by `h264-craft`'s streams ([vaapi.md](vaapi.md), "Crafted streams"). Only one shape of each was written. Fields' marking is untested, since fields are refused.
- Damage: a truncated slice is found on NVIDIA by NVDEC's status, and not on VA-API (B41); a lost frame is concealed on both.
- **T4. Encode on VA-API.**
- HEVC has no B-frames, since radeonsi reports no second list.
- The hardware's slice headers have not been compared with ours.
- **T16. The NVIDIA decoder.** HEVC as T1: tiles, dependent slice segments, slice headers' own short-term sets and field pictures reached NVDEC in kvazaar's streams, every frame bit-exact (**measured**, RTX 5080 Laptop GPU, driver 615.71.09, 2026-10-24), and long-term pictures, list modification and predicted short-term sets in hevc-craft's, 28 of 28 runs (driver 615.71.09, 2026-10-25). Left as T1: PCM, which no encoder here writes. In the guest, one stream of each codec and size was decoded: the guest's other paths onto NVDEC, Safari and the wallpaper's playback, were not looked at.
- **T17. The checks' shell scripts are not run through shellcheck:** it is on none of the hosts the checks run on.
## Put off on purpose
- **D10. No tool copies a test VM between hosts.** The first VM on the NVIDIA host was made from a Radeon host's VM by hand: a snapshot, its free space zeroed in a scratch VM, `qemu-img convert`, and a copy over the network. A tool that crosses hosts waits until a second cross-host VM is wanted, since the next VM on that host is better copied from the one there.
- **D12. NVENC runs without lookahead.** The `nvidia` module's encoder turns it off in every preset's configuration (`crates/reims-vgpu-video/src/nvidia/nvenc/encoder.rs`), since with it on frames are lost (U6). P6 and P7 lose the quality lookahead brings, unmeasured.
- **D14. NVIDIA's smallest frames.** NVDEC decodes HEVC from 144x144 and H.264 from 48x64; NVENC encodes H.264 from 145x49 and HEVC from 129x33. Each is the driver's answer (**measured** with `nvidia-probe`, RTX 5080 Laptop GPU, 2026-10-24), and the graphics device's caps give the guest the decoder's.
- **D25. The graphics device's video driver cannot report a host's H.264 decode failure.** The guest lane's video driver (`guest/bundle/src/RgfxVideoDriver.cpp`, docs/graphics-kext/design.md, "A decode the driver cannot complete is a decode error") fails the schedule of an HEVC picture the host failed, as the schedule waits for the host's verdict on it, and VideoToolbox reports `kVTVideoDecoderMalfunctionErr` (-12911) from that picture on (`waitsForHost`, `guest/bundle/src/RgfxVideoStatus.hpp`). AppleGVA's H.264 decoder reports no failure at all: a failed schedule (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 leave every frame decoded, and a picture whose schedule failed is not decoded (**measured** on the guest with the RTX 5080, 2026-11-07, every picture failed on the host). AppleGVA's code on macOS 26.7.1 holds no other way (**read** 2026-11-08): its decode flow takes every query for the command's completion, reading neither the status nor the error word, and reports a failure only through a failed batch schedule, while the H.264 pipelines schedule their commands one at a time and keep no decode's result. So an H.264 schedule waits for no verdict, and an H.264 picture the host fails after it was sent reaches the guest as decoded. What the driver can tell before a picture it refuses at its context's create instead: a coded size outside the host's H.264 decode entry (`sizeTaken`, `CreateContexts`), and VideoToolbox decodes the stream in software (**measured** in the guest on a Radeon 780M, 2026-11-08: a 4096x4096 stream, past the entry's 4096x4080 (U28), failed its hardware session's create and decoded right in software; answered 4096x4096, it was taken, and its frames reached the client undecoded). The session's create also fails, in the guest as on the real Macs, for 4:2:2, 4:4:4, monochrome and lossless streams, for 8192x4320, and for interlaced ones (T3); VideoToolbox's software decoder then decodes 8192x4320 and JM's interlaced streams right, x264's interlaced ones wrongly, and fails on the rest. AppleGVA hands the driver no SPS or PPS before the first picture, so what the host refuses from them or from the slices still reaches the guest undecoded: High 10, slice groups (FMO), data partitioning, and SP and SI slices. The guest's frames of them are the real Macs': their hardware decodes those wrongly too, on the Radeon Pro 5300M and the UHD 630 alike, and mostly with no error: every frame of High 10 wrong, FMO's wrong (a box-out stream's with errors), a data-partitioned stream's first frame and then none, and an Extended stream with SP slices wrong from its first SP picture (**measured** on macOS 26.7.1, and in the guest with the 5300M's counts, 2026-11-08, streams of JM 19.0 and x264). Left are those, a host's refusal of the picture once it has it (its planes refused), and a decode the hardware failed once it ran. Put off: AppleGVA leaves no answer. To lift it: an H.264 path in AppleGVA that reads a driver's failure, on a release that has one.