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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.