Commit Graph
767 Commits
Author SHA1 Message Date
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
Anees Iqbal db058169b4 🆕 Split the time before a command buffer's take by its stamps
Where the guest took GUEST_TIMES, a queue's thread notes the host's clock as
it takes each buffer, before the gate, and as it comes back to the ring after
the buffer before it. With ring 0's clock offset (its bound read with
acquire, then the offset) it splits the buffer's time before the take:
encode (committed - made), post_wait (posted - committed), queued (behind
the queue's buffer before it, on the host) and transport (the doorbell, the
thread's wake and the ring), posted mapped to the host's clock. With no
offset held only encode and post_wait are given.

Each buffer's spans go to the host's trace as a cbguest event: queue, seqno,
the spans, the offset's bound, and held, the time from the take to the event,
so a reader places the take. Once a second a debug line of target
reims_vgpu_graphics::guest_times gives the buffers' count, each span's sum
and median, and the longest transport. Both are diagnostics: the device does
nothing else differently, and reads nothing of a guest that did not take the
bit.

The device's tests: a stamped buffer's spans reach the trace, alone and
queued behind a buffer the host holds; a buffer without the op, or a guest
without the bit, gives no event; with bound 0 there is no transport. The
module's own tests cover the spans' clamps and the line's window.
2026-11-13 21:25:37 -08:00
Anees Iqbal 14c2c18e8c 🆕 Stamp each command buffer with the guest's clock (GUEST_TIMES)
The host sees a command buffer only once a queue's thread takes it off its
ring, so the app's encode and the buffer's way to the host show as one span
with nothing pending on the host. This adds the guest's stamps that split it,
a diagnostic.

What changes for the guest:
- The device offers a new feature bit, RGFX_FEATURE_GUEST_TIMES (bit 44,
  FEATURES_HI bit 12), and DRIVER_FEATURES takes it. The kext carries it.
- Where the device's word holds it, the bundle starts each command buffer's
  stream with a new op, RGFX_OP_GUEST_TIMES (0x000e, 32 bytes): the guest's
  clock as the buffer was made, as its commit was entered, and as its message
  went on its ring. The last is written under the ring's lock, after the copy
  and before producer is published; for a buffer in a block, into the block.
- After each VBLANK's reading of HOST_TIME the kext writes ring 0's new header
  fields: guest_clock_offset_ns (0x18), then guest_clock_bound_ns (0x20) with
  release, split out of reserved bytes. The host zeroes both as it initialises
  a ring.
- The decoder walks the op as a no-op, so it changes nothing a buffer does,
  and a host that did not offer the bit never sees it. Old guest sets carry
  no bit, send no op and leave the fields 0.

The header is regenerated, both guest sets are rebuilt from the same sources,
and the option ROM's record takes the header's new hash; the ROM's bytes are
unchanged. The tests cover the op's and fields' layout (the header test, the
kext's vblank clock test), the bit's negotiation (the kext's features test,
the peer and memory-map tests), the stamps (the bundle's serializer and shell
tests) and the walk (a cmdbuf test, and the fuzz's streams). The host's
reading of the stamps is the next commit.
2026-11-13 21:25:12 -08:00
Anees Iqbal 2bd0bed6b5 📝 Record route 1 of the compositor's window as built and measured [ci skip]
The design's route 1, the window shown by the compositor's GPU through a mirror
of the changed tiles, is built: the doc now says how the mirror is made, synced
and drawn, how the CPU orders the two GPUs until the runtime's sync file is
taken, and where it falls back.

It records the before/after walk on um870's RTX 3090, whose compositor is on its
Radeon 780M, against development at fe56cae17 on the same runtime: the link's
megabytes a present fell from 31.2 / 2.0 to 6.1 / 2.5 over the walk, the 3090's
busy time from 21.0 to 9.5 ms a present, the guest's rates held, and the render
thread waits 1.6 to 10.8 ms a present for the tiles' copy.
2026-11-13 21:07:48 -08:00
Anees Iqbal 31377954ea 📝 Record route 2 of the compositor's window as measured and rejected [ci skip]
A prototype laid only the presented surfaces in place, with the window as
today, and walked the desktop on um870's RTX 3090.

About 169 MB crossed the link a present: 90.5 MB from the GPU beyond today's
34.8 MB window copy, and 78.8 MB to it. That is five times today's copy and
27 times what the frames change. The guest's presents over the walk fell
from 4324 to 1735, and the autoscroll from 45 to 9 a second.

The cause is the composite's own passes: the runtime's GPU renders and
blends WindowServer's frame into guest RAM over the link, loads included,
while the shadow counts stay flat. So the presented surfaces keep their
device caches, and route 1 is the route taken.
2026-11-13 21:07:48 -08:00
Anees Iqbal 39783f7d90 📝 Record the guest's stalls beside a terminal's build [ci skip]
A cold `cargo xtask dist` typed into a bash terminal on CachyOS runs its
compilers at nice -4 (ananicy-cpp's rule for bash) against QEMU's nice 9, and
stopped the guest's Safari pages for up to 2.6 s with 8 vCPUs. In the stalls
the vCPUs waited on run queues while the device's threads were idle, and the
gaps were 2.4 to 28 times what the lost share accounts for.

Record the measurement in docs/qemu.md, with why nothing of ours moves it and
why reims-ctl's vCPU default stays: 4 vCPUs cut the worst scroll gap 3 times
but took 1.81 times as long for a CPU-bound guest on an idle host. Record the
nice -4 trap in docs/lessons.md, since a load started at nice 0 measures less
than a user's build.
2026-11-13 20:42:23 -08:00
Anees Iqbal 493f91acd9 📝 Tag Q37's answers by class, with the arm64 guest's [ci skip]
The order of encoders' writes is all three Macs' answer (class 3), the bytes
past a plane's texels the Macs' divergent one (class 2). An arm64 macOS 27.0.1
guest on the M3 now answers the eight aliasing cases as the M3 does natively
(a64walk oracles step, m3-max-27485; before, m3-max-27484, the wide texture
was refused).
2026-11-13 17:49:41 -08:00
Anees Iqbal 7809cef902 📝 Record what aliased surface textures see in one command buffer [ci skip]
dgpu-oracle Q37 records oracle_surftex's aliasing cases on the three Macs: a
write through one texture over a plane reaches the next encoder's read through
another, tracked or behind a fence, on all three; the bytes past the plane's
texels are the surface's own on the M3 and the GPU's own on the x86 Macs. It
says which answer each wide home gives. Decided 14 in the device's design and
the oracle tools' list name the wide home and its copies.
2026-11-13 17:49:41 -08:00
Anees Iqbal b7572e8312 📝 Record which usage bits a texture answers and ends the process at [ci skip]
Q36 holds oracle_surftex's sixth and seventh rounds on the M3 Max, the AMD
5300M and the Intel UHD 630: the atomic bit and 0x8 left out of every
texture's answer, the formats the atomic bit takes, and the usage bits
Metal's validation ends the process at.
2026-11-13 16:44:56 -08:00
Anees Iqbal 9cb5693ab5 📝 Measure what crosses an x4 link per present [ci skip]
On an RTX 3090 or RTX 2080 behind an x4 or Thunderbolt link the walk ran 20 ms
of GPU time a present, against 2.8 ms on the RTX 5080 Laptop GPU, and moved 25
to 44 MB a present across the link. Device-cache fills and downloads were the
same on all three, so they don't explain it. The extra bytes go from the GPU
to the host: the window's swapchain is the runtime's GPU's, and where the
compositor runs on another GPU each window present moves a LINEAR copy of the
window's image (29.75 MB at 3648 x 2039) across the link. The window presents
0.93 times for each guest present, so each carries a new frame. The 3090's
link moves 1.83 GB/s from the GPU from any queue family, and NVIDIA presents
only from its graphics family, so neither another present queue nor the copy
engine would help. Only fewer bytes per present would.

The swapchain module's doc records that platform fact. design.md (Decided, 14)
records the walks, the link's and the compositor GPU's rates, and how much the
guest's frames change a present (6.27 MB of 29.7 MB on average, measured with a
build that is not landed, steelbrain/x4link-damage at 32bfa734c). It lays out
two routes for the owner to choose between, neither built: the window shown by
the compositor's GPU from a copy of the changed tiles, or from the presented
surfaces in place in guest RAM. For each it gives what is measured and what is
not, what it touches, and its fallback.
2026-11-13 16:44:31 -08:00
Anees Iqbal 459e76e6af 📝 Record what in-place surfaces cost on discrete GPUs [ci skip]
Decided 14 gains two items. The first is the measurement of surfaces in place
first on a GPU of its own memory (steelbrain/routeb, unlanded) against
development at b615cec64, one walk per GPU on an RTX 5080, an RX 7900 XTX, an
RTX 3090 and an RTX 2080. The GPU then reads the layers it composites across
its link at each present: at 16 GB/s it costs a 5080 3x the GPU time and 6% of
the presents, the XTX is level, and the two x4 links saturate at 1.6 to 2.4
GB/s with the steps' presents three to nine times fewer. In place first also
took RADV's shadows off most of the video's frames.

The second is a proposal, not built: every surface in place first and a device
cache only once the guest's use shows a surface re-read unchanged, counted on
the host, promoted through a kext notice, undone at a CPU write, with every
guest-visible value kept. Its runtime side, moving a no-copy buffer and its
textures into device memory at the same GPU address, is metal2vulkan's.
2026-11-13 15:41:19 -08:00
Anees Iqbal e617b1a999 🐛 Keep no-copy buffers and function tables NonVolatile
Metal's no-copy buffers answer NonVolatile to every purgeable state they are
told, on the M3 Max, the AMD Radeon Pro 5300M and the Intel UHD 630 alike
(oracle_bundle purgeable.kinds), as views, textures over buffers and heaps'
resources already do here: the host backs none of them with a purgeable
allocation of its own. The bundle's no-copy buffers kept the state told.

A visible function table answers NonVolatile on the M3 Max and the Intel 630,
where the AMD 5300M keeps the state told; the bundle answered the AMD's (2,
then 3 when asked). It now answers the M3's and the Intel's on every guest.

What the guest sees: setPurgeableState: on a no-copy buffer or a visible
function table answers NonVolatile, whatever was set before, and isPurgeable
answers NO. Every other resource keeps the state told, as before. The oracle
doc records the measurement (Q35), and both guest sets are rebuilt.
2026-11-13 14:24:45 -08:00
Anees Iqbal 0ab4ed4c11 📝 Say how the GL renderer's settings decide GL's provoking vertex [ci skip]
gl_cases' provoking-line-last fails in arm64 macOS 27.0.1 guests on the M3
Max and passes on the M3 Max itself. The renderer picks per-vendor settings by
the device's vendorName, then by Apple7 and Apple5, and only its Apple and
AMD settings send setProvokingVertexMode: to the encoder. Under the others it
reorders a triangle's vertices itself and leaves a line's first vertex
provoking. Our device answers the host's vendor, "AMD" for any other, and no
Apple family, so its guests take NVIDIA's settings, or Intel's on an Intel
host. The x86 Macs measured take the same: the Intel 630's Metal GL renderer
fails the same case, and the 5300M's Metal device is not of the class AMD's
settings need. The M3 Max sends the setter at every case (traced).

The same settings send GL_POINT polygon mode as setTriangleFillMode: 2, which
the M3 Max and the 630 draw as the triangle's vertex points. The Vulkan
platform has no such mode, so a guest given Intel's settings would die on it.
2026-11-13 14:01:39 -08:00
Anees Iqbal e50601af41 📝 Record the xHCI completions and usb-host's off-loop alt setting [ci skip]
docs/qemu.md's table of the branch's QEMU changes gains 3d04e62f and
926fc8dc (each command's own Command Completion Event) and 78b3270c (no
usbfs call on a device while it sets an alternate setting), and the USB
passthrough section the before and after boot of 78b3270c (m3-max-26476):
the output interface's alt-0 calls no longer stall QMP.
2026-11-13 13:11:55 -08:00
Anees Iqbal 75629b2f32 📝 Record what Metal's base answers under the M3 Max's profile [ci skip]
The arm64 guest's device answers the x86 Macs' feature profile, 10002,
where the M3 Max answers 10. oracle_profile measured what Metal's base
device answers under each: under 10 it answers 123 members the device
leaves to it as an Apple GPU's, memoryless targets, tile memory, sparse
textures, Metal 4 queues and mesh commands in indirect command buffers
among them, which the host's GPU lacks. So the profile, and the tiled
texture SPI WindowServer asks under 10002, stay as they are until the
device answers those members itself.
2026-11-13 13:05:57 -08:00
Anees Iqbal 674370fdc2 📝 Record the M3 Max's answers to the rest of the x86 rules [ci skip]
Q34 gains the answers arm64rules2 measured on the M3 Max under macOS 27.0.1:
the depth/stencil queries, ids and words the arm64 guest now takes, and
those the M3 gives as the x86 Macs do (a state's resourceIndex and
uniqueIdentifier, dynamic library refusals, a dylib's exported function,
texture addresses, the indirect command read-back), so they stay as they
are.
2026-11-13 13:02:55 -08:00
Anees Iqbal 1b7ce9c948 🐛 Keep the device's event BH to QEMU's exit
vendor/qemu moves to baa655fe. reims-graphics-pci's teardown deleted the BH
that the window's input and the cursor's callbacks schedule, right after
the library's release, and set it to NULL. A window callback already
running on the window's thread as the release closes the window, or a
cursor callback of a device thread the release's 5 s bound left running,
then scheduled NULL and ended QEMU with SIGSEGV at its quit. The BH now
stays to the exit and drops the events it finds once the console is
closed. Read from the code; no run reached the crash.
2026-11-13 12:38:11 -08:00
Anees Iqbal 99d927a987 📝 Record the desktop over a timed Metal app as a trap [ci skip]
Apple's Modern Rendering sample ran 8% slower on the RTX 3090 in each run
after 843056209, with WindowServer at 6 times the render encoders, and the
commit was blamed. The runs' desktops differed: an active window with a glass
sidebar lay over the sample, which the harness never brings to the front, and
WindowServer drew twice the command buffers at three times the encoders. One
build read 4.74 frames a second with the Finder window over the sample and 5.18
with the sample in front, so the lesson says how to spot the next one.
2026-11-13 12:21:54 -08:00
Anees Iqbal 1b7d9ab609 🆕 Count the control ring's full spells, waits and dropped VBLANKs
Every process's ring-0 answers, the present answers and the display's events
share the one control completion ring. When it had no room, a VBLANK was
dropped silently (the guest sees no event for that refresh) and the posts that
waited left no trace, so no boot could say whether the ring ever filled.

The device now tells its host of each kind (Host::ring_degraded,
RingDegradation): a full spell at its first post that found no room, a post
that waited once it goes on, and a dropped VBLANK. It logs each kind's first
at warn, which the library's logger writes once per kind and counts after.
reims-vgpu counts them by code (answer::count_kind) into the degradation
counts line: control-ring-full, control-ring-post-waited, vblank-dropped.
Diagnostics only: what the guest sees is unchanged.
2026-11-13 12:20:14 -08:00
Anees Iqbal 7fc3deed4e 📝 Record the device's QMP and BQL waits as a lesson [ci skip]
QMP's screendump held every QMP monitor while the display read it waited
for never ended, and the teardown's release under the BQL waited for a
route call that took the BQL. Both are traps of the same kind: a host call
that waits on device work while holding what other parties wait for. The
lesson says how each showed and how to spot the next one.
2026-11-13 12:10:36 -08:00