Commit Graph
51 Commits
Author SHA1 Message Date
Anees Iqbal 031e0e8ca3 🐛 Hold the process's exit until the library's GPU steps end
A process exits on one thread, which runs the exit handlers and the loaded
libraries' destructors while every other thread goes on. A thread of the
library's inside a driver then ends the process: on the RTX 5080 test processes
ended with SIGSEGV inside libnvidia-glvkspirv after their tests passed, and the
awake thread's touches segfaulted 79 times in six minutes before it got a gate
of its own. The runtime's guard covers only the runtime's own threads, and the
platform keeps its devices for the process, so dropping them is no way out.

So the awake thread's gate becomes the library's: reims_vgpu_vulkan::exit_gate.
Each job of the library's threads that may call a driver is a step of it:
every reims-vgpu entry (the C API's calls, the device's callbacks, the jobs of
lanes, compile threads and surface workers), each compile (a making), a
window's frame, a video picture landed or frame encoded, and each call of the
video crate's threads, through a new Runtime::exit_step. An exit handler,
registered at each device's adoption, as a compile pool starts, after each
making and at each power of two of a thread's steps, closes the gate and
waits for the steps in progress on other threads, 2 s at most, or 60 s while
a compile is among them, as the runtime's guard waits for its makings. A step
begun after it ran parks its thread for good, except on the exiting thread.

What the host sees: an exit (QEMU's quit, a test process's end) now waits for
the library's GPU work in progress, bounded as above, where it could end the
process with a signal; a library thread or a call of the host's that would
begin work after the exit began parks. docs/api.md says so. Nothing the guest
sees changes. Tests: a child process that exits mid-compile with a second
compile queued (the first ends, the second never runs), the gate's own exit
children, and the awake thread's exit test on the shared gate.
2026-11-08 09:23:03 -08:00
Anees Iqbal 5a4418c894 📝 Say that core is the Vulkan crate's module [ci skip]
reims-vgpu-core is folded into reims-vgpu-vulkan, so the docs, the
manifests' comments and the crate descriptions that named the crate name
its module now: the crate lists and graph, seven crates, core's files under
crates/reims-vgpu-vulkan/src/core, the testkit feature, and what the x86-64
leg runs. The design note that put the decoder in core says where it is,
reims-vgpu's graphics::decode, and the path of a deleted file goes. The
kache measurement keeps the crate's name, as it was measured then.
2026-11-08 01:55:07 -08:00
Anees Iqbal 6fb33ecd27 🎨 Rename the reims-graphics crate to reims-vgpu-graphics
The crate that holds the reims-graphics device's wire and transport now
carries the library's prefix, as reims-vgpu-video does: its directory is
crates/reims-vgpu-graphics, its package reims-vgpu-graphics, and its Rust
path and log target reims_vgpu_graphics. The guest's, the option ROM's and
Ambrosia's Makefiles include the wire header from the new directory, and the
prebuilt records name it there.

Nothing changes for the guest or the host. The device keeps its name
(reims-graphics, QEMU's reims-graphics-pci, PCI 1234:5247), and the wire
header keeps its file name and RGFX_ symbols. The C API header is unchanged,
and the prebuilt kexts and option ROM are byte-identical; only the records'
paths and source hashes move. A log filter names the crate's lines by its
new target (REIMS_VGPU_LOG=info,reims_vgpu_graphics=trace), a diagnostic.
2026-11-08 01:37:50 -08:00
Anees Iqbal acd9919a93 📝 Say the library runs on the Vulkan platform alone [ci skip]
The Metal platform is gone (the commit before): AGENTS.md, README.md and the
docs now say the library carries out the guest's calls on the Vulkan
platform, on Linux and on a Mac over MoltenVK for development and tests;
that the display's shaders live in the Vulkan crate; that `cargo xtask
dist` writes target/dist-vulkan on every OS; and that the tests of the
Vulkan platform compare with Metal's recorded answers. architecture.md's
section 4.6 describes the answer layer and the macOS message layer in
place of the metal crate's. conventions.md keeps "core changes as little as
the Vulkan and Linux work allows" without its reason, the Metal product.
2026-11-07 23:22:28 -08:00
Anees Iqbal a0dc2e80ff 🔥 Draw the scanout at each refresh, without the host's dirty log
The display showed the guest's scanout again at a refresh only where the
host's dirty log said the guest wrote it (scanout_written, QEMU's log over
BAR 2's allocations). The scanout shows only at boot and in recovery, and
the owner takes its full cost for the simplicity (2026-11-07): the
callback, RvgGraphicsScanoutWrittenFn and RvgGraphicsCallbacks'
scanout_written, are gone from the C API, with reims-vgpu's
ScanoutWrittenFn and reims-graphics' Host::scanout_written.

Each refresh while the guest has a scanout now asks the screen to show it
again (Screen::present). The window draws it only while it shows the
scanout: while a presented surface shows, a refresh draws nothing, and the
guest's presents alone draw, as before, so an accelerated desktop's
refreshes cost no frame (a 4K window at 120 Hz would otherwise copy about
4 GB/s for nothing).

For the host: RvgGraphicsCallbacks loses its scanout_written field, so the
cursor callbacks after it move up one pointer; QEMU's reims-graphics-pci
no longer sets it (the commit before). For the guest: the boot and
recovery screens show what the guest wrote by the next refresh, as before.

Window::frames_asked counts the frames a window is asked for, which the
new tests read: a refresh draws the scanout while no surface shows, and
nothing while one does.
2026-11-07 22:15:20 -08:00
Anees Iqbal d4a4431911 📝 Describe the architecture and the C API of our device [ci skip]
architecture.md and api.md described Apple's paravirtualized device: its
tasks, FIFOs, displays, frames, IOSurface and video devices, suspend and
resume, isolated tasks, the suite's runner and QEMU's apple-gfx. api.md now
specifies the C API there is, the graphics device's ten functions, with its
threads and locks in section 5, which the header cites. architecture.md
describes the crates and the device as they are, keeping the section and
decision numbers code cites; the numbers of what went are retired, not
reused.
2026-11-07 20:07:29 -08:00
Anees Iqbal 4f5d1d5069 ⬆️ Build on metal2vulkan fa07d59e81's runtime
Pin moves 17 and 18 in one: metal2vulkan development 6b4b4b0692..fa07d59e81
(220 commits), RUNTIME_VERSION 1807, SEMANTICS_VERSION 1990,
ARTIFACT_FORMAT_VERSION 492. What changes for the guest and the host:
- Guest RAM on a dma-buf device is a few long chunks, none made ahead, idle
  ones released; no making or copy waits for a chunk's import. On the 780M the
  first object over an unimported chunk took 665-692 ms and now 1-2 ms, and a
  gather's encode about 660 ms and now 23-38 ms.
- On Linux the process's exit waits within a bound for the runtime's work,
  then runs the earlier exit handlers (QEMU's exit notifiers among them).
- A colour attachment stored DontCare stores as the driver stores it by
  default, announced dont-care-store, and keeps its earlier texels, as Apple's
  GPU leaves them, under REIMS_VGPU_EXACT=dont_care_colors.
- Off macOS, the GPU's writes to no-copy memory made with Metal's private
  option bit 24 are dropped through a copy, as Metal drops them.
- Twenty formats Metal makes and the runtime refused, its one-plane YCbCr
  formats, the padded 10- and 12-bit display formats and transfer twins
  among them, are made for copies alone; every read, write and render of one
  stays refused.
- A 2D or 2D-array texture over a buffer whose texels run past its length is
  made, its tail the runtime's own.
- Mesh pipelines with maxVertexAmplificationCount above 1 are made, and their
  amplified draws refused.
- ARGB8Unorm destination alpha is blended in the shader where no Vulkan state
  gives Metal's blend; an executed command's unstrided buffer reads at stride
  2^32-1, as Metal reads it.
- Encoding costs less per draw: attachment memory worked out once a layout
  version, host-byte uses kept in the encoder, per-thread argument-table
  stamps, a bind memo.

No degradation kind is added or removed, so answer.rs places nothing new.
Cargo.lock is unchanged: the runtime's dependencies are the same, and the lock
keeps its metal2vulkan source lines stripped. RuntimeGap::
IndirectCommandUnstridedBuffer, which this tree never named, is gone.

Adapted here:
- The Linux remap test and the remap docs read Device::
  pointer_imports_follow_their_address, in place of the removed DriverFact::
  PointerImportsFollowTheirAddress.
- REIMS_VGPU_EXACT names dont_care_colors, selecting DontCareColorPolicy::
  Kept (platform.rs, docs/api.md, an accuracy-ledger row).
- The texture-gap tests take RGB10A8_2P (624), a format the runtime still
  refuses, since 501 is now made for copies alone.
- The MoltenVK tests take the copies-only formats: the formats-the-runtime-
  lacks test drops 501 and holds the two-plane RGB10A8 family (624-627); a new
  test makes and copies the nine one-plane formats at every creator as Metal
  does; the legacy-heap comparison leaves those nine out. Two ignored tests
  and two accuracy-ledger entries record the runtime's gaps there, asked of
  metal2vulkan: a kernel's read of one reads zeros, and in a heap its texels
  are tiled where Metal lays plain rows.

Checked on the Mac (MoltenVK), the 780M (RADV, the whole workspace) and the
RTX 5080, and the merged tree on um870's 780M with a video decode boot. The
Iris Xe leg is still to run: its host stopped answering before the run ended,
and the leg runs when the host is back, with any failure fixed forward.
2026-11-07 13:13:06 -08:00
Anees Iqbal 99bfd0583f 🐛 Build the library on Linux without the vulkan feature
On Linux the Vulkan platform is the library's only one, yet reims-vgpu and
reims-vgpu-c refused to build without their `vulkan` features (a
compile_error!), and the code behind it did not compile either: a
default-feature Linux build of the package failed. A crate that does not
build in a feature setting is a failure, so the platform is now unconditional
on Linux.

- reims-vgpu's new build script sets `cfg(vulkan_platform)` on Linux, and on
  macOS with the `vulkan` feature, declared for check-cfg. Every
  `feature = "vulkan"` gate in the crate is that cfg; the gates of "macOS or
  the feature", true on every target the library builds for, are gone.
- The Vulkan platform's dependencies are not optional on Linux; on macOS they
  stay the feature's, optional, so the Mac's default build is as before.
- reims-vgpu-c makes every handle on VulkanPlatform on Linux whatever its
  features; the compile_error!s go.

Behaviour is unchanged on both OSes: on macOS every cfg answers as the
feature did, and on Linux as the builds with the feature did. The docs and
comments that said Linux needs the feature say it no longer does.
2026-11-07 06:54:33 -08:00
Anees Iqbal 89c76816fc 🆕 Tell the graphics device's host the guest's cursor
The library kept the guest's SET_CURSOR and MOVE_CURSOR for its own window
and told the host nothing of them, so QEMU's console never had a cursor
for reims-graphics-pci: a VM on the reims-vgpu graphics option shown
through QEMU's own displays (SPICE, VNC, GTK, D-Bus) had none, though the
pointer moved the guest's, where apple-gfx's displays draw one.

RvgGraphicsCallbacks grows cursor_glyph, cursor_show and cursor_move, the
display's own callback types, and rvg_graphics_device_cursor_position reads
where the guest put its cursor's hot spot. The device queues them onto the
display thread in the order its control thread took the guest's commands
and its resets, so they run as a display's do and never inside a call of
the host's, a reset's included. The glyph is the straight-alpha RGBA the
window takes; the cursor shows once the guest has an image while it shows
its cursor. A host built against the first version passes 40 bytes and is
told nothing. The guest sees nothing of it, and the window is unchanged.
2026-11-07 04:20:17 -08:00
Anees Iqbal 8970ba8391 🐎 Answer a landed download on its ring-0 doorbell's thread
A CPU lock of a surface whose pages already hold its device cache (a decoder's
output whose early copy has landed, or a cache nothing wrote) still waited for
the control thread to wake and take its SURFACE_DOWNLOAD: p50 95.4 us from
the doorbell to the COMPLETE on the 5080 (decode-perf), most of it the idle
core's wake.

A DOORBELL write of ring 0 through mmio_write_taking now takes ring 0's next
message on the writing thread and answers it there, where it is a
SURFACE_DOWNLOAD the host has carried out already (Host::surface_downloaded,
new, default false), the control thread sleeps with every answer of what it
took posted (Submit::asleep, set and cleared under the ring's lock), the
block's lane has nothing left and the control completion ring has room.
Every lock is tried, the message is copied onto the stack, and nothing is
allocated or freed. The host's answer is the caches' own (downloaded_now):
true only where its download would answer at once with nothing to copy and
nothing to wait for, keeping the download's counts as it does. The interrupt
is raised with no lock held. In every other case the control thread takes
the download as before.

What changes for the host: a ring-0 DOORBELL write through
rvg_graphics_device_mmio_write_taking may now post a COMPLETE and call
raise_interrupt inside the call, as a queue's doorbell write already may (the
header, docs/api.md). The guest sees its answer sooner; its order among ring
0's answers is as the control thread gives it. QEMU 22ae1fd1 takes ring 0's
doorbell with an ioeventfd, so under QEMU nothing changes until
reims-graphics-pci sends that write through _mmio_write_taking too.

Tests: a_landed_download_is_answered_on_its_doorbell_s_thread and
a_doorbell_s_thread_leaves_a_download_the_control_thread_must_take
(reims-graphics), a_landed_download_s_answer_at_its_doorbell_allocates_nothing
(reims-vgpu). a_landed_download_s_doorbell_to_its_answer now measures both
writes, in turns over five rounds each.

Car 14's stack: device.rs keeps both new methods beside each other,
c14-submit-path's mark_idle and mark_awake (a queue's ring, efd360f45) and this
commit's download_on_doorbell (ring 0); ring_taking sends ring 0 to
download_on_doorbell and a queue's ring to answer_on_doorbell, as before.
2026-11-05 21:59:36 -08:00
Anees Iqbal 6bfd19641b 🐎 Serve ring 0's lanes on shared threads kept 10 s
Each of ring 0's lanes (a context's, the presents', a block's) had a thread of
its own, made as a message came to a lane with none and gone once the lane had
had none for 1 s. So every new surface's block made a thread for its first
SURFACE_PAGES, and so did every lane's message after a pause of a second. A
thread's start may map a 2 MiB stack and its end unmap one, writes of the
process's memory map that a vCPU's page fault waits behind: car 12's B1
counted 345 graphics threads made in 30 s of a WindowServer probe, and a vCPU
sat 30 ms or more in a fault while one of them was in munmap of 0x201000
bytes, inside an 81 ms frame (msi RTX 5080; measured).

Ring 0's threads, reims-vgpu.graphics-ring0-<i>, now serve the lanes. A lane
handed a message while it has no thread is given the thread that went idle
last, or one made for it where none waits, and keeps it until it has no
message left; the thread then waits for the next lane and goes once it has
waited 10 s (reims_graphics::keep, new: KEEP, and a clock the tests move). A
lane with nothing to do holds no thread, so the device holds as many threads
as it had lanes busy at once in the last 10 s, whichever contexts and blocks
they were. A lane with a message is never refused a thread, so the waits the
lanes' order relies on still end.

Measured on the M3 Max with
ring_0_s_threads_under_a_windowserver_probe_s_and_a_game_s_wakes, which
replays 30 s of B1's rates (presents at 60 Hz, ten contexts' messages at gaps
of 1.1 to 3 s, a new block's pages every 150 ms and again 1.5 s later) and of
a game's, wakes made up to their kinds, which make more threads without it
than the boots counted: ring 0's threads made in each 10 s went from 177, 183
and 181 to 3, 2 and 0 under the probe's wakes, and those ended from 158, 183
and 185 to 0, 0 and 1; under the game's, made from 14, 11 and 10 to 2, 0 and
0, and ended from 10, 11 and 11 to none. A synchronous create's round trip
(a_sync_create_s_round_trip, release, three runs each with this change and
without, alternating, on the M3 Max under other builds' load): after a pause
of 1.2 s, 64 to 171 us at the median against 116 to 353 us without, where the
pause ended the lane's thread; back to back, 13.6 to 16.4 us against 10.3 to
13.9; behind four creates it does not wait for, 10.6 to 12.8 us against 11.7
to 12.5. What this adds to a message for a lane that had emptied is a lane
record made again and the hand-over of a waiting thread through its own
condvar, where the lane's own thread was woken before.

For the host: the callbacks the lanes make (raise_interrupt among them) run on
reims-vgpu.graphics-ring0-<i> in place of reims-vgpu.graphics-context-<n>,
reims-vgpu.graphics-presents and reims-vgpu.graphics-block-<offset>. Thread
names are diagnostics (docs/api.md); the header's comment, api.md and
design.md name the new ones. The guest sees only timing.

Tests, on the test clock:
a_steady_load_s_lanes_are_served_by_one_thread_through_its_pauses (30 messages
of three contexts, each after 2 s, on one thread; it goes after 10 s with
none), a_burst_s_other_threads_go_once_they_have_waited_keep (three busy
lanes' threads, then one lane at a time: the two others go 10 s after the
burst, the one serving stays) and
the_device_s_end_ends_the_threads_that_wait_for_a_lane. The tests that named a
lane's thread now check it is one of ring 0's;
an_idle_lane_goes_while_another_context_s_is_busy, whose lane thread no longer
exists, is gone.
ring_0_s_threads_under_a_windowserver_probe_s_and_a_game_s_wakes is the
measurement, run by hand on macOS.
2026-11-05 21:59:35 -08:00
Anees Iqbal ed70015809 🐛 Answer nil where the runtime refuses an object for a gap
On the Vulkan platform, a runtime refusal at a creator for a gap of its own
or of the device's (Unsupported, but by a GPU family or a device Metal
itself refuses it on; NotImplemented; AppleOnly; a compile's Unsupported)
ended the process at the creator, where Metal makes the object. A Flutter
app's BGRA10_XR render pipeline on an RTX 5060 Ti took a macOS guest down
this way (Unsupported { feature: Format, needs: NotImplemented }).

Behaviour change, for the guest and the host: by default the creator now
answers nil, a pipeline state or a library creator with the runtime's
refusal as its NSError, so core's nil-without-error death never fires;
textures, views, buffers, heaps, functions, sampler and depth-stencil states,
argument encoders, indirect command buffers and rate maps answer nil. Apple's
guest framework then fails the work that names the object, as where Metal
answers nil: what was a VM going down is that exec faulting. In strict mode
(REIMS_VGPU_STRICT=1) each still dies at its selector with the same line.

This keeps the owner's rule on runtime gaps: the gap stays visible, relayed
as the new kind inexact-refused-create (the first of its kind writes a line
naming the refusal and the descriptor's formats, each one is counted) and a
death in strict mode, and it is handed to metal2vulkan. Nothing here makes
the missing feature. A lost device, a Vulkan failure, no memory, an answer
the runtime cannot prove and every other refusal still die at the creator.
The library's own pipelines and shader library are unchanged.

The kind is placed in every_inexact_kind_is_placed_once, the placement test
of this platform's own kinds, which also checks its code is no runtime
kind's. The accuracy ledger lists it.
2026-11-05 21:59:35 -08:00
Anees Iqbal a562b48c14 🆕 Read the graphics display back, and show it in QEMU's console
reims-graphics-pci's QEMU console carried input only, so QMP's screendump
was always an empty 640x480 image: the login-clock, desktop and lane-gate
checks had no way to see the guest's frame once WindowServer presents
IOSurfaces, which live in the host's device caches, not in the scanout.

For the host: rvg_graphics_device_read_display, the C API's 57th function
(additive), reads what the display shows now into the host's buffer: the
scanout or the presented IOSurface, through the display's colour, drawn as
the window draws it into a texture of the display's mode, BGRA8 rows of
width * 4 bytes, black where the guest shows nothing. It gives the mode's
size whatever it answers, so a NULL buffer asks it, and waits only for its
own draw on the GPU, on a queue of its own. QEMU (vendor/qemu 70a9a466)
calls it from the console's gfx_update on a thread of its pool, so the
console, QEMU's displays and screendump show the guest's frame.

For the guest: nothing. The read answers no present (the window's draw does,
through ScanoutDraw::encode, now over encode_shown), tells the guest no
mode, and holds a presented surface's block only while its draw reads it,
as the window's draw does. A device with no window keeps the guest's
scanout in a screen of its own for the reads, offering the same 1920 x 1080
at 60 Hz as before.
2026-11-05 21:59:34 -08:00
Anees Iqbal c9b243ff80 📝 Say what reims-graphics-pci calls and what its BAR 2 needs [ci skip]
QEMU's reims-graphics-pci writes every register through
rvg_graphics_device_mmio_write_taking, so a queue's doorbell may answer its
next command buffer on the vCPU; docs/api.md said it called everything but
that function. Its BAR 2 is the library's 1 GiB region, with the guest's
allocations from 0x400000, where the docs still said 256 MiB and 0x20000,
and a 1 GiB BAR needs the machine's max-ram-below-4g=1G, which docs/qemu.md
never named: reims-ctl does not add the device, so whoever adds it needs the
option too.
2026-11-05 21:59:32 -08:00
Anees Iqbal 859625a1f5 🐛 Keep the graphics display's scanout across a reset
A reset of the reims-graphics device (STATUS 0, or the host's reset) blanked
the display: the screen was told there was no scanout, and the window kept
its last frame. The kext's start resets the device to take it, and where the
start fails after that (the device lists no usable display, IOFramebuffer's
start fails) it resets it again on the way out. The OS then draws into the
firmware's framebuffer, but the firmware's scanout was gone. The host's
window stayed on the boot screen, and nothing the guest drew after that
reached it.

What the host sees now: a reset leaves the display's scanout as the last
SET_SCANOUT set it. A GPU's display engine does the same across a reset of
its driver. The screen is told nothing at the reset, and each refresh shows
the guest's writes there as before, until the guest sets another scanout or
blanks it. A reset while the display pipe shows a surface shows the kept
scanout in its place. The guest sees no change: nothing it reads names the
scanout.

The tests cover the failure after the take on the device and through the
window's sink on the testkit's platform. In the crate's tests the window
asks the host for no screen, so on Linux they start no UI thread.
2026-11-05 21:59:31 -08:00
Anees Iqbal 2204e4a7dc 📝 Name the closes' worker among raise_interrupt's threads [ci skip]
Since the close-cost change, a context's close lets go of its objects on the
closes' worker, reims-vgpu.graphics-closes-<i>, and drops the close's drain
there. Where its command buffers had already finished, the drain's answers run
on that thread: the close's answer, the waiting posts and raise_interrupt.
Releases chained behind the drain answer there too. The header promises
raise_interrupt only on the threads it names, and this one was missing from
the list. It is added to the C API's list, the Rust API's and docs/api.md's.
The names list in api.md also gains graphics-video-<i>, the video sessions'
worker, which raises nothing. cargo xtask header rewrote the header.
2026-11-05 21:59:30 -08:00
Anees Iqbal ff0a952a2b 🎨 Name the event-waits thread in the reims-vgpu scheme
Every other thread of the library's is named reims-vgpu.<role>, so a sample or
a crash log groups it with its device; the watcher of command buffers waiting
for shared events was still rgfx-event-waits. It is now
reims-vgpu.graphics-event-waits, and docs/api.md's list of thread names has it
with the graphics device's others. Thread names are diagnostics (docs/api.md),
so nothing a guest or host sees changes.
2026-11-05 21:59:29 -08:00
Anees Iqbal f892111aa6 🐎 Give each surface block and process a worker turn of its own
The surface worker and the ICB worker were one thread each, so one block's slow
view (9000 mappings of a 3840x2400 layer took up to 478 ms on the msi 5080
host) held every other block's SURFACE_PAGES behind it, and one process's ICB
creates every other process's. Each worker is now a pool of at most four
threads, made as a job finds none waiting and gone after 1 s idle, that runs one
key's jobs one at a time in the order handed over and different keys' at once.
The surface worker's key is the block (its SURFACE_PAGES, its BUFFER_OVER_PAGES
handed over, its release's drops, a buffer over its view at its destroy); the
ICB worker's is the buffer's context. A key's job wakes one waiting thread, a
ready key that finds every thread busy is counted, and a job runs where it is
handed over where no thread can be started.

No job waits for another key's job, so the cap cannot deadlock: a
BUFFER_OVER_PAGES waits only for its own block's SURFACE_PAGES, which ran
before it, and SURFACE_PAGES jobs wait for nothing. A debug build checks it in
Unsettled::wait. The one order the single thread gave that nothing needs: two
BUFFER_OVER_PAGES of one context on different blocks are made in either order,
which no answer orders; the context's later messages still wait for both.

The threads are named <name>-<i>, which docs/api.md, the header's comment and
reims-vgpu's callbacks doc now say. Beside K blocks that each run 25 ms jobs
back to back, another block's job starts after its hand-off in 0.015 ms at the
median for K of 1 or 2, 5 to 6 ms for 4 and 35 to 38 ms for 8, where one thread
took 24, 115 to 117 and 241 ms (another_blocks_job_beside_busy_blocks, release
build, M3 Max, two alternated runs each at load averages of 28 to 52).
2026-11-05 21:59:29 -08:00
Anees Iqbal 05d23288a2 🆕 Carry each block's pages and downloads on a lane of its own
A block's SURFACE_PAGES rode its context's ring-0 lane and its
SURFACE_DOWNLOAD ran on the control thread. The kext's hand-over of a
surface's put-off pages is a SURFACE_PAGES for the surface's maker, posted
from another process's CPU lock or from the release thread, and followed by
a download or a release without waiting for its answer. On the maker's lane
it sat behind the maker's unrelated messages, or behind a lane held by a
maker that had closed, and the download on the control thread could go
first.

Every SURFACE_PAGES and SURFACE_DOWNLOAD now goes to the lane of the block
it names, in ring order, whatever its flags or context. What reads what
that lane makes of the block waits for it through its position: a buffer
or heap over a pages block, a buffer over a surface's pages, and a release.
A context's later messages and command buffers still wait for its
SURFACE_PAGES, and a SURFACE_PAGES waits for its context's earlier makes
over the same block. So the only order dropped is a SURFACE_PAGES waiting
for its context's messages that do not name its block. A SURFACE_PAGES
also no longer clears a block's holders, so a release after a hand-over
still waits for the other holders' lanes. The lanes' module doc lists
every message that names a block by offset and what orders it.

What the guest sees: answers to a block's pages and downloads may come
before those of messages its maker posted earlier on other lanes. The kext
matches answers by seqno. The fuzz now generates every block-naming kind
against held block lanes.
2026-11-05 21:59:29 -08:00
Anees Iqbal 17f6d6cf47 📝 Name every thread that raises a graphics interrupt [ci skip]
raise_interrupt's thread list named the control, refresh, queue, compile and
ring-0 lane threads and the platform's handler thread, but not three threads
of reims-vgpu's that post on the control completion ring. Counted by thread
in two boots of 75 processes on the RTX 5080 host (car 8's image, before and
after ring 0's lanes), the control ring's interrupt was also raised on a
command queue's lane threads (reims-vgpu.graphics-lane-<id>, 84 and 62
times), the surface worker (reims-vgpu.graphics-surfaces, 4196 and 4284) and
the ICB worker (reims-vgpu.icb-create, once each). The header's comment,
docs/api.md and reims-vgpu's own doc now name them.
2026-11-05 21:59:28 -08:00
Anees Iqbal 4f666851e4 🐎 Carry each process's ring-0 messages out on a lane of its own
Ring 0's control thread carried out every guest process's control messages
in ring order, so one slow message, a pipeline compile of tens of ms or a
large buffer's make, held every other process's command buffers behind it:
their queues wait until the control thread has carried out what they name.

The control thread now takes each message and hands the lifecycle messages
of a context to that context's lane (`reims-vgpu.graphics-context-<n>`) and
PRESENT_SURFACE to the presents' lane (`reims-vgpu.graphics-presents`). Each
lane carries its messages out in ring order, made on demand and ended after
a second idle. A message waits on the lanes only where an order crosses
processes: a present for the creates and destroys of its surface's textures
and the closes of contexts that hold one, a block's release for its former
holders, a scanout grant for every other context, a resource-ID chunk for
its previous holder's close, and a context's first message for every close
not yet carried out. A queue's gate also waits for its own context's lane
to carry out the messages it names.

Each lane's thread waits on a wake of its own: it is woken for its own
messages and, where its next message waits for other lanes, as they carry
theirs out. With one wake for every lane, a boot of 75 processes on the RTX
5080 host woke every lane at each message any lane took or carried out, so
no lane ever went idle, and command buffers waited 1 ms or more for ring 0
1610 times (3266 ms in all) against 428 (1064 ms) on the control thread
alone; beside 75 idle lanes a context's burst of 200 messages took 16 to 59
ms at the median against under 1 ms beside none.

Display commands stay on the control thread, held, and a reset still drops
what no lane has begun, after the lanes' begun messages return. The host's
raise_interrupt may now run on a lane, which the header and docs/api.md say
(an additive change to the thread list).
2026-11-05 21:59:28 -08:00
Anees Iqbal 5bde808250 🐎 Answer a command buffer on its doorbell's vCPU
A guest write to a command queue's DOORBELL can now answer the buffer at
the head of that queue's ring, if it comes through
rvg_graphics_device_mmio_write_taking. The answer posts the buffer's
CB_SUBMITTED and raises the queue's vector on the writing vCPU, before the
queue's thread wakes. The buffer stays on the ring. The queue's thread
then takes it as it takes any other, without waiting for ring 0 again.

The vCPU only tries locks, and never waits, loops or allocates: the
message is copied onto its stack, at most 16 KiB. Any try that misses
leaves the buffer to the queue's thread, as before: a lock held
elsewhere, ring 0 not yet carried out as far as the buffer waits for, or
a buffer that uses a device cache, waits for an event or sits behind a
held buffer. The answer takes the buffer's lane turn and its ticket in
the commit order together. The begin uses them in place of its own, so
queue, commit and ring-0 order are those of an answer at the take.

What the guest sees: CB_SUBMITTED of such a buffer arrives inside the
doorbell write. A platform refusal of a buffer answered there fails the
buffer in its turn, after the answer, as one answered at its take does.

Tests:
- a counting allocator holds the vCPU path to no allocation;
- a reset between the answer and the begin lets the answer go;
- a refused make after an answer fails in turn;
- the decoder fuzz checks that queue and commit order match the
  worker-only path;
- the device checks that an answered buffer waits for no later ring-0
  message.
2026-11-05 21:59:26 -08:00
Anees Iqbal 55cdab6483 ⬆️ Build on metal2vulkan e71efbe0e9's runtime
metal2vulkan e71efbe0e9 is c8a0481cf8 plus three stacks (RUNTIME 1747):
- Command queues share VkQueues where the device's own check finds the GPU
  idles at each switch between queues (the 5080), with an unshared form for
  a queue that must never wait behind another's long command buffer:
  new_command_queue_unshared. The graphics lane's WindowServer queues
  (RGFX_QUEUE_UNSHARED) now take it through unshared_queue, which made the
  plain queue until the runtime had one; on a device that shares no VkQueue
  it is the queue every create makes. The runtime's exact answers keep every
  queue on its own VkQueue, so REIMS_VGPU_EXACT gains queue_sharing
  (QueueSharingPolicy::PerQueue), with its accuracy-ledger row; docs/api.md
  now also lists extended_range_blits there.
- Noted textures' pattern reads and writes are logged once each, with no
  allocation per draw.
- A command buffer joins its ended encoders' resources into its residency
  where its work reads them, not as each encoder ends (end_call with 4096
  resident: 205 to 7.2 us on the RTX 5080); a sampler state's creation prunes
  the live states' map only once it has doubled (1.97 to 0.56 us at 1000
  live, 16.75 to 0.48 us at 10000, on the M3 Max); a commit counts its
  buffers' host imports in place, and the translator's spec_key makes its
  lists once.
2026-11-05 21:59:25 -08:00
Anees Iqbal da9c930aaf 🐛 Drop every object the guest made at a device reset
A reset (the framebuffer's STATUS 0, and QEMU's reset of the device at a
reboot inside one QEMU run) put the rings and the display back, but told the
host nothing: the decoder kept every texture, heap, buffer, pipeline, library,
surface view (with its lease on guest RAM and its imports), device cache and
managed copy, and the region kept every block grant. A rebooted guest then met
its own leaked objects: the next boot's WindowServer had its buffer pins
refused by Metal's space ("refused the pin: Held { requested:
400000008000.., held: 400000008000 }"), and its command buffers faulted by
the thousand.

After a reset the device now looks new, as a real device does after a function
reset. Every queue ends and is fenced, no block is any process's, and the host
is told on the control thread (Host::device_reset), before the thread takes
anything published after the reset. The decoder drops every context's objects
as a close does, each in a refusal scope, lowest context first, and with them
the surface views, the device caches (uncopied: the pages are the rebooted
guest's), the library cache, the presents waiting, the pipelines compiling and
the shown surface. Nothing begun before the reset reaches the guest after it:
a poster carries the reset count its work began at, a queue made before the
reset hands the host nothing more (not even its destroy, which the reset
stands for), and a compile begun before it stores nothing.

What the guest observes after a reset: the ids it picks, the texture resource
ids and pinned GPU addresses it uses, and the samplers' ids it is handed are
free as on a new device; a library lookup misses; no answer or event of work
from before the reset arrives.
2026-11-05 21:59:23 -08:00
Anees Iqbal 0600467702 ⬆️ Ring a queue's doorbell with the plain write in QEMU
QEMU 67cc08ad takes reims-graphics-pci's command queue doorbells through
rvg_graphics_device_mmio_write again, so the queue's thread takes its
command buffers and the vCPU only wakes it. The library keeps
_mmio_write_taking, additive and now unused by QEMU.

The take on the vCPU did not pay on msi's x86-64 guest. 86% of the
compositor queue's doorbells found ring 0 behind and fell back to the
queue's thread, so the frame's command buffer was rarely taken inline.
WindowServer's composite (CLTD, its CompositeLayersToDestination call's
wall time) was a wash at the tip, mean 555 us with the take against 621
without and p50 442 against 435, and the take cost the vCPU about 15 us a
doorbell at the p50. Its tail was jemalloc's decay purge, madvise calls of
up to 340 us run on the vCPU inside the take's allocations.

A cold boot of the x86-64 guest on msi with this QEMU reached the desktop
and dragged a window with no fatal or ERROR line; CLTD measured mean 407 us,
p50 396, p99 613.

docs/qemu.md and docs/api.md say what QEMU calls again.
2026-11-05 21:59:21 -08:00
Anees Iqbal 38b6912e60 📝 Say which locks a graphics raise_interrupt may run under
The header, api.md section 5, the Rust API's GraphicsCallbacks and the
device's Host doc said raise_interrupt runs with no lock of the library's
held. It does not: on a queue's service thread it runs under the queue's
claim on its next message, and some events are posted, and their vector
raised, under locks of the library's:
- the decoder's lock, at a command buffer's CB_SUBMITTED posted as the
  buffer is taken, on its queue's thread or inside
  rvg_graphics_device_mmio_write_taking, and, with the download's answer
  slot, at a SURFACE_DOWNLOAD answered at once;
- a command buffer's CB_SUBMITTED latch, wherever that is posted, which
  keeps it once and ahead of the buffer's other records;
- the presents' queue, at a present answered at once with no window.
Moving those raises out from under the locks would delay the CB_SUBMITTED
the guest's commitAndWaitUntilSubmitted waits for, or break its order.

What a host relies on still holds: no function of the graphics device
takes any of them, and rvg_graphics_device_mmio_write_taking only tries the
claim and the decoder's lock. So the docs now say that: the library calls
raise_interrupt with no lock held that a function it may call waits for,
directly or through a thread of the library's, so it may call them at once,
and it may still wait for a lock the host holds while it calls the device.
api.md section 5 and GraphicsCallbacks name the locks.

Two doc errors of the inline take's commits go with it: the Host doc still
said no callback runs inside a call of the host's, though
Device::mmio_write_taking calls take_command_buffer and may raise there,
and GraphicsCallbacks did not name the host's own thread inside
mmio_write_taking. A raise_interrupt doc line ran past 100 columns.
2026-11-05 21:59:21 -08:00
Anees Iqbal 0ee908e0a8 ⬆️ Point vendor/qemu at reims-graphics-pci's taking doorbell
QEMU f2c7e2a5 sends the vCPU's BAR 0 writes of reims-graphics-pci to
rvg_graphics_device_mmio_write_taking. A DOORBELL write of a command queue's
ring can then take the queue's next command buffer on the vCPU, post its
CB_SUBMITTED and raise the interrupt there, through the irqfd under KVM or
the BH elsewhere. The control ring's doorbell still goes to the ioeventfd,
and reads are unchanged.

Measured on msi under KVM in one boot, the same guest under window-drag
load, with the take switched on and off every 20 s (the first 5 s of each
window left out; 60 s on, 51 s off):
- WindowServer's commit to its wake in commitAndWaitUntilSubmitted fell to
  173 us on average, from 218 (p50 168, from 185; p99 440, against 402);
- its CA::Layer::commit_transaction-to-display (CLTD) fell to 384 us on
  average, from 434 (p50 376, from 400; p99 667, against 654). Every 20 s
  window with the take on beat both windows next to it;
- the vCPU took 32% of all doorbell writes, and 62% of the buffers that ask
  for their CB_SUBMITTED. The rest went to the queue's thread: 2731 because
  a ring-0 message published before them was not carried out yet, 23
  because a lock was held. The 6608 buffers that ask for no CB_SUBMITTED
  were left too;
- a take cost the vCPU 14 us at the p50 and 31 us at the p99, 274 us at
  most, and a plain doorbell write 2 us. A vCPU-posted CB_SUBMITTED reached
  the ring 10.7 us after the doorbell, against 199 us for one the queue's
  thread posted;
- the control thread waited for the decoder at 20.6% of its locks, from
  15.3%, for 38.2 ms a second in all, from 36.8. 2204 of those waits were
  behind a take's carried lock. The queue's thread never waited for it.
A boot of the plain build (no measurement) reached the desktop and dragged
at 59.6 composites a second, with CLTD averaging 369 us and no fatal,
ERROR or WARN line in the host log.

docs/qemu.md and docs/api.md now say which BAR 0 call QEMU makes, and how
the interrupt is sent since 36deb281.
2026-11-05 21:59:21 -08:00
Anees Iqbal 46324049a2 🐎 Take a command buffer on its doorbell's thread
rvg_graphics_device_mmio_write_taking is rvg_graphics_device_mmio_write,
except that a DOORBELL write of a command queue's ring first offers the
queue's next COMMAND_BUFFER to the host on the writing thread. Under QEMU
that thread is the guest's vCPU. Where the buffer asks for its CB_SUBMITTED
and nothing need be waited for, the vCPU takes it: it makes the buffer's
command buffer, posts its CB_SUBMITTED onto the queue's completion ring and
raises the queue's vector. It then hands the rest to the queue's service
thread, which walks and commits the buffer before it takes anything more of
the queue's. The guest's commitAndWaitUntilSubmitted no longer waits for
that thread to wake, which costs about 85 us on msi's host, the exit of an
idle CPU from its deep C-state.

Nothing on the vCPU waits. Every lock the take needs is tried: the queue's
claim, which its service thread holds from its take of a message to the
hand-over; the queue's submission ring; the control submission ring; the
compile table; and the decoder. Where any is held, the buffer stays on the
ring and the write wakes the queue's thread, as rvg_graphics_device_mmio_write
does. It also stays there where:
- a ring-0 message published before it is not carried out yet;
- it waits for an event, or a buffer before it holds its queue;
- a pipeline it names is compiling;
- a device cache it uses wants a fill, or a wait for one;
- its queue holds 48 command buffers made and not completed (the
  platform's commandBuffer waits at 64);
- it does not ask for its CB_SUBMITTED.
The CB_SUBMITTED's post on the vCPU waits for nothing either. Where the
completion ring is busy or full, the service thread posts it before the
walk, where the post is today.

The decoder's lock is taken on the vCPU and let go on the service thread
after the commit. So every message the guest sends after it sees the
CB_SUBMITTED is carried out after the buffer's commit, as it is today.

Class: FREE. Only the thread that posts a buffer's CB_SUBMITTED and its
timing change. Each queue's events keep its order: the vCPU takes only
while the service thread holds none of the queue's messages, and the
service thread carries out what the vCPU took before it takes the next.
The interrupt still follows its ring write on the same thread.

The C API gains the function, additively: the header and api.md list it,
and section 5 names the calling thread for raise_interrupt inside it, which
must not wait for a lock the host holds while it calls the function.
rvg_graphics_device_mmio_write and its "Calls back: never" are unchanged,
and so are the pins (re-recorded, no difference). The decoder's lock
crosses threads through parking_lot's arc_lock and send_guard.
2026-11-05 21:59:21 -08:00
Anees Iqbal b3db450e0a 📝 Name every thread the graphics raise_interrupt arrives on
api.md section 5, the header's RvgGraphicsRaiseFn and the device's Host
doc named only the control and refresh threads. The interrupt is raised
on whichever thread posts the event it is for, so it also arrives on a
command queue's service thread (an early CB_SUBMITTED), a pipeline
compile's thread (a reflection) and the platform's thread that runs a
command buffer's scheduled or completed handler. The thread-name list
gains the queue and compile threads. Comments and docs only.

[ci skip]
2026-11-05 21:59:21 -08:00
Anees Iqbal 0b798d10f7 🐎 Take no dirty source on the graphics device
This reverts 71d7ba107 (Give the graphics device the host's dirty source),
8f1b8b02e (Resolve an import's pages once per range for the dirty log) and
67edfb6ee (its test's fix), and points vendor/qemu at 926401c49, which
reverts reims-graphics-pci's dirty source on its branch.

With the source, the runtime asked the guest pages behind each IOSurface's
import at each command buffer's reports and watches, and the graphics
device's thread resolved them through the backing table and the registry,
under locks the runtime's queue threads also took. On the msi's RTX 5080,
the same guest under window-drag load, the host with the source against the
host without it, back to back:

- the decode and commit of a command buffer took 5.2-7.3 ms, against
  0.33-0.51 ms;
- WindowServer composited 27-30 times a second, against 40-45, and its
  CompositeLayersToDestination averaged 9.65 ms, against 3.24 ms;
- QEMU used 122% of a core, against 89%.

The copies the source saved, an IOSurface's shadow copied in whole at each
use on a discrete GPU, are what the device cache of IOSurfaces replaces.
RvgGraphicsDeviceConfig is at its second version again; the third was never
in development.
2026-11-05 21:59:20 -08:00
Anees Iqbal 2705249327 🐎 Give the graphics device the host's dirty source
WindowServer composites into an IOSurface the GPU now draws in place over
its guest pages. On the Vulkan platform the runtime keeps a render target
over host pages as a shadow, copied in before each use: with no dirty
source each copy in was the whole surface, 37 MB at 3840x2400, every
composite. RvgGraphicsDeviceConfig's third version takes the host's dirty
source, as RvgDeviceConfig does, and the device keeps the same harvest and
log over the guest's RAM, so the runtime copies again only the pages the
guest wrote. The log is closed while the host's reset runs, as a device's
is under its host's lock.
2026-11-05 21:59:19 -08:00
Anees Iqbal abf6571d4f 🆕 Let the GPU use an IOSurface's own guest pages in place
WindowServer's composites spent most of their CPU copying IOSurfaces: each
GPU view of a surface was a copy of its pages in the region, uploaded at
newTexture and written back after every command buffer (55 GB per 10 s on
the fix-1 boot, 83% of WindowServer's samples in memmove).

With the guest RAM's map in its config (RvgGraphicsDeviceConfig v2, gated
by struct_size), the graphics device offers RGFX_FEATURE_SURFACE_PAGES. The
kext then names a surface's page runs with SURFACE_PAGES, and the decoder
makes one view of them in guest RAM, through core's range mappings, and
buffers over it for BUFFER_OVER_SURFACE_PAGES. The runs must lie in guest
RAM, be page aligned and sum to the length; else that surface alone is
refused and stays a copy. Views are cached by their runs (32 views, 1 GiB),
since WindowServer makes a surface's block again about every frame; the
map is fixed at create and nothing removes guest RAM under it.
2026-11-05 21:59:19 -08:00
Anees Iqbal 15eee48dbc ⬆️ Build on metal2vulkan 45b3427434's runtime
metal2vulkan 45b3427434 is 4ba981e668 plus two things the guest's Metal
reaches. Its encoder draws setLineWidth:'s every width as Metal does (the M3
Max, macOS 27.0.1): floor(16 width) / 16 clamped to [0, 16], width 0 as 1/16,
by the device's own lines or a band of two triangles over each segment. What
neither draws at the width (on MoltenVK, which has no wide lines, a triangle's
edges in fill mode Lines and a mesh draw's lines) it draws by the device's
lines at the nearest width they draw, 1 pixel there, announcing it. A draw of
too few vertices for one primitive draws nothing, as Metal's. And binary
functions linked into a pipeline give plain Metal's answers: a direct call to a
function only binaryFunctions holds fails as an unresolved call, a function in
both lists is made, and one not compiled to a binary fails with Metal's code 2.

The Vulkan platform drew every line 1 pixel wide after another width, and
relayed it (inexact-line-width), or died in strict mode. It now sends the
width to the runtime's encoder, and the relay kind is gone. A new Metal-twin
test draws lines and line strips at widths 1, 3, 2.5 and 0 pixel for pixel as
the Metal platform does on MoltenVK. Its first vertex is white: the flat
vertices' first colour is the clear's black, which hid the line it provokes.
Two tests that died at a draw after a line width now leave what such a draw
draws to the runtime's tests.

The runtime announces two new kinds, placed with the kinds that die: relayed
by default, a death in strict mode. device-wide-lines: a device's own wide
lines that are not Metal's parallelogram (a strict device's rectangle, lines
Vulkan does not state as parallelograms, a width off its granularity), the
runtime's default. lines-at-nearest-width: lines drawn at another width than
Metal's, where neither route draws it. REIMS_VGPU_EXACT's new name wide_lines
takes the runtime's WideLinePolicy::Exact, the band over Metal's
parallelogram, on a device with tessellationShader. The accuracy ledger lists
the trade in place of the 1-pixel row.

A pipeline whose function calls a visible function that only binaryFunctions
holds now answers the guest Metal's code 3, where it was made. The Metal-twin
test of linked functions drops that exception, and adds a function in
binaryFunctions alone and in both lists, compiled to a binary and not. It
makes the binary copy after the cases of the function made by name: while the
copy lives Metal answers one object for both, of options 1 (measured on the M3
Max, macOS 27.0.1), so the cases after it linked the binary where they named
the plain function.
2026-11-05 21:59:19 -08:00
Anees Iqbal 59df0ffbb5 🆕 Add the reims-graphics device to the C API
QEMU drives devices through the C API, so the graphics device gets seven
functions there: create and release, the region QEMU maps as BAR 2, BAR 0's
reads and writes, the doorbell file QEMU's ioeventfd fills, and the bus
reset. Its two callbacks raise the MSI-X vector and ask QEMU's dirty log
whether the guest wrote the scanout. Both run on the device's threads with
no lock of the library's held, so QEMU may take the BQL inside them, and no
function waits for those threads.

The additions are strictly additive (docs/api.md section 1): new functions,
types and constants, and status 17, RVG_ERR_HOST_RESOURCES, for a host that
refuses the region's memory, a pipe or a thread. The C harness calls each new
function and drives one GET_DISPLAYS through the region to its interrupt.
2026-11-05 21:58:28 -08:00
Anees Iqbal c3aac4c217 ⬆️ Build on metal2vulkan 0a1851164d's runtime
Move the runtime from eeb7934025 to 0a1851164d, six commits of
metal2vulkan's development.

What changes for the guest:

- A draw, compute dispatch or tile dispatch whose pipeline the driver is still
  making 4.5 s after its command buffer's commit runs nothing, and the command
  buffer runs on (PipelineWaitPolicy::Bounded, the runtime's default, announced
  draw-dropped-still-making or dispatch-dropped-still-making). A state's
  creation likewise returns after 4.5 s with its predicted pipeline still being
  made. Before, a cold compile (11.59 s on an M2 Pro's MoltenVK boot) held the
  command buffer past the guest's 10 s check of its FIFO.
- A draw whose pipeline the driver failed to make after the draw returned runs
  nothing, and the command buffer runs on (draw-dropped-unmade), where it
  failed before.
- A no-copy buffer, heap or buffer rebind whose import fails (out of memory, or
  a driver out of mappings) is made over a copy of the pages in the device's
  own memory (copied-host-pages), where the call was refused before.
- Nothing else in the span moves what a guest observes. On NVIDIA's driver on
  the RTX 5080 Laptop GPU, the 2.2 to 3.7 ms stall the driver spends in every
  1,024th signalling submit of a queue is taken by empty submits while the
  queue is idle, not by a batch. A discrete GPU zeroes new buffers by a fill.
  A warm render state is linked from its recorded stages. The shader cache is
  keyed by its translator, so a runtime-only change no longer turns it cold.

The four kinds are placed in DIES: by default each is relayed and counted, and
in strict mode it ends the process, where a difference the guest can see
does. Unplaced, they fail every_degradation_kind_is_placed_once.

A strict process, every test of this crate among them, waits for each pipeline
until it is made (PipelineWaitPolicy::Exact), so a slow compile under the
check's load never dies there as a dropped draw. REIMS_VGPU_EXACT names the
same exact form as pipeline_waits, and the accuracy ledger records the fast
form's bound.

A no-copy buffer over host memory with a page not mapped, or mapped without
read access, is answered nil before the runtime is asked, as Metal answers it,
where development asked the runtime and answered nil at its refusal. At
0a1851164d a placed buffer the runtime refuses keeps its range held, so the
next buffer Metal places at that address met a conflict and died (measured on
the M3 Max: no_copy_buffers_over_pages_without_access_are_nil_as_metals).
Those pages are the only refusal there answered without dying, so nothing else
meets the held range. metal2vulkan has the report.

The import gate the runtime now takes (HostMemory::with_import_gate) is wired
in the next commit.
2026-10-29 00:48:36 +02:00
Anees Iqbal 12765ee8ae 🐎 Copy again only the guest pages written since the last copy
Where the Vulkan runtime keeps copies of guest memory in GPU memory (a
discrete GPU's, and an iGPU's whose driver cannot use the guest's pages in
place), it copied each one whole at each use, as nothing told it which pages
the guest wrote. Under KVM the host now gives the device a dirty source, and
the runtime copies only the row bands of the pages written since its copy.

- Core keeps the dirty log: a stamp per watched 4 KiB guest page (8 bytes),
  read without a lock, fed by the harvests and by the library's own writes
  into guest RAM (every GuestPtr write, the IOSurface byte copies, the video
  decoders' lends), each stamped after its bytes land, so a copy racing a
  write takes the page again. With no log a write costs one relaxed load.
  Waits are bounded (about 4 ms) and refuse at once while the device resets,
  pauses, stops or suspends; an answer the log cannot give is a whole copy,
  never a missed write.
- The C API, additively: RvgDeviceConfig's fourth version (72 bytes) carries
  an RvgDirtySource: the KVM VM's fd and four callbacks (start, flush_vcpus,
  for_each_slot, take_host_writes), and rvg_dirty_slot, which for_each_slot
  calls for each logged slot. The device's thread reims-vgpu.dirty
  runs each harvest: the vCPUs' page-modification logs flushed where PML is
  on, one KVM_GET_DIRTY_LOG and one KVM_CLEAR_DIRTY_LOG of exactly the
  watched pages written per slot, then QEMU's own DMA. QEMU's side is 154
  lines (vendor/qemu 01650c7f08).
- The Vulkan platform answers the runtime's DirtyPages per import, in the
  import's offsets, and leaves a shadow's own copy back out of its next copy
  in (REIMS_VGPU_DIRTY_WRITERS=0 counts it). The EFI framebuffer is never
  logged, so the firmware's presents never start the KVM log.
- REIMS_VGPU_DIRTY_PAGE_TRACKING=0 turns the source off.
- The runtime moves from metal2vulkan 0db5825a60 to eeb7934025, its release
  with the dirty-band copies, the discrete GPU's device copies of sampled
  textures and one wait per log per submission. It also fixes the MoltenVK
  failure the owner hit on the M3 Max with a macOS 26 guest ("Vulkan failure
  -3 (the pipeline of draw 0 of the command buffer's render encoder 0)" after
  a 4K HEVC decode): Core Animation's fragment that samples the in-place
  Y'CbCr texture in a loop had its push field's uvec4[2] materialized with an
  OpCopyObject, whose SPIRV-Cross copy Metal's compiler refused; 751c861c15
  copies it element by element. And it takes the device's native forms: its
  own depth bias on every depth format, its store of an extended-range,
  padded 10-bit or bfloat attachment's untouched texels, a half colour output
  declared 16-bit where the device enables storageInputOutput16, and its own
  Y'CbCr conversion for 4:2:2 twins and planes read in place. Its semantics go
  from 1907 to 1911, so every cached shader compiles again on the first boot.
- With the runtime's unused-bits load pass and its capture replay gone, a
  pass that loads and stores such an attachment keeps the bytes its draws do
  not write, and each draw announces extended-range-bits-kept; the
  unreached-tiles-rewritten kind is gone. The Vulkan platform's answer table,
  its tests of the extended-range formats and its docs follow, and the test of
  the captured reach goes with the machinery.

Measured on an RTX 5080 Laptop GPU with an x86-64 macOS 26 guest
(docs/qemu.md, "Linux hosts: the dirty source"): a window drag at 3840x2160
went from 18.0 to 26.1 fps with 439 MB a frame host to GPU, from 938; at
1680x1050 the drag stays at about 56 fps with 98 MB a frame, from 182, and
SM use 46%, from 65%. Pixels are unchanged. Nothing changes on macOS, nor
where the runtime uses the guest's pages in place.
2026-10-28 21:55:55 +02:00
Anees Iqbal c8ec271abc ⬆️ Build on metal2vulkan 0db5825a60's runtime
Move the runtime from a759d0e88f to 0db5825a60, metal2vulkan's development
re-cut into one commit per work packet (tree 22aab1ece6, the same as its linear
history's d0f1b87e2e, which is the public repository's development; 0db5825a60
is not on it yet). Runtime version 1648 to 1681, semantics 1907, artifact format
475; its runtime sources pinned as 4314cee1. Every cached artifact and plan is
made again.

What changes for the guest:

- Answers come from one macOS release, 27.0.1, on every host. MoltenVK on a
  macOS host of another release answers as 27.0.1 too. MetalLevel, the
  metal_level of DeviceOptions and DeviceProperties, and the degradations
  metal-level-below-host, metal-level-not-macos and mipmaps-as-apple-m4 are
  gone, and so is our side of the levels: the OS's METAL_LEVEL, the
  level-dependent answers of format_info, the deaths on a host whose release the
  runtime did not measure, and Inexact::MetalLevel (the same adaptation as
  development-performance's e47f89760).
- The device's own arithmetic and value answers are the contract, with a
  precision note where they can differ from Metal's (the owner's
  native-arithmetic rule): BC and sRGB texels, half precision, fast-math
  grouping, maths functions, sampler details and pixel samplers, two-plane
  YCbCr (the device's Y'CbCr sampler), clears and fills, multisample resolves,
  mipmaps (the device's blit chain) and vertex conversions. The runtime's exact
  emulations of these are deleted, so REIMS_VGPU_EXACT loses sampling,
  ycbcr_filter, float_maths, texel_conversion, vertex_normalized, half_rounding,
  nan_and_min_max, rounding_order, half_blend, half_texel_bits,
  multisample_depth_twin, decoded_texels, tile_store and resolve: such a name
  now writes the stderr line and changes nothing. It keeps batch_order and
  host_page_textures and gains half_chains (each half operation of a fast-math
  chain rounded on a device without shaderFloat16). docs/api.md and the
  accuracy ledger say so; the ledger lists the deleted forms' bounds as the
  device's own answers.
- Degradations: 17 kinds retired, which leave DIES, NATIVE_RELAYED and the
  relayed lists. DevicePackConversion, DeviceVertexConversion and
  DeviceAlphaCoverage, notes of the device's own maths, vertex input and
  coverage, join DIES and NATIVE_RELAYED, as the other device-maths notes are
  placed. DeviceFilteredMipmaps, announced on every device, MoltenVK included,
  is relayed, never a death. None of them is in DIES_BY_DEFAULT, so by default
  nothing new ends the process.
- The read-only store mask is gone: on macOS a read-only view drops the store,
  as Metal does; off macOS, GPU writes into read-only memory land (the
  runtime's known gap). set-past-layout-support is announced at every bind past
  the driver's support.

Tests: the YCbCr comparisons and the resolve test run on the platform's own
device, as the exact-form devices are gone (device_with_policy and
device_with_ycbcr_filter with them); the mipmap tests no longer check the
retired tie kind.

Checked:
- on the M3 Max: rustfmt and the three clippy passes cargo xtask check makes
  (all features, the tested features without the defaults, and
  x86_64-unknown-linux-gnu), clean;
- the Vulkan crate on gem10's RX 7900 XTX and Radeon 780M, 432 of 432 each;
- reims-vgpu's and the C API's video and scaler tests on the XTX, the 780M and
  msi's RTX 5080 Laptop GPU, 50 of 50 each.

Failing, not fixed, at the owner's word (strict mode is not a concern):
- the Vulkan crate on the RTX 5080, 429 of 432: three encode_render tests read a
  channel one code off the byte they assert (0x7f where 0x80), the device's own
  colour conversion;
- reims-vgpu-vulkan's and reims-vgpu's 898 tests on MoltenVK, 796 passing: 102
  fail, 57 of them the YCbCr comparisons with Metal, most dying in strict mode
  at the device notes MoltenVK now announces where the exact forms answered
  before (device-nan-encoding, native-half-conversion), the rest comparing
  Metal's exact bits.
Not run: the rest of cargo xtask check (core, the Metal, window and video
crates, the header) and the suite, which the runtime does not reach; no boot.
2026-10-28 17:59:34 +02:00
Anees Iqbal aaec87ae4f ⬆️ Build on metal2vulkan a759d0e88f's runtime
Move the runtime from f6a96b7da8 to a759d0e88f, the tip of metal2vulkan's
development (runtime version 1643 to 1648; its runtime sources pinned as
abac6049).

metal2vulkan's gate on a759d0e88f was still running when this was committed;
the owner chose not to wait for it.

What changes for the guest:

- A 2D texture over host pages whose usage only samples or reads it is a linear
  image over the pages, with no shadow and no copy in at each command buffer's
  first use, on a device whose startup check passes: on that device, an image's
  first move keeps every byte while the CPU writes beside it, checked for
  pointer imports, fresh pages and dma-bufs each, and kept in the shader cache
  by driver and runtime version. Vulkan does not promise that move (an image
  over imported memory starts UNDEFINED), so this relies on the driver, by the
  owner's ruling of 2026-10-26. REIMS_VGPU_EXACT gains `host_page_textures`,
  which keeps every such texture a shadow, as before, and `all` names it; the
  accuracy ledger and docs/api.md say so. Render targets, written textures and
  two-plane YCbCr surfaces keep their shadows.
- A memoryless texture bound at a texture slot is taken, as plain Metal takes
  it, where the runtime refused the setter and this platform died there (an RX
  580 user's guest, at setFragmentTextures:withRange:). A command whose function
  uses the slot, a useResource of it or a blit of it fails the command buffer
  with MTLCommandBufferErrorInvalidResource (9) from the Metal submission that
  holds it, as Metal's GPU does (measured by metal2vulkan on the M3 Max). This
  platform passes the new CommandBufferError::InvalidResource to core as one of
  Metal's failures: the fourteenth it lists. A memoryless texture's CPU reads
  and writes move nothing, and its views are nil, as on Metal.
- new_texture_with_vk_image takes IdPlacement::Outside; nothing here passes it
  yet, so the window's swapchain images still take texture IDs.
- Nothing else in the span moves what a guest computes or observes: the
  in-place check's dma-buf pages come from cached memory, and the rest is
  counts, docs, tests and the sources pins.

The public surface gains CommandBufferError::InvalidResource,
DevicePolicy::host_page_textures and its HostPageTexturePolicy, and WorkCounts'
in-place and shadow-cause counts. No Degradation, RuntimeGap, refusal or notice
kind moved, so DIES and the relayed kinds stand. Device info, GPU families and
feature queries answer as before. The Vulkan platform ends the process at one
site fewer: the memoryless binding.

docs/video/bugs.md says what the pin carries for B73: the in-place textures and
the counts that tell them from the shadows that stay.

New tests, of the memoryless binding, on every platform:
a_memoryless_texture_at_a_fragment_slot_fails_only_a_draw_that_uses_it; and on
the Mac, memoryless_slots_fail_as_metals, which measured Metal's lines
(macOS 27.0.1): a draw whose function ignores the slot completes; one that
samples it fails the command buffer with code 9, the blit before its pass run
and neither its clear nor the blit after it, the signal after them not firing.

Checked, every test passing in its full run:
- on the M3 Max (macOS 27.0.1): rustfmt, the three clippy passes cargo xtask
  check makes (the Mac's, its tested features', and x86_64-unknown-linux-gnu's),
  and the 900 tests of reims-vgpu-vulkan and reims-vgpu on MoltenVK;
- the Vulkan crate's 434 tests and reims-vgpu's and the C API's 50 video and
  scaler tests on gem10's RX 7900 XTX and Radeon 780M, with no amdgpu reset.
The RTX 5080 Laptop GPU's run was skipped at the owner's word: the GPU was busy
with the owner's VM.
Only those crates link the runtime, so the rest of cargo xtask check (core's
tests, under Rosetta too, the Metal, window and video crates, and the header)
and the suite, which drives the C API on the Metal platform, do not
reach the change and were not run.
2026-10-26 21:45:46 +02:00
Anees Iqbal 95644d758d 🆕 Add the VideoToolbox and M2 scaler devices to the library and QEMU
A macOS guest hands its VideoToolbox sessions, and its
IOSurfaceAccelerator's scaling and conversion, to the host through two
virtio-PCI devices, 106b:1a03 and 106b:1a0b, as Virtualization.framework
gives them. The library gains their host side, VideoDevice and
ScalerDevice over core's host session and scaler, and QEMU their
transports, apple-videotoolbox-pci and apple-m2scaler-pci, with no
properties of their own.

The library picks each device's backend itself and logs why, on the GPU
apple-gfx-pci's device runs on, taken from the runtime's identity of it:
NVDEC and NVENC on an NVIDIA GPU, else VA-API on its render node, and
VideoToolbox on macOS. The scaler device exists on every host and refuses
its features where it cannot transform; a guest message over 16 MiB is
answered -12904 unread.

For the host: the C API gains rvg_video_device_* and rvg_scaler_device_*,
additively. For the guest: a VM given the devices has the host's video
decode, encode and scaling.

Source: c5b409362 375acb462 8be7593eb fbbeebfb2 e3d5616a4 60d08c4f4 c4c476643
        fe105edcb 36a6a82c6 ee2b1ca71 d7d5cfede b15f40717 a07ffd70b bfe6b8338
        7433026a9 0030b24a7 64497f931 76acbacc7 3bf366e81 6d3b97a59 fa5b4aafc
        401e0b727 1af53ce1a 0fa52d070 ce6eab571 33b40ae4a 82beaf64a ef26f02e1
        08bb763c4 5ff2dd73f 62e19c8ef ce406ddb2 fd92f66c4 52fba93c9 e179dc0bd
        b5f40ad74 d01bbdc9e 950a7e024 601c23067 9857b1fc8 b427bebfb 55a1d96e7
        a0243edfc ef54c395f c23c83073 bc6fcdaa7 1b783baca
2026-10-26 12:24:31 +02:00
Anees Iqbal d527b7257c ⬆️ Build on metal2vulkan 6c9cad047a's runtime
Move the runtime from 6b67bd44af to 6c9cad047a (runtime version 1520 to
1643), through dc80eb2bd4, 67c64f99d8 and 27935d575e, and hold three tests
to the runtime's answers at the pin.

For the guest:
- a draw whose state's reflection the runtime could not finish asks per
  slot what a function may store through, where every read-only object
  counted as written and a user's Linux guest died in kept_write;
- a detach in a completed handler of an object the last submission used
  answers YES, Metal's answer once the use retired;
- shareable padded 10-bit formats are made in Private storage, and the
  packed ones answer nil and 0 bytes, as Metal's;
- a command encoded again at a replace no longer writes the pages it was
  encoded over;
- a shadowed texture copied back by a dispatch stores wide texels whole.

The runtime's identity of the GPU device, which the video devices use to
find their GPU, comes with this pin.

Source: 7ad52b99b 0e37d329c cb582881c 94d2b0ef6 5ee2d000e 221176d06 051c64ebb
2026-10-26 12:24:31 +02:00
Anees Iqbal c60e16cb18 🐛 Fix the window's capture, input and sizes, and offer the set rate
- A captured window drops its resize edges until capture ends, so a click
  where the image meets the window's edge reaches the guest.
- No window input reaches the host once the display's release has
  returned, and the display's end lets go of the keyboard grab, mouse rect
  and size hold the capture set.
- A sixth mouse button or later captures nothing, as the guest's tablet
  has no such button.
- A smooth scroll gesture whose end went unseen no longer decides where
  the next one goes.
- A mode or cursor the guest sets while the window's opening is posted is
  delivered.
- An X11 window is sized in pixels at the desktop's content scale, and a
  Linux screen's rate comes from modes of its own size.

For the guest: its display modes run at the host screen's current rate,
the one the person set, where they ran at the highest its size offers.
For the host: HostScreen's max_refresh_hz is refresh_hz in the Rust API
(the header changes in a comment only), and features.md registers that a
captured window cannot be resized.

Source: 5806f9c1c bc50f04b4 b12cb3ab0 76b7ae409 f6c3b116b 5811164a5 2ad407c98
        42c178305 6415d881f 1c0563f85 78426429a e61a8dc56
2026-10-26 12:24:31 +02:00
Anees Iqbal f0b1635053 🐛 Offer the guest modes where a window display's window cannot open
A VM started with reims-ctl from an ssh shell stopped its boot at the Apple
logo. With no Wayland compositor or X server named, SDL starts no video, so
the window does not open and there is no host screen to match. QEMU leaves
the modes to a window display that matches its host screen, and the display
offered none, so the guest had no mode to set.

Now a display matching its host screen with no screen to match still offers
modes: the window's chosen mode (QEMU's resolution) and the standard sizes
within it, at its chosen density as on a screen, or 1920x1080 at 1x where
none is chosen (resolution=host), at REIMS_VGPU_WINDOW_REFRESH's rate or else
60 Hz. Displays with a screen, and the modes a host sets, are unchanged. The
docs that said a display with no screen offers what its config says now say
what it offers.
2026-10-20 03:46:39 +03:00
Anees Iqbal 30c7cd604b 🆕 Capture the pointer with the keyboard, held over the image
A click into the image captured only the keyboard: the host's pointer could
still leave the window for the bars, the title bar or another app, where a
click meant for the guest's edge landed on the host instead. Capture now takes
the pointer too, and never one without the other: while captured, the host's
pointer is held over the image, and ⌃⌥⌘ (Ctrl+Alt+Super on Linux), Release
Input, losing focus or closing frees both.

On AppKit's window the hold is NSWindow's mouseConfinementRect, the property
SDL3 confines its macOS windows with, which AppKit leaves out of its headers;
a window that does not answer it leaves the pointer free and logs one line.
On SDL's windows it is SDL's mouse rect, rounded out to whole points so the
image's last row and column stay in reach, which SDL keeps with the
compositor's pointer constraints on Wayland, XFixes barriers on X11 and the
same property on macOS; where SDL has no mouse rect, its mouse grab holds the
pointer in the whole window. In native full screen an image that reaches the
screen's top or bottom edge takes the pointer there, where macOS slides its
own menu bar or Dock in.

features.md, README.md, docs/api.md, docs/architecture.md and the module docs
say so. The macOS walk releases capture wherever a step needs the pointer off
the image, captures before Finder takes focus in C4, and walks the hold at
each edge and corner (C2), at the window's edge (C2e), across Mission Control
(C2m), in full screen (C2f) and after a mode change (M4), which only a
person's own mouse shows: a warped pointer, or one moved by events posted at
the HID tap, is not held.
2026-10-19 02:47:57 +03:00
Anees Iqbal 9f2e1c2c34 🐎 Move metal2vulkan to 62cad6be54: per-sample reads, ANV fits
62cad6be54 lands metal2vulkan's bug-fix wave on its development, 55 commits
past 6b322fb50f (SEMANTICS_VERSION 1759 -> 1798, RUNTIME_VERSION 1314 -> 1496).

What changes for the guest:
- A multisampled fragment function that reads its colour attachment (so runs
  per sample) and [[position]]'s w, [[point_coord]], [[barycentric_coord]] or
  a centroid varying now compiles, those reads taken where Vulkan evaluates
  them for the sample and announced as multisample-position, where link
  refused it, which killed the guest at every launch of Claude Desktop
  (0a34e8c7).
- On ANV, mesh render, tile render and compute pipelines whose largest stage
  passes the compiler's word bound under exact forms are fitted, as render
  pipelines were, where brw's allocator faulted the process (33e89bd4).
- The UHD 770 splits an interlocked pass as every GPU measured does, faster
  there (affd8a5e). lavapipe records a dispatch of a variant that
  bakes samplers in a command buffer of its own, which 26.0.8 sampled as
  Repeat after a copy (ImmutableSamplersLostAfterCopies, 84ba0af3).
- A texture over a no-copy buffer's host pages, padded rows included, is the
  runtime's shadow on every device, MoltenVK too: a CPU write to bytes a
  command buffer does not write is kept, as Metal keeps it, where an image's
  first move could undo it (e35bf78b).
- ASTC LDR, ETC2/EAC and PVRTC textures read through decoded twins where the
  device lacks the format, A8Unorm through R8, and 4:2:2 through a twin on
  every device.
- New fast defaults, each bounded, logged and behind an exact switch, none of
  which applies on MoltenVK: the device's resolve (resolve), the device's tile
  store of loaded snorm and RGB9E5Float attachments (tile_store), compact ASTC
  and EAC twins (decoded_texels), and batches ordered by their ends
  (batch_order).
- Every device takes the runtime's exact completion, each command buffer seen
  complete at its own end as Metal's, not its new default of Mesa's grouped
  submissions: when work completes is the guest's to observe, and ip34
  measured no frame rate gained on the Iris Xe (15.7-17.3 fps grouped,
  16.4-17.6 exact).
- Every device takes uncompressed heap textures too, not the new default of
  ANV's compressed image, which would change the heap size query's answers
  (0x4100 bytes at 0x10000 for a 64x64 BGRA8Unorm texture on the Iris Xe,
  where the guests booted with 0x4080 at 0x1000) and could hide writes through
  aliases.
- A device's teardown no longer races the watch of the program's queue marks
  or the release of freed memory: the last drop tears the device down on its
  own thread before it returns (6898b52e).

Here: REIMS_VGPU_EXACT names four of the new DevicePolicy fields, with their
ledger rows and docs/api.md's list; completion and heap_compression have none,
and the ledger and docs/api.md say every device takes their exact forms, and
why. padded_reads, whose field and fast form are gone, falls to the path
docs/api.md gives a name that is no field: nothing changes, and stderr says so.
Its ledger row goes. The runtime's six new kinds are placed: CarriedDecodedTwin
relayed (a performance kind); DecodedTexelPrecision, HeapTextureCompressed,
SnormMinimumKept, SharedExponentKept and GroupedCompletion in DIES,
GroupedCompletion and HeapTextureCompressed never announced under the exact
forms, DecodedTexelPrecision also relayed on native devices as the runtime's
default sampling. DeviceRoundedResolve moves from HEARD to DIES and is relayed
on native devices too (class (e), the device's rounding of an average, as
measured on RADV, ANV, NVIDIA and lavapipe), so Inexact::RoundedResolve and
device_rounded go: a strict run on Mesa's drivers, this crate's tests among
them, no longer dies at a grouped submission or a resolve the device averages,
and MoltenVK, which resolves as Metal, announces neither. None dies by default.
The retired UnorderedFramebufferFetch and UnrestoredFirstMoveBytes leave DIES.
The docs of the runtime's VK_EXT_metal_objects, the first move's keep and the
fitted pipeline kinds are brought up to date.

Tests: the resolve test, a_device_resolve_ends_its_pass, ends passes under both
resolve policies (device_with_policy). A texture over a surface's memory is now
the runtime's shadow, so the runtime may free the surface buffer's import as it
goes, a command buffer still running; the Linux test of the surface's memory
hold, renamed
a_released_surface_texture_keeps_the_surfaces_memory_while_imported, checks that
the memory stays mapped while the device imports it, in place of until the
command buffer completed. a_type_9_hang_is_in_flight_as_long_as_metals commits
its queue's command buffer right after the hang's, before another queue's runs:
under the suite's load that run took 42 to 98 ms on the Iris Xe, past the 40 ms
hang, on 6b322fb50f too.

Checked at this tree, built on c662e1c78b, metal2vulkan's commit whose tree
62cad6be54's equals. On the M3 Max: cargo xtask check, 3517 of 3528 tests
passed; the 11 that failed under its load (nine YCbCr sampling sweeps, and
detach_backing's detached_in_flight on Metal and on Vulkan) passed alone. On the
Iris Xe (homelab-ms01, ANV, Mesa 26.2.4, strict): the Vulkan crate's tests, 388
of 388. Cold boots on the M3 Max's Vulkan platform (MoltenVK), each with an
empty translation cache: arm64 macOS 27 to its login window and macOS 26 to its
desktop, with no fatal line or refusal. x86-64 macOS 26 with the ported GPU
kexts, headless at 1920x1080, opened 69 apps in turn on the Iris Xe (ANV), the
RTX 5080 Laptop and the Radeon 780M (RADV), the last two from an empty
translation cache: no QEMU death, fatal line, refusal or crash report on any of
the three. Not run here: the suite, which drives the Metal platform alone.
2026-10-19 01:04:01 +03:00
Anees Iqbal a0b288ed52 🐎 Move metal2vulkan to 6b322fb50f: YCbCr filter, ANV halves
6b322fb50f is metal2vulkan's development, three commits on 29d3ebb22e's line:
the fetched 8-bit blend for every factor, mask and blend color (01841476dd),
the device's filter of a two-plane YCbCr texture by default (b7da00074a), and
the cut of ANV's and RADV's cold making of half-heavy shaders (6b322fb50f).

What changes for the guest:
- Intel (ANV) builds the guest's big A2X pipelines cold in about 4 s, where
  it took about 14 s plus two 38 s remakes at a draw, past the guest's 10 s
  GPU watchdog: a cold first boot of the x86-64 port on Iris Xe stalled with
  19,572 FIFO resumes, and now boots with none. RADV's 780M takes 0.39-0.43 s
  where it took 0.80 s. A computed half rounds through an f32->f16->f32 pair
  under Vulkan's 16-bit float controls, exact by the spec, and a half read
  from its bits widens by the device's conversion, every value but a NaN
  exact (its bits the device's, announced as NativeNanEncoding). NVIDIA keeps
  its forms (DriverWorkaround::HalfConversionPairFolded).
- A linear sample of a two-plane YCbCr texture is the device's own filter by
  default (the owner's ruling, 2026-10-17: the fast form, logged, the exact
  one behind a switch): within 1.18 codes of Metal's on the RTX 3090, 0.88 on
  RADV, 1.06 on ANV and 0.1245 on MoltenVK on the M3 Max, so a draw binding
  one makes no pipeline of its own. REIMS_VGPU_EXACT=ycbcr_filter, and `all`,
  take Metal's filter, byte for byte as before.

Here: the switch's name in platform.rs, its docs in docs/api.md and its row
in the accuracy ledger, with the half-rounding and NaN rows brought up to
date. The runtime's seven new kinds are placed (AttachmentReadInPlace,
NotMipmappedAnisotropicSampler and -Filter, UnmeasuredGroupSpeculation and
DeviceSampleLevel in DIES, DeviceSampleLevel also relayed on native devices;
FloatTininessAfterRounding and ExactFormsOverCompilerLimit relayed); none dies
by default. The Mac's YCbCr comparisons run on a device under
YCbCrFilterPolicy::Exact, compared exactly, and a new test holds the default
to its bound and its notices.

Checked at this tree (metal2vulkan's e742fe531c, the same tree): cargo xtask
check on the M3 Max (the 11 load-sensitive failures passed alone), the
Vulkan crate's tests on um780's RX 7900 XTX and 780M (388/388 each), and the
port's cold boots on ms01's Iris Xe and gem10's 780M with no fatal line.
2026-10-17 11:18:09 +03:00
Anees Iqbal afdb76f844 🆕 Give every x86-64 VM the IOSurface device over PCI
An x86-64 macOS guest running Apple's arm64 GPU driver, ported, needs the
IOSurface host device vmapple has as apple-gfx-mmio's second region: the
driver's start waits for its mapper's service, and every texture over an
IOSurface is a mapper texture. reims-ctl now gives every x86-64 VM on
reims-vgpu that device, with no opt-in, and Apple's own x86-64 driver keeps
running as before.

For the guest:
- apple-gfx-iosurface-pci (106b:eeef, ours) sits at 00:06.0 next to the GPU
  at 00:04.0: its registers in BAR 0 at 0x1000, 8-byte accesses passed
  whole, one MSI vector per completed command. A reset returns its
  registers to 0, ring size aside.
- 0x1028 offers the second, 0x400-byte descriptor form only where its table
  holds all 8192 mapping ids (16 KiB pages); on x86-64's 4 KiB pages it
  reads 0, and the guest's mapper takes the first form, which fills them.
- On apple-gfx-pci, a task other than task 0 runs isolated only if the
  IOSurface device has a descriptor table when the guest defines it, and
  device info offers argument buffers (key 33 bit 0x20, key 42) only while
  it has one. Apple's x86-64 driver, stock (binary version 6) or patched by
  reims-util (245), never programs the IOSurface device and makes ref
  textures whose backing is in task 0, which an isolated task does not
  serve (testing.md 6.20); its tasks stay in process and its device info
  is as without isolation. The ported driver's mapper programs the device
  before its GPU driver starts, and its tasks run isolated, which its info
  replies need. apple-gfx-mmio still isolates every task.

For the host:
- apple-gfx-pci has no option for this: adding apple-gfx-iosurface-pci is
  the only switch, and a VM without it runs as before. Its gpu link is
  optional, the machine's only apple-gfx-pci when unset. vendor/qemu moves
  to bd95509a.
- RvgDeviceConfig gains process_isolation_follows_guest at its end (64
  bytes; a host that passes 56 reads it false), and the Rust API's
  DeviceConfig the same field; apple-gfx-pci always sets it with
  use_iosurface_mapper and process_isolation. Each task made under it logs
  whether it runs isolated or in process, and device info logs each change
  of its argument-buffer answer.
- reims-ctl's q35-x86_64 profile adds
  apple-gfx-iosurface-pci,id=iosfc,gpu=gfx,addr=0x6; vmware-svga and
  vmapple VMs are unchanged. reims-ctl and QEMU from this commit go
  together, as its installer installs them.
- On Linux, the detach heap's temporary and a writable alias with zeros
  past its pages come from a range of a file of the library's own, so the
  Vulkan platform can alias and import them; QEMU no longer ends at an
  x86-64 guest's first such heap. macOS is unchanged.
- The first command given to a task whose service has died writes one
  warning naming the task.
- scripts/qtest_iosurface_pci.py checks the device under qtest (27 checks).

Checked: cargo xtask check and the suite on the M3 Max; reims-ctl's install
and a cold boot on um780; stock, reims-util and ported-driver guests booted
on gem10 and ms01 with the isolation rule, Apple's driver's tasks in
process at about 62 fps, the port's isolated.
2026-10-17 06:43:31 +03:00
Anees Iqbal 2631a11edc 🐛 Move metal2vulkan to 720ef1ce9a: exact padded surfaces
metal2vulkan fd22785008..720ef1ce9a (18 commits, one per work packet) brings:
- padded guest surfaces, whose rows lie with bytes between them (a browser's
  tiles): on every device but MoltenVK, one a pass draws into or a shader
  writes is the runtime's shadow, as a render pass may write back any byte of
  its attachment and Metal never writes those bytes (measured on the M3 Max);
  a loaded colour attachment copies back only the rectangle bounding its draws'
  scissors, and a pass that reaches no tile copies nothing. One that only reads
  stays an image over the buffer's bytes, and REIMS_VGPU_EXACT's new
  `padded_reads` takes the shadow for it too;
- scheduler fixes: a commit left to the scheduler is taken in before its next
  check, and a commit's passes are bounded;
- function storage measured on the RTX 3090 (128 KiB) and RX 7900 XTX (96 KiB),
  where FunctionStorageAssumed no longer fires;
- threads a runtime thread starts no longer inherit its utilization floor;
- the execution status through a binding where the device addresses no
  buffer, the macOS 27 fixes on the M3 Max, and a half texel's NaN as Metal's
  under nan_and_min_max on MoltenVK, which the docs now say MoltenVK answers
  only under that switch;
- RUNTIME_VERSION 1211, SEMANTICS 1698.

Checked on the same runtime sources before metal2vulkan squashed its history:
cargo xtask check on the M3 Max (only the known macOS 27 failures); the Vulkan
and core crates' tests on Iris Xe, two 780Ms, the RX 7900 XTX, the RTX 3090
and the RTX 5080 Laptop GPU (nothing new but load flakes that pass alone); and
a cold boot of the x86-64 guest on each, with no fatal line. Iris Xe's steady
frames/s at the users' scheduling class matched the last round's.
2026-10-14 20:32:08 +03:00
Anees Iqbal 06f3069b34 🐛 Keep the trace's diagnostics quiet, flushed and documented
The review of the surface crash fix (be81ac03c) and the trace (9b93b71db)
found nothing wrong with either one's behaviour. It did find places where the
trace's diagnostics misbehave, or where the docs say something the code does
not do.

- REIMS_VGPU_TRACE_DEGRADE asked the runtime to announce every occurrence of
  every kind as soon as REIMS_VGPU_TRACE was set. The sink writes those to
  the trace, and relays a once-only kind only once, but only where the
  trace's file opened. With a path that could not be created, every
  occurrence went to stderr, some once per draw. The request now takes the
  sink's own condition, trace::on(). The variable is now on only at "1",
  like REIMS_VGPU_STRICT; before, any value turned it on, "0" included.
- A death aborts without running Drop, so a trace lost up to its last
  quarter second of events, the ones a hunt like the DEVICE_LOST one needs
  most. Core's one death path now flushes the trace after its stderr line
  and before abort(). The flush takes the file's lock only with try_lock,
  so a death never waits on it. trace.rs's doc now says when lines are
  written: a write flushes once a quarter second has passed since the last
  flush.
- a_line_per_event checks every line the trace writes, an imp/impfree pair
  included, flushed the way a death flushes.
- A surface over a single range of pages lies in the host's RAM, which the
  host maps and unmaps and core never unmaps through VulkanVm. So its unmap
  hold defers nothing under QEMU. surface.rs, remap.rs and the device
  test's doc now say so. The hold stays: it costs one leaf lock per import,
  and the test's second case still pins it.
- docs/api.md lists REIMS_VGPU_TRACE and REIMS_VGPU_TRACE_DEGRADE as
  diagnostics of the Vulkan platform; the Metal platform writes no trace.
- trace_degradations' doc gives the runtime's rule for announcing every
  occurrence: inside a program call or a host step only. A breach is the
  runtime's: a build with debug assertions aborts there, and the dist's
  release build logs a misplaced-notice line.

Nothing the guest or host observes changes, with or without the variables.
Checked: core's trace:: and raise::death tests, the Vulkan crate's answer::
and platform:: tests on the M3 Max, and clippy for macOS and x86-64 Linux.
2026-10-14 14:11:53 +03:00
Anees Iqbal b1058d16fb 🆕 Say "click to capture input" in an uncaptured window's title
The title said nothing until input was captured, so someone new to the
window had no hint that a click into the image captures the keyboard, or
that it was not captured yet. Uncaptured, the title now ends " — click to
capture input", on macOS (AppKit's and SDL's window) and on Linux, and it
says so again after a release. Captured, it reads as before.

features.md's entries for the title now say both states, guarded by the
renamed capture::the_title_says_whether_input_is_captured; docs/api.md and
the macOS walk name the new title.
2026-10-14 12:23:53 +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