17 Commits
Author SHA1 Message Date
Anees Iqbal e3a3fc82eb ✅ Add a test shader of GPU-encoded indexed commands
The rt platform's indirect command buffer tests need commands that a kernel
encodes on the GPU, as a guest's shaders do. icb_encode encodes indexed
triangles, each with its own colour, into a buffer it reaches through the
gpuResourceID in an argument buffer, and icb_vertex and icb_fragment draw them.
icb_encode_wide binds 29 vertex buffers. icb_vertex_23 to icb_vertex_29 read
23 to 29 of them, so a command of theirs binds 24 to 30 slots, across the most
slots rt's push range carries.

The metallib is the Mac's metal compiler's, built from the source beside it.
2026-11-21 04:38:15 -08:00
Anees Iqbal 9939485879 🐛 Declare a render encoder's useResources: to rt as compute's are
What the guest sees changes. Before, a render encoder's useResources: (each
form, with or without stages) never reached metal2vulkan-runtime: the platform
noted its textures and nothing else. So a draw whose vertex or fragment
function wrote a texture beyond its slots (through an argument buffer or a
resource ID) after a declared write of a texture with no storage element ran,
and Vulkan dropped the writes Metal makes. Now each resource it names but nil
is rt's use_resource with the declared usage, as the compute encoder's is (the
two share resource_usage and the declaration's notes, compute::declared). rt
keeps the resource until the command buffer retires and records nothing, and
such a draw is rt's Gap::StorageElement: it draws nothing, is counted under
rt-refused-gap, the process's first on a line of stderr, as the compute
encoder's dispatch is, and the process goes on. Declared textures over a buffer
in an image of their own now take rt's copies around the draws after them, and
a usage no Metal value is (0, or a bit past sample's) is Metal's refusal,
counted under rt-refused-metal, as on the compute side.

The texture notes stay: a tiled texture's take at the commit and a read
through the platform's own index are not retention. rt's keep of its own
buffer or texture until the command buffer retires is inside the platform, as
for every bound resource and the compute encoder's declarations; the guest's
objects go when core drops them, as before, so the order of releases the host
sees is unchanged.

Tests: a_draw_after_a_declared_write_of_a_texture_with_no_storage_element_
is_refused_on_vulkan, over a new fragment function, render_argwrite.metal,
whose metallib build.sh's two steps made on a Mac (metal 32023.922), with the
compute encoder's dispatch of tex_write as the oracle of which textures have
no storage element on the device. render_encoders_on_vulkan now counts a usage
of 8 as Metal's refusal.
2026-11-21 00:36:16 -08:00
Anees Iqbal c50dfba740 🐛 Answer argument buffers' layouts on the rt platform
On rt, newArgumentEncoderWithArguments: and a function's
newArgumentEncoderWithBufferIndex: were an unbuilt piece
(rt-unbuilt-argument-layout). The host answered ARGUMENT_LAYOUT as refused,
the guest's encoder was nil, and a kernel then read through an argument
buffer whose words nobody wrote. On a guest's probe the RX 550 read zeros,
and the 780M faulted on the null pointers and timed out its gfx ring.

What changes for the guest: both calls now answer metal2vulkan's layout.
That is ArgumentBufferLayout::from_descriptors for descriptors, and
Function::argument_buffer_layout for a function's argument buffer, the
layout the function's translation reads. Every argument kind maps to the
core kind of the same name, nested layouts with their holders. Where Metal
makes no encoder, the call still answers nil, now counted under
rt-refused-metal; the translator's own failures are counted under
rt-refused-translation.

The unbuilt piece and its ledger row go. The tests read
tests/shaders/argument_buffers.metallib. sum_args answers 16 bytes,
aligned to 8, pointers at 0 and 8, from the function and from descriptors.
mixed_args lays out a pointer array, a constant, a texture and a nested
argument buffer. On the Vulkan platform, both kernels read back the words
written at those offsets.
2026-11-20 11:16:05 -08:00
Anees Iqbal 3be674aa41 ✅ Add the argument-buffer kernels the layout tests read
sum_args is the shape a guest's probe reads wrong on the rt platform: two
pointers of an argument buffer, which the guest's encoder writes at the
offsets the host's layout gives. mixed_args holds every kind a kernel reads
through an argument buffer on rt (an array of pointers, a constant, a read
texture, a pointer to a nested argument buffer), for the layout of each kind
and the words the guest writes there. The metallib follows from a Mac.
2026-11-20 11:16:05 -08:00
Anees Iqbal 28e6a6f0b2 ✅ Hold that tessellation states tessellate as Metal's do
tessellation_states_tessellate_as_metals draws two triangle patches through a
post-tessellation vertex function of our own, tests/shaders/render_tess_bump.
The function pushes the edge between control points 0 and 1 down by a bump of
its position along that edge, so the target shows where the tessellator put
the edge's vertices. Its fragment function colours front faces blue and back
faces red.

The test draws Metal's defaults and one case for each field that changes
pixels: each other partition mode, a maximum factor of 2, counter-clockwise
winding, a per-patch step function, a factor scale of 2, and UInt16 control
point indices through the stage-in variant. Each 32x16 target must equal
Metal's bytes. The answers were measured on the M3 Max under macOS 27.0.1 by
the recorder beside them, which draws the same cases on Metal itself. They
match on RADV (780M and 7900 XTX) and on NVIDIA (RTX 2080).

The factor format and the call stack depths have no pixel case. Half is the
only factor format Metal has. A call stack depth bounds calls through function
pointers, and going past it is undefined, so no defined result shows it. The
decoder's and the recorder's tests hold that both reach the runtime.

compute_state_answers_are_metals_for_every_kernel_here reads every test
metallib. Its recorder, run on the 53 metallibs the test now reads, printed
the file's 201 answers and three more, None for each of the new library's
functions. Those three are added from its output.
2026-11-18 18:12:19 -08:00
Anees Iqbal fa218dcdde ✅ Draw draw_cost's 10k under the bench's own shaders
draws.10k's guest bench draws with v_small and f_flat, which take their bytes
as a constant float4 & at buffer 0. draw_cost's 10k drew with render_vbuf and
render_fbuf, which read device pointers, so the runtime bound storage buffers
where the VM's draws bind constant ones: on Iris the VM's lane thread spends
7.7% in the runtime's push_set, and draw_cost's 10k never reached it, with
either kind of upload chunk. The 10k and many shapes now run under the
bench's pair, render_small and render_flat, compiled alone here with Xcode's
metal (no other metallib rebuilt).

The runtime path also takes DRAW_COST_RUNTIME_PASS=fresh, which makes each
pass's descriptor anew inside the count as the platform's and the decoder's
paths do: whether the runtime's extra pass work under the platform comes of a
new descriptor each pass or of what the platform's descriptors carry.
2026-11-14 20:26:38 -08:00
Anees Iqbal dae3e6b13d 🔥 Delete the behaviour-lock suite and its make targets
The suite drove apple-gfx's C API as QEMU did and recorded what the paravirt
device did; the owner's ruling deletes apple-gfx and everything of it, the
suite with it, so make test, bless and coverage go too.

Its shader fixtures are the platforms', the graphics device's and the guest
bundle's tests too: they move to tests/shaders. guest/bundle's Makefile, an
input of the prebuilt kexts, still names tests/suite/fixtures/shaders, which
stays as a link to tests/shaders until the kexts are next built. A worktree
no longer clones the suite's 257 MiB, so new-worktree.sh adds it plainly.
2026-11-07 18:21:42 -08:00
Anees Iqbal d73bf8c005 📝 Regenerate a FIFO scenario after its doc edit [ci skip]
7198fe60c cut "read, not yet locked" from the docstring of
interplay_fifo_timeout_report_mismatch_dies, but its generated file kept the
old text, so every `pgtest gen` since rewrote it (job m3-max-4254 at
3ab4579d4). A generated file's # line is its docstring, which no expected
file's input hashes, so this changes no run and no expected file.
2026-11-07 09:36:09 -08:00
Anees Iqbal 8a7fbaf8bc ✅ Record mutgap_svc_function_over_hole from its own build
The scenario added with the hole fix records, on the M3 Max, what the guest
sees when a pipeline's function IR sits over a page-table hole: the first
dispatch's exec faults (fault status 1 at the exec's stamp), and once the
page is mapped again the same dispatch runs and writes its output. The three
setups record the same observations.

The generated ops are from the same build; the expected files are new, so
no earlier observation changes.
2026-11-05 21:59:35 -08:00
Anees Iqbal 8e4c8bc455 🐛 Fault the exec at a function whose IR sits over a page-table hole
A function whose IR the task could not copy was handed to Metal as nil, so a
pipeline naming it ended the host's process inside Metal ("Metal aborts at a
render descriptor with no vertex function"), isolated tasks included. On an
x86-64 macOS 26 guest, Safari's WebGPU renderBundles sample ended QEMU this
way, right after an info indirect (69). The guest commits a buffer's pages
to the task's page table as it prepares a command buffer that lists the
buffer, and every stream that names a pipeline lists its functions' IR
buffers (read from the guest's Metal driver), so IR over a hole is IR the
guest has not mapped yet.

What changes for the guest and the host: IR over a hole in the task's page
table now raises the function lookup's failure ("function lookup failed"),
as an empty entry's lookup already does, so the exec or info faults and the
guest restarts the channel, where the host's process used to end. Nothing
is cached, so a lookup after the guest maps the IR makes the function. IR
the task cannot otherwise copy (past the task's end, or ending at it) is
still nil to Metal, as Apple's framework answers it. Whether the boot's
failed copy was a hole is for the next boot's log to say: the previous
commit makes it name the reason.

The suite's mutgap_svc_function_over_hole locks it; its records follow.
2026-11-05 21:59:34 -08:00
Anees Iqbal 7198fe60c9 📝 Cut docs/testing.md and docs/qemu.md to what holds now [ci skip]
Both docs had picked up history, and docs/qemu.md had grown into a journal:
dated measurement blocks, the commits and builds each figure was taken at,
and the story of how each hang or death was hunted. A reader needs what
holds now.

docs/testing.md:
- Cut: which macOS builds the suite's host ran and when its files were
  dropped, a dated suite run, the run tallies behind the determinism and
  exclusive-scenario rules, a probe's raw values, and an Apple blob's size.
  Each now states its conclusion once, with its tag and the host that makes
  it checkable.
- Corrected to match QEMU: apple-gfx-iosurface-pci also drives the IOSurface
  host device and passes 8-byte accesses whole, and apple-gfx-pci isolates a
  task when its guest's mapper has a descriptor table, so it does not always
  run tasks in-process. The runner's MMIO row no longer explains itself by
  what QEMU did before, the environment list names REIMS_VGPU_TRACE, and a
  pytest wrapper that does not exist is gone.
- Facts said twice now live in one place, with a pointer from the other: a
  fresh device's registers (4.2), the EFI frame as a view (6.22), the debug
  layer's assert (6.21), the heap reply's descriptor bit (6.10), the W3
  recovery (6.7), and the runner's 32-bit IOSurface access (3.1).
- interplay_fifo_timeout_report_mismatch_dies no longer quotes 7.4 as "read,
  not yet locked": the row has been measured by that very scenario. A
  docstring is not hashed into the expected files.

docs/qemu.md:
- Cut: the measurement dates and the reims-vgpu, metal2vulkan and QEMU
  builds behind them; table rows and notes naming QEMU commits that the
  squashes and reverts left out of vendor/qemu's history (the table now
  names only commits in it, with one note for the replaced and reverted
  ones); the qtest and paused-realize logs, kept as the facts they showed;
  the lists of what was tried and was not the cause; and repeated facts,
  among them the density list policy.rs holds and the shadow-copy
  explanation video/bugs.md holds. Evidence lists fold into their
  conclusions, each marked measured with its host and guest.
- Corrected: the build's configure line gains --enable-gnutls, as the
  Makefile has it, and apple-gfx calls 21 of the header's 47 functions, not
  35.
- reims-ctl's command-line notes no longer cite docs/qemu.md for how long a
  core dump with guest RAM takes; that doc has never covered core dumps.

No rule, contract statement, ABI fact, kept behaviour, device contract,
procedure, host requirement or run instruction changed. Every section number
and title other files cite is kept and still says what they cite it for; the
4K-on-780M section keeps the tables and method that video/bugs.md's B73
points to.

Source: 501010f72 2d5eb81dd d261c89d4 2d25dc1e8
2026-10-28 01:19:16 +02:00
Anees Iqbal e6ff175880 🐛 Write back ICB lengths per word and strides by kernel binds
A compute indirect command buffer's write-back (SynchronizeResources 53, and
the eviction at suspend) wrote every threadgroup memory length at the
layout's lengths offset, and sized its strides cursor by the descriptor's
vertex bind count. Apple's GPU task service on macOS 27.0.1 (read:
synchronizeIndirectComputeCommandBuffer) writes each length to its own word
and takes one stride a kernel bind, as prepare reads them, so testing.md
7.1's stride quirk is not Apple's on this release and leaves the list.

For the guest: a written-back compute command holds each threadgroup length
in its own word, and lengths that run past the command end the write-back
there; a dynamic-stride command holds a stride for each kernel bind,
whatever its vertex bind count. The expected files of icb_evict, icb_sync,
icb_sync_errors and mutgap_tex_icb_sync_more (26A434) are recorded again,
with the scenarios and generated inputs that make them.

Source: 03bcf248f 85b938f3c
2026-10-26 12:24:31 +02:00
Anees Iqbal 1c6aaa5c6a 🔥 Record the suite for macOS 27 alone, dropping 26.7's files
The suite's host has been the M3 Max on macOS 27.0.1 (26A434) since
2026-10-13, and every behaviour change since was recorded there alone. The
1361 expected files keyed AppleM3Max-40c-25G229 (macOS 26.7), last written
on 2026-10-11, describe a library that no longer exists, and no host runs
25G229 to record them again, so they go. A host on another build records
its files with make bless, as after any OS update.

README.md, docs/testing.md and tests/suite/README.md name 26A434's key, and
testing.md says which build each scenario's measurements were made on.
Nothing the suite runs or compares on this host changes.

Source: f958e21c6
2026-10-26 12:24:31 +02:00
Anees Iqbal 23f971ebe2 🐛 Run on macOS 27.0.1 hosts: end rate-map passes with an empty draw
The M3 Max moved to macOS 27.0.1 (26A434). There, a render pass that clears
over a mutable rasterization rate map and draws nothing hangs the host's GPU
(kIOGPUCommandBufferCallbackErrorHang, about 29 ms in), and a guest reaches
it through the Metal platform. Some of Metal's answers also changed, so the
tests and the suite are made to follow the host's release.

The fix, the one change in what runs:
- The Metal platform marks the encoder of a pass over a map that is not
  immutable, and right before its endEncoding binds a cached pipeline (void
  vertex function, rasterization off, no formats, the device's largest
  amplification count) and draws no triangles. Measured on the M3 Max at
  27.0.1, every attachment's stored bytes and the visibility buffer stay as
  without the draw, across the pass shapes a guest can give, and nothing
  raises under MTL_DEBUG_LAYER. gpu/rate_map.rs records the measurements,
  and its tests fail with the hang without the draw.

Tests that follow the host's release:
- A depth-stencil state's gpuResourceID answers 0 at 27.0.1 where it raised
  at 26.7, and resourceIndex still raises. The getter tests expect each
  release's measured answer. Core's depth-stencil info reply reads both, so
  the request still raises on either release.
- Three Vulkan tests follow the runtime's Metal level: the setter takes 301
  values at 27.0.1 (288 at 26.7), YCbCr8_420_2P's cast class is 46 (43),
  and the legacy-heap test leaves out formats 630 to 645, whose block rule
  is 26.7's. format_info.rs records that Metal on the M3 Max describes none
  of 630 to 645 at 27.0.1, where the runtime's level, measured on an M4,
  describes all 16; the tests that hit that stay failing on this host until
  metal2vulkan's level does.
- Metal answers supportsMemoryOrderAtomics true at 27.0.1 (false at 26.7).
  The Vulkan platform's stand-in stays false, as the runtime has none, and
  the test pins the device's own answer and Metal's at each level.

The suite:
- The 1361 host-keyed cases are recorded for AppleM3Max-40c-26A434; the
  25G229 files stay for hosts on 26.7. 1089 differ only in the key. 272
  differ in Metal answers the Metal platform passes through: device-info key
  26 (memory-order atomics) is 1, and 13 buffer and heap-placement GPU
  addresses in isolated tasks' replies come out lower.
- suspend_crafted_resume is keyed by host: its last suspend's blob holds the
  host's device info. Its unkeyed 26.7 files are removed.
- interplay_decodewalk_27's walk ends at its host-dependent exec, an
  indirect dispatch after two compute encoders of different dispatch types:
  Metal ended the process there at 26.7 and runs it at 27.0.1. The seed is
  keyed by host and stops at that exec, waiting for its stamp and comparing
  every window with the model. Only seed 27's ops change. Its 26.7 outcome
  cannot be recorded again without a 26.x host, so its unkeyed files are
  removed.

Nothing changes for the guest or the host, except that the host's GPU no
longer hangs on such a pass. On this branch's tree, cargo xtask check fails
only the 11 tests the runtime's 27.0.1 level decides (formats 630 to 645,
format 263's heap alignment, four mipmap chains), plus YCbCr sweeps that pass
run again alone; make test passes on 26A434.
2026-10-15 22:02:38 +03:00
Anees Iqbal 0d44fea30a 🐛 Keep QEMU alive when a guest process dies with work queued
A guest empties a task's object list when the process that owns it ends,
without waiting for the execs that process queued. On an x86-64 macOS 26
guest the icon services abort as they start (Metal's nil device
architecture, docs/qemu.md), and the host, still compiling pipelines for
earlier execs, reaches their last execs after the lists are gone. Most
lookups then fail and fault the exec, but two answered nil where nil ends
the process:
- A pipeline descriptor's function: Metal aborts on a render descriptor
  with no vertex function, and QEMU died at Setup Assistant on a new
  install (2 of 10 boots on an RTX 5080 Laptop GPU host). A function whose
  entry is empty now raises the function lookup's failure.
- A resource named by UseResources in a concurrent compute encoder, where
  Metal ends the process at a nil entry. Such a reference whose entry is
  empty now raises too. Serial encoders, barriers and the render lists
  keep the nil, which Metal skips.
The Vulkan platform ended the process at a nil entry of
useResources:count:usage:stages:, which nothing had measured on Metal.
Metal skips it (measured here), and so does the platform now.

reims-ctl adds dump-guest-core=off to the q35 machine on Linux hosts. With
guest RAM in the core, a crash took QEMU 26 s to go away (a 2.7 GB core)
while its window stayed frozen; with the option, 1 to 4 s. QEMU refuses
the option on macOS, so the vmapple command line is unchanged.

What the guest and host observe: an exec whose pipeline function, or whose
concurrent UseResources reference, has an empty entry faults instead of
ending the process. interplay_lifetime_held_pipeline_function_retyped is
recorded again; interplay_lifetime_emptied_resource and
interplay_lifetime_emptied_resource_render are new. Six boots of the new
install to Setup Assistant on the fixed builds kept QEMU alive, though
none reached an empty function entry. docs/qemu.md records the race's
measurements and why no value the host answers avoids the nil
architecture.
2026-10-13 01:24:15 +03:00
Anees Iqbal 2624fe619b 📝 Move the README's developer reference to docs/development.md [ci skip]
The README now speaks to people running VMs through reims-ctl. The repository
layout, the tests and the Rust library's crates, commands, profiles and
features move to docs/development.md, which the README's Developing section,
AGENTS.md and the docs that cited those sections now point to. The QEMU and VM
section is gone (docs/qemu.md covers it), as are History, whose tags AGENTS.md
now names itself, and the interoperability note under Legal.
2026-10-11 22:10:39 +03:00
Anees Iqbal 98fe2a3bd5 🆕 Replace the tree with libreims_vgpu and its C API
This repository now holds libreims_vgpu, a Rust library that is the host
side of the paravirtualized GPU macOS guests drive, in place of Apple's
ParavirtualizedGraphics.framework: the library and its C API
(reims_vgpu.h), the PCI device's option ROM, QEMU's apple-gfx on that API
(vendor/qemu), the behaviour-lock suite that drives the C API as QEMU
does, and reims-ctl, the VM manager users run. README.md says what it is
and how it is laid out, and AGENTS.md how to change it.

Every file of the earlier tree is replaced. vendor/qemu moves to the
steelbrain/reims-vgpu branch of the same public repository.
2026-10-11 20:27:17 +03:00