Commit Graph
4823 Commits
Author SHA1 Message Date
Anees Iqbal ea34cfbee8 ✅ Resize gl_window's window mid-run on -r
A GL window that resizes sets its surface's shape again and then its
drawable's surface, which makes the window's buffers anew at the new size.
gl_window -r resizes the window's content to 320x200 at the middle frame, so
the frames after it and the read of the back buffer exercise that path.
2026-11-07 11:18:17 -08:00
Anees Iqbal 06a13b6cb4 🆕 Offer to turn MGLRU's thrashing guard off on Linux hosts
With /sys/kernel/mm/lru_gen/min_ttl_ms above 0, the kernel kills a process
where it can't keep the pages used in the last that many milliseconds in
memory, even while RAM is free (the kernel's multigen_lru.rst, "Thrashing
prevention"), and a VM's QEMU can be the one killed. CachyOS's kernel sets it
to 100. Measured on hosts here at 100: kswapd invoked the global OOM killer
with most RAM free, killing a compiler with 19 GiB free on um870, and making 19
of a day's 22 OOM kills on ms01. An hour of builds beside a VM on um870 killed
no QEMU.

The installer and reims-ctl doctor now read the file, and above 0 they say
what it does in one line. On a terminal they offer to write 0 with sudo, and
they show the systemd-tmpfiles line that keeps it at 0 after a restart.
Without a terminal they only tell. VMs run either way, so doctor doesn't count
it as a failure.

Tested in mount namespaces on um790, where the file was a root-owned copy
holding 100 or 0: the installer without a terminal, and on one answering y and
n; then doctor the same ways. Each wrote 0 only on a y, said nothing at 0, and
left the host's own file at 100.
2026-11-07 11:12:50 -08:00
Anees Iqbal c2be12ca83 🆕 Bring the VMs an older reims-ctl made up to date after an update
After an update, an x86-64 VM made by an older reims-ctl stayed on apple-gfx
with the ported drivers in its OpenCore image, and its user had to make the
image again, drop those drivers and switch its graphics by hand. Its settings
name no graphics: master's reims-ctl never wrote them.

reims-ctl now keeps a record of the migrations it ran, migrations.toml in its
config directory. Its first run after an update (the restart from the interface,
or any later command) runs migration 1 once, on each stopped x86-64 VM whose
settings name no graphics: it saves reims-vgpu as the VM's graphics where the
macOS on its disk runs the device's drivers (macOS 26.4 or later), and apple-gfx
where it doesn't, then makes the OpenCore image again for them, presenting the
same Mac, and keeps the old image beside it as <image>.pre-migration-1. Each
VM gets one line, which the interface shows first and a command writes to
stderr, after a line saying reims-ctl is updated. A running VM is migrated at
its next start. A VM that can't be migrated stays as it was, and its line says
why and names the manual command. A VM whose settings name graphics, set by
its user or by a reims-ctl that knew the device, keeps them.

A start of a VM on reims-vgpu whose image holds other builds of the device's
kexts than this reims-ctl carries now makes the image again with these, so a
later update of the kexts reaches the guest without a manual step.

Measured on um870: master's reims-ctl (1fe0acb68) made two VMs on copies of a
26.7.2 disk, one patched to read as 15.7.2, both on apple-gfx with the ported
kexts. After the update, reims-ctl list moved the first to reims-vgpu and kept
the second on apple-gfx, both images made again without the ported kexts. The
first then booted to its desktop on the 780M with the five kexts loaded and no
fatal line.
2026-11-07 11:10:40 -08:00
Anees Iqbal e8d6d2dcd7 ✅ Run the copied-surface order test on joined copies
a_texture_over_a_copied_surface_reads_another_ones_writes_as_metals was ignored
because metal2vulkan cd511955f7 made each buffer over the same bytes a copy of
its own, so a write through one texture over a surface reached the other's copy
only after its command buffer completed. The runtime at the pin (6b4b4b0692)
joins copies of the same bytes as it joins imports, and the test passes on
MoltenVK with every import refused: the runtime copied the surface's pages, and
the read through the second texture matches Metal's, in one command buffer and
across queues by event.
2026-11-07 11:08:12 -08:00
Anees Iqbal f5a32dc8aa ✅ Test the surface textures' order across queues by event
The read through the second texture also runs in a command buffer of another
queue, committed first and waiting for an event the write signals after its
blit, which Metal orders as one memory too. Past the gate the read's copy is
filled at its commit, before the write was even committed.
2026-11-07 11:08:12 -08:00
Anees Iqbal d616657af9 ✅ Test that two textures over one surface are one memory
A texture over a surface reads what a blit through another texture over the
same surface wrote in the encoder before, as Metal's does. In place the runtime
imports the surface once for both buffers under them. Past the views' gate on
Linux each buffer over the surface is a copy of its own, which the second test
reproduces on macOS by refusing every import at a gate of the test's: it is
ignored until metal2vulkan joins copies of the same bytes as it joins imports.
2026-11-07 11:08:12 -08:00
Anees Iqbal 4e1f847978 🐛 Answer nil for a device texture of more bytes than maxBufferLength
The device's newTextureWithDescriptor: sent every texture its validation
passed to the host, posted, and answered a texture, however many bytes it took.
Metal answers nil for one too large to make: the Intel 630 past its
maxBufferLength, the AMD 5300M past 16 GiB (the previous commit's
measurement). A texture whose create the host's platform refused for its size
was then one the app held, and the draws of every command buffer naming it
were dropped (refused.rs), where Metal's app would have seen nil and taken
another path.

What the guest sees: the device's creator answers nil, sending nothing, for a
texture whose bytes, every level of every slice and sample in its format's
blocks (its allocatedSize), are more than the device's maxBufferLength, as the
Intel does and as the bundle answers a buffer and a heap past it. It is inside
both x86 GPUs' answers, and keeps a texture within three quarters of the host
GPU's working set, which our maxBufferLength is. A heap's, a buffer's and an
IOSurface's creators place a texture in memory of their own size, and are
unchanged. test_textures_past_max_buffer_length_are_nil expects it.

guest/prebuilt is rebuilt from the tree (make -C guest prebuilt, the macOS
26.7.1 KDK): RgfxGate, which carries the bundle, and the record.
2026-11-07 11:07:32 -08:00
Anees Iqbal 8b59610c48 ✅ Measure where Metal answers nil for a large texture
The bundle sends a texture create to the host posted and answers a texture
whatever the host's platform then does with it, so a texture Metal answers nil
for by its descriptor alone has to be answered nil in the bundle. The
descriptor's rules were copied on 11-05 (Q24); what Metal answers for a texture
too large to make had not been measured.

oracle_texdesc's 13 new cases are RGBA32Float textures within every rule, of
2 GiB to 8 TiB, at the device's creator; each prints the size
heapTextureSizeAndAlignWithDescriptor: answers, and a made one its
allocatedSize and the process's footprint. On macOS 26.7.1 the Intel 630 makes
2 GiB, its maxBufferLength, and answers nil a row taller; the AMD 5300M makes
16 GiB and answers nil from 20 GiB, its maxBufferLength 3.2 GB. A texture that
is made commits no memory. The M3 Max answers nil for the 128 GiB and 8 TiB
ones. dgpu-oracle.md, Q24, records the table.
2026-11-07 11:07:32 -08:00
Anees Iqbal 0cd94af10a 🐛 Answer a split buffer's GPU times from its first part's start
A command buffer committed in parts answered the guest GPU times from its
first part's start to its last part's end. The GPU waits between parts for
the host's walk of the next, so that span held the walk: game_6000's frames
answered a gpu_p50 of 5.4 to 8.5 ms on the RTX 5080 against under 1 ms before
car 12's split, so a game or engine that scales its work by GPU time saw a
GPU about 7 times slower than it is. macOS's SkyLight and QuartzCore read
GPUStartTime and GPUEndTime too. On both x86 Macs one long buffer spans its
encoders' GPU time summed (the previous commit's measurement).

What the guest sees: a buffer committed in parts answers its first part's GPU
start, and that start plus its parts' GPU time summed (each part's end less
its start) as its end, never past its last part's end, where parts that
overlap on the GPU sum to more. A buffer committed whole answers as before.
a_buffer_s_outcome_is_all_its_parts and
a_buffer_walked_long_is_committed_in_parts_with_one_outcome expect it.

The summing is 3e974a4a6's, which anchored the span at the last part's end;
this anchors it at the first part's start, which the GPU reaches soonest
after the commit, as a Mac's buffer starts 0.08 to 0.40 ms after its commit.
2026-11-07 11:01:27 -08:00
Anees Iqbal 1c77a6d25a ✅ Measure a long command buffer's GPU times on x86 Macs
A command buffer the host commits in parts answers GPU times from its first
part's start to its last part's end, which hold the host's walk between parts:
game_6000's gpu_p50 went from under 1 ms to 5.4-8.5 ms with car 12's split.
What a Mac answers for one long buffer had not been measured.

oracle_cmdbuf's new gputimes case commits K encoders of about 0.5 ms each (K
= 1, 8, 32; compute and render passes) in one buffer, and the same encoders
one buffer each, back to back. On both x86 Macs (macOS 26.7.1, the AMD Radeon
Pro 5300M and the Intel UHD Graphics 630) one buffer spans its encoders' GPU
time summed, as the back-to-back buffers do, within the GPUs' clock ramp; the
CPU's encoding time never counts; GPUStartTime comes 0.08 to 0.40 ms after
the commit. dgpu-oracle.md, Q7, records the table.
2026-11-07 11:01:27 -08:00
Anees Iqbal 912d72dfd5 📝 Record the RX 550's UVD faults on grey JPEG decodes [ci skip]
The day's journal on the RX 550's host names the processes behind every UVD
fault and ring timeout: each was one decoding jpeg-check.sh's grey cases,
development's engine or a diagnostic build. 10 faults, and 3 ring hangs the
kernel ended by resetting the GPU with VRAM lost, so a guest's grey JPEG on
development could reset the host's GPU. The engine that refuses grey made
none in 792 starts, each decoding the trial's 32x32 grey image. The module
doc and U25 say so.
2026-11-07 10:57:33 -08:00
Anees Iqbal 28e6f82489 🎨 Format the RX 550 batch and name Rows::to_even as clippy asks
rustfmt wraps the lines the batch's commits left long, and clippy's
wrong_self_convention asks a from_ method to take no self: Rows::from_even,
a Copy value's widened copy, is to_even. The trial's chroma pairs are read
by as_chunks, as clippy's chunks_exact_to_as_chunks asks. Nothing the code
does changes.
2026-11-07 10:57:33 -08:00
Anees Iqbal 497df25c3b 🐛 Read a JPEG output's bands from the even row at or above them
An output read in strips, past udmabuf's limit, was read in bands from
the first row of the guest's region. Strips::read refuses a band that
starts on an odd row, where a 4:2:0 strip's first chroma row would
split, so a copy of a region from an odd row of such an output failed as
a malfunction (read from the code; the JPEG gate's odd crops are of
small outputs, read whole).

Each band is now read from the even row at or above it, and is 2 rows
shorter where the region starts on an odd row, so that what is read still
fits the strip. write_band takes the region's rows from within that read.
The bands' rows in the destination stay as they were, so the chroma rows
the destination takes are the whole read's: the unit test now writes in
bands from an odd row as well as from an even one, through strips and
through offsets, and compares with the whole write.
2026-11-07 10:57:33 -08:00
Anees Iqbal e3efaaf736 🐛 Make each JPEG decode's vaEndPicture by its deadline
The JPEG engine made every decode's vaEndPicture on the decoding thread.
Each decode is its context's first picture, in which radeonsi may wait for
the GPU (U24): on an RX 550 (Polaris 12's UVD, Mesa 26.2.6), with the
compute rings that take the process's work held by the tests' spins, the
call waited 1.22 s in drmSyncobjWait, until the GPU was done, and the
decode then returned as decoded, past its 50 ms deadline, with the
driver's lock held all along (jobs 4555, 4562). So the held tests of the
compute rings failed there (job 4534).

The decode now ends its picture through render_decode, as a new H.264
decoder's first picture is: on the display's call thread, by the decode's
deadline. Past it the decode fails as stalled, and the engine stalls with
its context and surface kept until the GPU is done, as for its other waits.
The conversion's held test takes the display's other calls as the decode
stalled: they fail by their deadline while its first picture holds the
call thread, and go on where it waits on the memory's dma-buf.

For the guest: where the driver waits for the GPU in a JPEG decode's
vaEndPicture, as on Polaris's UVD with the GPU busy, the decode fails by
its deadline (kIOReturnDeviceError) instead of blocking past it, and the
display's other calls each fail by their own deadline meanwhile instead of
waiting inside the driver. Elsewhere nothing changes but that the call is
made on the display's call thread.
2026-11-07 10:57:33 -08:00
Anees Iqbal 8a7d533993 ✅ Hold a GPU with no uncached memory by a timed spin
The tests of a held GPU (va::wait::held) spin on a flag in host memory the
GPU reads and writes uncached, VK_AMD_device_coherent_memory's
DEVICE_UNCACHED_AMD. RADV gives the RX 550 (GFX8) no such memory, so each
test's setup panicked there: 7 of the VA-API host's 10 tests failed on
development (job 4229). In host-visible memory the GPU's caches kept the
spin's start from the host until it ended, and the host's flag from the
spin, nontemporal accesses too (measured, 2026-11-07).

On such a GPU the spin is now timed: it holds its ring for SPUN_AT_MOST by
the GPU's own clock, whatever the host does, and the host learns it has
begun from a timestamp the queue writes just before it, once the work ahead
of it is done, read with vkGetQueryPoolResults. A test lets it go by
waiting for it to end. On the RX 550 a timed spin held its ring for
30,000,000 ticks in 1.1999 s, at the device's timestamp period (job 4478).
A GPU with neither the memory nor timestamps and a host query reset has no
spin, as NoSpin::Unheld says, and the held tests say so and end.
2026-11-07 10:57:33 -08:00
Anees Iqbal 6ec443c256 🐛 Refuse what the JPEG engine's trial at start decodes wrong
The JPEG engine took every sampling its VA driver lists as decoded right.
On an RX 550 (radeonsi on Polaris 12's UVD, Mesa 26.2.6) the driver lists
grey, and its decode of grey into a Y800 surface writes a luma none of
whose samples are the stream's, so the guest got a wrong picture for every
grey JPEG: the 14 grey cases of jpeg-check.sh failed (job 4315), and
ffmpeg's VA-API decode of grey on that GPU is wrong too (job 4318).

At start the engine now decodes a flat 32x32 JPEG of each listed sampling,
as a guest's decode would be made, and checks its samples. A sampling
whose trial decodes wrong is refused as unsupported, as one the driver
does not list, and left out of the backend's answer of what it decodes.

No other route decodes grey right there. Into NV12 surfaces of the
driver's, copied out by a run, grey decoded right for some streams and
wrong for others (jobs 4470, 4496): 3 of jpeg-check.sh's 14 grey cases
wrong, 15 more grey streams of cjpeg's and jpegtran's all wrong, and the
trial's luma not written at all. So that route is not taken.

For the guest: on a driver whose trial decodes a sampling wrong, its
JPEGs are refused as unsupported streams (kIOReturnBadMedia), where they
decoded wrong before. Where every trial passes, as on the RX 7900 XTX and
the Radeon 780M, nothing changes.
2026-11-07 10:57:33 -08:00
Anees Iqbal e0208b1571 ✅ Pass a JPEG refusal outside what the backend answers
Core's JpegDecoder now answers what its backend decodes at all
(JpegDecodes: the samplings and the largest picture): VA-API's the
samplings its driver lists and its largest size, NVIDIA's the four it
measures at any size. The guest hears of it only through the refusals it
already got, so nothing it sees changes.

The conformance suite's jpeg-check reads it. A stream outside the answer
that a case asked to decode now passes when refused as UnsupportedStream
("refused as answered"), and fails when it decodes; inside the answer every
refusal fails, as before. jpeg-check.sh's last line counts the passes, the
refused as answered among them, and the failures.

On an RX 550 (radeonsi, Polaris 12) the driver lists 4:2:0, 4:2:2 and grey
up to 4096x4096, so 19 cases failed on development (job 4315): every 4:4:4
one, and the 16384-wide 4:2:2 case. Each was the engine refusing a stream
by the driver's own answer.
2026-11-07 10:57:33 -08:00
Anees Iqbal a276b72fd7 🐛 Fill a device cache from its pages as its block is named again
A cached block named again over the same pages kept its device cache and
forgot the cache's generation, so the cache was filled from the pages only
at the next command buffer that named the surface (RGFX_OP_SURFACE_USE). A
texture over it that a buffer reached through an argument buffer with no
useResource:, which no RGFX_OP_SURFACE_USE names, read what the cache held
before the naming. Metal leaves such residency to the app and faults it.

The cache is now filled from the pages at the naming, as of the CPU's
generation in the block's header then, after the copy of what a buffer wrote
of it into the pages, as edb0c436a fills a new cache at its make. A buffer
still walked that uses the cache has the fill made in its finish, as a use's
fill is. The next named use of that generation fills nothing more, and one
of a newer generation fills again. The caches' log line counts these fills
with the make's.

What the guest sees: a surface reached only through an argument buffer reads
its pages as they were when its block was named again, not the cache's older
bytes. a_block_named_again_keeps_its_cache_filled_from_its_pages and
a_block_named_again_behind_a_walk_is_filled_in_its_finish expect it; the
first no longer waits 10 s for a copy between its two namings.
2026-11-07 10:56:06 -08:00
Anees Iqbal 0f69919562 🐛 Restart the updated reims-ctl from its own path on Linux
After an update from its interface, reims-ctl runs the new binary in its place,
from the path std::env::current_exe gives. On Linux that path comes from
/proc/self/exe, which names a binary replaced since the process started as
"PATH (deleted)": the update's cargo install --force had just replaced it, so
every restart failed with "run .../reims-ctl (deleted): No such file or
directory", though the update itself had worked. macOS gives the path itself,
and restarted.

The restart now runs PATH, where the update installed the new binary. Measured
in a scratch install on um790: master's reims-ctl updating from its interface
printed that error; on the M3 the same update restarted.
2026-11-07 10:46:20 -08:00
Anees Iqbal 6f4ade4ac9 🐛 Make a block's pages wait for a cached release over them
a47f0b613 made a SURFACE_PAGES wait for a released block's device cache to
land in the same pages, noted at the release's ask. Ring 0's lanes are per
block, and a BLOCK_RELEASE is carried out on its context's lane. Where that
lane was behind a slow message when the kext gave up its 10 s wait for the
release's answer and made the surface's new block, the release had not been
asked yet, no copy was noted, the new block's SURFACE_PAGES went first, and
the old cache's copy could land over what the new block's buffers wrote.

The lanes now keep each block's last SURFACE_PAGES marked cached, until a
block's SURFACE_PAGES over its span, and a SURFACE_PAGES that lists runs
waits for each context's lane through its last BLOCK_RELEASE not yet carried
out of such a block whose runs share a page with its own, both blocks' runs
read out of the region as it is handed. The host's wait for the copy, at
most 10 s, then sees the release's copy. That cap stays: a reset drops a
copy not yet made, and an unbounded wait would hold the block's lane past it.

What the guest sees: a SURFACE_PAGES over pages of a cached block whose
release is still behind its lane is answered after that release is carried
out. a_block_s_pages_wait_for_a_cached_block_s_release_over_their_pages
fails on the lanes before this.
2026-11-07 10:41:12 -08:00
Anees Iqbal afb81e0c0c 🐛 Fault the exec at a function refused for a runtime gap
Since 4c0248b29 the Vulkan platform answers a library the runtime refuses for
a gap with the refusal as its NSError, and such a function nil, where it used
to die. Core took the library's NSError as Metal's own refusal of the IR, so
the function was nil to Metal, and the state naming it then ended the process
one create later, as Metal aborts at a descriptor with no vertex or compute
function: on apple-gfx, any translation gap an app's library hit still ended
QEMU (the WebGPU code-30 and Godot bitreverse deaths of 11-03). A function
nil for a gap reached the registration's assert instead.

What changes for the guest and the host, on the Vulkan platform: a library or
function the platform refuses for a gap now raises the function lookup's
failure, as IR over a page-table hole does (8e4c8bc45). The state that names
it is never made, so the exec or info that names the state faults, as where
the platform refuses the state itself for a gap. Nothing is cached, so each
lookup asks the platform again. Metal never refuses there, so the Metal
platform, the suite and the pins see nothing new: Metal's own refusal of the
IR is still nil to Metal, and Metal's nil function still reaches the assert.

The platform tells core: core's platform::device::note_relayed_gap, which the
Vulkan platform's relay_gap calls on the creator's thread, and
relaying_gaps, which core reads it with around the library and function
creators. FakePlatform's Step::Gap scripts it.
a_state_naming_a_function_refused_for_a_gap_is_never_made locks the pattern
for the compute, render and tile forms.
2026-11-07 10:37:06 -08:00
Anees Iqbal 1e2d621c47 📝 Record B90's banded vaGetImage as tried and slower [ci skip]
B90's fix named vaGetImage of bands, small enough that each hold of the
display's lock would be short. Measured on the Radeon 780M and the RX 7900
XTX (jobs 4279, 4284), the bands held the lock longer than the derived map,
in all and at most. The engine keeps the derived map, and the fix left is
Mesa's (U22).
2026-11-07 10:28:30 -08:00
Anees Iqbal b0f350dfbf 🆕 Open reims-vgpu's window at the VM's resolution
reims-vgpu's display follows its window, which always opened at 1920x1080,
and reims-ctl refused any other resolution for a VM on it. A person who wanted
a larger or smaller desktop resized the window at every start.

QEMU's reims-graphics-pci now takes a resolution property, WIDTHxHEIGHT, the
window's first size (the library's window config mode_width and mode_height).
reims-ctl passes the VM's resolution there where it is not 1920x1080, which
leaves a QEMU built before the property working at the default, and its TUI
shows the field for reims-vgpu. host stays refused there: it names no size.

Measured on a KDE Wayland desktop of 3840x2160 at 2.1x, 1829x1029 points, with
a macOS 26.7.2 guest: 1280x720 opened the window at 1280x720 points and the
guest ran 2688x1512; 2560x1440 and the default opened it shrunk to fit, at
1744x981 points, the guest at 3662x2039.

vendor/qemu moves to the commit that adds the property.
2026-11-07 10:23:33 -08:00
Anees Iqbal ddaf1e3602 🐛 Clear the boot screen at WindowServer's first frame
When WindowServer quits at a shutdown, or dies, the kext shows the scanout
again (PRESENT_SURFACE 0). The scanout still held the Apple logo and progress
bar that the firmware and the kernel's console drew during boot, so the window
showed the boot screen until power off, and for a moment after a WindowServer
crash.

The kext now clears the scanout to black once per boot, on the work loop, at
the host's answer to the first present of a surface. The display shows that
surface by then, so the clear is never seen. It clears the boot framebuffer's
rows, or the largest mode's where that is more. Nothing draws the boot screen
again, so a later return to the scanout shows black with no more work.

Measured on um870's 780M with a macOS 26.7.2 guest, through QMP screendumps:
the boot still shows the logo and progress bar; a shutdown shows black until
QEMU exits, where it showed the boot frame from 14 s in; a WindowServer kill
shows black, then the login window, where it showed that boot frame first.

The guest's kext set is built again with it.
2026-11-07 10:17:45 -08:00
Anees Iqbal fb4381635f ✅ Run the VA-API held-GPU tests one at a time under nextest
The tests of va::spin, va::wait::gpu and va::wait::held each hold the GPU
ring with a spin of their own and time the display's calls against it. Their
module asks for one test at a time, but nextest ran the 21 opt-in tests of
the VA-API leg together, and one of them,
jpeg_conversions_then_copies_out_do_not_wait_for_a_held_graphics_ring,
failed beside the others' spins on the Radeon 780M (job m3-max-4299), then
passed 6 of 6 alone (job m3-max-4303). They now run with nothing else in
flight, on Linux, as the paging discard tests do.
2026-11-07 09:36:09 -08:00
Anees Iqbal 67c3844e92 ✅ Run the released-buffer ICB test resident for writing
It was ignored since 11-03, when metal2vulkan c8a0481cf8 ran nothing for a
command naming a released buffer in an ICB it replays on the host. The pin
16 runtime (6b4b4b0692) runs it, reading zero as from a buffer resident for
reading: 3 of 3 with --run-ignored on the Radeon 780M (job m3-max-4282).
2026-11-07 09:36:09 -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 0ffc60d575 🐛 Make an x86-64 VM's OpenCore image follow its graphics
A VM switched from reims-vgpu to apple-gfx or VMware SVGA kept the OpenCore
image made for reims-vgpu, and OpenCore loaded the guest's kexts with no device
of theirs: on apple-gfx with a macOS 26.7.2 guest, ReimsGraphicsLoader and
RgfxGate loaded, and RgfxGate installed its Metal bundle in /Library/GPUBundles
and set AppleGVA's gvaForceAMDKE at every boot.

Setting the graphics now makes a new image for them where the VM is stopped
(set --graphics, and the TUI's edit); while it runs, its next start does. A
start of a VM whose image loads the kexts on other graphics makes a new one
first, so a VM switched by an older reims-ctl follows too. The new image
presents the same Mac.

reims-ctl can't change the guest's files. The new image's note reads the
guest's Data volume and, where gvaForceAMDKE is set, says that it changes
nothing off reims-vgpu's device (measured on apple-gfx: VideoToolbox reports
no hardware decoding or encoding with it and without it) and how to remove it:
sudo rm of the file RgfxGate made, which it makes again if the VM goes back to
reims-vgpu. Not defaults delete: it leaves an empty binary plist, which
RgfxGate never edits again. The Metal bundle stays, as SIP keeps root from
removing it.
2026-11-07 09:16:20 -08:00
Anees Iqbal 3ab4579d42 📦 Build the guest's kext set again with GL texture buffers
RgfxGate carries the bundle, which now sizes a GL buffer's pointee from its LLVM
type, makes texture buffers over a buffer by the public form (nil past its
bytes), reads an OpenCL library's arguments from its kernels' metallib and
answers a function's reflectionWithOptions:. Built by make -C guest prebuilt
from the 26.7.1 KDK (m3-max-4222), which also ran make -C guest test and
prebuilt-check, both passing.
2026-11-07 09:15:01 -08:00
Anees Iqbal 450661e889 🐛 Answer nil for a texture buffer past its buffer's bytes
Both x86 Macs make a texture buffer by the public form even when its texels
lie past the buffer's bytes (measured: macOS 26.7.1, 4 RGBA32Float texels at
offset 4064 of a 4096-byte buffer). metal2vulkan refuses such a texture
(TexelsPastLength), and the Vulkan host ends its process at a refusal by this
creator. So the bundle answers nil, logged once, and sends nothing, as it does
for the other textures over a buffer the host does not carry.
2026-11-07 09:11:16 -08:00
Anees Iqbal 1a7b309917 🆕 Answer a function's reflectionWithOptions:
The GL renderer builds each OpenCL program's kernels in gldBuildComputeProgram
and sends each one reflectionWithOptions:3, unguarded (read from its code).
Our functions did not answer it, so every OpenCL build on our GPU ended the
process with an unrecognized selector (cl_probe on the RTX 5080 host,
m3-max-3947).

What the AMD 5300M and the Intel 630 answer, alike (measured: macOS 26.7.1,
OpenCL C and Metal kernels):
- an MTLFunctionReflectionInternal, for options 0, 1 and 3;
- its arguments and bindings are the same objects a pipeline's reflection
  lists;
- a kernel's by-value argument is a buffer binding of type 22, of the value's
  type, size and alignment, with a pointer type that is no constant buffer.

Our functions now answer that class over the arguments their pipelines'
reflection lists. A by-value argument (air.constant) of a scalar type is now
reflected, where it was refused. A struct passed by value was not measured
and is still refused.
2026-11-07 09:11:16 -08:00
Anees Iqbal 04b1282f7f 🐛 Read an OpenCL library's arguments from its kernels' metallib
newLibraryWithData: keeps the bytes it was given, for the library's shadow.
For the bytes Metal's compiler answers for OpenCL C source, that is the
container, not the .metallib of its kernels that the library was made from.
The library then read its entry points' arguments from the container, found
no bitcode, and answered none. So the GL renderer's OpenCL kernels on the
RTX 5080 host had no arguments ("__entry_add: no arguments read (the library
holds no bitcode for it)", m3-max-3947).

The reader now takes the container as the .metallib of its kernels, as the
library was made from it.
2026-11-07 09:11:16 -08:00
Anees Iqbal 55bbbd0f82 🆕 Make texture buffers over a buffer by the public form
A buffer's newTextureWithDescriptor:offset:bytesPerRow: answered nil for a
texture buffer, logged as a type the host does not carry. The GL renderer
makes each GL texture buffer this way: gl_cases' texbuffer case got nil, and
the renderer drew it in software (RTX 5080 host, m3-max-3947).

Both x86 Macs make one by this form (measured: macOS 26.7.1, RGBA32Float and
RGBA8Unorm):
- over a Shared or a Managed buffer, at any offset (0, 4, 16, 64, 100, 256);
- with rows of at least its texels' bytes (64 and 4096);
- and their kernels read the buffer's bytes from the offset.

The host's platform makes one by the same form, at any offset, so the create
now goes to the host as TEXTURE_FROM_BUFFER with its type. For rows of 0 bytes
both Macs end the process with the same words, and the bundle does too. For
fewer bytes than the texels need, the AMD answers nil where the Intel ends
the process; the bundle answers nil, as the AMD does.
2026-11-07 09:11:16 -08:00
Anees Iqbal fbd4b951fe 🐛 Size a GL buffer's pointee from its LLVM type, not its name
The lowering added air.arg_type_size and air.arg_type_align_size to a GL
buffer argument from its air.arg_type_name. The generator names a uniform
block's pointer, typed <4 x float> addrspace(2)*, "uchar" (measured: macOS
26.7.1, gl_cases' block case). So the lowering wrote a size of 1, and
metal2vulkan refused each such pipeline: it requires the pointee's
allocation size (TypeSizeMismatch at air.arg_type_size). The GL renderer then
drew the block case in software (RTX 5080 host, m3-max-3947).

The size and alignment now come from the parameter's pointee type in the
entry point's function type, as `metal` writes them:
- an integer, half, float or double;
- a vector or an array of them.

No size is added for any other pointee, a struct among them.
2026-11-07 09:11:16 -08:00
Anees Iqbal 8f748fa587 🆕 Trace a GL context's textures and samplers in gl_inject
On the RTX 5080 guest, ten of gl_cases' texture cases sample zeros on our
device (m3-max-3831) while the same lowered shaders pass over the Intel 630's
textures on the oracle. GL_INJECT_TEXTURES=1 writes the first calls of each kind
that make, fill, view, copy into and bind the device's textures and samplers,
with their arguments and each object's number, so a guest run shows which step
loses the texels.
2026-11-07 09:11:16 -08:00
Anees Iqbal 462de526bf ✅ Wait for a crashed exec's completion in its test
a_crash_during_the_exec_completes_four read the completion's status as the
exec returned, which the crash's order does not promise: the crash signals
the GPU token, which wakes the FIFO thread, before the completion's token. It
failed once in 4736 tests in job m3-max-4026. The exec returning before its
completion runs is what the code does and what
the_exec_reply_drops_gpu_token_then_token_then_the_task records; making the
exec wait for the completion instead deadlocks that test, whose completion
waits until the exec has returned (jobs m3-max-4104 and m3-max-4105 hung).

The test's completion now takes 50 ms, so the late completion comes in every
run, and the test waits for it before it reads the 4: with the old read it
fails every run (10/10, job m3-max-4177), and with the wait 0/200 at 48
threads and 0/1000 at 64 (job m3-max-4163).
2026-11-07 08:57:55 -08:00
Anees Iqbal 0b41bb9e6a 🐛 Put a context behind those that waited through its compile
a_context_s_create_waits_behind_no_other_context_s_backlog failed twice in 200
runs 48 at a time on ms01 (job m3-max-3956), with the take order a3b8aa8d2
records: [1, 1, 1, 1, 1, 2]. Context 1's four running compiles sleep 100 ms
from the same release, and all four ended before any thread took the next.
Context 1 then had no compile running, as context 2 had none, and the tie went
to the one ahead in the turns: context 1, which its last take had put at the
back before context 2 joined. Context 2's create so waited past a second
compile's end, where the module doc says it waits for at most the first; with
one thread it always did. The cause a3b8aa8d2 gave, a thread put off between
its take and its start note, is not what the runs showed, and its 260 runs
were 220, besides 520 pinned ones.

A context now goes to the back of the turns as a compile of it ends too, so a
context whose compiles all ended before the next take goes behind one that
waited through them. Where the running counts differ they decide as before.
Which context's compile a thread takes next is the pool's own; a guest sees
only when each create's reply comes.

The new test runs one thread, which reaches the tie at every end: it takes the
contexts 1, 2, 1, 1, where before the change it took 1, 1, 2, 1.
2026-11-07 08:57:37 -08:00
Anees Iqbal 36a2590413 ✅ Read the compile turns test's order as the pool took it
a_context_s_create_waits_behind_no_other_context_s_backlog failed once in
the Linux check of reims-vgpu's tests on an Iris Xe host (job m3-max-3843,
0.21 s), and passed in 260 runs alone or 48 at a time. It read the order the
compiles started in, which each compile notes when its job begins, after the
thread took it and passed the test's gate. A thread put off between its take
and that note lets the compiles other threads took after it note theirs first,
so context 2's create, taken fifth as the first compile ended, could be seen
starting later than fifth. In 0.21 s the test can fail at no other assertion:
the create finished about two compile times after the release, under the
three the time check allows.

The pool now keeps, in tests, the context of each compile it takes, in the
order it takes them, and the test reads that order. Nothing changes outside
the tests.
2026-11-07 08:57:36 -08:00
Anees Iqbal f20ce23594 🎨 Format the present writers' fix as rustfmt does
rustfmt's check on Linux failed on 9ad3e97e4's lines: they are wrapped as it
wraps them, with nothing else changed.
2026-11-07 08:57:36 -08:00
Anees Iqbal 2821247918 🐛 Wait for a present's writer whose queue has no handle yet
The device answers a QUEUE_CREATE once it has made the queue's rings and
started its service thread, and tells the host of the queue before it
answers (Host::queue_made); the service thread then has the decoder make
the queue's handle. A present kept only the writers that named a queue the
decoder held a handle for, so a present whose writer was the first buffer
of a queue created just before, taken while the service thread had yet to
make the handle, dropped that writer and showed the surface before the
buffer that draws it had run.

The decoder now hands the present every writer slot that names a buffer,
and the present queue, which knows each queue from Host::queue_made to its
destroy, its context's close or the device's reset, keeps those of a queue
it knows: a writer of a queue the host does not hold holds nothing, as it
did.

What the guest observes: a present whose writer names a buffer of a queue
whose create was answered, while the host has yet to make that queue's
handle, is now shown once that buffer finishes, as it is once the handle is
made; it was shown at once before. Nothing else changes.

Found as
a_completion_across_a_reset_shows_no_present_of_the_rebooted_guest_early
failing under load (13 of 200 runs at 48 at a time on 16 CPUs): a trace of
each failure showed the rebooted guest's present carried out on the
presents' lane before the new queue's service thread made its handle, the
reset long done. Test:
a_present_waits_for_a_writer_of_a_queue_whose_handle_is_not_yet_made, with
the queue's service thread held before it hands on the create, failing
before.
2026-11-07 08:57:36 -08:00
Anees Iqbal 82aee1e5c0 🐎 Give both planes of a 4:2:0 window a kernel of their own
The kernels' cut to one place a pixel is worked out ran a 4:2:0 window's
both planes through write_word's loop over the word's block, inside
scaler_transform. On the Radeon 780M that made 720p BGRA to 720p 420v
slower (docs/video/scaler.md recorded 0.26 to 0.31 ms). The old
both_planes, whose loop over a chroma row's two luma rows has a constant
count, is unrolled by the driver into two copies of a pixel's work that
run side by side. Put back inside scaler_transform, it was as fast as
before, but it grew that kernel from 21,524 to 31,216 bytes of code,
which every transform's making would pay for.

So both_planes gets a kernel of its own, scaler_transform_both_planes,
which non-adaptive dispatches of both planes take (Biplanar8,
Biplanar16). scaler_transform keeps its code. The making ahead
dispatches eight kernels, and the probe of first transforms has a 4:2:0
destination.

On the 780M, six alternated processes of each build: GPU time 0.230 to
0.206 ms at the median, the other benches within their spread. The
making ahead went from 274 ms to 298 cold, and the new kernel's own
making takes 27 ms. Its outputs are the same arithmetic in the same
order; the whole suite passes (113 of 113).
2026-11-07 08:54:06 -08:00
Anees Iqbal ffbac38070 🐛 Run an older macOS guest on apple-gfx, decided from its disk
Since x86-64 VMs moved to reims-vgpu's own GPU device by default, a VM whose
settings name no graphics, as every VM saved before the switch, ran that device
whatever its macOS. Its drivers, the guest kexts reims-ctl puts in the OpenCore
image, load only on Darwin 25.4 to 25.99.99, macOS 26.4 and later, so an older
guest booted with no GPU, and nothing said so.

reims-ctl now reads which macOS a VM holds: from the disk, through the APFS
container's Preboot volume, whose <volume group UUID>/System/Library/
CoreServices/SystemVersion.plist names the release and build (macos.rs, a
read-only reader of what macOS writes there: the latest checkpoint, the object
maps, the Preboot volume's tree); or from the offline installer reims-util
downloads, whose build it now keeps, or the online one's macOS number. The
build's number and letter give the Darwin version, compared with the set's
bounds.

- create decides the graphics from the download's or the given disk's macOS
  and saves it by name, and makes the OpenCore image for it: an older macOS
  gets apple-gfx and an image without the kexts, and create says why. A
  --graphics reims-vgpu given for an older macOS is kept, and create says the
  guest has no driver for it.
- A VM whose settings name no graphics, or whose macOS isn't known at create
  (a new disk with an installer of the user's), gets them at the first start
  that finds macOS on its disk, saved by name and said: apple-gfx on an older
  macOS, reims-vgpu on 26.4 and later. The TUI's start says it in its status.
- A start of a VM set to reims-vgpu on an older macOS warns, naming
  reims-ctl set NAME --graphics apple-gfx; a disk reims-ctl can't read (a qcow2
  with a backing file) warns likewise where the VM runs the default.
- command, show and list show the graphics a start would save.
- The TUI's edit form keeps none where the choice is left at the default, and
  its create form passes the default as none given, so both follow the macOS.
- qcow2 images with an external data file or extended L2 entries are refused
  rather than misread.

The help texts and README say the default is reims-vgpu on macOS 26.4 and
later and apple-gfx on an older macOS.
2026-11-07 08:44:57 -08:00
Anees Iqbal b9912e537b 🐛 Build QEMU that answers x-query-virtio-status
vendor/qemu moves to d151bcd9, on steelbrain/reims-vgpu: upstream's
b501f213, taken as it is. QMP's x-query-virtio-status, and HMP's info
virtio-status, ended QEMU on any realized virtio device (the virtio sound
device among them): upstream's 1ee0bc0c dropped the line that set the
status's backend-features, a member the schema requires, and QMP's output
visitor asserted on the NULL. The status carries the device's backend
features again.
2026-11-07 08:34:49 -08:00
Anees Iqbal 9d2a56d062 🐛 Prove the Vulkan tests' objects thread-safe within the limit
rustc warned (recursion_depth_exceeding_limit, a future hard error) as
new_images and detach_backing dropped an Obj<PredicatedEncoder>: Obj's bound,
like core's Handle, asks every platform object to be Send and Sync, and the
proof walks an encoder's command buffer, its predication and the runtime
objects that holds, 141 to 150 levels deep (rustc warns at a limit of 140, not
at 150). The depth is that of the objects' fields, fixed by their types, and
the library and the other crates over the platform already take 256 for it;
these two tests now do too.
2026-11-07 08:31:27 -08:00
Anees Iqbal 7c6c2ef54c 📦 Build the guest's kext set again with plain-page slabs and WC spans
make -C guest prebuilt on the Mac, from the guest sources of bbaef7ab3: the slabs
in plain pages where no superpage is left, the upload chunks in the slabs, and
the write-only spans mapped write-combined from a descriptor of their own.
2026-11-07 08:27:28 -08:00
Anees Iqbal 402b7463a9 🐎 Restore the write-combined spans: they take, and the encode was theirs
Reverts 0825b1ea2, restoring 0afc30f37, e8d04b187 and ea13ccbca. A write-combined
mapping of the region does take: the region's descriptor is physically
contiguous, and xnu's fault path maps such an object's pages in its own cache
mode (vm_fault's pmap_map_block_addr, read from the public xnu source), which
the earlier reading missed. The page-table probe that seemed to agree saw only
the processes on the CPUs at its instant, not the bench.

Measured on the Radeon 780M host, draws.10k's encode: 9.2-9.5 ms at the base,
7.7 ms with the slabs in the process's own pages alone (936e3968d's set), and
1.05-1.3 ms with the spans write-combined as well (0afc30f37's and ea13ccbca's
sets). The kext's comment and the design doc say why, and docs/lessons.md the
probe's trap.

For the guest, as 0afc30f37: a queue's submission ring starts 3840 bytes into
its block, the kext's Alloc takes a third input and its feature word holds
1 << 7.
2026-11-07 08:27:28 -08:00
Anees Iqbal c08c19f377 🔥 Drop the write-combined spans: no user mapping of the region can be
Reverts 0afc30f37, e8d04b187 and ea13ccbca. On x86-64 xnu every mapping of
the region in a guest process is uncached, whatever cache mode the kext asks:
vm_fault enters each page with no cache flags, and the pmap gives a page it
does not manage PCD alone, the guest PAT's UC- (read from the public xnu
source: pmap_get_cache_attributes and vm_fault's pmap_enter wrappers). Measured
on the Radeon 780M host with both the region's own descriptor and one of the
write-combined spans' own: every page of a process's over BAR 2 was PCD alone,
none PAT and PCD, and draws.10k encoded as fast as with the spans write-back.

For the guest, a queue's submission ring starts its block again, the kext's
Alloc takes two inputs and its feature word drops 1 << 7; the slabs in the
process's own pages (72c09eddc) carry the measured gains. The design doc says
why the region is uncached, as measured.
2026-11-07 08:27:28 -08:00
Anees Iqbal 4136b501d9 🐛 Map the write-combined spans from a descriptor of their own
The kext mapped a block's write-combined part from the region's own descriptor,
whose one VM object every span shares: xnu's IOKit hands a mapping's cache
mode to mach_make_memory_entry with MAP_MEM_ONLY, which sets the object's WIMG
bits for all of its pages (read from the public xnu source), so each
write-back span mapped after it took the mode back before the process's first
touch. Measured on the Radeon 780M host: every page of the process's over BAR 2
came out PCD alone (the guest PAT's UC-), none PAT and PCD (WC).

Those parts are now mapped from a descriptor of the region of their own, made
with the contexts' state, which only write-combined spans use; where it could
not be made a span is mapped write-back. For the guest, the bytes the bundle
only writes are write-combined as 0afc30f37 meant; nothing else changes.
2026-11-07 08:27:28 -08:00
Anees Iqbal e841993cd8 🎨 Format the heap-over-view change
rustfmt's layout of the B change's lines.
2026-11-07 08:27:28 -08:00
Anees Iqbal bcd75ba81e ✅ Give the heap tests views a heap of Metal's page fits
On a host of 4 KiB pages, a heap of 3 pages rounds up to Metal's 16 KiB page, past a
view of 3 pages; and a region slab's heap is its class's slab size, not 2 MiB.
2026-11-07 08:27:28 -08:00