Commit Graph
374 Commits
Author SHA1 Message Date
Anees Iqbal 892a0eefb0 🐛 Make BC textures over a surface where they answered nil
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.
2026-11-05 21:59:37 -08:00
Anees Iqbal 9beab79d22 📝 Number texture-nil's oracle sections Q24 and Q25 after shared events
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.
2026-11-05 21:59:37 -08:00
Anees Iqbal 9e226f2f98 📝 Record what a command buffer does with nil objects [ci skip]
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.
2026-11-05 21:59:37 -08:00
Anees Iqbal 019bfa1b38 🐛 Draw with nil where a binding names a refused resource
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).
2026-11-05 21:59:36 -08:00
Anees Iqbal 5a208f8829 📝 Record which texture descriptors each creator refuses [ci skip]
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.
2026-11-05 21:59:36 -08:00
Anees Iqbal 94d9df7c3b 🐎 Draw a colour with no matrix through a table of every value
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.
2026-11-05 21:59:36 -08:00
Anees Iqbal 8970ba8391 🐎 Answer a landed download on its ring-0 doorbell's thread
A CPU lock of a surface whose pages already hold its device cache (a decoder's
output whose early copy has landed, or a cache nothing wrote) still waited for
the control thread to wake and take its SURFACE_DOWNLOAD: p50 95.4 us from
the doorbell to the COMPLETE on the 5080 (decode-perf), most of it the idle
core's wake.

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

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

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

Car 14's stack: device.rs keeps both new methods beside each other,
c14-submit-path's mark_idle and mark_awake (a queue's ring, efd360f45) and this
commit's download_on_doorbell (ring 0); ring_taking sends ring 0 to
download_on_doorbell and a queue's ring to answer_on_doorbell, as before.
2026-11-05 21:59:36 -08:00
Anees Iqbal 023663e5ad 📝 Describe shared events across processes [ci skip]
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.
2026-11-05 21:59:36 -08:00
Anees Iqbal c073fcd2a7 🐎 Answer buffers that use a device cache at the doorbell
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.
2026-11-05 21:59:36 -08:00
Anees Iqbal 1261fd0125 🐎 Order device caches' copies on the GPU, not at begins
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).
2026-11-05 21:59:36 -08:00
Anees Iqbal d0f61d5b5c 🐎 Mark a queue's ring idle through a walk on its thread
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.
2026-11-05 21:59:36 -08:00
Anees Iqbal d4d451f636 🐛 Post a buffer's records off a commit on a foreign thread
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.
2026-11-05 21:59:36 -08:00
Anees Iqbal 2a2415f400 🐎 Post an asking buffer's CB_SCHEDULED with its CB_SUBMITTED
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.
2026-11-05 21:59:36 -08:00
Anees Iqbal 4ed0e6923a 🐎 Schedule a buffer with no scheduled handler where it is seen
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.
2026-11-05 21:59:36 -08:00
Anees Iqbal 18872e171b 📝 Trace QEMU system-wide, never with per-task perf events [ci skip]
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.
2026-11-05 21:59:36 -08:00
Anees Iqbal c7cf38125a 📝 Say why nextest calls tests leaky on macOS that leak nothing [ci skip]
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.
2026-11-05 21:59:36 -08:00
Anees Iqbal 202e0a6560 🆕 Build the kext for a trace image with OSBundleForceDTraceInit
dtrace lists no fbt probe in our kext. For a Boot-collection kext, as
OpenCore injects it, the kernel makes the probes at its load only where its
Info.plist sets OSBundleForceDTraceInit and the guest boots with keepsyms=1,
on an image whose csr-active-config allows dtrace. make DTRACE=1 now writes
the key into the built Info.plist; a plain make leaves it out, so the kext
guests get is unchanged. docs/qemu.md says how to build it and how to check
the probes on a trace image.
2026-11-05 21:59:36 -08:00
Anees Iqbal 9cae8cfe4d 🐎 Keep the decoder's lane and worker threads 10 s
A command queue's lane and each of the decoder's workers (surfaces, closes,
video, ICB creates) ended a thread after 1 s with no job, and made one again
for the next job: a game's queue whose walks needed a second thread every few
seconds, or a worker with a job every 2 s, made and ended a thread each time.
A thread's start may map a 2 MiB stack and its end unmap one, writes of the
process's memory map a vCPU's page fault waits behind (car 12's B1 and
draws-regress: 7 to 10 graphics threads made every 10 s in games, 345 in 30 s
of a WindowServer probe, and a vCPU held 30 ms or more behind one munmap; msi
RTX 5080, measured).

Now a thread waits 10 s for a job before it goes (reims_graphics::keep::KEEP).
The workers, as the lanes have since e58563767, give each job to the thread
that went idle last, where they woke the one idle longest, so every thread
took jobs in turn and none would ever go once kept longer. So the threads a
steady load runs at once take its jobs and stay through its pauses, and those
only a burst made wait at the bottom and go 10 s after it. Car 13's lane LIFO
keeps its effect, 10 s after a thread's last use in place of 1 s: game_6000's
third walk thread still goes where its bursts come less often than every 10 s.
A thread that has waited out its keep goes only where no job waits that no
other thread was woken for, so it does not take a woken thread's job and stay.

Measured on the M3 Max with
lane_and_worker_threads_under_a_game_s_and_a_windowserver_probe_s_wakes (30 s
of each pattern, eight queues' lanes and the surface and close workers): under
a game's wakes the threads made in each 10 s went from 12, 8 and 8 to 5, 1 and
0 (the 5 being the first threads the load makes), and those ended from 10, 8
and 8 to 0, 1 and 0; under the probe's, made from 95, 89 and 100 to 27, 1 and
2, and ended from 88, 83 and 108 to 1, 2 and 2. What is made and ended after
the start are threads a burst ran beyond the steady load's, going 10 s after
it.

The guest sees only timing.

Tests, on the test clock:
a_lane_keeps_its_thread_through_a_steady_load_s_pauses and
a_burst_s_other_threads_go_after_keep_while_one_takes_the_jobs (the lane),
an_idle_thread_ends_after_keep (replacing
an_idle_thread_ends_after_the_idle_time, which slept the real 1 s) and
jobs_after_a_burst_go_to_the_thread_that_went_idle_last (the worker).
lane_and_worker_threads_under_a_game_s_and_a_windowserver_probe_s_wakes is the
measurement, run by hand on macOS, the same before this change and after it.
2026-11-05 21:59:35 -08:00
Anees Iqbal 6bfd19641b 🐎 Serve ring 0's lanes on shared threads kept 10 s
Each of ring 0's lanes (a context's, the presents', a block's) had a thread of
its own, made as a message came to a lane with none and gone once the lane had
had none for 1 s. So every new surface's block made a thread for its first
SURFACE_PAGES, and so did every lane's message after a pause of a second. A
thread's start may map a 2 MiB stack and its end unmap one, writes of the
process's memory map that a vCPU's page fault waits behind: car 12's B1
counted 345 graphics threads made in 30 s of a WindowServer probe, and a vCPU
sat 30 ms or more in a fault while one of them was in munmap of 0x201000
bytes, inside an 81 ms frame (msi RTX 5080; measured).

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

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

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

Tests, on the test clock:
a_steady_load_s_lanes_are_served_by_one_thread_through_its_pauses (30 messages
of three contexts, each after 2 s, on one thread; it goes after 10 s with
none), a_burst_s_other_threads_go_once_they_have_waited_keep (three busy
lanes' threads, then one lane at a time: the two others go 10 s after the
burst, the one serving stays) and
the_device_s_end_ends_the_threads_that_wait_for_a_lane. The tests that named a
lane's thread now check it is one of ring 0's;
an_idle_lane_goes_while_another_context_s_is_busy, whose lane thread no longer
exists, is gone.
ring_0_s_threads_under_a_windowserver_probe_s_and_a_game_s_wakes is the
measurement, run by hand on macOS.
2026-11-05 21:59:35 -08:00
Anees Iqbal 5c7184849e 🐛 Refuse a mesh pipeline's undescribed attachment before Metal
c14-scopes refuses a render pipeline create whose colour, depth or stencil
attachment is a pixel format the device describes none for, before the
platform is asked, since Metal asserts there as it makes the state and an
assertion is no death a refusal scope takes on a Mac host (ledger R099e).
c13-mesh's mesh render pipeline create, which scopes' base lacked, hands the
platform the same raw attachment formats through FullMeshRenderPipelineDesc,
so on car 14 it still reached Metal's assertion. The mesh descriptor's colour
attachments are the same attachment descriptors as a render pipeline's (read
from Metal's headers, not measured on the assertion).

The attachment check now takes the attachments themselves, and the mesh
branch of compile_pipeline runs it before any library wait, as the render
branch does.

What the guest and the host see changes: a mesh render pipeline create of
such an attachment is answered with a refused PIPELINE_REFLECTION of the mesh
kind before the platform is asked, where a Mac host's QEMU ended at Metal's
assertion and the Vulkan platform refused it in the op's scope. A guest's
bundle sends only formats Metal described in the guest, so no boot should see
one.

Car 14's stack: a fix where c14-scopes (e53735e7a) meets c13-mesh.
2026-11-05 21:59:35 -08:00
Anees Iqbal bb8a64a3c3 🐛 Refuse a pixel format Metal asserts at before the platform
On a Mac host an assertion inside Metal ends the process past every refusal
scope, being no death of the library's (ledger R099e). The texture creates,
TEXTURE_VIEW, HEAP_TEXTURE_SIZE_AND_ALIGN and render pipeline creates
forwarded the guest's raw pixel format, at which Metal asserts wherever it
describes no format for it (its setter, every texture creator, the state's
creation; the Vulkan platform imitates these as deaths, which its scope took).

The lane now asks the device's own description (MTLPixelFormatGetInfoForDevice,
for values up to 2047, which were measured; none past it is a format) and
refuses such an op before any platform call: the create stands refused, the
size query is answered refused, and the pipeline's reflection gives the
reason. An attachment of none (0) is no attachment.

What the guest and the host see changes: such an op is refused where a Mac
host's QEMU ended, and before the platform is asked where the Vulkan platform
died at it in the scope. A guest's bundle sends only formats Metal described
in the guest, so no boot should see one.
2026-11-05 21:59:35 -08:00
Anees Iqbal 1268a84f48 🐛 Refuse a death in a draw of the display alone
The window's draw and the host's reads of the display ran in no refusal
scope, so a death in them, the platform refusing an encode of the surface
the guest presented, its format or the scanout's pages among them, ended
QEMU (ledger R099c), though what they draw is the guest's.

Each draw now runs in a scope of its own (ScanoutDraw::scoped): a refused
draw commits nothing, ends the encoder it held open in a scope of its own,
as Metal asserts at an encoder released without its end, and the window
keeps the frame it shows. Its presents are answered at the next refresh, as
for a draw that shows nothing, and the next draw is tried as any is. The
first refusal is a WARN line, later ones debug.

What the guest and the host see changes: where QEMU ended, the window keeps
its last frame, and a refused read answers RVG_ERR_METAL, as the read's doc
says of a draw the platform refuses.
2026-11-05 21:59:35 -08:00
Anees Iqbal c4ae86719e 🐛 Refuse a panic in a guest op instead of ending QEMU
A Rust panic in the graphics lane's code, a bug that guest input can reach,
ended QEMU: the panic hook aborted before anything unwound, and a refusal
scope would have re-raised the unwind anyway (ledger R099g). The lane's rule
is that no guest input ends QEMU (docs/graphics-kext/design.md, "Guest input
the host refuses").

Inside a refusal scope the hook now writes its line and lets the panic
unwind, and the scope answers it as a Refusal of DeathId::Panic, logged at
ERROR as the bug it is: the op is refused as for a death there. Outside every
scope (the paravirt device, the host's calls) a panic aborts as before.
Under the test capture a panic still fails its test, passing every scope, so
the decoder's fuzz and every test's assertion in scoped work still fail.

What the guest and the host see changes: an op whose decode panics is
refused (its create unanswered, its command buffer failed, a completion
handler's work ended alone) where QEMU ended before.
2026-11-05 21:59:35 -08:00
Anees Iqbal 68933bd407 🐛 Refuse a death in a release an unwind runs
A release the lane refuses alone runs in a refusal scope of its own (a
command buffer's carried releases and changes, the lane's refused drops). A
death in one still ended the process when the release ran inside the unwind
of another death toward the op's scope: the trap saw the thread unwinding and
let the death through (ledger R099f). Rust lets a scope opened inside a Drop
catch an unwind there, so a scope entered as the thread unwinds now takes a
death inside it, and the unwind goes on to the op's own scope.

What the host sees changes: such a death while the lane refuses a guest op is
refused and logged, where QEMU ended before. A death in a Drop an unwind runs
outside any scope the Drop opened still ends the process, as Rust allows no
unwind out of it.
2026-11-05 21:59:35 -08:00
Anees Iqbal a43ef6e5e3 🐛 Answer the display's gamma as the AMD Mac's display does
Request 2 of AGDC attribute 0x711 answered one gamma entry naming no plane
and tables of 0 entries. CoreDisplay then found no gamma on plane 0
("Attempting to get capabilities from plane with no gamma", 76 times on car
13's boot) and drew CGDisplayFade into WindowServer's own frames instead of
sending the display pipe's gamma selectors a table each step. The frames
stopped early, so B4's held black read 34% and the fade in stayed at 71%.

The entry is now the first one macOS 26.7.1's AMDRadeonX6000Framebuffer
answers (getFbCapabilityForGamma, read): flags 0x88005, plane 0, table type
0x10, values 0.0 to 1.0, 256 entries. Its fields stay field_xx, each with the
IOPresentment key it fills. The AMD's optional second entry, a configuration
that IOPresentment sends through selector 11, is not answered, so selectors
10 and 11 stay refused.

For the guest: CoreDisplay sees plane gamma and sends fades and calibration
tables through selectors 5 to 7, which the kext already carries to the host.
2026-11-05 21:59:35 -08:00
Anees Iqbal 9741501d34 🆕 Publish the boot framebuffer ReimsGraphics finds at its start
Whether the firmware gave the OS a boot framebuffer (the option ROM's GOP)
was readable only from the loader's "BSD is up" line in the kernel's
message ring, which has wrapped by the time a boot's check can log in, and
the unified log keeps no IOLog line. ReimsGraphics now reads the platform
expert's console info at its start, before IOFramebuffer moves the console
onto it, and publishes it as its RgfxBootFramebuffer property (Answered,
Address, Width, Height, RowBytes, Depth), and logs it once.

What the guest sees: one new property on the framebuffer's registry entry,
and one log line. Nothing else changes.
2026-11-05 21:59:35 -08:00
Anees Iqbal 3353dcfb03 🐎 Give the lanes' walk threads the FIFO thread's scheduler hints
A decode lane's threads were plain std threads and gave the scheduler no
hint, so each one ran with only what it inherited from the thread that
started it. The paravirt FIFO threads ask for a utilization floor of the
CPU's full capacity. On the Core Ultra 9 275HX that is what steers a thread
to its 1024-capacity cores: the kernel runs capacity-aware scheduling there
(cpu_capacity 1024, 991 and 747, hints.rs's measured notes), and the
guest's eight vCPU threads keep about four cores busy during game_6000.
In 5 of the day's 19 game_6000 runs, one walk thread of the game's queue
ran on the efficiency cores alone. One of them was the second of car 13's
base's two threads (L14), where the walks ran 45% of their instructions on
those cores, against 37% for car 11's two (L11).

A walk's speed is the frame rate, as a FIFO thread's is, so each lane
thread now gives itself the FIFO thread's hints as it starts:
- Threads gains give_fifo_hints, which does nothing by default.
- The Linux platform implements it with hint_fifo_thread.
- The decoder's lane budget carries the platform's Threads to its lanes.
The threads keep their names (reims-vgpu.graphics-lane-<id>, which
docs/api.md lists), their policy and their nice. No thread is bound to a
CPU. The queue service thread is left as it was. macOS and the fake
platform give no hint, as for the FIFO thread. The guest sees only timing.

each_thread_gives_itself_the_fifo_hints_before_its_first_job checks, with
a Threads that logs each call, that every thread of a lane hints itself
before it runs its first job.
2026-11-05 21:59:35 -08:00
Anees Iqbal 3a127e823d 📝 Record Macs' mesh pipeline answers and the mesh wire [ci skip]
dgpu-oracle.md Q22 holds oracle_mesh's and base_answers_probe's measurements
on the 5300M, the Intel 630 and the M3 Max, each classified, and what the lane
answers. design.md names FEATURES_LO bit 25 and the mesh create in the wire's
table, and the oracle README lists oracle_mesh.
2026-11-05 21:59:35 -08:00
Anees Iqbal b81ffafdc2 🐎 Hand a lane's job to the thread that went idle last
A lane's idle threads waited on one condvar, and parking_lot's notify_one
wakes the longest waiter, so under steady work the threads took jobs in
turn and none was ever idle for the second after which a thread goes. A
thread made by one burst stayed for good. On car 10's image, game_6000's
queue kept the three threads it had from the game's start. One of them ran
on the host's efficiency cores alone, and the walks took 13.4 ms of CPU a
frame, against 10.4 ms on two threads with car 9's image, at 92.7 against
105.6 fps (msi's RTX 5080 Laptop GPU, diag11 rounds). In 14 runs of the
day, all but car 8's, whose host's lanes differ, fps was 1.06 to 1.24 over
the walk's CPU time a frame.

Each idle thread now waits on a condvar of its own, on a stack. A job wakes
the thread that went idle last, so jobs that come one at a time stay on
one thread and the others go after IDLE. A thread that goes gives back a
budget thread first, so the lane's own thread is the last to go. Growth
is as before: a job that comes while every thread is busy may get another
thread, up to LANE_THREADS, from the budget. A burst that comes after
the threads went grows the lane again as from cold, each new thread
costing one spawn.

This changes which of the lane's threads runs a job, which the C API's
contract leaves free. It is not CPU pinning and not a scheduling hint to
the OS. The guest sees only timing.

a_burst_s_threads_go_while_jobs_come_one_at_a_time fails on the code
before this change (three threads stay) and passes after.
a_burst_after_the_threads_went_grows_the_lane_to_its_limit_again checks
that a burst still grows the lane to LANE_THREADS after the idle-out.
2026-11-05 21:59:35 -08:00
Anees Iqbal ed70015809 🐛 Answer nil where the runtime refuses an object for a gap
On the Vulkan platform, a runtime refusal at a creator for a gap of its own
or of the device's (Unsupported, but by a GPU family or a device Metal
itself refuses it on; NotImplemented; AppleOnly; a compile's Unsupported)
ended the process at the creator, where Metal makes the object. A Flutter
app's BGRA10_XR render pipeline on an RTX 5060 Ti took a macOS guest down
this way (Unsupported { feature: Format, needs: NotImplemented }).

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

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

The kind is placed in every_inexact_kind_is_placed_once, the placement test
of this platform's own kinds, which also checks its code is no runtime
kind's. The accuracy ledger lists it.
2026-11-05 21:59:35 -08:00
Anees Iqbal 8e4c8bc455 🐛 Fault the exec at a function whose IR sits over a page-table hole
A function whose IR the task could not copy was handed to Metal as nil, so a
pipeline naming it ended the host's process inside Metal ("Metal aborts at a
render descriptor with no vertex function"), isolated tasks included. On an
x86-64 macOS 26 guest, Safari's WebGPU renderBundles sample ended QEMU this
way, right after an info indirect (69). The guest commits a buffer's pages
to the task's page table as it prepares a command buffer that lists the
buffer, and every stream that names a pipeline lists its functions' IR
buffers (read from the guest's Metal driver), so IR over a hole is IR the
guest has not mapped yet.

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

The suite's mutgap_svc_function_over_hole locks it; its records follow.
2026-11-05 21:59:34 -08:00
Anees Iqbal 60595867f9 🐎 Answer a buffer behind a service-thread walk before it ends
Since car 12 walks and commits a short buffer that waits for nothing on its
queue's service thread (757de8422), that thread held the queue's claim on its
ring's messages through the walk and the commit, as through any hand-over. A
doorbell rung meanwhile found the claim held and answered nothing, so a
buffer that asked for its CB_SUBMITTED behind such a walk was answered only at
the thread's take after it. On the RTX 5080 laptop host the guest's
commitAndWaitUntilSubmitted of a tiny buffer behind one of fills went from 18
to 32-36 us at the median and from 27-35 to 70-240 us at the 90th percentile.

The device now hands the host its claim with each command buffer (QueueClaim).
The host lets it go once the buffer is begun and before a walk on the service
thread, and letting it go offers the queue's next message to the host there,
as a doorbell's thread does. The device takes the claim back after the
hand-over. The answer at a doorbell, or at that offer, still needs everything
it needed before.

For the guest: a buffer that asks for its CB_SUBMITTED behind a short buffer
the service thread walks gets it inside its doorbell write, where it is rung
for during the walk, or before the walk starts, where it was published before
the service thread took the buffer before it. Before, it came after that
walk and its commit. Its CB_SUBMITTED may now come before the earlier
buffer's CB_SCHEDULED, as it already could behind a buffer walked on a lane.
Nothing changes for the host: the raise comes on the vCPU's thread inside the
write, or on the queue's service thread, as other answers already do.

New test:
a_buffer_that_asks_behind_a_walk_on_its_service_thread_is_answered_before_the_walk_ends.

Car 13's stack: resolved graphics.rs against c13-decoder-order
(Host::queue_made beside this commit's command_buffer with its QueueClaim) and
c13-tooling (FixedScreen no longer imported here): kept both hosts' calls, and
QueueClaim among the imports.
2026-11-05 21:59:34 -08:00
Anees Iqbal 417bddfb3b 🔥 Refuse a Managed create the platform has no GPU copy for
Where the platform refused a Managed buffer's or texture's GPU copy on a GPU
of its own memory, the object was made one copy over its block instead, the GPU
reading and writing the guest's memory in place. That worked around the Vulkan
platform's runtime refusing past a full device-local heap, where Metal makes
Managed resources past the GPU's memory (measured on the AMD 5300M: 12 GiB of
them on its 4 GiB). The metal2vulkan pin, 52969c03d7, places them in system
memory past a full device-local heap itself, so the workaround goes, as ours do
at the pin that carries the runtime's fix.

A behaviour change at exhaustion only. BUFFER_OVER_HOST_MEMORY of a Managed
buffer, BUFFER_MANAGED_AT_OFFSET and MANAGED_TEXTURE_CREATE are now refused
(nil in the guest) where the platform refuses the GPU's copy, where before
they were made one copy. Wherever the platform makes the GPU's copy, and on a
GPU that shares the CPU's memory, the creates are as before. The three tests
of the one-copy form become one of the refusal.
2026-11-05 21:59:34 -08:00
Anees Iqbal d8aa8f1b5d 📝 Say why fbt lists no probes in our kext, and what tracing needs [ci skip]
dtrace -l -P fbt -m com.steelbrain.ReimsGraphics lists nothing, and the
kext's build is not why: as built it keeps all 398 __text symbols, 324 of them
global, has its LC_UUID, and 384 of its 392 functions start with the push
%rbp; mov %rsp,%rbp prologue fbt patches. The guest's kernel decides it (read
from xnu's source): with SIP restricting dtrace no module gets fbt probes, and
a Boot-collection kext, where OpenCore injects ours, gets them only from
symbols the dtrace command finds for its UUID, unless OSBundleForceDTraceInit
asks for them at load, which the kernel honours there only under keepsyms=1.
The note says what a tracing image sets; a boot measures whether it works.
2026-11-05 21:59:34 -08:00
Anees Iqbal f15b1b3b6d 🔊 Warn at realize where BAR 2 gets no address in macOS
reims-graphics-pci's BAR 2 (1 GiB) needs -machine max-ram-below-4g=1G on a
PC machine: macOS lays 64-bit BARs out below 4 GiB, and with q35's default
2 GiB of RAM there the BAR gets no address and the kext finds no region,
with nothing said on the host. The docs left the option to whoever adds the
device; reims-ctl's VMs still have no reims-graphics-pci, so nothing there
needs it yet.

For the host: QEMU (vendor/qemu 22ae1fd1) now warns at the device's realize,
naming the option, where a PC machine has RAM at 1 GiB, so a host that adds
the device without the option is told. The guest sees nothing new: the
device is realized as before.
2026-11-05 21:59:34 -08:00
Anees Iqbal a562b48c14 🆕 Read the graphics display back, and show it in QEMU's console
reims-graphics-pci's QEMU console carried input only, so QMP's screendump
was always an empty 640x480 image: the login-clock, desktop and lane-gate
checks had no way to see the guest's frame once WindowServer presents
IOSurfaces, which live in the host's device caches, not in the scanout.

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

For the guest: nothing. The read answers no present (the window's draw does,
through ScanoutDraw::encode, now over encode_shown), tells the guest no
mode, and holds a presented surface's block only while its draw reads it,
as the window's draw does. A device with no window keeps the guest's
scanout in a screen of its own for the reads, offering the same 1920 x 1080
at 60 Hz as before.
2026-11-05 21:59:34 -08:00
Anees Iqbal 320b9e5314 🐛 Answer pipelines' reflection as an x86 Mac's Metal
Every pipeline creator answered a nil reflection, whatever its options. An
app that asks for MTLPipelineOptionBindingInfo or BufferTypeInfo to find its
buffers' indices, sizes or struct layouts found none.

What changes for the guest: a render, mesh or compute pipeline made with
either option now answers Metal's own reflection (its private reflection
classes), in the synchronous creators and in the completion handlers alike.
It is built in the guest from the AIR of the pipeline's functions and its
vertex or stage input descriptor: each stage's bindings, built-in arguments,
types and struct members, and the private postVertexDumpStride. Options of
neither still answer nil. A pipeline the bundle cannot answer exactly (an
index function constants compute, a kind no x86 Mac was measured for, a
function of no library of ours) still answers nil, logged once per reason.
An argument read only in code its function constants remove is answered
used, where Metal answers it unused; Intel's postVertexDumpStride is 4 less
than ours, which is AMD's. Nothing changes on the wire.

The values are an x86 Mac's (macOS 26.7.1, AMD Radeon Pro 5300M and Intel
UHD Graphics 630), measured with the oracle_reflection probe and recorded in
docs/graphics-kext/dgpu-oracle.md, Q20. tools/pipeline_reflection_check.mm
makes the same pipelines on a device and compares its reflection with ours,
getter by getter and instance variable by instance variable: over 80 cases it
finds no difference on the AMD GPU, and on the Intel GPU only that stride.
The shell test checks ours over the probe's library. RgfxMeshPipelineReflectionOf is the
mesh creators' to answer once they make mesh pipelines.

Car 13's stack: resolved docs/graphics-kext/dgpu-oracle.md, where c13-contract
added Q20 (textures over an IOSurface) first: this commit's section is Q21, and
the probe list names oracle_surftex and oracle_reflection;
guest/bundle/Makefile's shell tests take both RGFX_AIR_REFLECTED
(c13-wire-gaps) and RGFX_ORACLE_REFLECTION.
2026-11-05 21:59:34 -08:00
Anees Iqbal 9a9077389c 🐛 End the process at every two-plane texture over a surface
The bundle made two-plane Y'CbCr textures over a surface as the M3 Max does
(dgpu-oracle.md Q13, read as class 2). The lane imitates the x86 dGPU Macs,
and both end the process there: oracle_surftex's third round measured
"MTLTextureDescriptor has invalid pixelFormat (N)." on the AMD 5300M and the
Intel 630 under macOS 26.7.1 at every two-plane Y'CbCr format (500, 502, 503,
505 to 510, 520, 522, 523, 525 to 530, 540 to 545) and at the extended-range
RGB10A8_2P_XR10 and its sRGB twin (550, 551), over either plane of a 420v
surface, a one-plane surface and a surface without planes. Where both agree,
their answer is the lane's contract; the M3, which makes them all, is outside
its envelope. Q13 records the reversal.

What changes for the guest: newTextureWithDescriptor:iosurface:plane: ends
the process at a texture of any of these formats, at any size, with the x86
Macs' words, sending the host nothing. The odd-extent render target rule
folds into it. No code of the bundle makes such a texture: the video decoder
lands pictures through R8, RG8, R16 and RG16 textures over the planes. The
one-plane 4:2:2 formats (GBGR422, BGRG422) are made as before.

Test: test_invalid_surface_textures_end_the_process holds a death per format
over the luma plane, 500 over the chroma plane and over a surface without
planes, and passes for the planes' own formats and the 4:2:2 ones; it fails
at surface-ycbcr-flat with the rule stubbed out.
2026-11-05 21:59:34 -08:00
Anees Iqbal 61b40c6a9d 🐛 Map each VBLANK by the host clock's offset, not its delivery
What the guest sees: where the device offers HOST_TIME, the kext takes it and
reads the host's clock at each VBLANK, HOST_TIME_LO between two reads of
mach_absolute_time, and maps each refresh's stamp by the reading whose round
trip bounds the clocks' offset closest, that bound widening by 50 ppm of the
reading's age so newer readings take over and a drift is followed. The display
link's vsync times and the display pipe's presented times then follow the
host's exact grid, however late each VBLANK's interrupt is taken. It costs
three BAR 0 reads a refresh.

Why: the offset inferred from delivery (the least receipt - stamp, rising 2 us
a refresh) moves with the delivery. A quicker delivery pulls it down at once
and slower ones let it creep back, so under Safari's 1080p60 playback on car 10
(msi) the display link's times sat 38.6 to 75.6 us rms off a straight line,
157 us at most, against 0 idle. A host without the bit keeps that estimator.

Car 13's stack (rebased from 6f8118d14 onto car 13's 08385e63e): resolved
ReimsGraphics.cpp/.hpp (hostTime beside c13-display's displayColorTaken, set
and cleared at the same places), RgfxFeatures.hpp's carried bits,
features_test.cpp and design.md against bits 21 to 24: HOST_TIME, bit 20,
beside them in bit order. The car changed neither the VBLANK handler nor
RgfxVblankClock since 6f8118d14.
2026-11-05 21:59:34 -08:00
Anees Iqbal abcc57b6a0 🆕 Let the guest read the clock its VBLANKs are stamped on
What the guest sees: FEATURES_LO offers bit 20, HOST_TIME, on every host.
Where the guest's driver takes it, BAR 0's HOST_TIME_LO (0x038) and
HOST_TIME_HI (0x03c) read the host's monotonic clock in nanoseconds, the clock
each VBLANK's host_time_ns is on. Nothing is latched: the guest reads HI, LO
and HI again. They read 0 where the bit is not taken, as before, and a guest
that leaves the bit sees the device as it was.

Why: the kext maps each VBLANK's stamp into its own clock by an offset it
infers from the VBLANKs' delivery, and that offset moves with the delivery.
Under Safari's 1080p60 playback on car 10 (msi), the guest's display link
times sat 38.6 to 75.6 us rms off a straight line, against 0 idle, though the
host's grid is exact. A read of the host's clock between two of the guest's
own bounds the offset by the read's round trip, whatever the delivery takes.

Car 13's stack (rebased from 6f8118d14 onto car 13's 08385e63e): resolved the
wire header, wire.rs, device.rs, graphics.rs, graphics/tests.rs and design.md
against bits 21 to 24 (MANAGED_TEXTURE_SLABS, MANAGED_BUFFER_SLABS,
SMALL_ID_CHUNKS, DISPLAY_COLOR): each list names HOST_TIME, bit 20, beside them
in bit order, and graphics.rs's comment says both. KNOWN_FEATURES is bits 0 to
8 and 11 to 24.
2026-11-05 21:59:34 -08:00
Anees Iqbal eaa39e35eb 📝 Say what a Managed texture with no CPU copy is now [ci skip]
The design listed depth, stencil, PVRTC and three-component formats as the
Managed textures that keep no CPU copy. A depth or stencil one in Managed
storage ends the process before the bundle makes it, as on the x86 oracles
(882198139), and Metal has no three-component pixel format. What is left, a
PVRTC one, is the platform's texture alone, one copy on any GPU, reached by
the CPU through the staging blit a Shared texture's calls wait for, which sees
the GPU's writes with no synchronize: inside Q2's envelope, as the Intel 630's
and the M3's Managed textures behave.
2026-11-05 21:59:34 -08:00
Anees Iqbal 2cfd44fb18 🐎 Lay a one-level Managed 2D array over its CPU copy
On a GPU that shares the CPU's memory the host laid a Managed texture over
its CPU copy only where it was a one-level 2D texture: every 2D array kept two
copies there, the guest's CPU copy and the platform's own texture, so it took
its size twice in memory, each replaceRegion: was copied again on the host,
and the guest's getBytes: of it waited for a device copy. The platform makes a
one-level 2D array over a buffer too, by the linear SPI, which lays each slice
at its rows' bytes rounded up to 128 (measured on the M3 Max; the Vulkan
platform's runtime alike, array_over_host_memory_is_metals), and a CPU copy's
rows are multiples of 256 bytes, so its slices lie where the copy's layout
puts them.

For the host: on unified memory MANAGED_TEXTURE_CREATE of a one-level 2D
array of a linear format is newLinearTextureWithDescriptor: over the CPU
copy's buffer, its rows and slices the layout's, in place of a
newTextureWithDescriptor: beside it; TEXTURE_REPLACE_REGION and
synchronizeTexture: of it copy nothing. A texture of the one-copy shape whose
texture over its buffer the platform refuses is logged once. On a GPU of its
own memory nothing changes but where it has no memory for the GPU's copy,
where such an array now takes the one-copy form too.

For the guest: where the device answers hasUnifiedMemory yes, getBytes: of such
an array reads its CPU copy, as a one-level 2D texture's does, with no device
copy (rgfxManagedLiesOverCopy). A mipmapped texture, a cube, a 3D texture and a
block-compressed one stay two copies: no texture over a buffer has their shape,
and without the CPU copy an upload would be a staging blit the call waits for,
340 to 420 us a call where a Managed one's is 2 to 4 (dgpu-oracle.md Q17).

An older bundle on this host reads such an array through a device copy, which
reads the one copy: correct. This bundle on an older host would read a CPU
copy the host keeps apart: the two ship together.

Car 13's stack: resolved a comment in shell_tests.mm over
test_managed_texture_reads_on_unified_memory against c13-answers (16c2a86ad):
kept this commit's 2D-array wording and c13-answers' virtualAddress sentence.
2026-11-05 21:59:34 -08:00
Anees Iqbal dba9e9ce00 🐛 Give a queue its process's slot where a surface's record is full
Each surface's shared block holds four writer slots and four reader slots,
shared by every process's queues. A queue that found none free left its
access unnamed (logged once): a later write of another queue did not wait
for its reads, nor a later read or a present for its writes.

Where a record has no slot left for a queue, the bundle now gives it a slot
of its own process's that names a buffer of another of its queues which the
buffer runs after on the GPU, its post's SURFACE_ORDER having named that
buffer at the slot's seqno or later: whatever names the slot from then on
runs after both, as it ran after each. A read that finds no reader slot is
named among the writers instead (its queue's writer slot, a free one, or
one taken so), which every later buffer that uses the surface names. Only a
slot of this process's is written, and one raised past what the post named
is kept.

What the guest observes: an access to a surface whose record is full of
slots of this process's other queues is ordered against later accesses of
other queues as one with a slot is, where it was not ordered before; a read
named among the writers is also waited for by a later read of another queue
and by a present of the surface, which is later than a Mac would and never
sooner. An access whose records hold every slot for other processes' queues
is still not named.

Tests: test_iosurface_full_records_take_this_process_s_slots fails before;
test_iosurface_slots_free_at_completion's fifth queue's read is now named
among the writers until it finishes.
2026-11-05 21:59:34 -08:00
Anees Iqbal 0ac7209ebd 🐛 Set a timeline on the CPU only after its queue's earlier signals
Where a queue's buffer is not carried out and its queue makes no command
buffer for its stand-in, nor for a signal of its own (the platform out of
memory), the host set the queue's surface timeline to the buffer's seqno on
the CPU at once. A buffer of another queue that waited on the GPU for that
seqno then went on while the queue's earlier buffers, which named the same
surfaces, could still be running.

The host now notes, per queue, the highest seqno a committed command buffer
signals (a buffer whose walk faulted after its signal was encoded leaves it
as it was), and the CPU set waits first, with no lock held, for the timeline
to reach it, as a command buffer's signal would come after them. A reset of
the device ends the wait, as it ends the host's other waits for another
queue's buffers. A queue's destroy or close that has to set on the CPU waits
the same way.

What the guest observes, only where the platform makes no command buffer: a
buffer of another queue that runs after such a buffer now runs after the
queue's earlier work on the surfaces they share, not alongside it.

Test: a_cpu_set_for_a_buffer_not_carried_out_waits_for_its_queue_s_earlier_work
fails before. a_buffer_not_carried_out_still_signals finishes the queue's
earlier signals before its CPU set, which now waits for them.

Car 13's stack: resolved surface_order.rs's Release::signal, where
c13-decode-stalls (5e922707f) raises the done mark from the completion-seen
handler: kept that handler and took this commit's Arc clone of the marks for
it, and its committed mark after the commit. The CPU set's wait also ends on
the event's GPU-set value, so it still comes only after the queue's earlier
signals.
2026-11-05 21:59:34 -08:00
Anees Iqbal 39808c3a12 🐛 Know a queue in the surface order from its create's answer
The device answers a QUEUE_CREATE on its context's lane as soon as it has
made the queue's rings and started its service thread, and that thread then
hands the host the create, at which the host first learnt of the queue. In
between, a buffer of another queue whose SURFACE_ORDER named one of the new
queue's buffers found the queue unknown, counted it stale and waited for
nothing; a buffer of another queue of the process whose COMMIT_ORDER named
it was committed without waiting for it.

The device now tells the host of the queue before it answers the create
(Host::queue_made), and the host registers there what the queue's ring
publishes, for the surface order, the commit order and the presents, where
the service thread's create did it before.

What the guest observes: a buffer that names a buffer of a queue created
just before, while the host has yet to make that queue's handle, now runs
on the GPU after it (and, in its process, is committed after it), as it does
once the handle is made; it ran unordered before. Nothing else changes.

Tests: the_host_is_told_of_a_queue_before_its_create_is_answered (device)
and a_queue_s_buffers_are_waited_for_before_its_handle_is_made (host, with
the queue's service thread held before it hands on the create), each failing
before.
2026-11-05 21:59:34 -08:00
Anees Iqbal b5681a6e33 📝 Say why read-only no-copy memory never lies in place [ci skip]
Every Mac measured makes a no-copy buffer over read-only memory and drops
its GPU writes, a file under it included, where the host's buffer over a
pages block takes them: in place they would reach the process's read-only
pages. The shadow never writes back to read-only memory, so it drops them
as Metal does. The oracle README names oracle_bundle's new cases.
2026-11-05 21:59:34 -08:00
Anees Iqbal 814c527080 🐛 End the linear alignment query at every format x86 Metal ends it
minimumLinearTextureAlignmentForPixelFormat: answered 256 for every raw format
but the 105 of the SDK's that 3274b39d1 ended the process at. Both x86 Macs'
Metal (AMD 5300M and Intel 630, macOS 26.7.1, no validation layer; oracle_bundle
linalign over every raw value from 0 to 799 and 1000, 1023, 4096 and 65535)
answer 256 for 64 values alike, the SDK's 46 and 18 it has no name for (84, 85,
300 to 304, 313 to 315, 323 to 325, 556, 586, 587, 628, 629), and end the
process at all the others, with the compressed or depth words for those
formats and MTLPixelFormatInvalid for the rest.

What the guest sees now: the query answers 256 for those 64 values only, and
ends the process with Metal's words at every other: MTLPixelFormatInvalid (0),
the Y'CbCr formats, and values no format has among them, which answered 256
before. The bundle's own callers still ask the internal query, which ends
nothing.

Car 13's stack: resolved RgfxTexture.mm's rgfxEndAtUnalignableLinearFormat,
where c13-contract had moved the same lacked-format list into rgfxDeviceLacks
(kept for its other use): took this commit's answered-format list, which ends
at every lacked format too.
2026-11-05 21:59:33 -08:00
Anees Iqbal e828db91bc 🐎 Lay no-copy Managed buffers over the app's pages in place
A no-copy Managed buffer over writable app memory took a shadow: a range of
a slab as its CPU copy, synced with the app's memory at every commit that used
it and written back at every completion that might write it, and on a discrete
host a third copy, the platform's own Managed buffer, beside it.

Where the region has pages blocks it now lies over the app's own pages, as a
writable Shared one has since 2c09b2196: a BUFFER_OVER_PAGES whose buffer the
host makes Shared, so the memory is one copy on every host, as the Intel 630's
no-copy Managed buffer is (dgpu-oracle.md Q3; the AMD 5300M keeps two, and
Metal's contract for the mode allows either). The buffer still answers the
Managed options it was asked. Its didModifyRange:, and a blit's
synchronizeResource: or synchronizeTexture: of it or of a texture over it,
send the host nothing, as one copy has nothing to bring over.

What the guest sees: a GPU write to such a buffer shows in the app's memory as
the GPU makes it, not at its command buffer's completion, and a CPU write is
seen by the GPU's next read with no didModifyRange:, as on the Intel 630.
Read-only memory, and memory the kext or host makes no pages block of, keep
the shadow.
2026-11-05 21:59:33 -08:00
Anees Iqbal b4c0e4d67d 📝 Record what Metal does with textures over an IOSurface [ci skip]
Q20 holds oracle_surftex's answers on the AMD 5300M, the Intel 630 and the
M3 Max: the three steps where Metal ends the process, what a plane of a planar
surface takes, where the M3 answers nil, and which of the textures the x86
Macs make the host still refuses.
2026-11-05 21:59:33 -08:00
Anees Iqbal bd998e7ef8 🐛 Drop an ICB command's draws where it names a refused object
An indirect command buffer's CPU encode (an ICB_WRITE record or an ICB_SLOTS
field) that named an object whose posted create the host refused was skipped
alone, so the command kept its earlier binding or pipeline and went on drawing
or dispatching with it, where Metal would have drawn with the object the guest
named. The encoders already drop their draws and dispatches while a slot holds
such an object (94b7cb0b6); indirect command buffers did not.

What changes for the guest: such an encode is dropped and its command reset,
so it draws or dispatches nothing, and the command's later draws and
dispatches are dropped while its other encodes are carried out, until the
guest resets the command (a reset record or slot, a reset of a range, or a
blit's resetCommandsInBuffer:) or copies another command over it; a command
copied from a dropped one is dropped. The marks live with the indirect command
buffer's entry and cost one load a record where nothing was refused. A
command the GPU encodes is not seen by the host, as before.

Tests: an_encode_naming_a_refused_object_drops_its_draws_until_a_reset (the
records, each reset that ends a drop, a blit's reset and copy, a compute
command) and a_slot_naming_a_refused_object_drops_its_draw_until_a_reset (the
slots) fail at the base, where the draw after the refused binding is carried
out and no reset is.
2026-11-05 21:59:33 -08:00