Commit Graph
786 Commits
Author SHA1 Message Date
Anees Iqbal e89df2c8f3 🆕 Seed the kext's shared pipelines from the device's kept answers
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.
2026-11-14 20:26:38 -08:00
Anees Iqbal 032e8c937c 🆕 Name the wire's PIPELINE_ANSWERS feature and query
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).
2026-11-14 20:26:38 -08:00
Anees Iqbal d4940536d4 📝 Record when pa's capture holds a record stream [ci skip]
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.
2026-11-14 20:25:35 -08:00
Anees Iqbal c103f8fe03 🐛 Answer nil for a texture past an Apple GPU's buffer allocation
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.
2026-11-14 19:13:43 -08:00
Anees Iqbal 5c49ec8aaa 🐛 Make a texture buffer whose texels run past its buffer's end
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.
2026-11-14 19:13:43 -08:00
Anees Iqbal ac0c562f43 📝 Say the platform draws GL's point polygons as points [ci skip]
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.
2026-11-14 18:31:31 -08:00
Anees Iqbal e4d0911066 📝 Name the scheduled signal's oracle entry by its number, Q45
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.
2026-11-14 18:01:39 -08:00
Anees Iqbal 5c1dd4f2e1 📝 Say where a rebound doorbell page drops its old routes
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.
2026-11-14 18:01:16 -08:00
Anees Iqbal 8a738391d7 🐎 Ring ring 0's doorbell out of its submit lock
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.
2026-11-14 18:01:06 -08:00
Anees Iqbal 1c8ae23515 🆕 Ring a context's queues at its doorbell page
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.
2026-11-14 18:01:06 -08:00
Anees Iqbal 18a87b6026 🆕 Give the device doorbell pages in BAR 4
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.
2026-11-14 18:01:06 -08:00
Anees Iqbal b89f7444a3 📝 Record what a scheduled event signal does on an Apple GPU [ci skip]
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.
2026-11-14 17:58:46 -08:00
Anees Iqbal 03a0ee2cc1 🐎 Wake a lane's idle thread as its long buffer is begun
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.
2026-11-14 17:58:31 -08:00
Anees Iqbal 3c47efc458 🐛 Relay by default the kinds that ended the process
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.
2026-11-14 16:35:04 -08:00
Anees Iqbal c68174680d 🐛 Give the control ring's answers without waiting for room
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.
2026-11-14 16:35:03 -08:00
Anees Iqbal 4d893084a6 🐛 Post a command buffer's records without waiting for room
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.
2026-11-14 16:35:03 -08:00
Anees Iqbal d00f2adab2 🆕 Count and log room waits on queue completion rings
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.
2026-11-14 16:35:03 -08:00
Anees Iqbal b37e44b9bd 📝 Record what arm64 guests do without a Neural Engine [ci skip]
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.
2026-11-14 16:28:55 -08:00
Anees Iqbal 51b141b586 📝 Record the GL renderer's silent software fallback [ci skip]
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.
2026-11-14 15:16:51 -08:00
Anees Iqbal 32dd62ef28 🐛 Make a GL tessellated draw's kernel one Metal compiles
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.
2026-11-14 15:16:50 -08:00
Anees Iqbal 3c6aca62b9 📝 Record what KVM halt polling costs on the Linux hosts [ci skip]
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.
2026-11-14 14:14:46 -08:00
Anees Iqbal e33c569c9c 🐛 Answer the device's own compiler target, never nil
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.
2026-11-14 13:39:38 -08:00
Anees Iqbal c70c0ec328 📝 Give the measured wait for held creates and the help's cut [ci skip]
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.
2026-11-14 10:14:02 -08:00
Anees Iqbal ab8958afd0 🐎 Carry out the creates a buffer waits for on its queue's thread
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.
2026-11-14 10:14:02 -08:00
Anees Iqbal 8e97a01eeb 🐛 Drop untouched resolves into textures over a surface's planes
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.
2026-11-14 10:04:24 -08:00
Anees Iqbal 544d741f4f 📝 Split SubmitBatch's time and add the kext's arm-once [ci skip]
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).
2026-11-14 10:01:56 -08:00
Anees Iqbal a66f2b91f6 🐎 Publish a commit's buffer in the kext call that posts the held
A command buffer committed while the control ring held messages made two kext
calls: SubmitBatch posted the held, then the bundle published the buffer on
its queue's ring and rang the queue's doorbell through the kext. The second
call costs its kernel entry and return around the doorbell's write: measured
with the commit probe and the kext's stamps at 4.6 us p50 a commit on the Iris
Xe host (1.3 in, 2.0 the write, 1.2 out), and on the 780M host 4.5 us warm and
11.3 us after 2 ms idle (3.2 in, 2.7 out). Every commit the probe made behind
held messages rang it.

Where the kext answers kRgfxKextFeatureQueuePublish, SubmitBatch takes three
scalars more: the queue, its ring's new producer and the doorbell's flags. The
bundle writes the buffer on its ring and fences its stores, leaves the
producer, and hands the publish to the held (RgfxRingWriter::tryPost's `via`,
RgfxSerializer::publishVia). Once the kext has posted every held message it
stores the producer, fences, reads consumer_idle and rings the doorbell as the
bundle's own publish does (RgfxQueuePublish.hpp), so the host sees the held on
ring 0, then the buffer, as before. A commit with nothing held, or behind an
indirect command buffer's encodes or a refused destroy, goes as before; so
does every commit with a kext that lacks the bit. Where the kext leaves a held
message other than a destroy unposted it publishes nothing, and the bundle
takes the buffer off its ring unseen, its seqno the next buffer's and its
expected records dropped (RgfxReplyReader::forget), and fails it as before.
The buffer's posted time is stamped before the call.

The kext maps each queue's submission ring header at QUEUE_CREATE, while the
ring's block is pinned, only where the block is the client's own (ownsBlock),
in RgfxAcceleratorUserClient::keepQueueHeader. It lets the mapping go before
the pages can: at the queue's destroy (destroyQueueIfTracked), at Free of the
block the ring lies in, before the free, and at the context's close
(releaseContext, before the window and the blocks go). Each publish runs under
the client's list lock, which every drop takes. A device reset frees no block:
the mapping stays the process's ring until one of those. A queue past the
client's first 64 is published by the bundle.

Tests: queue_publish_test (the kext's publish against the bundle's own, every
consumer state and flag, and the headers' table through create, free, destroy
and close), shell_tests' test_commit_hands_its_publish_to_the_held (one call,
nothing held, a kext without the bit, a refused create, refused destroys
alone) and user_client_words_test (the bit).
2026-11-14 10:01:56 -08:00
Anees Iqbal d3cd30088b 🔥 Delete the import twins, the files of zeros and their budget
A writable twin of read-only pages was made only for a surface's read-only
alias, and a file of zeros only for an alias's block past its ranges: both
went with the host-OS surfaces, which no production path has made since
110b53637. So import_view loses its twin argument, and with it the twins'
map (shown_at), their mappings in the views' budget, the notwin refusal and
its trace record. Read-only pages are given to the runtime as they are, and
the views' gate refuses them, so the runtime copies them, as before.

The dma-buf sources lose their files of zeros (Zeros), which only those
blocks' pages took, and the budget's claims their reach, as only a twin
reached into the headroom. An import's pages are made once, so its record
says whether that import is still being made rather than how many are. The
remap, budget, vm, files and host_ram docs, qemu.md, lessons.md,
architecture.md and conventions.md no longer describe the twins, the
stand-in or the IOSurface memory the library held; the measured facts about
what a remap under an import reads stay in remap.rs. ResourceAddressRange,
which only the surface aliases gathered, goes.

Nothing the guest or host observes changes, as no production path has made
an OS surface since 110b53637.
2026-11-14 09:27:31 -08:00
Anees Iqbal 5a31c8ab28 🔥 Delete the host-OS surfaces and the checks only they reached
Since 110b53637 nothing in production makes a host-OS surface: the
reims-graphics device's surfaces reach the Vulkan platform as buffers, and a
texture over a surface's plane is made with new_texture_over_surface_plane.
Only tests made IOSurfaces, and the previous commit moved those onto that
creator.

So the platform's surfaces go: the Surfaces trait and Platform::surfaces,
GpuDevice::new_buffer_on_surface and new_texture_on_surface, the resources'
iosurface getters, the OS modules (os/surface.rs, os/linux/surface.rs,
os/macos/iosurface.rs) and the testkit's counted surfaces. With them goes
what only an object over an OS surface reached:
- metal_space's surface ranges and Over::Surface/Over::Plane;
- backing.rs's surface aliases (Alias, gather_or_nil, its zeros);
- writes.rs's bound-memory and slot-writes queries, and encode_render's
  Reach and binds, which decided the refused writes of 523 and 527 into a
  texture over a surface, with the compute pipelines' kept descriptors that
  only those queries read (a render pipeline keeps its guest descriptor,
  which its encoders read);
- predication's dropped texel writes, and the message layer's fatal_send;
- allocate_zeros, TWINS_READ_ONLY and an import's second making on Linux.

The measured facts the live path relies on stay, in the live modules' docs:
metal_space's (the surfaces' address ranges Metal gives), ycbcr.rs's
("Writes": which YCbCr writes Metal stores, drops, or changes by a rule the
runtime does not hold) and resource.rs's (the plane Metal asserts or answers
nil at). out_of_host_memory is Linux's alone now, as only Linux's views and
imports run out of memory short of Metal. docs/architecture.md,
development.md and qemu.md no longer describe the OS surfaces.

Nothing the guest or host observes changes, as no production path has made
an OS surface since 110b53637.
2026-11-14 09:27:31 -08:00
Anees Iqbal a2e110a8db 📝 Record what Metal stores through an argument buffer in Q40 [ci skip]
On the M3 Max a kernel's write through an argument buffer of 500, 503, 507, 523
and 527 stores the same bytes into both planes as the write through a slot: the
4:4:4 formats their codes, 500 nothing. metal2vulkan asked for it before taking
the slot answers for the writes it refuses through an argument buffer; the
platform's own refusal stays as it is until the runtime stores them.
2026-11-14 09:23:30 -08:00
Anees Iqbal 694f2178f3 🐛 Complete a depth resolve into read-only memory as Metal's GPU does
A depth attachment's StoreAndMultisampleResolve into a resolve texture over a
guest's read-only memory (bit 24, or pages mapped read-only) ended the process
where the pass was made, or at the late store action or resolve texture, as the
runtime faulted it where the M3 Max completes it with the texture unchanged.
The runtime now stores the attachment and drops the resolve (metal2vulkan
RUNTIME 2298, in this pin), so the pass is sent and the command buffer
completes with the pages unchanged, for the descriptor's action and a late one,
into the descriptor's resolve texture or one the setter's SPI named. That is the
M3 Max's answer, given to every guest; the x86 Macs write the texture.

Beside a stencil attachment that resolves, or whose store action is still
Unknown, the runtime faults the pass, and nothing measured Metal's GPU there, so
that pairing still dies at the same three sites. A late resolve texture over
such memory for an attachment the pass lacks still dies too: RUNTIME 2298 does
not reach it. The tests that held the death now assert completion with the
pages zeros, and the pairing's death at each site.
2026-11-14 09:23:11 -08:00
Anees Iqbal 51fae61024 📝 Record Q39's two-way failures and Q40's twin writes [ci skip]
Q39 gives what the M3 Max, the AMD 5300M and the Intel UHD 630 answer for a
command buffer that protection options fail, alone and beside a store into
read-only memory, with the job ids and OS builds, and what the platform now
answers. Q40 gives the bytes Metal stores through 523 and 527 on the M3 Max,
which the x86 Macs do not make, and where the runtime refuses those writes.
2026-11-14 09:15:10 -08:00
Anees Iqbal c1fcbf5fd1 🔥 Drop read-only surfaces and the deaths through their twins
Only tests have made host-OS IOSurfaces since 110b53637: no production caller
reaches the platform's surfaces, so nothing the guest or the host observes
changes. The client direction goes from SurfaceSpec, so no surface is
read-only for the GPU, and with it what answered writes through one:
- Kept::Always, the deaths through a read-only surface's writable twin (a
  pass's attachment, resolve or visibility results, a draw's or dispatch's
  write, a blit), and the count of kept objects only those deaths read;
- the dropped-write class: gpu_read_only on buffers and textures, the blit
  extents measured to drop, the swizzled views and usage bits answered over
  read-only surfaces, the CPU write through a twin;
- macOS's kIOSurfaceClientDirection key and the Linux surface's read-only
  view of the guest's pages.

Read-only memory the runtime copies (Kept::Copied) is answered as before: the
pass-level check of a depth StoreAndMultisampleResolve into it now gates on
COPIES_READ_ONLY, which equals TWINS_READ_ONLY on both hosts. The tests of the
twin class go; those of the live classes bind the YCbCr formats whose writes
the runtime refuses instead. The measured swizzle-usage and Unknown-usage
facts move to view()'s and gpu::desc's docs, and the accuracy ledger's
read-only row keeps the guest's read-only objects alone.
2026-11-14 08:30:30 -08:00
Anees Iqbal 372f39e877 🔥 Delete the client-direction tests of host-made surfaces
tests/client_direction.rs made host-OS IOSurfaces read-only for the GPU
(kIOSurfaceClientDirection) and wrote through them, its blit test faulting a
Mac's GPU on purpose. No production caller has made a host-OS IOSurface since
110b53637: the reims-graphics device's surfaces are the guest's pages, which
the library reaches through buffers, so nothing the guest or the host observes
changes. nextest's override for the fault test goes with it, since a filter
that names a binary the workspace no longer has fails every run, and the
lesson it taught says the test was deleted.
2026-11-14 08:30:30 -08:00
Anees Iqbal cee5813f21 📝 Record that a wrapper must forward a HostVm default [ci skip]
Group dma-bufs were implemented on LinuxVm and FakeVm, and every test passed,
while remap::VulkanVm, the VM the devices are given, answered the trait's
default: a Geekbench walk on the 780M grouped no view. view_mappings had the
same gap. Record the trap, the lint that now keeps it shut and its sign, a
feature's counter at 0 on the hardware it is for.
2026-11-14 08:07:42 -08:00
Anees Iqbal 0650f401dc 📝 Give grouping's measured import counts and its projected gain [ci skip]
The design's figure of about 1,000 imports at Geekbench Metal Super
Resolution's midpoint counted no-copy objects, not imports. A third walk on
the Radeon 780M (2026-11-14) read the imports directly, from debugfs's
amdgpu_gem_info and the runtime's dma_buf_memories_live gauge. About 580 were
live, under about 1,573 no-copy objects, of the 945 buffer objects the process
held; about 605 of those are the runtime's own memory by its gauges.
vkQueueSubmit took about 494 us a batch.

The design doc and the module doc now give those numbers. The projected gain
becomes a batch of about 250 us or less. Feature Matching, Particle Physics
and Fluid Simulation hold 2,000 to 8,700 other buffer objects that are not
the runtime's, so grouping cuts less there. The replay's 81 to 86% is stated
as a cut in the live views' imports, which is what it measured.
2026-11-14 08:07:42 -08:00
Anees Iqbal e9e9fb73b8 🐎 Group a context's pages blocks' views into shared dma-bufs
On RADV each live view of a pages block is a dma-buf import of its own, and
every vkQueueSubmit lists every import, at about 0.45 us each. Geekbench
Metal's Super Resolution holds about 1,000 of them at its midpoint, and its
submits took about 450 us (Radeon 780M, macOS 26.7.2 guest).

The surface worker now gathers a context's views for a short window and has
the platform put them in one shared file, so the driver lists one import per
group instead of one per view.

How a group forms:
- The BUFFER_OVER_PAGES or HEAP_OVER_PAGES job that makes a block's view
  maps it and joins its context's open group (SurfaceViews::join_group).
- A group stays open 1 ms from its first member, or until its runs or bytes
  reach the platform's limits.
- A job of its own, under the context's key, then seals it: group_views,
  then each view's import, made as a piece of its file.
- The seal hands back the members' messages in their order, those that
  joined while it sealed among them.
- The context's and the blocks' settles drop only after that, so the guest's
  later messages still see each buffer as right after its create.

What takes no group: a view over 16 MiB, a view past a group's limits alone,
a cached view, a heap over the guest's RAM, a read-only block, and a bit-24
buffer (the last two are made over a copy).

What falls back:
- A view the platform leaves alone, or whose piece the runtime refuses,
  leaves its group and is made alone.
- A context's close and the device's reset drop the groups being formed.

The guest sees the same objects, GPU addresses, refusals and order of events.
Only the timing changes: the first message after a burst waits up to 1 ms
more. Where the platform answers no limits (NVIDIA, ANV, the Mac), nothing
changes at all.

The views log line counts the grouped views and the groups.
docs/graphics-kext/design.md says what the guest sees, and that a member
whose buffers went keeps its pages pinned in its group's import, with each
group's bytes capped at 64 MiB.

Tests, all on the fake platform's virtual clock:
- a burst shares one group;
- contexts never share one;
- a reset or a close inside the window makes nothing;
- a refused group, and a refused piece, fall back per view;
- a view past 16 MiB and a read-only buffer take no group;
- a group closes at its limits.
2026-11-14 08:07:42 -08:00
Anees Iqbal 21906bbf3a 📝 Record ring 0's write-combined data and the arm-once [ci skip]
design.md's region notes now say how the kext writes ring 0's submit data
(write-combined on x86-64, fenced before the producer; arm64 as before) and
what it measured: a SubmitBatch call on the 780M host went from 33.6 to
31.3 us p50, so the data's stores were a small part of it. The interrupt
notes say the completion thread arms an idle ring once and stores consumer
only on a take, which ring/interleavings.rs walks.
2026-11-14 07:50:59 -08:00
Anees Iqbal 788561ff8f 📝 Record Metal's order of waits against handlers that block [ci skip]
oracle_waits on the 5300M, the 630 and the M3 Max: a queue's statuses,
handlers and waits run in one order on its completion queue. A status changes
before its stage's handlers, waits return only after them, and a handler that
blocks holds everything of its queue after it. Our delivery keeps that order.
The probe now counts a status its polling thread never read apart.
2026-11-14 07:50:59 -08:00
Anees Iqbal 3ba94c6eb5 📝 Record what each write into read-only memory answers [ci skip]
dgpu-oracle.md Q38 records oracle_readonly's runs on the M3 Max (macOS
27.0.1) and the dGPU oracle's Radeon Pro 5300M and UHD Graphics 630 (macOS
26.7.1), each shape with its class: agreed, divergent or outside the
envelope, and the x86 finding that bit 24 does nothing there. The accuracy
ledger's read-only-pages-written row, the writes module's docs, the command
module's note on read-only store faults and design.md's no-copy buffers say
what the platform now answers: a store-out faults as the M3 Max's does, every
other GPU write completes with its write dropped, a CPU write lands where the
pages are writable, and a depth StoreAndMultisampleResolve into such memory
still ends the process until metal2vulkan completes it.
2026-11-14 07:25:13 -08:00
Anees Iqbal f264ac73b8 🐛 Drop kernel and blit-copy texture writes into read-only memory
A kernel's write() of a texture over memory the process maps read-only
(Metal's private option bit 24, a no-copy buffer or heap the runtime makes
over a copy of the pages on Linux), and a blit's copy into such a texture,
ended the process where they were encoded (kept_write), as what Metal does
there was read as unmeasured. metal2vulkan measured both on the M3 Max,
macOS 27.0.1, plain Metal (probes/readonly_gpu_writes.m; the runtime's
read_only_view.rs): a texture over such memory takes a kernel's write() and
a blit's copy into it, out of a buffer or a texture, nowhere; each completes
with no error and leaves the pages as they were. The runtime's copy drops
those writes too: a texture over a copy lies in the copy's memory, or is a
shadow of its bytes, and each batch's completion writes back over every byte
the GPU changed in a copy that drops writes (copied.rs), so a later command
buffer reads the pages' bytes.

What changes for the guest: such a dispatch and such a blit copy complete
with no error, their writes dropped, where they used to end the process.

predication.rs's kept_write_through asks texture_twinned instead of
texture_kept for a texture a kernel writes, bound or made resident for
writing, so only a surface's read-only memory the runtime twins still dies
there. encode_blit.rs sends a copy into a texture over memory the runtime
copies (copy_dropped: CopyBufferToTexture, CopyTextureRegion,
CopyTextureSlices and their options forms).

What stays a death, as nothing measured it: a draw's write of such a
texture, another blit's write of one (a fill, mipmaps, an invalidation),
and a CPU write of one.

Tests: texture_writes_into_read_only_memory_are_dropped runs a kernel's
write, a copy out of a buffer and a copy out of a texture into a texture over
a bit-24 buffer and one in a bit-24 heap over pages: each completes with no
error, the pages stay zeros, and a later command buffer reads zeros.
a_blit_into_a_read_only_buffer_is_dropped's copy into a texture over the
buffer now completes where it died. gpu/writes.rs's docs and the accuracy
ledger's read-only row say the same.

No boot: no walk has reached this path (no app in our walks writes a texture
over read-only memory).
2026-11-14 06:10:59 -08:00
Anees Iqbal 68a94da601 🐛 Fault measured resolves and depth stores into read-only memory
A pass that resolved a multisample colour attachment into a texture over
memory the process maps read-only (Metal's private option bit 24), or kept a
depth attachment there by CustomSampleDepthStore, ended the process where it
was encoded, as what Metal does there was unmeasured. metal2vulkan has since
measured both on the M3 Max, macOS 27.0.1, plain Metal (m3-max-28796,
m3-max-28797): a colour MultisampleResolve into a texture over a buffer of
bit 24, and a depth attachment in a heap of bit 24 kept by
CustomSampleDepthStore, each by the descriptor's action or one the encoder
set, fail the command buffer with PageFault, as a Store there does. RUNTIME
2280 (pin 89) faults both itself (store_out.rs), and counts the fault toward
its queue's revocation.

What changes for the guest: those two shapes now fail their command buffer
with PageFault (3), the pass and the encoders after it running nothing, every
event signal firing, the pages unchanged, and the queue serving on until its
second fault, where they used to end the process.

kept_attachment and late_store let them through, and read_only_stores and
late_store tell the command buffer of the fault (faults_at_read_only_store),
as a Store there is told, so a command buffer that fails another way too
still dies at its commit. faults_over and faults_into name the store actions
that fault. A colour attachment's resolve texture over such memory, the
descriptor's, is marked Unsent::Copied while its store action is Unknown, so
a late MultisampleResolve into it faults.

The store-out shapes 2280 did not measure stay deaths where they are
encoded: StoreAndMultisampleResolve into such a texture (at the pass's
creation, or at its late store action), a depth or stencil resolve into one,
a resolve into a texture a late resolve setter named, a colour or stencil
attachment kept there by CustomSampleDepthStore, and a colour resolve into
such a texture that this platform drops because plain Metal leaves a texture
of that format untouched (now dying in read_only_stores, at the same
selector, where it died in kept_attachment before).

Tests: a_resolve_into_read_only_memory_dies becomes
a_resolve_into_read_only_memory_faults_its_command_buffer: MultisampleResolve
given at once or late faults and the queue runs on, while
StoreAndMultisampleResolve dies at renderCommandEncoderWithDescriptor: and at
setColorStoreAction:atIndex:. In
a_depth_store_into_read_only_memory_faults_its_command_buffer,
CustomSampleDepthStore at once or late, and Store, in a
heap of bit 24 over pages fault, the queue running on, and DontCare
completes. The read-only pass helper takes any pass (pass_line_on). The
module docs, gpu/writes.rs's and the accuracy ledger's read-only row say the
same.

No boot: no walk has reached this path (no app in our walks stores into
read-only memory).
2026-11-14 06:04:48 -08:00
Anees Iqbal 67e65365e5 🐛 Let a read-only store's fault revoke its queue, not end the process
A render pass that stores an attachment into memory the process maps
read-only (Metal's private option bit 24) faults its command buffer with
PageFault. This platform then made the commit of every later command buffer
of the process die (READ_ONLY_FAULTED), as Metal was read to fail them all.
Measured on the M3 Max, macOS 27.0.1, plain Metal, that reading was of the
probe's runs sharing one queue: one fault a process leaves the next command
buffer of the same queue Completed (m3-max-29110, twice, a process each), and
so do one on the same queue 100 ms on and one on a new queue (m3-max-28796,
m3-max-28797); four faulting runs on one queue fail every command buffer of
that queue after its second fault. That is the queue revocation the runtime
models in command_buffer/revocation.rs, measured on the same Mac: the
queue's second page fault or hang revokes it, every later commit on it
failing with AccessRevoked (4); other queues, and a new one, serve on.

What changes for the guest: a command buffer committed after such a fault
runs, where the commit used to end the process; the queue's second fault
revokes that queue, every later command buffer of it completing with
AccessRevoked, running nothing and signalling nothing; other queues run.

Since RUNTIME 2280 (pin 89) the runtime faults such a store-out itself, with
the same code, from the same pass on, every event signal firing
(store_out.rs), and counts it toward its queue's revocation. This platform
no longer commits the fault as failed (commit_failed of code 3): the command
buffer commits as any other, and the runtime faults it. The pass is still
told to the command buffer, now as a failure the runtime makes (the field
type_9 becomes by_runtime, holding type-9 draws' failures and these), so a
command buffer that fails another way too still dies at its commit as a
combination nothing measured, and is never cut into parts.

The executions of indirect command buffers in the encoders such a failure
runs nothing of stay unchecked at the commit, as they were while this
platform committed the failure. The same now holds for a type-9 draw's
failure, whose later encoders' executions were checked, and could die there,
though Metal runs nothing of them.

Tests: a_store_into_read_only_memory_fails_its_command_buffer and its late
store variant now see the next command buffer of the queue and of a new
queue run, the faulted one's blit after the pass not run and its signal
fired; read_only_faults_revoke_queues_as_metals holds the revocation at the
second fault, while a new queue runs and takes a first fault of its own
without revocation; a_command_buffer_failing_two_ways_dies_at_its_commit
gains the read-only cases and the first encoder that runs nothing. The
module docs, gpu/writes.rs's and the accuracy ledger's read-only row say
the same.

No boot: no walk has reached this path (no app in our walks stores into
read-only memory).
2026-11-14 05:50:22 -08:00
Anees Iqbal 320ad08811 🐎 Lay read-only no-copy memory over its pages, not a copy
newBufferWithBytesNoCopy: over Shared memory the process maps read-only took
a slab copy that the bundle merged from the memory at every commit using it.
On macOS 12.7.6's WindowServer, which wraps clients' Core Animation backing
stores (VM_MEMORY_LAYERKIT, mapped read-only, 8-30 MB each) so and draws from
them every frame, that merge was 14.10 s of the commit path's 14.25 s over a 451 s walk, 130,850 MiB
compared, and its commit-to-post wait 2-6 ms a frame where 14.8.9's is
20-60 us (appwalk14, ms01's Iris Xe).

Where the kext makes a read-only pages block (RGFX_FEATURE_READ_ONLY_PAGES),
such memory now lies over its own pages: the bundle asks the block for
reading alone and makes its BUFFER_OVER_PAGES with Metal's private bit 24,
sent to the host alone. The buffer answers the app's options, without the
bit, as Metal's does; its contents, length, allocatedSize and GPU address
(the pointer's offset in its page) answer as before. Read-only blocks join
only read-only ones. Read-only Managed memory keeps its copy: the host's two
copies would write the CPU copy back to the pages. Where the kext gives no
block (a host without the bit), the copy stays.

What changes for the guest, beside the time: the GPU's writes to such memory
follow accuracy-ledger.md's read-only-pages-written row, as Metal's do, where
the copy kept them in the slab for later command buffers to read:
- a shader's store, a blit's fill or copy and a pass's visibility results
  into it complete with their writes dropped, and later command buffers see
  the memory as it is;
- a pass that stores an attachment there (Store,
  StoreAndMultisampleResolve) fails its command buffer with
  MTLCommandBufferErrorPageFault, where the copy let it complete;
- the CPU sees its pages unchanged, as before.

On Linux the runtime makes a bit-24 buffer over a copy of the pages today,
compared with them at each commit that uses it, so the per-commit compare
moves from the guest's process to the host's commit until metal2vulkan
imports such memory in place.

The shell tests that held "read-only memory never asks for a block" now hold
the new route: the ask for reading alone, the bit on the wire and not in the
buffer's options, and the copy where no block is given. Both guest sets are
rebuilt in the 📦 commit that follows.
2026-11-14 03:39:14 -08:00
Anees Iqbal ccbcdabd6d 🆕 Make pages blocks of memory a process maps read-only
A no-copy buffer over memory its process maps read-only cannot lie over its
own pages today: the kext refuses the pages block, and the host would lay a
buffer over it that takes the GPU's writes. So the bundle syncs a slab copy
of it at every commit that uses it. macOS 12's WindowServer wraps clients'
Core Animation backing stores, mapped read-only into it (8-30 MB each), that
way, and spent 14.1 s of a 451 s walk syncing them (appwalk14, 12.7.6 on the
Iris Xe). This makes the device and the kext ready to keep them in place; the
bundle takes the route in the next commit.

What changes on the wire:
- A new feature bit, RGFX_FEATURE_READ_ONLY_PAGES (bit 45, FEATURES_HI bit
  13), offered wherever PAGES_BUFFERS is, and taken by the kext.
- A new SURFACE_PAGES flag, RGFX_SURFACE_PAGES_READ_ONLY (1 << 5), meaningful
  with RGFX_SURFACE_PAGES_PRIVATE alone (else INVALID_ARGUMENT): the pages
  block holds pages its process maps read-only.
- BUFFER_OVER_PAGES needs no new field: its options already carry
  MTLResourceOptions bit 24 to the host, which hands it to the runtime as
  memory whose GPU writes it drops (accuracy-ledger.md,
  read-only-pages-written).

The host keeps every object over a read-only block from writing its pages: a
BUFFER_OVER_PAGES without bit 24, a HEAP_OVER_PAGES, an ICB_SLOTS_IN_PAGES
and a MANAGED_BUFFER_CREATE or MANAGED_TEXTURE_CREATE whose CPU copy lies over
one are refused, each logged as the guest error it is. The block's view stays
the writable mapping of guest RAM.

Where the kext took the bit, PagesBlock makes a block of read-only memory too:
it wires the pages with kIODirectionOut, which asks the VM system only for
read access, completes them for that direction at the unwire, and marks the
block read-only (rgfxPagesWiring). Without the bit it refuses read-only
memory as before.

Why a feature bit, though reims-ctl ships the host and the x86 set together:
the mark is where the host holds the line, not a hint. A process can post any
message on its rings, so a forged BUFFER_OVER_PAGES without bit 24 over a
read-only block would let the GPU write pages the process maps read-only, a
file's page cache among them. A host older than the mark ignores it, so the
kext makes such a block only where the host took the bit. The arm64e set also
reaches VMs through Ambrosia's config bundle, apart from the host. Old guest
sets never ask, and change nothing; a new set on an older host gets no block
and keeps its copy.

The header is regenerated, and the option ROM's record takes the header's
new hash (the ROM's bytes are unchanged); both guest sets are rebuilt with
the bundle's change, in the 📦 commit after it. Tests: the
header test, the peer and offer tests, a decoder test of what a read-only
block admits and refuses
(a_read_only_pages_block_holds_only_buffers_that_drop_their_writes), and the
kext's features and pages-block tests.
2026-11-14 03:39:14 -08:00
Anees Iqbal c2dbffc7bb 📝 Name the unshared queues and their log line as they are [ci skip]
GpuDevice::new_command_queue_unshared's doc listed the device's blit and
exec queues and the process's frame queue, which no code makes since the
paravirt lane went, and left out the decoder's release queue and the window
mirror's queue, which do exist. It now names the queues made unshared today,
each with the reason its own doc gives: the window sink's and its mirror's
(on a present's path), the IOSurface device caches' transfer queue (presents
and cache-drawn frames wait for its fills) and the decoder's release queue
(no guest command buffer may hold up the signal of a closed context's
events).

design.md said the host logs each unshared queue at info on
reims_vgpu::graphics; since f75493990 the line is at debug on its own
target, reims_vgpu::graphics::queues.
2026-11-14 03:33:56 -08:00
Anees Iqbal 9e942f2447 🐛 Refuse overlaps of half constants and function tables at newFunction
What changes for the guest: newFunction now answers nil with
MTLLibraryErrorDomain 3 (CompileFailure) and Metal's own lines ("error:
buffer argument b has invalid location (<0,1>) in k\n"), by any way of
making the function, where function constant values put two present
arguments of one argument table at overlapping locations through
(a) a predicate or an index computed from a half constant,
(b) an index computed through a conversion between a float and an integer,
(c) a function table (visible or intersection) or an acceleration
    structure (primitive or instance) at a buffer's location.
Before, newFunction made the function in those three cases and the
pipeline's create refused it later on the host (OverlappingArgument). Metal
refuses at newFunction (oracle Q33), and the bundle already did so for
every other case its AIR reader decides.

Why the bundle missed them: the initialisers' evaluator folded no half
constant's value; the compiler writes a float-integer conversion as a call
(air.convert.u.i32.f.f16 and the like), which it took as any value; and the
reader did not count a function table's or an acceleration structure's
location, whose table and word were not measured.

Q33's probe, oracle_overlap, gains eight functions (k_halfpred, k_halfidx,
k_fidx, k_sidx, k_vft, k_ift, k_pas, k_ias), measured on the 5300M, the 630
and the M3 Max (m3-max-28663, 28662, 28659). The three oracles agree on
every newFunction answer: function tables and acceleration structures take
locations of the buffers' table, with the word `buffer`; a half constant's
predicate and index, and an index through conversions truncated toward
zero (-1.5 gives -1), count as any other. One pipeline differs: the 630
refuses k_vft's compute pipeline where the table is called, its compiler
service dying (CompilerError 1, XPC_ERROR_CONNECTION_INTERRUPTED), while
the 5300M and the M3 make it. Making it stays inside what the x86 Macs
answer, so nothing here follows the 630 there; Q33 records it.

For the overlap check alone (rgfxAirConstantGlobals) the evaluator now
folds a half constant's value, rounds each half result to the nearest half
as LLVM folds a half, and folds air.convert of scalars between floats and
integers (a float to an integer only where the truncated value is in the
integer's range); the bodies' specialisation (reflection's used arguments)
still takes those as any value. The reader counts a function table's or an
acceleration structure's location in the buffers' table, and the check
names it `buffer`. test_overlapping_arguments_refused_as_metal compares
the eight new functions with this Mac's Metal for every value and way, and
checks the x86 Macs' words.

Still left to the host, written in Q33: an initialiser operation the
evaluator does not fold (vector or array elements, conversions of two
integers or of vectors, other calls), an air.buffer with no address space
(no form built writes one), and a function of a library Metal's link made,
which keeps no bytes.
2026-11-14 01:59:32 -08:00
Anees Iqbal d8ad27f09c 🐎 Cut a command buffer of compute encoders into parts
The Vulkan platform refused a split while a unit of command predication
was open, and every compute encoder opens one, so a buffer of compute
encoders alone was never cut: Geekbench 7's Fluid Simulation commits
2,600 one-dispatch encoders in one buffer, and its GPU work waited for the
whole walk. A split now needs only no block open, no loop body being laid
down again and no unit an unbalanced record emptied
(Predication::cuttable). A unit open at the cut goes on in the next part
(Predication::go_on): its first dispatch type, work, indirect dispatch and
numbering carry over, so what Metal decides by the unit (an unbalanced
encodeEndIf after its work, a first indirect dispatch of another type)
dies where it would in the whole buffer. With no block open the GPU's skip
counter is 0, so the next part's counter, reset at its first step, stands
for the cut part's.

For the guest only timing changes, and where a walk faults after a part
was committed, that part's work has run, as for a buffer of render passes
(only invalid input reaches that).

dispatch_cost's fluid shape (1 buffer of 2,600 encoders of one dispatch,
M3 Max, MoltenVK, release, median of 5 runs of 6), through the decoder:
first take to completion 87.0 ms -> 34.8 ms; the walk's CPU 14.7 -> 8.8 us
a dispatch (164.2k -> 110.6k instructions), as the runtime's work for an
encoder grows with the encoders before it in its buffer. The small (64 x 5
encoders) and one-encoder shapes are not cut, and stay as they were.

Tested by a_unit_goes_on_in_the_next_part,
a_block_open_keeps_a_command_buffer_whole and the encode_compute dies and
goes_on cases across a split.
2026-11-14 01:37:31 -08:00
Anees Iqbal e080c5568f 📝 Record what GL's Apple settings need of the device [ci skip]
The design said the GL renderer's Apple settings need Apple7 and the vendor
"Apple". Its five settings records (macOS 27.0.1, arm64e) show Apple5's and
Apple7's are the same in every setting the renderer reads but the largest
point it draws, 16 pixels against 64, so Apple5 with a vendor none of AMD,
ATI, NVIDIA and Intel is the narrowest pair. The section now lists the
other settings the Apple records hold (the texture upload and mipmap path,
the seams on cube maps, the point clamp) and why the device claims neither:
Apple4's and Apple5's rows hold tile shaders, imageblocks and nonsquare tile
dispatch, which the device does not carry and the runtime refuses on every
device (its audit on an Iris Xe at metal2vulkan c796a88d6a: 26 of Apple5's
rows block), and the Apple settings send GL_POINT polygon mode as
setTriangleFillMode: 2, on which the platform dies.
2026-11-14 01:28:18 -08:00
Anees Iqbal 5353c7cba9 📝 Record the mirror's sync waited for on the compositor's GPU [ci skip]
Route 1's design notes described the CPU ordering the two GPUs and named the
sync-file export as the step still to take. The draw now waits for the
mirror's sync on the compositor's GPU, so the notes say how, and where the
window's thread still waits.

They record the walk pair on pin 83 that measured it, warm against warm, on
um870's RTX 3090 beside its 780M compositor and on um790's 780M beside its
XTX compositor: the render thread's wait a sync fell from 4.63 to 0.45 ms
and from 4.25 to 0.99 ms. Every sync went to the compositor as a sync file,
none after host copies, and rates and latencies held.

They also explain Mission Control's take-to-show median rising from 2.2 to
14.4 ms under route 1: its presents fall in two groups, those finished by
their take and those whose writers still run, and route 1 made the second
group faster (39.1 to 15.2 ms) and larger, so the median moved between them
while the mean fell from 18.2 to 10.0 ms. The GPU wait leaves both groups
as they were.
2026-11-13 22:36:52 -08:00