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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.
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.
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.
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).
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.
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.
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.
The guest's kernel maps the device region uncached whatever the kext asks:
xnu's pmap sets PCD on every page it does not manage, and the region is no RAM
of the guest's. An AMD host applies the guest's memory type (Intel's EPT
ignores it), so on the Radeon 780M host the guest's stores there ran at
13 MB/s and draws.10k spent 9.1 ms encoding against 0.5 ms on the RTX 5080.
The kext's Alloc now takes a third input, the byte from which the process's
mapping of the block is write-combined (kIOMapWriteCombineCache, PAT index 6),
behind a kext feature bit. The bundle puts there what it only writes: a
submission ring's data, which now starts its block's second page with the
ring's header ending the first, write-back as before, since the host writes
it too and the writer reads it; command buffers' bodies; and a library's
staging chunks, past the page of acks it reads. The ring writer fences its
stores (sfence) before it publishes a message, so write-combined stores reach
the host before the producer index that names them, as a release store
orders write-back ones. ICB slots stay write-back: their setters read fields
back and OR bits in with locked operations, which write-combined memory does
not keep atomic.
For the guest, a queue's submission ring now starts 3840 bytes into its block
where the kext has the feature; the wire is unchanged.
The pages slab source took only 2 MiB superpages, and the guest's kernel runs
out of them minutes after a boot: measured on an x86-64 macOS 26.7.2 guest of
8 GiB on the Radeon 780M host, a process got 19 at boot with 2.5 GiB free,
then KERN_NO_SPACE, and none three minutes later. Every Shared buffer, 4 KiB
up, then lay in the device region, which the guest maps uncached and an AMD
host applies: its stores ran at 13 MB/s, against 56-123 GB/s in a superpage.
Where the kernel refuses superpages, the source now takes plain pages,
zero-filled and wired into a pages block by the kext: a 2 MiB slab is one
HEAP_OVER_PAGES the host lays over the block's view, a larger dedicated
Shared one a BUFFER_OVER_PAGES over it, as before. Only where neither comes
is a slab the region's.
A queue's upload chunks, the bytes set*Bytes: hands in, are now Shared
buffers of the slabs, so they lie in the process's own pages too, and fall
back to region blocks only without slabs.
The region's memory changed with the previous commit: the design's Decided 5,
docs/qemu.md and the C API's doc of rvg_graphics_device_region (and so the
header) said it was private anonymous memory on every host.
Whether x86-64 macOS has a driver for reims-ctl's virtio-sound-pci had never
been checked by a boot. A macOS 26.7.2 guest booted on reims-ctl's q35
command answers it. AppleVirtIOSound binds the device, and Core Audio makes
it the default output and input. Played sound reaches QEMU, and with the
pipewire backend it reaches the host's default sink. Safari's Media Source
player plays to the end with audio. With audio off, every Media Source
stream that has an audio track fails with MEDIA_ERR_DECODE, and a video-only
stream still plays. The ICH9 HDA controller has no guest driver and plays
OpenCore's boot chime alone.
The command already gives x86-64 VMs working audio, so nothing in it
changes. The module doc and docs/qemu.md now give these results in place of
the "unchecked" note.
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.
reims-ctl told every x86-64 VM to set METAL_ERROR_MODE once macOS is installed:
in its install steps, after create, after an eject and in the TUI's create
message. That was measured on apple-gfx, whose guests' icon service ends as it
starts without it. On reims-vgpu's own device, the x86-64 default, a macOS
26.7.2 guest without the key comes up with its Dock and icon services running
and no crash report (a Radeon 780M host, 11-07), so users of the default were
sent through Recovery for nothing. runtime::needs_error_mode now gates every
one of those messages on apple-gfx, and README step 3 and docs/qemu.md say
which device needs it.
Two of gpu::fill's Metal tests failed on the M3 Max (macOS 27.0.1): for a
colour in a format Metal packs no colour in, Metal wrote 80 ef 0b 82 02 00 00
00 42 a2 3d fe 01 00 00 00 where the tests expected the bytes of the colour
fill before it.
Metal packs no colour there. It fills the 16 bytes of the calling thread's
stack where its packing writes a colour. Sent right after another colour
fill, with no call between them, it writes that fill's texel. Sent right
after a call that set the stack below to one byte, it writes that byte.
Both were measured from a plain Objective-C process and from the test
binary. The tests sent through the Metal platform, and in a dev build
objc2 checks the method before each send. That check left the encoder's
class and the selector there as pointers: the bytes above are those two
addresses (measured). So the tests were reading our own build's stack. It
held the earlier fill's texel when the tests were recorded.
The tests now send Metal's two fills by objc_msgSend itself.
metal_fills_a_colour_it_packs_none_in_with_its_stacks_bytes (renamed) pins
both measured answers for every format in LEFTOVER_FORMATS and
UNPACKED_FORMATS. leftover_colours_fill_an_earlier_colours_bytes_as_metals
compares ours, after the earlier fill in the same encoder or in an earlier
one, with Metal's fill sent right after another. Across an encoder's end,
Metal's stack holds other bytes, and the runtime holds the command buffer's
last packed texel: one answer of that envelope. The AMD 5300M and the
Intel 630 (macOS 26.7.1) raise NSInvalidArgumentException at every colour
fill, so they give no other answer to match.
Nothing the guest or the host sees changes. The module's docs and
docs/lessons.md say what was measured.
A screendump of a display whose width is not a multiple of 4, such as
reims-graphics-pci's window of 3662 x 2039 pixels on a host scaled by 2.1,
read back sheared by 2/3 of a pixel a row, with a dark diagonal seam and
its colours rotating from row to row (grey once scaled down). The display,
its window, VNC and SPICE were right, and so was a PNG screendump: QEMU's
ppm_save wrote each row with its pixman line buffer's stride, which is
rounded up to 4 bytes, where a PPM's rows are width * 3 bytes.
vendor/qemu moves to 23198e4b79, which writes width * 3 bytes a row, with
a qtest that dumps bochs-display at widths of 64, 66 and 67.
The boot that checked USB passthrough end to end: a macOS 26.7.2 guest
given a USB stick the host's kernel makes lists it, mounts it, writes to
it, and loses and regains it as reims-ctl takes it back and gives it again
while the VM runs. docs/qemu.md now says what was measured, and that macOS
26 lists USB devices under SPUSBHostDataType, not SPUSBDataType.
What reims-ctl's command line relies on, read from QEMU's code: the
controller's ports and their speeds, the full-speed hub QEMU chains on the
last free one, how usb-host matches a device and waits for one not plugged
in, and why a macOS host has no passthrough.
docs/qemu.md still said reims-ctl's VMs do not have reims-graphics-pci, which
stopped being true when x86-64 VMs moved onto it by default: reims-ctl now
adds the device and the max-ram-below-4g=1G option the device's BAR needs.
vendor/qemu moves to c119b802, where reims-graphics-pci gives QEMU's
console the guest's cursor from the graphics device's new cursor
callbacks: its image and hot spot, its place and whether it shows. A VM on
the reims-vgpu graphics option now shows its cursor through a SPICE, VNC,
GTK or D-Bus display added to its QEMU command, as one on apple-gfx does;
before, the pointer moved the guest's cursor and nothing drew it. Under
-display none nothing changes: the console has no display, and the window
shows the cursor as the host's pointer.
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.
Item 13 described the loader and its table as built outside the repo, with
no script here to make the table again; make -C guest set now builds the
kext, its shims and the loader together, and guest/prebuilt carries the set.
Since c13-contract (ae37ce1c2) the bundle answered nil for a BC1 to BC7
texture over an IOSurface or one of its planes, before it took a view of the
surface. Metal on the x86 Macs makes these wherever the rows fit, over a
surface with planes or without, in Managed or Private storage
(oracle_surftex, Q20). The nil was the host's limit: pin 14's runtime made
no texture of one over a surface's rows (NotLinear). metal2vulkan's stack
34, at this branch's pin, makes them in the x86 Macs' form, row j of blocks
at the plane's row j (on MoltenVK as a shadow image), and the bundle's own
CPU access takes the same rows since 187d1ee33. Runtime gaps are
metal2vulkan's, and ours go at the pin that fixes them.
What changes for the guest: newTextureWithDescriptor:iosurface:plane: of a
BC format answers a texture and posts its create, where it answered nil and
logged "no texture (descriptor)". The shapes stack 34 still refuses (a BC
texture over a plane at an offset or rows off 16 bytes, or wider than the
plane's rows) are posted and refused as the host's other refused shapes are
(decode/refused.rs). On the Metal platform, whose buffer creator answers nil
for BC as Metal's IOSurface creator does (87b24e27e), the texture is a
refused create too.
Test: test_iosurface_block_compressed_textures_are_made fails at the base,
where the bundle answers nil.
c14-shared-events and c14-texture-nil each added a Q23 to dgpu-oracle.md. The
car keeps shared events' Q23 and numbers texture-nil's two sections after it:
the texture descriptors each creator refuses are Q24, and what a command buffer
does with nil objects is Q25. The references in dgpu-oracle.md, design.md, the
decoder's refused.rs and the shell tests follow, and the report's probe list
names oracle_events, which shared events added to the oracle's README and
build.sh.
oracle_nilbind measured what the AMD 5300M and the Intel 630 do with nil where a
command buffer names an object: Q25 records it and what the decoder now does with
a refused one. Q24 adds the block-compressed and texture-buffer answers over a
buffer, and where the bundle answers nil beside them.
Car 14's stack: Q25 and Q24 were the lane's Q24 and Q23; c14-shared-events
holds Q23 on the car.
A binding of a buffer, texture or sampler whose posted create the host refused
bound nil and dropped the encoder's draws and dispatches until the slot was
bound again. Metal on the AMD 5300M and the Intel 630 runs a draw or dispatch
with nil bound there (oracle_nilbind, docs/graphics-kext/dgpu-oracle.md, Q25):
a texture reads zero on both, a buffer zero on the AMD. The decoder now binds
nil and runs them, as it does the guest's own nil; the slot stays marked, so
an offset op there still sets nothing. A refused pipeline state, depth/stencil
state or tessellation factor buffer still drops the draws.
For the guest: the draws and dispatches after a binding of a refused buffer,
texture or sampler reach the GPU, reading the platform's nil there
(metal2vulkan's zero image, sampler and buffer; Metal's own on the Metal
platform).
Car 14's stack: fix G (e551d6faa) had made Marks::drops_draws skips() || any(),
with the slot set reached only out of line; the lane's slot scan goes in a cold
Marks::holds_state, so drops_draws stays skips() || (any() && the scan), and
the struct's and the render walk's comments say both lanes' rules. Q25 was the
lane's Q24 (c14-shared-events holds Q23).
oracle_texdesc measured the descriptor validation every texture creator runs on
the AMD 5300M and the Intel 630, rule by rule and in order, which the bundle now
copies. Q24 records it, and Q12 says whose words the bundle now gives.
Car 14's stack: c14-shared-events holds Q23 on the car, so the lane's Q23 and
Q24 are Q24 and Q25 here, in these commits' bodies and in car 14's doc fix after
the lane's commits, which renumbers the doc's headings and references; the doc
keeps both sections, shared events' first.
CoreDisplay now sends its display profile's gamma tables to the pipe on every
boot (the display answers plane gamma as an AMD Mac's does), so the window's
draw goes through the display's colour on every frame: each pixel ran up to
three interpolated table stages, two buffer reads a channel each.
A colour with no matrix maps each channel on its own, and what the draw reads
takes only 256 values per channel (the scanout's bytes, an 8-bit unorm surface)
or 1024 (a 10-bit unorm surface, drawn at its own size). The sink now draws the
colour once into an n x 1 table in the drawable's format, through the colour's
own pipeline, from a ramp of every value, and then draws each frame through it:
one texel read a channel (displayPipeLutFragment and its scanout twin). Entry k
is what the pass draws for value k, so the drawable's bytes are the pass's,
which the new tests check on Metal and on the Vulkan platform, for the scanout
and each carried format over every value. A draw rebuilds the table until a
command buffer that drew it completes, so a dropped draw never leaves it
unbuilt. A colour with a matrix, a surface of another format or size, or a
drawable that is not 8-bit unorm still take the pass.
Nothing the guest or the host observes changes: the window's and the host's
reads' bytes are the pass's. The Vulkan platform's shaders.metallib is written
again (cargo xtask metallibs) for the two new functions.
The display_frame_cost bench gains the table's cases, and takes its cases in
turns frame by frame, each through a sink of its own, so the GPU's clock and
the host's load fall on each case alike.
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.
design.md's new section says how a shared event crosses processes: the port
is a connection of the kext's, which the bundle checks before it calls on it,
one host event per name, its values posted to every holder, and the port's
hold of the event, which outlives a maker killed with SIGKILL; and the residual
of a value read across processes. The user client table lists the 'RGSE'
selectors and kext feature 1 << 6. dgpu-oracle.md's Q23 records what the 5300M
and the 630 answered.
The doorbell's answer on the vCPU left every command buffer that used a cached
surface block to its queue's thread, so on a GPU with memory of its own video's
buffers and WindowServer's composites got their CB_SUBMITTED only at their
take. A buffer that uses caches is now answered there where it waits for no
copy of them at its begin: none needs a fill for it, their last fills are done,
and no copy asked of them is one it follows. Every lock it looks at is tried.
What the guest sees: such a buffer gets its CB_SUBMITTED on the doorbell's
thread, before its queue's thread takes it, as one that uses no cache does. A
copy asked between the answer and the begin (a fill a host device's write over
the pages asks, a present's fill, a download, a release) is still followed at
the begin where the buffer must follow it, the buffer waiting for it on the GPU
with its answer given.
On a GPU with memory of its own, a command buffer whose use of a surface
needed its device cache filled waited at its begin, on its queue's thread,
for every buffer begun before it that used the cache, and any begin behind a
download or a release waited for the writers that copy followed. WindowServer's
buffers once waited 13.5 s this way behind a WebGPU page's long buffer
(measured on the RTX 5080 Laptop GPU host).
Every use of a cache is now numbered as it is counted, a buffer's uses
together. A copy that a buffer begun and not finished holds up is asked, not
waited for: it is made in the finish of the last buffer it follows, after its
commit, in the order the copies were asked. The buffers counted after it wait
for it on the GPU, on the cache's own shared event, which the copy's command
buffer signals: one that reads what a fill writes, or may write what any copy
reads. A buffer finished while a copy it waits for is not yet made stays
counted until it is, so no copy waits for it ahead of that copy on the
transfer queue, and it takes no early copy on the read-back queue. Where the
platform makes no shared event, the begin waits on the CPU as before, counted
in the cache log line with the fills made behind buffers.
What the guest sees changes in timing only, the order of copies against the
buffers' uses kept:
- a buffer begun behind such a copy, which it reads or may write over, gets
its CB_SUBMITTED at its scheduling, as a buffer waiting for a fill does,
where it got it at its take after the wait on the host's CPU; a buffer that
only reads behind a download or a release waits for nothing;
- a present's fill behind a walk no longer waits on the control thread;
- a writer of a read-back surface finished before the copy it waits for is
made takes no early copy: the download after it copies its write out.
Measured with FakePlatform on the M3: a begin needing a fill behind another
queue's walk held 1 s blocked for 1652 ms with one wait on the CPU; now it is
begun at once with none
(a_begin_waits_on_the_cpu_for_no_other_queue_s_long_walk).
Since car 12 (757de8422) a queue's service thread walks and commits a
short buffer that waits for nothing itself. b5182273d then let the queue's
claim go before that walk, so a doorbell rung during the walk could answer
the next buffer. But the guest rings a queue's doorbell only while the host
marks the ring idle (consumer_idle 1), and the service thread kept it
marked busy through the walk and the commit. A buffer published during
them got no doorbell, and its CB_SUBMITTED waited for the take after the
commit. On the RTX 5080 host that is submit_probe's submitted.tiny.behind:
p50 26-32 us and p90 48-175 us against the control's 18 and 27-35, with a
second hump at 128-256 us (car 13 rerun, c13t-sublk).
When the host lets the claim go, the ring is now marked idle, with a full
fence before the look at the ring, as before the thread sleeps. The mark is
cleared when the thread takes the claim back. A buffer published during the
walk is rung for and answered inside its doorbell write, on the vCPU's
thread, where it waits for nothing, as behind a walk on a lane thread.
What the guest sees: such a buffer's CB_SUBMITTED comes inside the
doorbell write, before the walk ahead of it ends, not after that buffer's
commit. The guest also rings once for each buffer it publishes during such
a walk, as it does for a sleeping thread.
The walk test now rings only where the ring is marked idle, as the guest's
writer does, and fails without the mark. The behind measurement rings that
way too.
Since the pin that made the Vulkan platform commit with commit_and_submit,
the runtime runs, inside a commit, the submission handlers of every ready
batch, any command buffer's of the process. A graphics decoder buffer's
handler then posted its CB_SUBMITTED and CB_SCHEDULED onto its queue's
completion ring, and raised the queue's vector, on whichever thread
committed: the window's render thread, a PG device's thread, a frame
commit, or the host's thread inside rvg_graphics_device_read_display. The
header names none of those for RvgGraphicsRaiseFn, and read_display "calls
back: never". A full ring also made that thread wait for the guest.
A platform commit that may run handlers inside the call is now marked on its
thread (core's platform::command::committing, used by the Vulkan platform's
commit). A decoder buffer's handler that runs inside a marked commit on a
thread the header does not name hands its records to the queue's service
thread, which posts them and raises; every later post onto that ring goes
behind them, so the ring's order is kept. It waits for nothing. On the
device's own threads the handler posts inline as before, with no added wake.
The queues count the records handed over and, at most once a second, log
at info (reims_graphics::handed) the running total and the longest any
record waited for a thread to post it since the last line. Metal's handlers run on Metal's threads, so
nothing changes there.
The Vulkan test of a commit's checks now also checks the mark.
A command buffer that asks for its CB_SUBMITTED and waits for nothing got
that record at its take, or on its doorbell's thread, but its CB_SCHEDULED
only once the platform had taken its work: from the submission handler, on
the runtime's thread. On the RTX 5080 host that put a tiny buffer's
scheduled handler 0.34-0.39 ms after commitAndWaitUntilSubmitted on an idle
queue (car 12 and car 13, submit_probe's submitted.tiny.idle), against
0.20 ms on an AMD 5300M Mac and 0.05 ms on Apple's paravirtualized device.
Such a buffer now gets its CB_SCHEDULED right after its CB_SUBMITTED, at
the take or on the doorbell's thread, as long as no buffer begun before it
on its queue still owes its own record. Each queue counts the begun buffers
that owe one (Line's owed), so its records stay in commit order. A buffer
with nothing left to post runs no submission handler. Its ticket in its
process's commit order is issued at the take, as the CB_SUBMITTED there
already needed.
A buffer that does not ask keeps its CB_SCHEDULED to its scheduling.
Posting it at the take would need its ticket there too. A walk held on one
of a process's queues would then hold up the commits of its other queues
(a_walk_held_in_a_draw_holds_up_no_other_queue).
What the guest sees: an asking buffer that waits for nothing turns
Scheduled, and its scheduled handlers and waitUntilScheduled run, with its
commitAndWaitUntilSubmitted, before the platform has its work. Metal makes
it Scheduled within a fraction of a millisecond of its commit. Nothing the
guest orders depends on the difference (design.md, "Loose"). Such a buffer
whose walk then faults is now scheduled before its failure.
A buffer with a completed handler paid two hops to its queue's completion
queue, one for its CB_SCHEDULED and one for its CB_COMPLETE, though its
scheduling runs nothing of the app's when it has no scheduled handler. Such a
buffer's scheduling now runs on the completion thread as it takes the record,
where none of the queue's records still waits on the completion queue, as the
records of a buffer with no handler at all already do.
What the guest sees: for a buffer with no scheduled handler, the status turns
Scheduled and waitUntilScheduled returns from the completion thread, one
thread wake sooner. Behind a record of its queue still to run, it waits its
turn as before, so the status still flips in the ring's order among the
handlers. The completed handler still runs on the completion queue.
Car 13's WindowServer frames run (c13t-wsframes, RTX 5080 host) traced QEMU
with `perf record -p` and 47 tracepoint-class events, which every new thread
inherited. The host's lane threads come and go in bursts, and each exit then
freed its events in perf_event_exit_task: 0.12 to 12 s an exit, 22 to 23 of
24 CPUs at once, the vCPUs starved and the guest frozen for 1.3 to 10 s, read
in the guest as frames of up to 9.5 s. Every frame over 200 ms in that run
came from the recorder. Say so where the docs say how WindowServer is
measured, with what a host trace does instead.
reims-graphics' device tests were leaky in car 12's and car 13's checks,
and they spawn no process. A probe of tests that only read their own
descriptors and sleep shows why: std on macOS sets close-on-exec on a
child's pipes after making them, so a test nextest starts in that window
holds the output pipe of the test started beside it, and that test is
leaky when the other outlives it. No change to the tests can prevent it.