metal2vulkan v0.2.0 (257bdd7d14, RUNTIME 2319) keeps the program of each
freed pipeline state ID's last holder while an indirect command buffer of
the device lives. So a command a kernel encodes naming a state released
before the write, its ID taken by no other state, now runs the released
state's program, unannounced, and its command buffer completes. That is
the M3 Max's and the UHD 630's answer; the Radeon Pro 5300M fails the
command buffer with a timeout (dgpu-oracle.md Q43). The Macs differ, so
the runtime's answer is inside the contract. Before the pin, the command
ran nothing and the runtime relayed `released-command-state`.
released_command_states_are_relayed_by_default expected the old answer
and failed on every GPU at the new pin: the M3 Max, the Radeon 780M and
the RTX 2080 (m3-max-31882, 31883, 31850, 31891). The RTX 3090 pass it was
set against (m3-max-31685) ran ccdc018fc, before the pin moved.
The runtime still relays a state released while no indirect command
buffer of the device lived, and one past its ID's last four holders: the
command runs nothing. The test now makes its buffer after the release, to
reach that case, and keeps every check: the command buffer completes, the
command runs nothing, the kind is relayed once, and the device goes on.
a_state_released_while_a_buffer_lives_runs_where_a_kernel_names_it holds
the new answer: the buffer is made before the release, the program runs,
the command buffer completes, and nothing is relayed.
answer.rs's DIES entry for ReleasedCommandState and Q43's account of our
stack now say what the runtime does at d9236a8a11. A record a kernel
wrote naming an ID the CPU set, which another state then took, runs that
state, as on the M3 Max and the 5300M. Before the pin it ran the CPU's
state and was relayed.
The report was a black viewfinder in a macOS guest. With the xHCI fix,
Photo Booth on reims-graphics-pci shows the camera's frames, and on
vmware-svga, which gives the guest no Metal, it stays black while the frames
arrive, so the remaining black there is not the transport's.
A UVC camera on the host's vhci_hcd gave a macOS 26.7.2 guest no frame
before vendor/qemu's ae97f3f5 and a full 30 fps stream after it, its
frames' numbers in order, on vmware-svga and on reims-graphics-pci.
docs/qemu.md's USB passthrough section records both runs, so the next
change to the controller's isochronous path has them to compare with.
A macOS guest given a USB camera saw it but never got a frame: the
viewfinder stayed black with the camera's light on. macOS queues an
isochronous IN TD that crosses a page as an Isoch TRB chained to a Normal
TRB, and a camera's frames end in short packets. QEMU's xHCI posted the
short packet's event on the first TRB and none for the TD's last TRB,
which xHCI 4.10.1.1.2 asks for and macOS waits for: it took each later
event of the endpoint as mismatched, its requests never completed and the
stream stopped within about 100 ms. An emulated UVC camera over USB/IP
showed the same on every host.
vendor/qemu's ae97f3f5 posts every event a TD's TRBs owe after a short
packet, on isoch, bulk, interrupt and control rings alike, with a qtest of
the pattern, whose order 1890afed fixes (its isoch case read the empty
ring's Ring Overrun first). docs/qemu.md lists both.
An update to f378a38f8 stopped in QEMU's build on the owner's laptop:
"qemu-version.h: No such file or directory". QEMU of 2026-11-13 writes
that header at configure (configure_file) wherever `git describe --match
'v*'` fails, as it does in every shallow vendor/qemu; the QEMU before made
it with a build step. meson, configuring in place, runs `ninja -t
cleandead` after writing build.ninja, which deletes each file .ninja_log
records as built that build.ninja does not name: the header it had just
written. Every later configure in that directory deletes it again.
install-ctl.sh and `make qemu` now record the vendor/qemu commit a build
directory was configured from (qemu-source) and start the directory empty
when the commit differs; a directory without the record is started empty
once. The same commit keeps its directory, so edits not yet committed in
vendor/qemu rebuild as before.
Reproduced on ms01 (job m3-max-31803): the old QEMU's directory
configured in place for the new loses the header and the compile fails as
on the laptop, twice over; an empty directory keeps it and compiles, and
keeps it when configured again at the same commit.
Moves the runtime from ce54ad8b25 to the v0.2.0 release, d9236a8a11
(RUNTIME_VERSION 2342, SEMANTICS_VERSION 2122, ARTIFACT_FORMAT_VERSION
523). It adds no degradation kind. Two of our tests follow its answers:
the policy's exact forms name its new indirect_records field, and the
two-plane YCbCr argument-buffer write test checks 500 like the other
formats now that the runtime writes those slots through. The accuracy
ledger gains the row for the indirect-records policy.
Checked, at the owner's word, with one cold boot of the x86-64 macOS 26
guest on the RTX 5080 over this tree and vendor/qemu's 2026-11-13 move.
vendor/qemu was upstream's master of 2026-09-30 (9c88811b81) with our
commits on top. It is now upstream's master of 2026-11-13 (e9fa1f66f0,
3941 commits later) with the same commits rebased onto it, in order, on
the fork's branch steelbrain/reims-vgpu-rebase-2 (341397871f). The old
branch, steelbrain/reims-vgpu, stays at 1f6f4ea455, so every hash the
measurements and history in docs/qemu.md name still resolves.
Seven of our commits are not on the new branch, because upstream now has
them: five audio/pwaudio fixes and the x-query-virtio-status crash fix
(identical patches), and the thread pool's floor of one thread (upstream's
2566b6e902). Five conflicts were resolved by keeping both sides: upstream's
interface number in host-libusb beside our ep_interval; upstream's
reentrancy guard around our xhci_kick_ep(..., false); our qtest helpers'
machine and hc arguments on upstream's split of xhci_test_init and
xhci_test_start; and apple-gfx.m, which our branch deletes.
Checked at this tree's library with that QEMU: on Linux, the library's
dist and QEMU x86_64 and aarch64 softmmu with --enable-reims-vgpu and
install-ctl.sh's options; the usb-hcd-xhci (15 subtests) and
display-screendump qtests; reims-graphics-pci realized paused on an Iris Xe
(1234:5247, class 0x0380, BARs 0, 2 and 4; exit 0, no fatal line). On the
M3, aarch64 softmmu with HVF builds. No VM was booted (owner's call).
.gitmodules, README.md and docs/qemu.md name the new branch, and the
"What vendor/qemu carries" table names its commits; its doorbell row named
d81bcaac, a hash the branch never had, for 1c4c0ce3ff (now db9cb35f).
The bundle took texture buffers 2D textures' 16384 elements wide, and a
guest's MoltenVK died at a texel buffer view 46626 wide. Record what the
AMD, the Intel and the M3 answer (2^28 elements of any format at every
creator, Metal's death one past it), the guest before and after the fix,
and the host Vulkan devices' maxTexelBufferElements, ANV's 2^27 below
Metal's 2^28 being metal2vulkan's to carry.
Decided 14 gains the 2026-11-14 walk on um870's RTX 3090: the window drawn
from the mirror cost the guest 11% of its frames against the window
presenting from the 3090, because the tile kernel's writes into host memory
held the graphics engine for the link's time. It also describes the copies
on a copy engine. lessons.md says how to spot the next such cost.
The Mesa-layer entry said the library takes the loader's first device whenever a
selection variable is set. selmatch (75ef99afe) changed that: device_choice now
opens the device a variable names, by its IDs or DRI_PRIME's PCI address, so the
entry says what the library did and what it does now.
Mesa's device-select layer sorts the GPUs after the loader and puts its own
default first unless MESA_VK_DEVICE_SELECT names one, so the loader's variable
alone left um870's 780M first with the 3090 named (job m3-max-30538), and the
library, which takes the first device whenever a selection variable is set,
would log the layer's default as the user's pick.
The present hold makes a queue's next frame wait for the drawable's
present-scheduled report, which comes only after the presenting buffer is
scheduled. A buffer that does not ask for its CB_SUBMITTED is scheduled at the
platform's submission, and that can wait for the queue's earlier work on the
GPU. On the RTX 3090 host, the Modern Rendering sample's presenting buffer sat
behind its frame's 89 ms pass and was scheduled at the pass's end, 88.6 ms
after its commit. The GPU then stood idle 19 to 22 ms a frame, 12.3 -> 10.2
fps against the set without the hold. Metal schedules a buffer that waits for
nothing within a fraction of a millisecond of its commit, whatever its queue
runs before it.
What changes for the guest:
- Once a buffer of a queue presents a drawable, it and every buffer the queue
commits after it ask for their submission (RGFX_OP_SUBMITTED), where the
device answers it.
- The host then schedules each one at its take where it waits for nothing and
no buffer before it on its queue owes its scheduling. Such a buffer becomes
Scheduled, and its present is made, at its take instead of at the
platform's submission.
- Queues that never present ask as before: only commitAndWaitUntilSubmitted's
buffers ask.
A GPU-bound app's window reached the screen at about half the app's rate:
our bundle's presentDrawable: posted every later buffer of the queue at
once, so the app ran as many frames ahead of WindowServer as its queue
held, and WindowServer's composite waited behind them on the host's GPU.
Metal's base command buffer asks each drawable it presents for a
present-scheduled report (addPresentScheduledHandler:, CoreAnimation's),
and its queue submits nothing after the presenting buffer until the
report comes. Measured on the MBP16's AMD 5300M and Intel 630 (macOS
26.7.1): with the report 200 ms after the present, a buffer committed
right behind it was scheduled at 200.7 to 210.5 ms, against 0.3 to 1.3 ms
with an immediate report, and both commits returned in 0.03 ms.
What changes for the guest: a buffer committed after a presenting one
stays committed, unsubmitted, until CoreAnimation reports the present
serviced, as on a Mac. Every drawable a buffer presents is now asked
for addPresentScheduledHandler:, as Metal asks it; a buffer that failed
before its present gives the signal from its scheduled handler.
The bundle's fake drawables gain addPresentScheduledHandler:, and a new
test holds the later buffers through the present until the report, for a
report on demand, at add, at present, and behind a host-failed buffer.
The NVIDIA crate's threads and waits run on the runtime it is first handed,
and only the Annex B decoder handed one. A QEMU whose first NVIDIA video was
an NVENC encode session, before any decode session, made its encoder's lock
thread and waits on the crate's fallback: std's threads, outside the
library's, and no exit gate, so a call in NVENC or CUDA could run beside
the driver's exit-time destructors as the process ended, the class of the
exit aborts the gate exists for.
NvidiaVideo::new now hands its runtime to the crate (nvidia::use_runtime,
public) before it opens the GPU, as a VA display takes its runtime as it
opens, so every session kind runs on the platform's threads and clock, and
the crate arms the platform's exit gate as CUDA loads.
A test on the NVIDIA host opens the arm in a child process of its own, makes
an NVENC encoder before any decoder and encodes a frame: NVENC's lock thread
is started by the runtime the arm was opened with. Nothing the guest sees
changes; an encode-first QEMU's NVENC threads are now the library's.
The VA-API hardware tests open their displays on GatedRuntime since
b52eea52f, whose exit gate closes before the drivers' exit-time destructors
run, after iHD aborted a test process that exited while a kept session was let
go on another thread. The NVIDIA arm's tests ran on std's runtime, which has
no gate: its waits fell back to StdRuntime::shared where no backend's opening
made a runtime, and the Annex B decoder's test handed it std's. Its call
threads and the sweep of work kept past a deadline call NVDEC, NVENC and CUDA
on threads of their own, so a test's process could exit beside them the same
way. No abort was seen on NVIDIA.
In a test the NVIDIA waits now fall back to GatedRuntime, which the first load
of a driver's library makes and arms (arm_exit, as Library::open and cuInit
call it), so its hook runs before what the library registered. The Annex B
decoder's test and the session-start probes hand the gated runtime too. One
gate serves the process, whichever arm's driver loads, so the NVIDIA tests use
VA-API's (vaapi::gated) rather than a second one.
A test of the pattern runs in a child process that registers an exit handler
as a driver's library would, then has the crate arm its gate: at exit the
crate's steps are refused by the time that handler runs. On std's runtime they
were still given. The product is unchanged: outside tests the fallback is
std's, as before.
NVDEC's decoder kept the capabilities it asked, once per GPU, codec, chroma
format and bit depth, but the graphics device's NVDEC arm asks the same
three as it opens (H.264 8-bit, HEVC 8- and 10-bit) through
decode_capabilities, which kept nothing. So the first session of each codec
and bit depth asked cuvidGetDecoderCaps again before making its decoder:
6-9 ms on an RTX 3090 at idle, 15-19 ms beside two running decoders or 16
busy CPUs (the session-start probe, job m3-max-30770).
decode_capabilities now keeps every answer itself, and the decoder asks
through it, so the arm's open fills what the sessions read. A failed query
is still asked again. The answers are the same, and the caps the guest reads
are unchanged; the first session of each codec and bit depth in a QEMU
process starts that much sooner. The decoder's module doc records the 3090's
cuvidCreateDecoder times beside the 5080's.
Two rows of the unfixed-bugs ledger said that a session's first picture costs
the guest a lot at every clip start: ~175 ms of CPU on radeonsi before the
first wait, and 34 ms to 2.13 s for NVDEC's first decode. Neither said where
the time went, and the first was taken from a debug build of a held test.
Two ignored probes, run by hand (probes::va_session_starts and
probes::nvdec_session_starts), now start sessions as the graphics device's
video does: a new decoder per session, then the first access unit and its
wait, then the second for comparison. A record of the driver calls
(probes::timeline), stamped by the VA-API and CUDA check functions in test
builds only, splits a session's first decode into its calls: config, pool,
context, buffers and the first vaEndPicture on VA-API; the capabilities query,
the decoder's make and the submission on NVDEC.
On um870's Radeon 780M (release, idle, job m3-max-30770), a new decoder's
config, surfaces and context took 0.04 ms at most, since radeonsi allocates
them at first use. The first vaEndPicture took 1.0 to 3.0 ms (the session's
create job, U24), so the ~175 ms was the debug build's. The module doc of
buffer.rs and bugs.md B92 record the numbers. Nothing changes for the guest
or the host.
The lesson named Region::new's drop alone. The window's mirror hit the same
trap through a no-copy buffer's deallocator, which the runtime runs before it
frees the import, and RADV rejected a submission that never named the pages
(-14 EFAULT). The entry now says the trap is any unmap of the OS's under a
live import, gives the mirror's case, and adds the rejected submission to how
to spot the next one.
A command buffer walked in two ranges at once has its later range in a
command buffer of its own; if the platform keeps the buffer whole at the
first range's end, the decoder cannot cut it there and fails the buffer at
its stand-in, where the serial walk would have run it. That must never
happen silently, and the prescan must keep out every op that leads to it.
The platform now says why it keeps a buffer whole: PartCut::Whole carries
a KeptWhole reason (an open encoder, protection options, an execution of
indirect commands, a command's progress, predication, a signal encoded
when scheduled, a buffer already committed), each with its code, from the
same list `splits` reads. A test on the Vulkan platform holds each reason
to the commit_part answer it gives.
The decoder's test pins the two lists together: for every reason, an
exhaustive match names the guest ops that set it, and the prescan takes no
buffer with any of them; the two reasons no guest op sets
(setProtectionOptions:, encodeSignalEventScheduled:value:) are held by a
check that no walk sends them. Where a buffer is kept whole anyway, it is a
degradation, two-ranges-kept-whole: counted in the degradation counts line
and logged once per reason per process (docs/conventions.md), its test
checking both over two buffers.
Q21 gains the cases measured on 11-14 on the M3 Max, the AMD 5300M and the
Intel 630: an argument buffer nested 6 deep, colour inputs in a raster order
group and at a computed index, imageblocks of every form the compilers make
(explicit, under a function constant, fragment data, a view of a master),
and a texture in a raster order group. It records what each GPU makes and
answers, and that ours now matches.
Q46 records two answers all three GPUs agree on. An argument encoder's
reflection is the pipelines' binding (array stride 0), not the library's
(8). A function array's functionNames follow a hash order of Metal's own:
the given order reversed matches every array of two and 28 of 60 orders in
all, and none of the Foundation or libc++ containers tried reproduces it.
What the host does differently: a kept answers file is now read only by the
build of the library that wrote it. The identity covered the platform's
translation profile, runtime versions and driver, and a format constant
bumped by rule. Nothing covered this library's own code: how its decode makes
a create's descriptor, its platform's queries, and the reflections it posts
(decode/mod.rs, compute_reflection and render_reflection). An upgrade of
reims-vgpu alone that changed an answer's values would have seeded the guest
with the last version's answers. The guest takes a seeded answer's
reflection at the create and keeps it (the bundle's rgfxTakeKnown), so the
wrong values would have shown for that pipeline's life.
The identity now also hashes the build of the library that runs: the host's
executable, which links it statically, by path, size and modification time.
A new build of the library or of QEMU starts from no answers, and its second
boot is seeded again. ANSWERS_FORMAT now names only the file's layout. If the
executable cannot be told, nothing is kept past the device's life.
"Speed comes from what every run gets" says nothing is loaded by what an
earlier run drew. The runtime's pipeline records already keep, across a
host's processes, what Metal's own pipeline caches keep. The device's kept
pipeline answers now do the same across boots. Both hold only what the
platform or the device gave before, under the identity of what decides it,
and change no value the guest reads, only how soon it has it. The rule now
names them both and says neither is ever seeded for a measurement, so the
rule keeps its meaning.
What the guest sees differently: the kext's shared pipelines learnt only from
creates it waited for. A create answered at once from a kept answer, a seed
of an earlier run among them, got its own answer later, and the table did not
take that answer. Where the device answered such a create with other values,
every later equal create of the boot, in any process, was still given the
kept values. Now the table takes the device's answer to each create posted
without waiting, as it takes a waited one's (RgfxSharedPipelines::answered).
A made pipeline's keyed answer replaces the kept one; a refusal of one posted
for a kept answer forgets it, as before.
The create the kept answer answered keeps those values. The bundle's state
takes its reflection once (rgfxTakeKnown) and only its gpuResourceID from its
own answer. Under one identity of the device's answers the two agree, so the
gap is only a seed's whose identity missed a change.
What the guest sees differently: the kext can answer a create at once with an
answer it keeps by pipeline key, from another process or now from an earlier
run. Where the device then does not make that create's pipeline, the kext
forgets the kept answer. So the next equal create of any process waits for
its own answer and gets the refusal at the create. Before this, the kept
answer stayed until the kext's next start, and each later equal create was
answered as made, its refusal showing only at its first gpuResourceID (as 0)
and in the command buffers that name it.
The deferred slot of a create answered from the table holds the key. An
answer that is not a made pipeline's (its status not OK, or too short to say)
hands the key back, and the kext drops it from the table under the same lock.
What the guest sees differently: on a host that offers PIPELINE_KEYS and
PIPELINE_ANSWERS, the kext takes both, and at its start asks for the answers
the device kept of keyed creates of its earlier runs. It asks 64 a query,
newest first, until the device has none left or it has asked the table's
2,048, before any process can make a pipeline. A create whose key the device
accepted in an earlier run, under the same identity of its answers, takes
that answer at once, as an equal create of another process does. Its own
gpuResourceID still waits for its own answer. Before this, every boot's first
create of each pipeline waited for the host.
A seed takes only a free entry of a key the table does not hold, so a full
set keeps the newer seeds. A seed ranks below every answer the run learns or
finds, and the newer seed above the older, so a set full of seeds replaces
its oldest first. A query's answers fill at most a quarter of the completion
ring, so the ring's other events keep flowing. The kext logs how many came
and how many it kept.
A pipeline create that waits for its answer costs a round trip to the host,
and the kext forgets every answer at each start, so each boot's first creates
of the same pipelines wait again. Feature bit 47 (FEATURES_HI bit 15),
PIPELINE_ANSWERS, says the device keeps its keyed answers from one run to the
next, and the kext's ring-0 PIPELINE_ANSWERS (0x2f9,
RgfxPipelineAnswersQuery) asks for them, newest first: each comes as a keyed
PIPELINE_REFLECTION of the query's seqno, its per-create fields 0, then a
COMPLETE whose status is how many went. It makes nothing, so no command
buffer waits for it (backlog's NoOne), and the control thread carries it out.
The host knows the bit from here (KNOWN_FEATURES); the peer test's unknown
bit moves to 48. The wire header is cbindgen 0.29.4's output, and the option
ROM's record takes its new hash: make -C firmware prebuilt on the Mac wrote
the same ROM bytes and record (m3-max-30999).
docs/qemu.md says where reims-ctl picks pa (QEMU built without PipeWire, as
on Ubuntu 22.04 and Debian 11), and what one boot of the 26.7.2 guest on pa
measured at vendor/qemu 1f6f4ea4: no source output of QEMU's while the
guest is idle or only plays, one per recording, made and removed within
4 ms of the input device's START and STOP, and a recording that holds the
guest's own speech from the null sink's monitor. It also says where the
old PREPARE-to-RELEASE stream was longer.
What changes for the guest: a texture over a buffer whose texels end past an
Apple GPU's allocation of a buffer of 16 KiB or more (its length rounded up to
16 KiB) answers nil and posts nothing. Before, the bundle answered a texture
and posted its create, which the host refused, so the guest held a refused
object whose uses were dropped. This covers a 2D texture by
newTextureWithDescriptor:offset:bytesPerRow:, and a 2D texture, 2D array or
texture buffer by the linear SPI; the public form's texture buffer already
answered this nil. All of them now take one rule, rgfxPastAllocation:.
Why nil: the M3 Max answers nil there (a texture buffer and a 2D texture over
16384 and 20000 bytes, scratch probe tbpa, job m3-max-30902;
metal2vulkan measured the arrays). The runtime at ce54ad8b25 answers nil there
on every device (BufferTextureProblem::PastAllocation), so the host's
platform cannot make one. The AMD 5300M and the Intel 630 make every one of
them (jobs m3-max-30900, 30901): a class 2 divergence, recorded in Q11, and
the runtime's to take. Short of the allocation, and past any buffer under
16 KiB, the textures are made as before.
No test held the old answer: none made such a texture. New tests:
- the bundle's test_textures_past_a_buffers_allocation_answer_nil checks both
forms;
- reims-vgpu-vulkan's textures_past_their_buffers_allocation_are_nil_as_the_m3s
holds the host's answer to the same rule, so a runtime that changes it
fails here.
What changes for the guest: newTextureWithDescriptor:offset:bytesPerRow: of
a texture buffer whose texels run past the buffer's length answers a texture
and posts TEXTURE_FROM_BUFFER, where the bundle answered nil and posted
nothing. Both x86 Macs make it (4 RGBA32Float texels at offset 4064 of a
4096-byte buffer, dgpu-oracle.md Q11), and so does the M3 Max
(metal2vulkan's probes/texture_buffer_past_length.m). The host's platform has
made it since metal2vulkan RUNTIME 1808 (pin 37), keeping the texels past the
length in a tail of the texture's own, so the refusal the nil stood in for is
gone. The 11-07 opengl lane hit that refusal.
It stays nil, posting nothing, where the texels end past an Apple GPU's
allocation of a buffer of 16 KiB or more (its length rounded up to 16 KiB).
The M3 answers nil there, and the runtime at ce54ad8b25 answers nil there on
every device, so the device cannot make it. The x86 Macs do make it there
(scratch probe tbpa, jobs m3-max-30900 to 30902): a class 2 divergence,
recorded in Q11.
The tests that held the old answer change with it.
test_buffer_texture_buffers now expects the texture made, with its create,
over 4096 bytes from 4064 and 12288 and over 20000 bytes from 19968, and nil
past the allocation. The new reims-vgpu-vulkan test
a_texture_buffer_past_its_buffers_length_is_made_as_metals makes the measured
shape over host memory and checks four things:
- a kernel's read and a blit read the buffer's bytes inside the length, and
zero past it;
- a CPU write of the buffer reaches the next read;
- a blit's write lands in the buffer inside the length and in the tail past
it, and changes no byte outside the buffer;
- one past a 16 KiB buffer's allocation is nil.
The design doc said the Vulkan platform dies on setTriangleFillMode: 2, which
Apple's GL renderer sends for glPolygonMode(GL_POINT). That has not been so
since metal2vulkan's RUNTIME 2246, in the pinned commit: the runtime draws the
mode as VK_POLYGON_MODE_POINT where the device has fillModeNonSolid (and
pointPolygons on a portability subset), as the M3 Max draws it, and refuses it
elsewhere. The renderer's AMD settings send the mode too (read from its
settings records), which the doc left out. The Apple5 paragraph loses the
death as a reason, since it no longer holds.
The bundle's comment on encodeSignalEventScheduled:value: and the oracle's
SPI row both point at dgpu-oracle.md's Q43 for what an Apple GPU's command
buffer does with a scheduled signal. That entry merged as Q45, two released
state and bit-24 entries having taken Q43 and Q44 first; Q43 is now the
released state's.
The device drops the routes on a doorbell page of its old context's queues
when a DOORBELL_PAGE_BIND write binds the page to another context, on the
host's thread that writes the register. The module doc still said such a
route stayed until its queue ended, and neither it, the host trait's
unroute_doorbell nor docs/api.md named the register write among the calls
that drop a route on the caller's thread, where the host must not wait for
a lock it holds around the call.
The framebuffer wrote ring 0's doorbell inside submitLock, a spin lock, so
every other CPU's post to the control ring waited out the write's exit to
the host. It now publishes and reads whether the host's consumer sleeps
under the lock (rgfxControlPublishWantsBell), and writes DOORBELL once it
has let the lock go, in tryPost and in a batch's post. The order of the
ring's messages is the producer's, which the lock still keeps; the
doorbell is only a wake, and two posts that both find the consumer asleep
ring it twice, as they could before. The guest and the host see the same
messages, doorbells and order.
Where the host offers DOORBELL_PAGES the framebuffer takes it, and the
accelerator maps BAR 4 into the kernel at its contexts' start. A context
opened for a bundle that asks for OpenContext's seventh output (kext
feature 1 << 12, DoorbellPage) gets a free page, taken round-robin: the
kext binds it to the context with DOORBELL_PAGE_BIND before the process
learns of it, and maps it into the process uncached, its address the
seventh output. The bundle then rings a queue with one 32-bit store of the
ring's id at the page (a DMB OSHST first on arm64, and one STR of a W
register, the form a hypervisor decodes from its abort's syndrome), where
it called the kext before. The kext's own publish of a queue's ring rings
at the page too, where the host routes the queue's doorbell now. At the
context's close the page is unmapped from the process with its window,
then unbound, then given back.
A context with no page (a host without the pages, every page held, a
context numbered 2^24 or more, or a mapping that failed) answers 0 and its
process rings through the Doorbell call as before.
Ambrosia's driver module places BAR 4 between BAR 0 and BAR 2, so an arm64
guest's kernel finds it assigned; BAR 2 keeps its address.
A guest's single commit costs 5.4 us against 2.9-3.1 on a native Mac, and
about 1.5 us of it is the bundle's call into the kext to write DOORBELL.
The device now has a BAR 4 of 256 doorbell pages of 16 KiB, which a guest
binds to its contexts through DOORBELL_PAGE_BIND (0x040, `page | context <<
8`) where it took DOORBELL_PAGES (feature bit 46). A page is its context's
own DOORBELL: a write of a ring's id at its first byte wakes that ring
where it is one of the context's queues', and is answered at the doorbell
as there when it asks. Every other write is dropped and counted, logged
once per kind: at an unbound page or another offset (`unbound`), or of
ring 0 or another context's ring (`foreign`). Reads answer 0. A reset
unbinds every page.
A queue of a context with a page is routed on the page's doorbell
(`route_doorbell_page`), and on DOORBELL otherwise. A page bound to another
context drops the routes on it of its old context's queues, so the host
wakes no ring at a page but its context's.
What the host and guest see:
- the C API: `rvg_graphics_device_doorbell_write`, the config's
`doorbell_pages` (third version) and the callbacks' `route_doorbell_page`
(third version), whose thread docs/api.md section 5 names;
- FEATURES_HI bit 14 is offered only where the host sets `doorbell_pages`;
- QEMU's reims-graphics-pci (b4771167) maps BAR 4 and offers the pages;
- a guest that does not take the bit, or a host that does not offer it,
has every doorbell on DOORBELL as before: the bind is ignored and every
BAR 4 write dropped (`without_doorbell_pages_the_doorbells_are_the_register_s`).
The wire header's change rewrites the option ROM's record; its bytes are
the same.
dgpu-oracle.md Q43: when encodeSignalEventScheduled:value: sets its shared
event on the M3 Max, with which value and in which order against the
buffer's GPU work, its signals and its waits, what each misuse does, who
sends it in macOS 27 (MPSGraph's Neural Engine region op alone), and what an
arm64 guest's buffers now do with it, with where they are later than Metal.
A command buffer longer than its queue's service thread walks itself goes to
its queue's lane, whose parked thread was woken only once the buffer was begun.
On the Iris Xe host, Geekbench 7.1's Super Resolution hands 4092 buffers a pass
to idle lanes, and each waited 10.1 us at the median, 58.0 ms of the pass, from
the hand-off to its walk's start: nearly all of it the thread's wake.
Now the service thread wakes the lane's last idle thread once the buffer's
turn is taken (Lane::expect), and that thread spins for the job for at most
EXPECT_SPIN, 50 us, which is above the whole begin's 99th percentile of
30.6 us. So the wake happens during the rest of the begin. A long buffer that
is walked in its turn on the service thread withdraws the expectation. Jobs,
their order and turns, and every record and interrupt stay as they were; only
when the thread wakes changes. The spin is timed on the keep's clock
(Keep::passed).
Measured with the SR walk on ms01's Iris Xe, before (m3-max-30439, development
plus the begin tracers) against after (m3-max-30453, this change plus the same
tracers and a spin tracer):
- hand-off to walk start: 58.0 -> 36.0 ms a pass (p50 10.1 -> 4.2 us);
- the begin: +9.1 ms, because the wake's call moved into it;
- take to walk start: 136.7 -> 123.9 ms, -12.8 +- 3.7 ms (8 paired slices);
over the pass's 11 workloads, -22.0 +- 6.5 ms;
- the spins: 11.3 ms in SR and 27.1 ms over the pass (p50 4.1 us), and 99.3%
of them ended with their job before the bound;
- SR's wall time and graphics-thread CPU per dispatch are unchanged within
noise: 44.35 -> 44.37 s, and 198.5 -> 205.4 us per dispatch (+4.8 +- 4.0%
paired, as walk_ops, which this does not touch, moved +5.8 +- 3.3 us).
Walking such buffers on the service thread at any length was rejected because
three things would wait for the walk: a SCHEDULED_ASK, which only that thread
takes; the queue's later buffers, which would be begun after it and so walk
one at a time, ending the lane's walks ahead; and the submission ring's room.
Tests: a_long_buffer_wakes_its_idle_lane_s_thread_as_it_is_begun, and the
lane's an_expected_job_starts_on_the_thread_woken_for_it,
an_expected_job_that_comes_after_the_spin_wakes_its_thread_as_it_comes,
a_withdrawn_expectation_or_the_close_ends_the_spin_at_once and
an_expectation_wakes_only_an_idle_thread_and_one_at_a_time.
DIES_BY_DEFAULT listed three runtime degradations that ended QEMU in
every mode: ReleasedCommandState, PrivateResourceOption and
HostDeallocatorDelayed. No Mac ends the process in any of them
(dgpu-oracle.md Q43 and Q44, new here, beside Q38):
- ReleasedCommandState: a record a kernel wrote naming a state released
before the write runs that state's program on the M3 Max and the UHD
Graphics 630, and fails its command buffer with a timeout on the Radeon
Pro 5300M; the runtime runs nothing there. A record naming the ID the
CPU set, which another state took before the GPU's write, runs the CPU's
state, where the M3 Max and the 5300M run the state that took the ID.
The death came on the runtime's scheduler thread, naming no command
buffer, so the 5300M's failed command buffer is not ours to give.
- PrivateResourceOption: a guest's Private heap or indirect command
buffer made with MTLResourceOptions bit 24 is made as without it. The
M3 Max keeps the GPU's writes from such memory, a kernel's records
included; the 5300M and the 630, which the x86-64 lane imitates, write
it as without the bit.
- HostDeallocatorDelayed: the runtime delays a no-copy buffer's
deallocator only for a release with no keep-alive, and every no-copy
buffer and heap this platform makes gives one, so it is never
announced here.
The accuracy ledger's rule is that a difference is logged and the
process runs on, ending only where Metal ends it or where an operation
cannot run at all. The list goes: each kind is relayed by default,
counted, its first line written, and dies in strict mode as every other
kind of DIES does. The runtime now announces them once per device by
default, as it does the rest of DIES. Each exact answer is the runtime's
to build (the program of an ID's last released holder kept, a record's
state told written by the GPU or set by the CPU, and the M3 Max's drop of
the GPU's writes into bit-24 memory).
answer.rs's PrivateResourceOption doc said the runtime announced no-copy
memory of the bit off macOS; at this pin it makes such memory over a
copy that drops the GPU's writes, unannounced.
Tests: the placement tests expect the three relayed by default and
dying in strict mode. New device tests reach each kind under the
default: an execution of a record a kernel wrote naming a state
released before the write (the command buffer completes with no error,
the command runs nothing, the kind is counted once and the device goes
on), a Private heap and an indirect command buffer of bit 24 (made, the
GPU's write landing, counted once), and a release whose import another
buffer holds (the deallocator runs at the release, nothing announced).
A test-only process-wide relaxed mode covers notices on the runtime's
own threads, sound under nextest's one process per test.
For the guest and the host: a run that meets one of these kinds goes on,
where it ended before. The guest sees the command run nothing or run the
state the CPU set, or the resource made as without bit 24; the host sees
the kind's line once and its count.
A command's answer given off the control thread (CompleteAnswer::answer, and
PresentAnswer, its alias) waited for room on the control completion ring on
the thread that gave it. Those threads include metal2vulkan's that run a
command buffer's handlers: a drain's last clone answers CONTEXT_CLOSE or
BLOCK_RELEASE there, a display hold's release answers BLOCK_RELEASE there, and
a present with no window is answered there. A full control ring then held up
every queue's completions behind the handler, which the runtime's contract
for those handlers forbids.
Such an answer now posts at once only where the ring has room and no answer
is handed over before it. Otherwise it is handed to the control thread, which
posts the answers in their order at the top of its loop, waiting for room, and
before its own. Every post onto the ring that waits goes behind them, a tried
post is busy while they wait, and a download answered on the doorbell's
thread is left to the control thread, so the guest sees the answers in the
order they were given, as before.
What the guest sees changes only while answers wait to be posted: a VBLANK
then is dropped and counted as on a full ring (vblank-dropped), and a
DISPLAY_CHANGED is told at a later refresh. The full spell is told by the
control thread's post, never on a platform thread.
A device test fills the ring, gives an answer, which returns at once, and
checks the order in which the guest then takes the ring:
an_answer_given_onto_a_full_control_ring_waits_for_nothing_and_keeps_its_place.
A graphics test runs a completion handler that ends a close's drain while the
guest holds the control ring full:
a_seen_handler_that_ends_a_drain_waits_for_no_room_on_the_control_ring.
A decoder buffer's records went onto its queue's completion ring through
posts that waited, with no bound, for the guest to make room. They waited on
whichever thread posted them. The completion-seen handler (EVENT_SIGNALLED
values, CB_COMPLETE) runs on the platform's waiter, where a wait holds every
queue's completions. The submission handler (CB_SUBMITTED, CB_SCHEDULED) runs
on the platform's scheduler thread, or on any thread whose commit submits
ready batches, where a wait holds every queue's submissions. The record
mutexes held across those posts (Submitted, Scheduled, the queue's Line, a
buffer's Signals) coupled them: a lane waiting inside Line::post_through held
the mutex the scheduler thread's submission handler then waited for.
metal2vulkan's handlers must never block.
CompletionPoster::post_unwaiting posts a record on the calling thread where
nothing is handed over before it on the ring and the ring has room, and
otherwise hands it over behind those records. It also posts as many of them
as the ring takes now, in order.
- The queue's service thread posts the rest as room comes: it looks at the
device's 1 ms poll while records wait, and takes the guest's buffers
meanwhile.
- Every later post onto the ring, from any thread, goes behind them.
- What follows a record runs right after the record is posted, or is dropped
at a reset or the queue's end: a value's fan-out to the other holders of the
event's name, the shows of the presents waiting for the buffer, and the
answers waiting for its context's drain.
So the guest sees every record, fan-out and answer in the order it saw them
when the handler waited. The decoder's four record sinks post this way from
every thread. A foreign committer still hands its records over without
posting. The full spells and waits of handed records are told on the service
thread (queue-ring-full, queue-ring-post-waited), never on a thread that hands
them over.
a_read_of_the_display_calls_nothing_back_and_waits_for_no_full_ring changes.
It said the first buffer's completion waits on its completion thread for
room, and it counted 2 records handed over in all. The completion now hands
what the ring has no room for to the queue's service thread and returns, so
those records count as handed over too. The test asserts that some were, and
that the read's commit hands over 2 more.
A post onto a command queue's completion ring that finds no room waits, with
no bound, until the guest's process takes more. Nothing counted or logged
those waits, so a stall behind a full ring, on a thread that runs the
platform's handlers among them, left no trace in a boot's log.
The device now tells its host, as it does for the control ring, each full
spell of a queue's ring (queue-ring-full) at its first post that waits and
finds no room, and each post that waited (queue-ring-post-waited) once it goes
on. Their lines name the queue and the thread that waits, and the codes reach
the process's degradation counts. Diagnostics alone: no post changes.
Live Text and Vision's accurate text recognition find nothing in arm64 macOS
27 guests: 27 ships only E5 models for Latin text and TextRecognition
compiles them for the Neural Engine alone, which vmapple does not give a
guest (Virtualization.framework gives a virtio one, whose kext 27 ships).
14, 15 and 26 run their Espresso models on the CPU in a VM, and x86-64
guests on our GPU, and read the text. The section records the measured
answers, the failure's exception, and what a fix would need, so the next
look starts from them.
A GL tessellated draw stayed in software after its kernel was made, for two
more causes the same boot showed: a reflection answered nil and a refused
render pipeline. The renderer says nothing of either, so the lesson is to
read every refusal and every reflection a draw's objects get.
The renderer makes a tessellated draw's vertex and control shaders one kernel
that takes the draw's vertices as a patch control point input, and makes its
compute pipeline under a stage input descriptor. Metal compiles that input in
no kernel (m3-max-30197): its own devices define the input's control point
function from the descriptor. The device's pipeline of the kernel was refused,
and the renderer drew the draw's vertex and control stages in software.
A kernel variant with the input now keeps its module's text, and its compute
pipeline is made of the kernel made one without the input under the
pipeline's descriptor, once per descriptor: a wrapper kernel of the same name
takes the buffers the fields read and the stage input region's origin, and
the control point function, defined in place of its declaration, fetches each
field as Metal's [[stage_in]] fetch does. The pipeline answers the variant's
reflection. GL tessellated draws run on the GPU where the renderer drew them
in software.
The fetch matches the M3 Max's own [[stage_in]] kernels bit for bit, for every
attribute format and step function (gl_tests' stage input oracle,
m3-max-30314), which measured two of its conversions: Int1010102Normalized's
10-bit components are c times the float nearest 1/511, and RG11B10Float's
NaNs are 0x7fc00000.
A cold guest thread wake on um870 waits 48 to 52 us on the host, most of it
the CPU leaving C3, so per-VM halt polling (KVM_CAP_HALT_POLL) looked like a
lever for our QEMU. Measured at 200 us, 1 ms and 4 ms on um870's 780M and
ms01's Iris: 4 ms takes the cold wake away but costs 16 to 18 W while Safari
plays a video and half a CPU over a Geekbench pass, for 2% on um870 and
nothing on ms01; 1 ms is inside the noise. So QEMU keeps the host's
kvm.halt_poll_ns, and reims-ctl gives no cpu-pm, which holds a host CPU per
idle vCPU.
The doc said halt polling is a module parameter QEMU cannot set; a VM can
set its own, and the new section says why ours does not.
What the guest sees changes: the device answers targetDeviceArchitecture
(MTLDeviceSPI) with an MTLTargetDeviceArchitecture, Metal's own class, of
cpuType 0x01005247, subType 0, version 1.0.0 and driverVersion 0x10000. It
answered nil, the IOGPU base's answer.
Metal's loader ends the process at nil (+[MTLLoader sliceIDForDevice:
legacyDriverVersion:airntDriverVersion:]), and MTLAssetUpgraderD, which asks
Metal's archive reader about every .metallib of an app it is told of for
every device, ended with SIGABRT at each app installed in the guest: 1-2
reports in every walk since pin 70, on Iris and the 3090.
Every Mac answers an object (oracle_archtype: AMD 5300M, Intel UHD 630, M3
Max, dgpu-oracle.md Q42), so nil is outside the envelope. The values name
each GPU's own compiler target, so the device names its own: CPU_ARCH_ABI64
with its PCI device id, which no Metal slice carries, so no archive holds a
slice Metal reads as this device's; one target whatever the host GPU; and
one version for both version fields, as the M3 Max and the Intel 630 answer.
Where the guest's Metal lacks the class or its setters, nil as before.
inherited_tests now checks the answer, and the register's line says why it
changed.
Step 3's Super Resolution walk on the Radeon 780M at development cee5813f2
(m3-max-29610) replaces the numbers from an older pin: 3480 of 6289 command
buffers waited at the gate for their context's held creates and destroys, 138
ms in all; carrying them out on the queue's thread cuts 42.5 ms of that
(simulated on the trace), under a walk's run-to-run spread. A bounded wait
without sleeping, measured against the same trace, could save at most 17 ms
for 34 ms of spinning, and was dropped.
A command buffer's queue thread waited at the gate while a ring-0 thread was
woken for its context's lane, then was woken itself once the lane was through.
Geekbench Metal's Super Resolution waits so for the BUFFER_AT_OFFSET creates and
OBJECT_DESTROYs the bundle flushes ahead of each commit: on the 780M, 4172 of
6823 buffers waited, 62.6 us at the median and 190 at the 90th percentile from
take to host begin, 12 and 38.5 of it the queue thread's own wake after the
last job (rtsr's walk A).
Now the queue thread carries out the lane's front job itself where the lane's
thread carries none out yet, the buffer waits for it, it is ready, and it is a
BUFFER_AT_OFFSET or an OBJECT_DESTROY of no queue (a queue's destroy routes its
doorbell, and the other kinds may wait long). The job is the lane's running one
meanwhile, so the lane's thread waits for it before its next: the lane keeps
one job at a time in ring order, and every wait for the lane sees it as before.
The buffer waits for the same messages, carried out through the same code
before its begin; only the thread that carries them out changes.
Tested by the new device tests in help.rs: with ring 0's threads holding off,
the buffer's thread carries its creates and destroy out in ring order, once,
before the buffer; it leaves an event's create to the lane's thread; what it
may take; and random runs of creates, destroys, slow messages and buffers keep
every buffer after its context's messages and ring 0 in order.
A 4-sample BGRA8Unorm or BGRA8Unorm_sRGB attachment's MultisampleResolve or
StoreAndMultisampleResolve into an RGBA16Float, BGR10_XR or BGR10_XR_sRGB
texture the guest made over an IOSurface ended the process at the pass's
making, named "not measured". The device makes such a texture over the
buffer that stands for the surface (new_texture_over_surface_plane), and
the drop of that resolve was measured only for textures of their own memory,
shareable ones and textures over an OS IOSurface.
oracle_surfresolve measured the rest (dgpu-oracle.md Q41). The M3 Max leaves
the texture untouched over a surface without planes and over planes 0 and 1
of a 420v surface, Shared, Managed and Private, as it does a texture of its
own (m3-max-29682, m3-max-29690). The 5300M and the UHD 630 write
RGBA16Float in every shape and make no XR texture (m3-max-29683, 29684,
29691, 29692). The GPUs differ, and the drop is the M3 Max's answer, which
costs nothing, as the runtime resolves into no other format.
So a texture over a surface's plane now tells itself apart (OverSurface;
Over::Surface and Over::Plane), and the drop takes it in any storage mode,
which the device picks (Private over a device cache), not the guest. A
dropped resolve no longer counts as a store into read-only memory: such a
pass completes with the memory unchanged, as the M3 Max completes it (Q38).
For the guest: such a pass now completes, the texture keeping its texels and
the samples kept as by DontCare or Store, where the process ended. A texture
over a buffer that stands for no surface still dies, named. The Metal
comparison test gets its IOSurface shapes back over stand-ins, and two new
tests hold the drop over surfaces and over read-only memory.
The design's account of a commit's kext call said its time in the kernel was
not yet split. The kext's kdebug stamps split it in Geekbench's Metal Super
Resolution on the 780M host: the framebuffer look-up each post made (16.1 of
33.3 us p50) was the guest kernel's own code, and the rest is the host's exits
and the system call's entry and return. It now records that split, what the
lane's cuts left (18.9 us p50, the doorbell exits and the call's entry and
return) and the commit's time before and after on the 780M and the Iris Xe.
The completion thread's arm-once paragraph now names the kext's take of ring
0's completion ring, which keeps the same rule (ReimsGraphics::takeCompletions,
RgfxCompletionArm.hpp, completion_arm_test).