Commit Graph
9 Commits
Author SHA1 Message Date
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 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 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 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 910ab53359 ⬆️ Build on metal2vulkan f6a96b7da8's runtime
Move the runtime from 6c9cad047a to f6a96b7da8, the tip of metal2vulkan's
development once it was cut into one commit a work packet (artifact format 450
to 451; semantics 1867 and runtime version 1643 unchanged), whose runtime
sources metal2vulkan pins as d2bdbfea. 6c9cad047a is no longer an ancestor of
that development: it resolves on metal2vulkan's
archive/development-linear-2026-10-26, which keeps the line as it was.

metal2vulkan's gate ran at 2c7b5dc395, that line's last commit, whose tree is
f6a96b7da8's (0b981bbfc3), with --no-fail-fast on every leg:

  land-check    0
  suite         0   5,667 of 5,667 (its four crates, --cfg m2v_gpu)
  validation    0   1,364 of 1,364
  conformance   0   1,003 of 1,003
  cost          0   the whole set's 1,122 cases, alone: no bound moved

What changes for the guest:

- A command buffer carries a shadowed texture's image across its encoders: a
  later encoder copies in nothing of a texture an earlier one of the same
  command buffer left holding the bytes, unless a write of the bytes another
  way, an event, semaphore or fence wait, or another encoder ending with the
  texture came between, where Metal would show it another writer's bytes. Metal
  shows an encoder the bytes as of its command buffer's commit (measured by
  metal2vulkan on the M3 Max), so the same texels are read. A later command
  buffer still copies in.
- A YCbCr texture's conversion module is built for its layout, range and
  matrix, where one module read them at run time: the same codes, from 288
  instructions where there were 465 for a 10-bit 4:2:0 surface.
- On a driver that takes it, a set-0 buffer binding that a stage uses through
  several variables is a dynamic descriptor, as far as the driver's count of
  dynamic storage buffers reaches in binding order, where it stayed static on
  every device: the same bytes, through one set a command buffer binds at each
  command's offset rather than a set a command. MoltenVK fails the runtime's
  self-check of that shape, so the Mac is unchanged; a device that pushes set 0
  never asks.
- Nothing else in the span moves what a guest computes or observes.
  - A command buffer's upload chunk is made without a clear, and each region
    zeroes the part of itself its data does not cover: every reader of a region
    reads the same bytes, for fewer bytes written.
  - A library's module is decoded once for every entry a creation compiles, a
    compiled function keeps its last relocation and its words' digest, and the
    verifier hands canonicalization its dominator tree: the same words, digests
    and artifacts.
  - The shader cache's directory is asked about a stage's function once, not
    once a pipeline state, and a render pipeline's artifact and variant record
    go there only where it lacks a stage's function: what is on disk, not what
    is made.
  - The rest counts (holds from commit to submission, a large surface's first
    copies in, the driver's pipeline makings and the directory's time and round
    trips), or is docs, tests, probes, the cost ledger and the sources pins.

The public surface gains 66 items and loses none. Four rows change in place:
YCbCrConvertModule's SHAPE_WORDS is 6 (22), ycbcr_convert_module and
ycbcr_convert_floats_module take a YCbCrConversion for a YCbCrOutput, and
CompiledFunction's Debug and equality are written by hand. Nothing here names
any of them. shadow_texels_first_copied_in_again keeps its name and type and
now counts only the copies in the carry could not leave out; nothing here reads
it.

No Degradation, RuntimeGap, refusal or notice kind moved, so DIES and the
relayed kinds stand. The span's device modules move only to time the driver's
pipeline makings and keep the self-check's answer: device info, GPU families and
feature queries answer as before, and the Vulkan platform ends the process at no
new site, so the pin owes no guest a cold boot. The accuracy ledger's table of
the runtime's answers passed on stays empty.

docs/video/bugs.md says what the pin carries for B73 (the carry, the counts that
divide its copies in, the YCbCr module) and B26 (the hold counts).

Checked, every test passing in its full run:
- on the M3 Max (macOS 27.0.1): the three clippy passes cargo xtask check
  makes (the Mac's, its tested features', and x86_64-unknown-linux-gnu's), and
  the 889 tests of reims-vgpu-vulkan and reims-vgpu on MoltenVK;
- the Vulkan crate's 432 tests and reims-vgpu's and the C API's 50 video and
  scaler tests on gem10's RX 7900 XTX and Radeon 780M and on msi's RTX 5080
  Laptop GPU, with no amdgpu reset and no NVRM or Xid line.
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, rustfmt 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 13:39:11 +02:00
Anees Iqbal 73a0b0988d 📝 Record the video devices' bugs, hardening and layout [ci skip]
docs/video/bugs.md records what is wrong with the video devices or put off,
and what each boot round found; hardening.md the bounds on guest input.
AGENTS.md, docs/development.md and docs/lessons.md gain the video crates'
rows, their checks and the traps their review found.

Source: c5b409362 f5d0311e3 532db9c03 cb582881c 5dd0d9373 60d08c4f4 efbcf2dbb
        c4c476643 82f25c397 fe105edcb 36a6a82c6 c5750b87f d7d5cfede 51bad7d67
        a07ffd70b 958524e64 cc8cbfd2d 8f9e68b8b 39881a0b3 aba73491a 233801b96
        886833dc2 710929c9d 509f64a8b fd20de9bf 2ae4acf64 7433026a9 0030b24a7
        64497f931 3bf366e81 eed5d9446 0fa52d070 c21cff4fb 1ff907b68 1ccde0ef6
        41235220c 33b40ae4a 0fbe863c3 0b7e8c004 ae49b63a3 4151f4de8 76951e3ea
        7cfd37c9b 853cfdc0e 6ed3d12a4 2dbca9dcd af2b396b2 16f8ee77b ba01dec38
        095f975b2 b6ac2bb54 943f091af ef26f02e1 d27a5f48a 7bbfdf888 203585632
        4aa89d356 31ffd8de7 08bb763c4 9400f48cb 9e050f933 5ff2dd73f 62e19c8ef
        c8c7b3400 ce406ddb2 fd92f66c4 52fba93c9 e179dc0bd b5f40ad74 73d7e9c85
        d01bbdc9e 0dcca7ff7 30ed556cb 601c23067 9857b1fc8 675e1cf8d b427bebfb
        9817ecd8f 55a1d96e7 96f459104 8c58f98c4 f9c7a5811 eef22173d 9628f09a8
        fa2a248c3 5dccbdd18 ef54c395f 745cef197 d02148033 da8b42c4c e7cb403a2
        46120bbf7 25e4ae539 221176d06 22625b578 75d879cf5 c23c83073 051c64ebb
        73e48ad5a bc6fcdaa7 b02b003f5 986872956 deb03015c 096878653 8b915bb9e
        89e863767
2026-10-26 12:24:31 +02:00