An arm64 guest's VideoToolbox paravirtual decoders now take HEVC's range
extensions, 4:2:0, 4:2:2 and 4:4:4 at 8, 10 and 12 bits, wherever the host
arm's own query lists a decoder of the stream. Until now they took 4:4:4 at
8 bits alone and refused the rest at the session's start.
What changes for the guest:
- dsta and dsts take a range extensions stream where VA-API lists the
decoder of its profile with the render targets and surfaces it needs.
iHD on an Iris Xe lists all six profiles, but its Main 12 has P012 and
P016 surfaces alone, so 4:2:0 at 8 and 10 bits stays refused there.
- They also take it where NVDEC's caps list its chroma format, depth and
size: 4:2:0 and 4:4:4 on an RTX 3090.
- Where nothing lists the stream, the refusal stays as before and names
the stream and the arm's reason. radeonsi lists no decoder of them.
- Each picture lands in the format the guest's own software decoder gives
the stream, which Dpba names: 420v/x420/tv20, 422v/x422/tv22,
444v/x444/tv44 and their full-range forms.
- NVDEC's 4:2:2 is not built: the 3090 lists none, and those streams stay
refused there.
- The x86-64 caps are unchanged.
The codec takes the range extensions at 4:2:0, 4:2:2 and 4:4:4 and at 8,
10 and 12 bits, with their tools. It still refuses extended precision and
high precision weighted prediction offsets past 8 bits. Its CPU tests
decode streams of each chroma format and depth, and an SPS cut at every
length or with any bit flipped is refused or decoded whole, with no panic.
VA-API decodes on the stream's range extensions profile into P012, YUY2,
Y210, Y212, XYUV, Y410 or Y412 surfaces. The CPU splits the packed ones
into the guest's two planes; the GPU still splits XYUV where its import
check passed. NVDEC's 4:2:0 lands as Main 10's, and the CPU interleaves
its 10 and 12-bit 4:4:4 planes. Each picture the CPU converts is counted
as video-pictures-cpu-converted.
CoreVideo has no format with the layout of Y210, Y212, Y410 or Y412, and
the Mac's decoders answer 422v, not yuvs, for 4:2:2 at 8 bits, so the
conversions stay. Under TCG on the Iris Xe, hardware sessions took 0.36
to 0.66 s for 30 pictures at 1080p of every listed profile, against 1.88
to 5.32 s for the guest's software decode (docs/video/devices.md). The
conformance suite decodes x265's streams of every listed profile.
The library wrote its counts line only at a device's reset and at the
process's exit, so a reims-ctl report made while the VM ran had none of
it in its qemu.log.
A host now asks for them with rvg_write_counts (the Rust API's
GraphicsDevice::write_counts), which writes the line before it returns,
where it changed since it was last written. QEMU's reims-graphics-pci
calls it when its new x-write-counts property is set to true over QMP
(vendor/qemu b057a987), and reims-ctl report sets it on a running VM
before it zips the logs, with a line in state.txt saying whether the
library wrote them. A trigger rather than a timer: a timer would touch
only the library, but write a line a minute into every log and still be
up to a minute old at the report; QEMU forwards no signal the library
could take, and Windows has none.
For the host: a new C API function and QOM property; QEMU's log gets the
counts line at each ask. api.md, conventions.md, qemu.md and the report's
help say so.
On Windows a picture whose cache's planes lie over Direct3D 11 textures lands
by a draw from the texture VA-API decoded it into. Where that draw fails, the
textures are cleared to the zeros they owe and the CPU's copy lands the
picture in them instead: read back, staged, and copied into the planes'
images. Nothing counted that: on Windows a plane in such a surface never
reaches the GPU copier, so rt-video-gpu-copy-declined counts only pictures
with no surface at all, and a failed draw showed only as the landing's info
line, the first of each kind.
Each picture not drawn is now counted as video-pictures-undrawn, so a
report's degradation counts say how many pictures took the CPU's copy after a
failed draw. The guest sees nothing new.
The bundle sends a render pipeline create with no vertex function, or a
compute create with no kernel (library 0, no name), where the device refused
the library the program's functions were to come from: the library is nil,
and so is each function made from it. The device counted each such create as
decode-bad-reference, the guest protocol error, so a boot's counts line read
as dropped work (25 a refused library in Steam's lab boots). The create names
no library id, so the device counts what it sees: a create naming no vertex
function or kernel, under decode-no-function, a DecodeError of its own.
The refused create's warn line now names the kind of create (render, mesh
render, compute), and its log kind is the why and that kind together, so the
first of each pair is written at warn and the rest are folded under a label
that names both on the repeated-lines line; before, every create of one why
folded into one count with only the first one's type.
What changes for the host's log: the counts line carries decode-no-function
where it carried decode-bad-reference for these creates, and the refused
pipeline create lines name their kind. The guest sees no change: each create
is answered refused as before. No test held the old count; the new test
holds the new one and the lines.
A diagnostic only: nothing the guest or the host observes changes. On a platform
that places pins only in its blocks (metal2vulkan-runtime), an OBJECT_DESTROY
of an object made at the platform's own address, a pin it did not keep or none,
is counted under destroys-at-rt-address-in-flight-<kind> where a command buffer
of the object's context is posted and not yet committed, or begun and not yet
complete. The count is an upper bound on the handles let go of at an address a
running command buffer may still use, so a boot's counts line tells whether
that stale-address lead applies to this class of object at all.
It costs no new lock and nothing per command buffer or per create. The object's
unkept::Live records at its make whether it lies at the platform's address,
from the pin and address made already compared there; the destroy reads it in
the table lookup it already makes, and the context's queues posted and not
committed it already reads. Only for such an object does it take the context's
drain lock, alone, to read the holds the drain keeps.
NVDEC's 4:4:4 pictures were read back to the host and interleaved by the
CPU into the guest's surface. Now, where CUDA imports the device's
exportable buffers, CUDA copies each plane within the GPU into a scratch of
the decoder's. videoGather444 then writes them into a Shared buffer over
the surface's pages, and the pass is waited for. This is the route NVDEC's
4:2:0 pictures already take, which writes the surface in place.
The guest's surface holds the same bytes as before. Each picture written
this way is counted as video-pictures-gpu-gathered, and a session logs how
many at its end. A refusal before anything is written (no exportable
scratch, a plane off a 32-bit word, a plane past the surface or the
scratch, a failed pass) falls back to the CPU's interleave, and its reason
is logged once per decoder.
first_use_waits_met sums the waits of every compute variant make rt keeps,
whoever started the make. Since rt's finish_pipeline, a compute state's main
pipeline is made by its finish, and a dispatch that needs it first waits for
that make in flight, or makes it itself: rt counts those waits as unfinished
waits, apart from the variants', yet they are variant makes, so the slow
answers count them too. The count is right for its code, the compute
dispatches' first-use waits; the docs said they were the variants' alone.
Say what it counts now, here and in conventions.md: the variants' waits and
the compute share of rt-first-use-unfinished-waits, a finish's make among
them, and that a draw's waits for a render state's main pipeline are not.
The rt platform's state finishes, ComputePipeline::finish and
RenderPipeline::finish, now call rt's finish_pipeline: the driver's create of
the state's main pipelines, which rt's creators leave out since 951285e7a7, runs
on the device's compile thread after the create's reply and before its store.
For the guest: a pipeline create's reply no longer waits for the driver's
create of its main pipeline, as it did before the pin move; the store, and the
command buffers, indirect command buffer writes and function handle and table
creates that name the pipeline, still do, so its first draw or dispatch no
longer makes that pipeline on its queue's lane, as it did with the pin move
alone. Every answer the reply carries is made before the driver's create, so
nothing the guest reads changes beside timing. A finish rt fails is the create's
late failure, pipeline-finish-failed, as before: the pipeline is stored as made,
and a draw or dispatch that needs it makes it again, refused at its encode where
that make fails too; the accuracy ledger lists it.
A create whose destroy, context close or reset came before its finish began is
no longer finished: its pipeline is never stored, so the driver's create would
be wasted. A finish already running still ends. A keyed create skipped so keeps
its answer as its make answered it.
The counts line gains rt's new metrics: rt-finished-pipelines and
rt-finished-pipeline-ns, rt-first-use-unfinished-waits and
rt-first-use-unfinished-wait-ns, and rt-first-use-unfinished-wait-max-ns at its
highest over the process's devices. The ten-second rt summary says the finishes
and the unfinished waits, and the trace's rtmetrics event ends with the five
values. rt's failed_finishes is not folded: the device's pipeline-finish-failed
counts each failure at the platform's seam, where every platform's finish
answers (a raise or death in the platform's refusal scope too, which rt never
sees) and where the failure's guest-visible effect is decided, so the line
carries each failure once.
docs/conventions.md's stall rule names the reply ahead of the driver's create as
its second exception, and compile.rs's Order, the design doc and the rt
platform's pipeline docs say what the finish now does.
The planner reads the pipeline cache's effect on a boot by what the guest
waited, and nothing on the counts line said what the guest waited for a
pipeline create: rt-pipeline-creation-ns sums concurrent makes,
slow-answer-over-make is about rt's pool memory makes, and
rt-first-use-variant-wait* is the compute dispatches' variant waits.
The counts line now carries, for render, mesh render and compute creates
together, each create's wait from the host's take of it off ring 0 to its
reply's post: pipeline-create-replies, pipeline-create-reply-ns (summed),
pipeline-create-reply-max-ns (the longest),
pipeline-create-replies-over-16ms (16.7 ms or more, SLOW_ANSWER_NS), and
pipeline-create-waiting-ns, the span during which at least one create
waited: their union, so waits at once count once. A refused create, and one
destroyed or closed before its reply, which is still posted, is counted at
its reply like every other; one let go of with no reply posted ends its
wait there, in the span but not among the replies.
A diagnostic: nothing changes for the guest. Each create costs two reads of
the platform's monotonic clock under a lock of the device's own.
A GL app's variants were lowered again in each of its runs, on the app's own
thread: the GL code generator, our text round trip and the metallib's
writing. Heaven on 26.7.2 (an RTX 3090) lowers 411 variants in each run, the
second as many as the first, 2 ms at the median and up to 37 ms, 2.1 s in
all, and a scene change waits on the lowerings of its variants. Metal's
compiler service keeps what it compiled for an app in the app's cache
directory; the device lowers GL variants in the app's process, so the bundle
keeps them itself, beside Metal's.
The store (src/RgfxGLStore.hpp) keeps each lowered variant and stage-in
kernel in a file of its own under the user's cache directory, the app's
bundle identifier (or its program name) and ai.aneesiqbal.reims-graphics/gl:
the path Metal's own cache takes (com.apple.metal there), which a sandboxed
app can write too, measured in a 26.7.2 guest. The key holds everything the
lowering reads: the variant's IR and plugin data, its bitcode and function
types, and the identity of the bundle, the generator, the system's LLVM, the
OS build, the builtins file and the generator's environment variables. An
entry carries its key and the SHA-256 of its bytes, which a read checks; an
entry that does not read whole is removed and the variant lowered again.
Writes are atomic (a file of their own, renamed into place). Past 64 MiB an
app's least recently used entries go first: Heaven's 298 variants and 34
stage-in kernels take 9.5 MB, so the cap keeps an app's variants at several
settings. Any failure leaves the variant to the lowering, as before, and the
first is logged once per process.
A run asks for some variants more than once: Heaven asks for 75 of its 298
again, 113 lowerings and 490 ms a run, and for 8 of its 34 stage-in kernels
again. A memo (RgfxGLMemo, 32 MiB) answers a variant the process asks for
again with the bytes it answered first, with or without a store.
What the guest reads does not change: a hit answers the bytes the lowering
answered (tests/gl_store_tests.mm, a hit and a memo's answer equal to the
lowering's byte for byte).
tests/bundle_files_check.sh's rule changes on purpose: the bundle now writes
a second kind of file of the app's own, in the app's own cache directory,
through Foundation as its binary archive is, and still imports none of
open(2)'s family.
At the pin, rt's AllocationInfo states when a make of its pool began and how
long it took (make_start, make_nanos), so the device's BlockMappings keeps both
for each of the last 16 makes instead of reading the clock as rt tells it of
one. A slow answer's line now gives each make that ran during the answer by its
start and end after the ask, a start before the ask negative, with its ms, its
allocation's MiB and storage mode and its thread, for example:
over 2 makes of rt's pool that ran during it, the last ending 5.000 ms before
the answer (each from its start to its end after the ask, a start before it
negative: -4.000 to 10.000 ms, 14.000 ms, a Private 16.000 MiB on
reims-vgpu.test-maker; 12.000 to 15.000 ms, 3.000 ms, a Shared 32.000 MiB on
reims-vgpu.test-maker)
A make is among an answer's where it ran during it, from its start to its end:
one that began before the ask counts, and how much of the answer each make
covered can now be read. rt tells of a make only once it ended, so one still
running when the answer is given is still not among them. The docs of overlap,
slow_answers and the device's BlockMappings say so, and the cost paragraph drops
the clock read a make took.
Diagnostics only: nothing changes for the guest or for the C API's host. The
counts' codes are unchanged; slow-answer-over-make counts the answers a make ran
during.
A ring-0 answer that reaches the guest a frame or more after the device read
its command stalls whatever the guest's frameworks wait on, and the makerstall
walks tied some of those to rt's 16 MiB pool makes only with a diag build.
Every boot and walk now carries it:
- reims-vgpu-graphics times each answer given through a CompleteAnswer,
PoolAnswer or PrivateAnswer (a clock read at its make and one at its post;
none for PRESENT_SURFACE, whose answer waits for the display's refresh) and
tells the host of one of 16.7 ms or more (Host::answer_slow).
- The rt platform keeps when each of rt's last 16 pool makes ended
(rt_platform::overlap, from the device's BlockMappings), and folds rt's
first-use variant waits of compute dispatches onto the counts line:
rt-first-use-variant-waits, -wait-ns and -wait-max-ns.
- reims-vgpu counts a slow answer during which a make ended,
slow-answer-over-make with slow-answer-over-make-max-ns, logs the first of
each command type with its makes and, for a BLOCK_RELEASE or a POOL_GIVE,
the split of its waits, and counts the first-use waits that met any slow
answer, slow-answer-first-use-waits.
A diagnostic: nothing the guest sees changes.
On the rt platform on Linux a decode's picture lands in its output's device
cache by the driver's video processing writing the cache in place, and where
the driver's import refuses the cache's layout, by the CPU: the frame read
back into host memory, copied into the session's staging and from there into
the cache. The guest's decoder asks its outputs of CoreVideo, which lays them
out itself (measured: at 1920x1080, rows of 1920 bytes, the luma plane at
byte 32 and the chroma at byte 2088992), and radeonsi's import refuses that
on the AMD GPUs we have: the RX 550's refuses rows below its pitch of 2048
bytes, the 780M's rows off a multiple of 256. On the RX 550 a walk's 1080p
H.264 and HEVC clips took that way for each of their 894 pictures (walk b1,
m3-max-66052).
Now the session's copier, gpu_copy's ScratchCopier, takes such a picture at
that refusal: the driver's video processing writes the picture into a
scratch of the session's, laid out as the driver's imports must be (each
plane at its dma-buf's first byte or whole rows after it, the even width's
rows at a pitch on 256), and fill's videoEncodeFill kernel copies each
plane's crop from it into the cache at the cache's own offset and pitch, as
plain words; the copy is waited for before the picture counts as landed, as
the CPU's copy is. The copier is reached only where the in-place write was
refused, for a plane in a device cache outside its surface, whatever the
GPU or its driver: every host whose import refuses the guest's rows takes it
(the RX 550 and the 780M), and none is chosen by name. It declines, so that
the CPU copies as before, a plane in the guest's pages or in a surface, a
crop that does not fill its rows in whole 32-bit words (rows of 1366 or 642
bytes), and an offset or pitch off a word.
Where the platform "makes no GPU copies" on Linux: f716a52d2a opened VA-API
on rt with no copier, and 13fb154934 kept it ("the copies make no copier,
for the same reason as before"), the reason f716a52d2a gave being only "as
no GPU copier is given". Neither, nor docs/conventions.md or lessons.md,
records a measured cost, a driver trap or a rule for it: the copier was not
built yet. This crosses no rule of the Vulkan platform's.
GPU memory stays the runtime's: the scratch is rt's, a dma-buf buffer made
through rt and exported through rt's API, one per session, zeroed by a blit
at its make. It is host-only: the guest never maps it, nothing read from it
decides anything, and the kernel's bounds come from the planes' layouts the
host computed. The driver writes it as it writes an in-place cache, the
runtime acquires it after (external_write_done), and the kernel reads only
bytes the driver wrote.
Guest-invisible: each plane's crop rows are the bytes the CPU's copy writes
and every other byte of the cache is as its fill left it, the layout the
device answers is unchanged, and the picture lands at the same point of its
decode. The ignored test
a_picture_copied_by_the_gpu_from_its_scratch_is_the_cpus_copy
compares every byte of the cache with the CPU's copy: 32 pictures of 8
streams (H.264, HEVC and HEVC Main10, 640x360 to 3840x2160) equal on the
RX 550 (m3-max-66105) and the 780M (m3-max-66127), the 1366x768 and 642x362
streams declined.
Each picture so copied counts video-pictures-gpu-copied and its crop's KiB
video-gpu-copied-kib, and a session logs its copies at its end. The fills'
test that held "the platform makes no GPU copies" now holds that the
device's fills make a copier each decode session.
A command buffer's pre-pass hands its dispatches' new pipeline shapes to the
compile pool, which makes them on all of its threads but one. On a cold boot on
um790's RTX 2080 (m3-max-65818), the boot's 52 makes ahead queued 4265.6 ms in
all behind one another at that cap, and the walk waited at each dispatch whose
shape was still queued or being made: 31 waits, 1044.5 ms, before the desktop
came up, 384.6 ms of it at 15 shapes it made itself, one at each dispatch, while
the compile threads were idle.
Each shape handed is of one of the buffer's own dispatches, whose commit waits
for it in any case. So the walk's thread now makes the shapes no compile thread
took yet at its first dispatch, beside the compile threads, then dispatches. The
pool's order and cap are unchanged, so library and pipeline creates keep the
thread left to them. The makes the walk ran are counted
(dispatch-prepass-made-on-walk) and logged at debug.
The test that held a queued make waiting for a compile thread now sees the walk
make it at its first dispatch, and not before; a new one sees a walk that ends
before its first dispatch drop them; the device release's test expects the one
shape its walk made.
On Linux with glibc, a pipeline make's translation frees nearly all it used
as the make returns. glibc, though, keeps the free chunks below its heaps' tops
resident, so the VM's process stayed at its largest make's level, up to about
450 MiB. Now each compile-pool make of 250 ms or more asks a thread of its own,
reims-vgpu.heap-trim, to run malloc_trim(0). One trim runs at a time, and the
asks made while it runs become one more trim.
For the host, resident memory falls after heavy creates (the ledger's kernel:
158 MiB to 32 MiB). The first trim is logged at info and later ones at debug,
each with resident bytes before and after and the trim's time. The counts line
carries heap-trims, heap-trim-us and heap-trim-returned-kib.
Nothing changes for the guest. No reply, value or order it sees moves, and the
compile's thread only asks for the trim. macOS, Windows and musl do nothing.
What is left: a trim takes each glibc arena's lock in turn, so a thread the
guest waits on (a make's or the ring's) that allocates meanwhile can wait up to
the trim's own time. That was 5.04 ms at most in a cold launch of the modelling
app on a 780M, and the contention itself was not measured.
The display's passes (the present shaders' conversion and the colour's) sampled
a presented IOSurface's texture through the texture's own resource index, which
is the guest's. The guest's indices belong to its processes: when one ends (a
logout, a window server restart), its indices go back to the guest's kext, and
the next process's texture made at one of them takes that index's element at
once. The display can still show the old texture and draws it again at each
refresh, so a refresh drew the new texture's pixels into the window, or
undefined ones once that texture had gone and emptied the element, until the
guest presented again.
The display now samples the texture through a view of its own: the whole
texture in its own pixel format, at one of the platform's own indices, made at
the texture's first such draw and kept with the decoder's entry and with each
of the display's holds of it, so a later present or refresh of that texture
makes no Vulkan call. The copy path reads the image through no index and is
unchanged. Where the platform refuses the view, the draw answers nothing: the
window keeps its last frame and the host's read of the display answers black,
counted as display-view-refused. No draw falls back to the guest's index.
For the host: a refresh after the guest reuses the shown texture's index still
shows that texture. a_color_draws_a_presented_surface_through_its_tables and
a_surface_takes_the_table_at_its_own_size_in_unorm now expect the view, not the
surface, in the fragment binds.
Moves both metal2vulkan revs from d83fb05624 to 82e7c39216, 65 commits on its
development branch, named green by its checks (m3-max-59311). The runtime's
crate takes its published name there (9a1c8fe6dc): metal2vulkan-rt 0.0.0 is
now metal2vulkan-runtime 0.2.0, its library metal2vulkan_runtime. The
dependency key, the crate's paths (each still `as rt`), the lock's entry and
the docs, comments, log lines and scripts that named the crate follow it. The
rename changes no API.
On rt:
- A command buffer waiting for a shared event's value whose signal is
submitted is Scheduled as it is submitted (4730af16e7): its scheduled
handlers run on the submit thread then, and its queue's later command
buffers are no longer held behind it. A wait for a value that neither the
host set nor a submitted signal promises stays held, Committed, as before
(counted in Metrics::event_holds, fb4b77048c). GPU order and completion are
unchanged. The docs that said rt's completion thread runs a held command
buffer's scheduled handlers now say its submit thread does.
- Copies over buffers are tracked by the memory a buffer lies in, never its
id (7e38a29b69): a texture over one buffer sees a draw through a texture
over another buffer over the same bytes, in one command buffer and across
a held group.
- A kernel that reads buffers through an argument buffer's pointer members,
or through a gpuAddress the CPU wrote into a constant buffer, now makes
(3cdca62567, c0403a1c98); the translator refused it (IdentityDomains).
- A refused kernel input names its kind (98895eb6d2, 1c26e1dc54):
Gap::KernelInput { kind }, so the refusal's text, in the log and in the
NSError's description, carries the kind. It is still counted as
KernelInput.
- Memory goes back sooner. The release of a texture or block that an unsent
upload holds sends the upload at once (0277c68696). A texture longer than
a 16 MiB block has its block to itself and gives it back at its release
(61949e8ba4). Every free of device memory on a normal path is made by the
block-maker thread, and counted against the submits it meets (4c808ffa6d,
09735ad792). New gauges tell texture blocks apart from the consumer's
Private takes (b3f6c859dd).
- ComputePipelineState::dispatch_variant, the key of the VkPipeline a dispatch
runs (82e7c39216), which this tree does not call yet.
- The translator's old path is deleted (0b94d919d9 to 16c831165d): its
profile comes from Vulkan queries alone, with no policy switches and no
driver-fact tables. SEMANTICS_VERSION goes from 2201 to 2203 and
RUNTIME_VERSION from 2540 to 2541, so rt's shader and pipeline caches miss
once: the first run on each host translates its pipelines again.
The rest is metal2vulkan's own: its conformance declarations and ledger, its
generated documents and the tests of each change. The NSError texts the guest
receives, and the comments of the wire header and the guest's sources that the
prebuilt kext sets and the option ROM record, keep the old name here; commits
of their own change them.
On the rt platform a dispatch's first use of a shape (its threadgroup size,
threadgroup memory lengths and grid) makes the kernel's VkPipeline on the walk's
thread, and the buffer's commit, with its process's wait for it, waits for that
make.
As a queue's service thread begins a buffer with a compute encoder, its
pre-pass (graphics::decode::prepass) reads the dispatches through the
message's views of the table and hands each shape not handed before to the
compile pool, one compile a shape, which calls the state's prepare_dispatch
while the walk goes on: rt makes the VkPipeline at the size the dispatch
gives, and lowers nothing. A dispatch then finds its pipeline made, or waits
for the one thread making it. It is bounded: a compute state's entry
remembers the last 64 shapes handed, a buffer hands 32 at the most, and the
pool runs these makes on all its threads but one, after every library and
pipeline create.
The walk waits for none of it. Right after the walk and commit, before the
message lets go of anything, the pre-pass is closed: the shapes no thread took
are dropped, and the walk's thread waits for those being made, so a compute
state the guest destroyed during the walk is still let go of where its view
closes, and the indices it gives back go back in the same order. Each wait is
counted (dispatch-prepass-waited, -wait-ns, -wait-max-ns), and the first of
each walk end (committed, refused, faulted) is logged.
Nothing the guest or the host sees changes: prepare_dispatch reports nothing,
and each dispatch's results and errors are decided in the walk as before. The
tests on the fake platform hold that each buffer completes as before, and that
a make the walk never reaches ends before the buffer's views close.
docs/conventions.md names the one exception to "compiles run only inside the
wait that needs them".
The cutdel branch deletes VulkanPlatform, metal2vulkan-runtime and the rt
feature, so RtPlatform over metal2vulkan-rt is the only platform. These
docs still described the old one: its answer policies, its exact
switches, MoltenVK on the Mac, its in-place guest memory, its records
cache, its device recovery and its Metal-answer tests.
- conventions.md: the guest-memory-in-place rule is replaced by the rt
rule (rt allocates GPU memory, the device maps its blocks into the
guest, textures sync at the guest's events, and there is one VkDevice
per process). The degradation codes are now rt-unbuilt and rt-refused,
and the deleted codes are dropped.
- accuracy-ledger.md: restated for rt, which has no switches. It keeps
the device's own arithmetic notes (tagged as measured before rt), the
19 unbuilt pieces and rt's refusal kinds, and device loss.
- api.md, README.md: REIMS_VGPU_EXACT, _CENSUS_DIR and _TRACE_DEGRADE
are gone, and STRICT now covers running out of memory only. The let-go
and the quiesce describe one platform.
- architecture.md, development.md, testing.md, qemu.md: KosmicKrisp in
place of MoltenVK; RtPlatform, rt_window and RtBlocks in place of
VulkanPlatform, the old window sink and HostBlocks; no Metal-answer
comparisons and no opt-in GPU-fault tests.
- lessons.md: the four lessons about deleted code only (the Metal
comparison after MoltenVK, the runtime's shadows, device recovery and
the in-place check) are dropped. The lessons that still bind mark
their deleted names.
- video/vaapi.md, graphics-kext/design.md: the GPU plane copy and the
compositor mirror are marked as gone.
- AGENTS.md: only the Vulkan platform's "Where things are" row changes.
On the rt platform on Windows, a picture whose output's planes lie in a
cache's surface over Direct3D 11 textures lands by a draw from the texture
the driver decoded it into. The landing waited for the decode, drew, and only
then did the guest hear of the frame: a command buffer of the decode alone
posted its CB_COMPLETE at its platform end, behind the session's signal. A
player that holds each picture keeps one decode in flight, so each picture
took the decode, the draw (4.4 to 5.2 ms of a 4K HEVC picture on a UHD 630)
and the guest's own work in turn (docs/video/bugs.md, B96).
The landing now tells of the decode done between its wait for the decode and
its draw, as the VA-API arm's video processing on Linux does as it issues its
copy. What changes for the guest: such a command buffer's CB_COMPLETE goes as
the decode is done, in its queue's order, with GPU times of 0, while the draw
runs. Nothing else moves. The session signals the decode once the draw is
done and the platform holds what it wrote, and the buffer's end, its surface
timeline and every read of the output wait for that signal: a command buffer
of another queue that uses the output (a blit or copy from its texture or its
buffer among them), a decode into it, a lock's download and a present. No
reader sees the picture half drawn. A draw that fails falls back to the CPU's
copy, still before the signal; a picture that fails to land after its
CB_COMPLETE fails the session's next decode in its stead, counted as
video-landing-failure-carried, as on Linux.
No test held the old order: the drawn landing needs vaon12 and a decode. New
tests: a session posts a picture's completion at its decode-done tell and
signals the decode only once the rest of its landing is done; and a blit of
another queue from the output, its texture's texels and its buffer's bytes,
copies only behind its wait for the decode's buffer's end, which that buffer
signals only behind its wait for its session's value. The tests of a reader
on another queue, a decode, a download and a present after a completion at
the decode hold for the draw as for the copy.
A drawn cache's ask that found no spare made its own surface on the ring
while the spares' thread could be making the very spare it asked for. Two
makes at once contend in the driver: in held 4K H.264 on the UHD 630
(m3-max-56925, round 1 pass 2), 78 makes on the ring took 29.2 ms each and
the spares' thread's 162 took 21.0 ms, where the same pass made each on
the ring at 9.8 ms before the spares (m3-max-56661), and the pass fell
from 76.1 to 44.3 fps.
So an ask whose make is running waits for it and takes its spare, bounded
at ten slices of 10 ms, past which it makes its own as before. Counted:
video-drawn-spares-waited, the asks that waited, with
video-drawn-spares-wait-ns their wait and video-drawn-spares-wait-max-ns
the longest, so a boot shows each take waits about one make.
On Windows a video cache's surface over two Direct3D 11 textures is made at the
guest's first texture over one of its planes, on the ring-0 thread that carries
that texture make out, and the guest's next messages wait for it. A player that
holds every picture it decoded takes a new IOSurface, and so a new surface, for
each picture. Measured on the UHD 630 (2026-11-19, a macOS guest's 4K playback,
pictures held): the targets' make took 9.3 to 9.8 ms on the ring and their
import about 0.7 ms a picture between the HEVC stream's decodes, of a 26 to 33
ms gap from one decode op to the next, as the guest keeps one HEVC decode in
flight; the H.264 stream's first round made them in 14.7 to 18.2 ms.
Each ask now takes a spare made ahead for the same plane shapes, formats and
device recoveries, where one is kept, and hands the makes that bring its spares
back up to the depth to a thread of their own
(reims-vgpu.graphics-drawn-spares-<i>), which nothing waits for; an ask that
finds none makes its own as before. The depth is the guest's decodes in flight
at its last decode (the session's value less its event's signalled value), at
least one and at most 8 spares in all, which bounds their memory; the makes run
one at a time under the device's reset gate held shared. The guest sees the
same surfaces: only the thread and the time of their make change. Counted as
video-drawn-spares-used, -missed, -made and -dropped.
A picture whose copy into its output's caches fails after its command buffer
completed at the decode can no longer fail that command buffer: the guest
was told it landed. The session's next decode now fails in its stead, its
command buffer completing as one whose picture did not land, so the guest
sees the decode error one picture late (an HEVC picture's schedule gets
kVTVideoDecoderMalfunctionErr) instead of never. The decode after it is not
affected.
It is counted as the degradation video-landing-failure-carried and logged
once per process.
On Windows on the rt platform, a video cache's two planes can lie in a surface
over two shared Direct3D 11 textures that the VA-API arm draws each picture
into (PlaneDraw), in place of the CPU's copy. The platform imports the textures
through GpuDevice::import_d3d11_surface, which rt_platform answers through a
stub of rt's provisional Device::import_d3d11_surface, the signature of m2v's
42993be0bc: it refuses every surface, counted (rt-refused-d3d11-surface), so
each picture still lands by the CPU's copy until the pin carries the import.
Swapping the stub for rt's call is one function and its plane type.
The draws are made at the arm's open (RtCopies::new), so no picture waits for
their devices and pipelines. A drawn picture holds the textures' keyed mutexes
across the draw, waits on the landing's thread, releases them, and then says
the writes are done (external_writes_done). Each draw is counted by picture
and KiB (video-pictures-drawn, video-drawn-kib): one GPU pass per picture that
a Mac does not make. A plane not drawn falls to the CPU's copy into its image.
The guest's Metal bundle is to ask for Private blocks of 16 MiB, metal2vulkan-rt's
allocation unit (MemoryClass::block_len), which rt's block maker makes ahead of
need, so the host answers such a take with no allocation of the driver's in it.
An object whose span is longer takes a block of its own, which rt allocates in
the take, on the context's take worker.
Those takes are now counted apart among the sourced ones: private-take-span, and
private-take-span-us, the source's time for them, with the first one's line in
each boot's log. UNIT_LEN names the unit, from rt's block_len. Nothing the guest
or the host observes changes: the counts and the log line are diagnostics.
Where the guest took MANAGED_AT_COPY and the platform makes the Managed
buffer at an address other than its CPU copy's (a copy in no block the
platform knows, such as one over the region), the host refused the
create, so the guest's id stood for a refused object: nil where bound,
its uses dropped. Metal makes that buffer, so the host must not refuse
it.
The host now keeps the buffer the platform made. It is the buffer the
same create makes from a guest that did not take the bit: the same
platform call, the same pin left unkept and counted, the same binding.
Each such create is counted as managed-at-copy-unkept, the first logged.
What changes for the guest on a unified rt host: such a create is a live
buffer, bound and used as without the bit, rather than a refused object.
Its gpuAddress is the address the guest posted, which the buffer is not
at, as a guest's own pick is not on that host today. Nothing changes
where the copy lies in a block the platform knows, nor on a host that
does not offer the bit.
The wire header's doc for the bit says so. The prebuilt sets and the
option ROM's record are rebuilt from it in their own commit.
The tests compare the answers with the same create's without the bit:
the decoder test its result, the platform's calls, the binding, the GPU
address, the unkept pin's count, a didModifyRange and a synchronize; the
rt GPU test its result, the binding and rt's address over the region.
What changes for the guest: on a host whose GPU shares the CPU's memory, on
metal2vulkan-rt's platform, with the Shared pool, the device offers feature
bit 63. A guest that takes it makes each Managed buffer at its CPU copy's
GPU address, so the gpuAddress its argument buffers and pointers hold is the
buffer's bytes, and it takes no Private block for it. Before, the guest held
its own pick in a Private block, rt made the buffer at the copy's address
instead, and a kernel reaching the buffer through its gpuAddress read the
Private block; each pick also held a Private take (1308 such picks and four
256 MiB Private blocks on a 780M desktop walk).
Where the guest took the bit and the platform does not make the buffer at
the copy's address (a copy in no block it knows), the host refuses the
create, as Metal answers nil, counted managed-at-copy-refused; it never
makes the buffer at an address of its own. A GPU of its own memory keeps two
copies, the Vulkan platform pins each buffer at the guest's pick, and a
device with no pool keeps the slabs' copies in region heaps: none offers
the bit, and their guests see no change.
The rebase onto development put the contexts' Private takes after the
Vulkan platform's command predication in the conventions' list of counted
codes, which left two "and"s in one list. Drop the first. [ci skip]
On the rt platform, a Windows host answered the guest no hardware video. It
now opens the VA-API arm there, on Mesa's VA-on-D3D12 driver, at the DXGI
adapter whose LUID Vulkan answers for rt's device (HostGpu::luid). The guest
sees H.264 and HEVC decodes where the driver has them, and no encoder, as on
Linux's rt arm.
rt imports no image of the shared Direct3D 12 texture a picture decodes into:
the UHD 630's driver faults binding a two-plane image imported from its D3D11
handle, and refuses single-plane images from the D3D12 resource. So the
session's copier declines each picture at the GPU's copy, counted as
rt-video-gpu-copy-declined, and each lands by vaGetImage and the CPU's copy.
On the old platform on that GPU the CPU's copy took 18.77, 68.35 and 79.28 ms
a picture (1080p NV12, 4K NV12, 4K P010) against the GPU copy's 1.47, 4.18
and 10.36 ms; bugs.md B94 records it and the measured way out.
PRIVATE_TAKE was carried out on the context's lane. On metal2vulkan-rt each
take is one of rt's Private blocks, a driver allocation, and NVIDIA's driver
holds the device's other calls while it allocates. On an RTX 3090 a boot took 7
blocks of 256 MiB, 52.7 ms in all and 11.5 ms at most, each on the control
ring's lane, which held every context's next messages behind it.
A take of the source's now goes to its context's worker
(reims-vgpu.graphics-private-take), as POOL_TAKE's does. The worker takes the
block from the source and answers. A context's takes are answered in its own
order, so a take waits only behind its own context's earlier takes. A take that
its context's close, the device's reset or its release ended is never answered,
and the block its worker was taking goes back to the source. The device's
release waits for the workers, so none calls the source past it; a worker that
the exit gate parks counts as gone. Where the platform gives no Private blocks,
the host's pick is still answered at once on the lane. The source decides this,
never the driver or the device.
What the guest observes: only when PRIVATE_BLOCK comes. It may now come after
the answers to messages the context posted after the take. Its status, address
and length are unchanged. The kext waits for PRIVATE_BLOCK with no deadline, on
the thread whose create found no room, so no other wait changes.
The degradation counts carry the takes by cause:
- private-take-queued: a take that waited behind its context's earlier take;
- private-take-sourced: a take its worker took from the source, with
private-take-sourced-us, the source's time for those takes;
- private-take-lane-us-most: the longest a take held the thread that carried
it out.
No block is made ahead: a 256 MiB Private make holds an NVIDIA device for
6.5 ms (RTX 3090) to 8 ms (RTX 2080) on any thread, while 16 MiB units stay at
the baseline (a no-boot probe). Smaller blocks are the guest's change, in its
own commit.
A message the decoder did not carry out was logged once per kind at warn,
and every later one only at debug, so a boot's degradation counts showed
none of them. On rt without the guest RAM lease, a walk refused 805 no-copy
creates and 701 textures over them, and the counts said nothing.
Each is now counted by why: decode-malformed, -unknown-command, -refused,
-bad-reference and -bad-resource-id from DecodeError, and decode-faulted
for a raise. This applies at the stage-3 report, a pipeline or library
create's refusal, and a deferred op's raise. A message of a context closed
before it came is owed nothing and is not counted. The lines are unchanged.
docs/conventions.md lists the codes. A test refuses two event creates: one
warn line, and decode-refused counts 2.
On Linux and Windows, a no-copy buffer over pages the process maps read-only
lies over a copy of those pages. Once such a buffer's identity has escaped,
the GPU may read the copy through memory after the guest's CPU has changed
the pages, with no binding naming the buffer. This commit records how often
that situation arises, and pins the runtime behaviour that keeps it correct.
The behaviour is unchanged: the decoder adds nothing to any command buffer.
Metal requires an encoder to make resident (useResource:usage:) any buffer a
function reaches through memory, and that names the buffer as a use. At the
commit, the runtime copies in every copy that a command buffer's uses name,
and every copy where its work may reach memory that no use names
(metal2vulkan's command_buffer/mod.rs:4747-4772 at the pinned commit, which
picks the copies at 4754-4766). A reach of a buffer that no encoder made
resident is undefined in Metal, and on the runtime it reads zero
(residency.rs).
What the decoder adds is bookkeeping:
- each process's count of its live escaped copies (Context::escaped_copies),
which a copy joins at its first note and leaves when it is dropped;
- escaped-copy-commits, which counts each command buffer begun by a process
that holds one, in the degradation counts line and the recorder's stats.
The first such command buffer is logged at info.
on_vulkan_an_escaped_copy_reached_by_its_address_reads_the_cpus_writes pins
today's runtime. A kernel reaches the escaped copy only through an address it
loads, with the encoder having made the copy resident. It reads the pages' old
bytes, then their new ones after the CPU's write.
The host reads a no-copy buffer's bytes in place. The guest's Metal can hand
that buffer's identity to the app, or write it where the GPU reads, with no
message naming the buffer, and from then on the GPU may reach the buffer
through memory alone. The host had no way to know which buffers that happened
to. This commit adds a note for it, so the host can tell them apart.
The note is RGFX_CMD_BUFFER_ESCAPED (0x23b), RgfxBufferEscaped of 32 bytes:
the buffer's object id and the act, one of GPU_ADDRESS, ARGUMENT_ENCODER,
RESOURCE_ID and RESIDENCY_SET. The device offers it as
RGFX_FEATURE_BUFFER_ESCAPED (bit 56), and both kexts carry it. The submit gate
takes it in a batch, like a Managed range's write: unwaited, a fixed size,
naming no block and making no object.
The bundle marks each covered buffer as it is made (_rgfxEscape, set by
rgfxOwesEscapeNote) where the host took the feature. The first of these acts
in the buffer's life posts the note, before the act returns:
- a read of the buffer's gpuAddress;
- an argument encoder's setBuffer(s) of it, or setTexture(s) of a texture or
view over it;
- a read of such a texture's or view's gpuResourceID;
- the buffer, or such a texture, joining a residency set.
Every later act is one relaxed load.
Wire order holds the note ahead of any command buffer that could use the
identity. The note goes on ring 0, posted or held in the serialiser to go
before the next commit's messages, and the device carries out a command buffer
only after every ring-0 message its process posted before it. Across threads,
the act's slow path posts the note under the buffer's lock and then clears the
mark with a release store. Every commit takes an acquire fence before it posts,
so a commit after an act that found the mark clear posts after the note.
The covered buffers are the app's no-copy buffers over its own pages
(BUFFER_OVER_PAGES, writable or read-only, bit 24) and over bytes already in
a block of the process (BUFFER_OVER_HOST_MEMORY). Managed buffers, heaps over
pages, IOSurface shadows and buffers placed in a slab's heap
(BUFFER_AT_OFFSET) are not covered.
A slab buffer made with an address of its own is covered too: a Shared buffer
past 2 MiB over a slab of the process's own pages, a device buffer, or a
no-copy buffer's shadow (RgfxSlabSource::Made's ownsAddress). It reaches the
host as the same BUFFER_OVER_PAGES or BUFFER_OVER_HOST_MEMORY message as an
app's no-copy buffer, and the host takes every such message alike. Leaving
slab buffers out would leave the host unable to read the mark as "this
buffer's identity never left".
The host marks the buffer's entry escaped, once for its life, and a later
note changes nothing. A note for an object that is not such a buffer is a bad
reference. A note for an object whose create the host refused is dropped, as
any naming of one is. Escapes are counted in the degradation counts line and
in the recorder's stats (`counted <code> <n>` lines), with no new stream
records:
- buffer-escaped-gpu-address, -argument-encoder, -resource-id and
-residency-set, by the act that noted the escape;
- buffer-escaped-read-only-pages, the escaped buffers over a copy of their
pages;
- no-copy-buffers, every no-copy buffer made, of which the escapes are a
share.
Each act's first escape is also logged at info.
This changes nothing the guest observes. No one waits for the note, it has no
reply, and the mark changes no answer, object, address or command. Both
prebuilt sets and the option ROM's record are rebuilt from these sources. The
ROM's bytes do not change: its record changes only by the wire header's hash.
At the runtime's cutover every host makes a no-copy buffer over pages the
guest maps read-only over a copy of them, the Mac included, where today it
imports them in place. To know what that copy costs a guest, the decoder now
counts each such buffer it makes, once a boot, in the degradation counts'
line: `read-only-pages-buffers` (how many were made) and `read-only-pages-kib`
(their bytes' sum in KiB, rounded up).
A BUFFER_OVER_PAGES over a block the kext marks RGFX_SURFACE_PAGES_READ_ONLY
is the only such object: the bundle sends read-only Shared memory there with
bit 24, and a heap, an indirect command buffer's slots or a Managed object's
CPU copy over the block is refused. The count is taken there, in the decoder
every host shares, so it means the same on Linux, Windows and macOS.
The counts' line is where they go: docs/conventions.md lists every kind
counted since the process began there, not degradations alone (the rings'
`vblank-dropped` and `*-post-waited` among them), and says no count goes
elsewhere. On macOS the buffers are no degradation; on Linux and Windows the
runtime also counts their copies, with failed imports, under its own code.
answer.rs gains count_kind_by, which adds an amount to a kind's count.
Diagnostics only: no ring message, value or answer the guest sees changes.
The swapchain, the window's presenter, the display's sink and the window
system's extensions present on Windows too, through SDL's Win32 surface
(os/windows.rs's WINDOW_SURFACE_EXTENSIONS), but their docs said "either OS"
or named Linux and macOS alone. rust-toolchain.toml still named the Metal
platform, deleted on 11-07. caps.rs's table gave a host's naming of its
device by Metal's registry ID (open_device, a handshake) as the reason for
the stand-in; no host names its device so now, and the reason that holds is
that Metal's core count and driver sizes for that GPU are found by that ID.
Comments and docs only.
A loop of command predication that ran past the iterations laid down for
it set a flag in its command buffer's state buffer, and a completed handler
of the platform's own read the flag and ended the process. That handler ran
on the runtime's thread outside every refusal scope, so a guest whose loop
ran on, or anything that wrote the flag, ended QEMU. The state buffer is host
data the GPU writes, and after the runtime's cutover every byte on the device
is guest-writable.
The flags are now read where the runtime's own failures are read, once the
command buffer completed with none: by each completed and completion-seen
handler's read, and by status, error and waitUntilCompleted. An overrun is a
failure that is none of Metal's, dying where it is read, as the others do.
What the guest sees: inside the graphics lane's refusal scope, which every
guest command buffer's handlers carry, the read is refused and the command
buffer completes with status Error and an internal error (RGFX_CB_INTERNAL),
after its event signals and in its queue's order, and QEMU goes on. Each
such command buffer is counted once as the degradation
predication-loop-overrun. Outside every scope (the library's own tests) it
still ends the process, now at the first read of the completion.
The death test now dies at the wait, and two tests pin the refused
completion and a loop that ends within its copies.
metal2vulkan is replacing its runtime with a new crate that has one path
for every device. reims-vgpu's rules now say what that means here until the
cutover: the current runtime takes regression fixes only, from one lane at
most, and nothing extends its device tables, device checks or queue-sharing
policies. reims-vgpu builds its side of the new contract: runtime-owned
memory mapped into the guest, device-image textures synced at the guest's
events, and host-assigned addresses with one VkDevice per guest process.
At the cutover that replaces guest memory in place, which conventions.md
now says.
The pin rule now states what the owner set on 2026-11-17: the pin is an
exact commit on metal2vulkan's development, on the remote before ours is
pushed, and a regression it brings is fixed forward rather than routed
around by holding or rolling back the pin.
An encode's frame at 1080p and 8 Mbit/s goes to the guest as two or more
16 KiB VT_MESSAGE events. Two of them do not fit the control completion
ring's 32 KiB at once, so an encode filled that ring about once a frame:
control-ring-full and control-ring-post-waited 592 times in an arm64 26.6.2
boot's encode bench (potluck job m3-max-38178). A full ring holds back the
display's VBLANKs and the presents' answers while the guest encodes.
Feature bit 54, VT_RING, which the device offers wherever its host offers
VT_MESSAGES and the arm64e kext takes with it, moves those messages into
the VideoToolbox ring: a 2 MiB ring at region offset 0x20000, in the room
between the control completion ring's span and the guest's allocations,
which the kexts already map with the control rings. It is the device's
memory, so the kext wires none of the guest's RAM for it and frees nothing
at the service's stop or its unload. Each message there is followed on the
control completion ring by a 24-byte VT_RING event (0x40f) carrying the
ring's count through it. The kext takes the ring through that count as it
takes the event, so the messages keep their place among the control
ring's events. A message that finds the ring full goes onto the control
completion ring as before, after the VT_RINGs of the messages ahead of it,
and the spell is counted as vt-ring-full. A guest or host without the bit
gets VT_MESSAGE events as before.
What the guest observes: the feature bit offered with VT_MESSAGES, and the
host's messages in the VideoToolbox ring with VT_RING events instead of
VT_MESSAGE events, in the same order.
macOS 26's unified log shows an NSLog argument that is an object or a string
made at run time as <private>, so the bundle's diagnostics named nothing there:
RealityKit's usdz Quick Look preview logged "RGFX: <private>: no reflection
(<private>); answered nil" and no more. The bundle's Objective-C sources now
log through rgfxLogLine, which formats the line as NSLog does, logs it as one
public string on the bundle's subsystem at the default level NSLog used, and
writes it to stderr where NSLog wrote there too (the death checks read a
death's words there). bundle_log_check.sh fails a bundle that calls NSLog.
The library builds and tests on Windows now, so AGENTS.md says Windows is
being brought up on homelab-mac-mini-2018, with nothing shipped for it yet.
Checking a change gets a row for Windows-only code: the check's Windows
clippy, then the crate's tests on the mini through
scripts/internal/windows-tests.sh. The note on what the check covers off the
host's own target now names the Windows clippy. conventions.md's list of
per-OS files gains the Vulkan crate's os/windows.rs and the graphics crate's
unix/windows splits.
With the window on Windows SDL3's on the library's own thread, as on Linux,
the C API's thread rules name Windows beside Linux: the header (from
window.rs, regenerated), docs/api.md and the feature's note in reims-vgpu's
manifest. docs/conventions.md says Windows takes Linux's host-call catch.
On Windows the window is the SDL thread's, as on Linux: SDL3's Win32 window on
the library's own reims-vgpu.ui thread, its Vulkan surface made by the render
thread through SDL_Vulkan_CreateSurface (VK_KHR_win32_surface). SDL3 is built
from its pinned source release and linked statically, as on Linux. A Win32
window's messages go to the thread that made it, and SDL makes and pumps it on
the thread its video started on, the UI thread.
native/windows.rs holds what Windows adds: it names no compositor GPU, so the
window presents on the runtime's device. Its doc records what SDL does there
(read from SDL 3.4.18's code): the process declared per-monitor DPI aware,
sizes in pixels with the monitor's DPI as the content scale, and the keyboard
grab as a low-level keyboard hook on the UI thread.
Linux and macOS build what they built before.
A buffer walked in two ranges at once reached the GPU in two steps: the first
range's parts as they were cut, the later range's whole work only at the join,
since queue order puts it after the first range's last part. On um870's 3090
(26.7.2, Launchpad) that left 3.7 ms of GPU work after the walk's end
(m3-max-31226), and a split into any number of contiguous ranges keeps such a
tail.
The walk now cuts such a buffer at encoder ends into chunks of 4 KiB of ops or
more (about 31 for WindowServer's 125 KiB Launchpad frame, near the 36 parts
its walk on one thread cut) and deals them in turn: the lane's thread walks the
even ones and one helper the odd ones, handed over at once. Each chunk goes
into a command buffer of its own, made from an empty one on the same thread
(CommandBuffer::part). After each of its own chunks the lane commits every
chunk walked, in their order, as a part, waiting for the helper only for the
chunk it commits next, so the GPU is fed throughout the walk. A part goes
where the whole buffer could be committed then, as a cut does; at the walk's
end, once every wait of its commit is met. The last chunk's command buffer
carries the buffer's handlers, records and present, as before.
The chunks' command buffers are made before any chunk is walked, each only
while its queue holds room, as a cut's make is: a make waits while the queue
holds 64 uncompleted command buffers, and a dealt walk holds walked chunks
uncommitted while its commit's gate is closed, so a make inside the walk, or
one look at the room for every chunk while the lane's own walks and begins
make command buffers on the queue, could wait for room only its own commits
free, and the walk would never end. Where the room runs out first, or the
platform makes no command buffer for a chunk, the buffer is walked whole.
What wslat kept stays: the prescan's op set and its pin to KeptWhole; a part
that fails from an encoder on takes in every later chunk in their order
(fold); Whole fails the buffer, counted as two-ranges-kept-whole; a fault
answers the first faulting chunk in their order, nothing at or after it
committed; what each chunk saw written of laid-out caches goes to the buffer
in their order; chunks no helper started by the end of the lane's first are
taken back and walked as a whole walk goes on. The cbpar trace event gives
each buffer's chunks, and a new cbdeal event each chunk's walk, wait and
commit. The platform is unchanged; its doc comments name the deal.
Measured on um870's RTX 3090, 26.7.2 cold boots walking Launchpad (wlb7
m3-max-31913 before, wla7 m3-max-31914 after, same harness, fatal 0 each),
the two Launchpad samples: GPU work left at the walk's end 3.42/3.56 ms ->
1.61/1.74 ms p50, present take to shown 10.95/10.84 -> 8.69/8.82 ms p50
(p90 12.09/12.09 -> 9.19/9.55), refresh to shown 14.55/14.41 -> 12.47/12.56
ms, frames answered two refreshes late 9/3 -> 0/1.
A command buffer walked in two ranges at once has its later range in a
command buffer of its own; if the platform keeps the buffer whole at the
first range's end, the decoder cannot cut it there and fails the buffer at
its stand-in, where the serial walk would have run it. That must never
happen silently, and the prescan must keep out every op that leads to it.
The platform now says why it keeps a buffer whole: PartCut::Whole carries
a KeptWhole reason (an open encoder, protection options, an execution of
indirect commands, a command's progress, predication, a signal encoded
when scheduled, a buffer already committed), each with its code, from the
same list `splits` reads. A test on the Vulkan platform holds each reason
to the commit_part answer it gives.
The decoder's test pins the two lists together: for every reason, an
exhaustive match names the guest ops that set it, and the prescan takes no
buffer with any of them; the two reasons no guest op sets
(setProtectionOptions:, encodeSignalEventScheduled:value:) are held by a
check that no walk sends them. Where a buffer is kept whole anyway, it is a
degradation, two-ranges-kept-whole: counted in the degradation counts line
and logged once per reason per process (docs/conventions.md), its test
checking both over two buffers.
"Speed comes from what every run gets" says nothing is loaded by what an
earlier run drew. The runtime's pipeline records already keep, across a
host's processes, what Metal's own pipeline caches keep. The device's kept
pipeline answers now do the same across boots. Both hold only what the
platform or the device gave before, under the identity of what decides it,
and change no value the guest reads, only how soon it has it. The rule now
names them both and says neither is ever seeded for a measurement, so the
rule keeps its meaning.
A post onto a command queue's completion ring that finds no room waits, with
no bound, until the guest's process takes more. Nothing counted or logged
those waits, so a stall behind a full ring, on a thread that runs the
platform's handlers among them, left no trace in a boot's log.
The device now tells its host, as it does for the control ring, each full
spell of a queue's ring (queue-ring-full) at its first post that waits and
finds no room, and each post that waited (queue-ring-post-waited) once it goes
on. Their lines name the queue and the thread that waits, and the codes reach
the process's degradation counts. Diagnostics alone: no post changes.
A writable twin of read-only pages was made only for a surface's read-only
alias, and a file of zeros only for an alias's block past its ranges: both
went with the host-OS surfaces, which no production path has made since
110b53637. So import_view loses its twin argument, and with it the twins'
map (shown_at), their mappings in the views' budget, the notwin refusal and
its trace record. Read-only pages are given to the runtime as they are, and
the views' gate refuses them, so the runtime copies them, as before.
The dma-buf sources lose their files of zeros (Zeros), which only those
blocks' pages took, and the budget's claims their reach, as only a twin
reached into the headroom. An import's pages are made once, so its record
says whether that import is still being made rather than how many are. The
remap, budget, vm, files and host_ram docs, qemu.md, lessons.md,
architecture.md and conventions.md no longer describe the twins, the
stand-in or the IOSurface memory the library held; the measured facts about
what a remap under an import reads stay in remap.rs. ResourceAddressRange,
which only the surface aliases gathered, goes.
Nothing the guest or host observes changes, as no production path has made
an OS surface since 110b53637.
Every process's ring-0 answers, the present answers and the display's events
share the one control completion ring. When it had no room, a VBLANK was
dropped silently (the guest sees no event for that refresh) and the posts that
waited left no trace, so no boot could say whether the ring ever filled.
The device now tells its host of each kind (Host::ring_degraded,
RingDegradation): a full spell at its first post that found no room, a post
that waited once it goes on, and a dropped VBLANK. It logs each kind's first
at warn, which the library's logger writes once per kind and counts after.
reims-vgpu counts them by code (answer::count_kind) into the degradation
counts line: control-ring-full, control-ring-post-waited, vblank-dropped.
Diagnostics only: what the guest sees is unchanged.
The bundle's os_log lines go to a subsystem of their own since the change
before the sets. conventions.md names it beside the bundle's once-a-kind
logging, with what its NSLog lines keep, and the lesson on the unread
counter says what read it on 26.7.2 and 27.0.1, and that a probe of the
counter reads a resource's answers once its buffer is scheduled.
logonce's guest part landed with batch4 (beb91ccd4, f064fbf69): the kexts
log a repeatable failure once a boot per kind, the Metal bundle once a
process, and their summaries at most once a minute. Add that to the rule's
list beside the library's and QEMU's.