On Linux an arm64 guest's VideoToolbox picture lands in the surface the guest lent by VA-API's video processing, in place, where the driver's import check takes the surface's layout. Where the driver declined it, the picture was read back and copied by the CPU, its reason logged once a decoder and no picture counted. The guest's buffers are now asked of a layout radeonsi and iHD write in place, and what is left is what the driver's own import declines: iHD's rows of samples that are not whole 64 bytes, a 1366-wide picture's among them. Such a 4:2:0 picture now lands as an x86-64 guest's picture lands in a device cache the driver declined: the session's GPU copier (gpu_copy's ScratchCopier) has the driver's video processing write it into a scratch of its own, and the GPU copy its crop into the surface through a Shared buffer of the device's over the surface's pages. The import's own refusal at run time chooses the route, never a card or driver name, and the CPU's copy stays last. The buffer over the surface is made at a picture's ask alone (GuestOutput::buffer_on_ask, kept with the surface's view in vt.rs), so no surface whose pictures land in place has one. Each picture is counted: video-vt-pictures-gpu-copied, with its rows' KiB as video-vt-gpu-copied-kib, and video-vt-pictures-cpu-copied for the CPU's copy, which was logged and not counted before; each reason is logged once a decoder. The three codes move from videotoolbox.rs to vt.rs, which the Mac arm shares. The guest sees the same bytes: the copy writes the rows the CPU's copy wrote, the crop alone. Tests: lent_planes' rows, the kernel's rt test over a lent layout, the VA host's copy into a lent surface against the CPU's copy (on the 780M, 297 pictures of 93 streams, each byte-equal, none declined), and the harness's card leg over a surface whose luma lies 32 bytes in, which no driver writes in place: each picture by the GPU's copy, none by the CPU. The fake leg has no such test: the copy is the VA arm's own, from a dma-buf scratch the driver writes, and the fake leg's arm is no VA arm, nor does the fake platform make a dma-buf. The hand-overs table gains rows 32 and 33, and bugs.md D33 records the copy a Mac does not make. (cherry picked from commit ced49c6b257438adaaf3aacb16973eed228c1e23)
34 KiB
Conventions
The conventions the code follows. AGENTS.md holds the rules of work around them, and architecture.md section 17 repeats the ones code cites.
- Names say what things mean:
Raise,Held,SerialQueue,HostRange.- No
PGprefixes, no Objective-C class names, nodealloc/init_with_*names, and no selector-keyword method names. - No
_locked/public pairs unless both are called. - The threads, queues and Metal object labels the library makes are
reims-vgpu.<role>(reims-vgpu.graphics-control,reims-vgpu.display-present). They are diagnostics: no host or guest reads them.
- No
- Modules are named by responsibility (
graphics/decode/cmdbuf.rs,memory/mapping.rs,display/pipeline.rs), never after-initor an Objective-C class. One module style:foo.rsbesidefoo/(D44). - Code for one OS goes in files of its own (the window crate's
native/macos/,native/linux/andnative/windows.rs, the Vulkan crate'sos/macos.rs,os/linux.rsandos/windows.rs, the graphics crate'sclock/,region/andwake/, eachunix.rsandwindows.rs, the C API'sffi/catch/{macos,linux}.rs, Linux's of which Windows takes), which the module above them picks with#[cfg(target_os = ...)](orunixandwindows), rather than incfgs spread through shared code. Code some OSes share and others do not goes in a module of its own that the index picks for those OSes (the window crate'snative/sdl_thread/, SDL on the library's own thread, for Linux and Windows). It sits in the crates the OSes share: no crate is one OS's. A file the OSes share is the exception, where splitting cannot be avoided, and keeps itscfgs to a few whole items; index files that pick modules are exempt. - The Vulkan platform (
RtPlatform) answers as Metal does through metal2vulkan-runtime, and these rules decide where its code goes and how it gets fast:- GPU memory is the runtime's. rt allocates it, and the device maps
its host-visible blocks into the guest: the pool's blocks and the
guest's Private blocks are rt's (
pool::RtBlocks), and the buffers and heaps the guest pins in them are ranges of them, at the guest's addresses. A buffer'sgpuAddressis its Vulkan device address, and agpuResourceIDa descriptor index. Textures are device images, synced at the guest's events (an IOSurface's lock and unlock,didModifyRange:,replaceRegion:), with no page logs. An app's no-copy memory, which no block maps, is rt's import of its pages, by their pointer or as a dma-buf of their files, and only where rt takes neither a copy synced at the commits that use it (rt_platform::copied). One exception: where the host says its hypervisor takes no cacheable mapping of the GPU's own memory as guest memory (QEMU under Linux's KVM on arm64 withoutKVM_CAP_ARM_CACHEABLE_PFNMAP_SUPPORTED; the C API'spool_host_memory), the pool's blocks are memfds of the library's own that rt imports as dma-bufs (pool::HostMemoryBlocks), rt's existing import with no new form of its own; the guest's Private blocks stay rt's. Its known gap: it is built and unit-tested here, and run only by its contributor, on an M1 Pro under Fedora Asahi Remix; no lab host is of that kind, and its speed is not measured by us. One VkDevice per process serves everything, the window's presents included, and no path shares objects across devices. The guest's processes are therefore not isolated from each other on the device: every byte on it is guest-writable, and the host never parses or trusts host data it keeps there. - Stalls are fixed on the Vulkan side: in this crate (caches, their
keys, when states are made) and in the runtime (translation speed,
sharing, making ahead), never by making core or the device's lanes
non-blocking, or by deferring or reordering their waits, since the guest
sees where they wait. Compiles run concurrently only inside the synchronous wait
that needs them, which joins every one before it returns, with two
exceptions. A command buffer's dispatch pre-pass makes its dispatches'
pipelines on the compile threads while its walk goes on, the walk's
thread makes those no compile thread took at its first dispatch, and the
walk's end drops those no thread took and joins those being made, before
the message lets go of anything, unless the device's reset begins, which
ends that join as it ends the walks' other waits
(
crates/reims-vgpu/src/graphics/decode/prepass.rs). And a pipeline create's reply is posted once the platform's make has made every answer it carries, ahead of the driver's create of the state's main pipelines, which the state's finish then makes on the same compile thread before the pipeline is stored; until the store, the command buffers, indirect command buffer writes and function handle and table creates that name the pipeline wait for it (crates/reims-vgpu/src/graphics/compile.rs, "Order"). Otherwise nothing compiles in the background, and nothing is deferred or released early. Nothing the guest sees (IDs, addresses, stamps, reflection order, shared state) is decided inside a concurrent section; it is assigned in order, before or after. Each concurrency change is a small commit of its own. - Speed comes from what every run gets: fewer and smaller pipelines,
sharing, concurrency inside a wait. Nothing is loaded or ordered by what
an earlier run drew, and no measurement starts from a cache seeded for
it. Three stores stand in for Metal's own caches across runs, as a Mac
keeps its compiled pipelines on disk: rt's shader and pipeline caches,
in
reims-vgpu-rtunder the user's cache directory (crates/reims-vgpu-vulkan/src/rt_platform/device.rs,CACHE), across a host's processes; the device's kept pipeline answers (crates/reims-vgpu/src/graphics/answers.rs), across boots; and, in the guest, the GL shader variants the bundle lowered, in each app's own cache directory beside Metal's (guest/bundle/src/RgfxGLStore.hpp), across the app's runs, as Metal's compiler service keeps what it compiled. Each holds only what the platform, the device or the generator gave before, under the identity of what decides it, so it changes no value the guest reads, only how soon the guest has it; none is ever seeded for a measurement. - A workaround for the OS or a driver lives in the runtime's code that calls it, never in core or the library's threads: a compile the system runs at its caller's priority is raised by the runtime, not by raising the library's threads'.
- What Metal does is the runtime's to build, its private API included; what only our device has is this crate's. A gap in the runtime goes to it with a repro (the call, its descriptor or arguments, the error or the difference from Metal, the device) rather than being patched around here.
- Dependencies are used as released. The Vulkan loader, the drivers (Mesa's KosmicKrisp on a Mac among them) and the others are never patched or rebuilt with changes: a fix one needs is proposed upstream, and the workaround lives here or in the runtime. A mark in the runtime that pays off only once upstream takes a fix stays if it changes nothing on the stock release.
- GPU memory is the runtime's. rt allocates it, and the device maps
its host-visible blocks into the guest: the pool's blocks and the
guest's Private blocks are rt's (
- Closed internal value sets are enums, converted with
TryFrom<u32>at the guest edge. A raw integer is kept only where the guest can write any value. There are nopub mod x { pub const … }integer-enum modules. - Refcounts: a type whose drop has an observable effect (a Metal object,
a host block, a device or display handle) never implements
Clone. Another reference is taken with.clone_ref(), everywhere, API types included (D6). A derive that would copy one does not compile. - Order-bearing types have an explicit
Dropthat takes their parts in the order the API shows (architecture 15.3). Field declaration order is never relied on. - Never guess a name for guest records, the wire and copies of Metal
structs. A field whose meaning nothing states is
field_xx(its byte offset in lowercase hex), and a name that is ours carries// name is ours: <evidence>. - An odd behaviour the guest or host can see carries a doc comment at
the code that says what it is, and a test named for the behaviour
(
denormal_depths_store_and_compare_as_metals). It is kept as it is: changing it is a deliberate change of behaviour, in a commit of its own that changes its test. - Comments say why, in terms of what the guest or host observes ("the stamp is in guest memory before its interrupt"), and may name a test.
- Each degradation is logged once per boot, then counted. A
degradation, fallback, refusal or unsupported case writes its first line
of each kind, and counts the rest:
-
The library's logger (
reims_vgpu_vulkan::core::logging) writes a warn or error line, and an info line that names akind, once per kind: the first at its level, each later one at debug, counted. The kind is the call site, and the class of the cause where the site names one,log::warn!(target: "…", kind:% = error; "…: {error}"): the cause's text up to its first digit, quote or;, so a number or an address in it makes no kind of its own. rt's error text can carry a value before those, a pixel format: where the code holds rt's error, the kind is its class (rt_platform::unbuilt::class), or the error is said as its class,;and its text (classed). A site with one cause names none. The logger tells apart the first 256 kinds; a line of a kind past them is written at debug and counted with the others past them. -
What the platform has not built and what rt refuses are answered as Metal's call answers where it fails, each kind's first on a line of stderr naming the call, and counted:
rt-unbuilt-<piece>andrt-refused-<kind>(rt_platform::unbuilt). -
rt's precision notes, where what the device makes can answer otherwise than Metal on the host's GPU, which rt records at the make and never decides at a draw, are read at each make of a pipeline, sampler or depth-stencil state, a texture and a render encoder's pass, and counted under rt's own code of each note,
metal2vulkan-degrade-<note>(itsPrecisionNote::code), each code's first on a line of stderr naming the call (rt_platform::precision). Nothing is read or counted at a draw or a dispatch. -
At each reset of the device, at the process's exit and when the host asks for them (
rvg_write_counts, which QEMU's device calls when itsx-write-countsproperty is set, asreims-ctl reportdoes on a running VM), two lines give the counts.reims-vgpu: degradation counts: <code> <n>, <code> <n>, …, on stderr, sorted by code, is every kind relayed or counted since the process began: the platform's (rt-unbuilt-<piece>,rt-refused-<kind>,rt-refused-texture-format-<n>and the otherrt-…codes; its stages'stage-unfilled-makeandstage-unfilled-dispatch, a pipeline state's make and a dispatch rt refused for a stage whose compile is not in its store, andstage-skipped-failedandstage-skipped-breached, a dispatch skipped after its stage's fill failed or breached, its command buffer failing (rt_platform::stage); and rt's precision notes,metal2vulkan-degrade-<note>),out-of-host-memory, and the reims-graphics device's completion rings' (control-ring-full,control-ring-post-waited,vblank-dropped,vt-ring-full,queue-ring-full,queue-ring-post-waited) and its decoder's (two-ranges-kept-whole, a command buffer dealt to two threads that the platform kept whole at a chunk's end, which fails at its stand-in;decode-malformed,decode-unknown-command,decode-refused,decode-bad-reference,decode-bad-resource-idanddecode-no-function, the messages it did not carry out, by why (DecodeError;decode-no-functionis a pipeline create naming no vertex function or kernel, as the bundle sends one where the device refused the library its functions were to come from, and no guest protocol error; one of a context closed before it came is owed nothing, and not counted), anddecode-faulted, those a raise kept it from, each kind's first logged;refused-object-named, each use of an object whose posted create the host refused, what named it dropped (graphics/decode/refused.rs);uploads-written-dropped, anUPLOADS_WRITTENrecord of noManagedbuffer, or past one, dropped, its command buffer running on, andmanaged-texture-two-copies, aManagedtexture of a shape that lies over its CPU copy, on unified memory, that the platform made two copies (graphics/decode/managed.rs);dynamic-library-create-failed, a dynamic library's create answered other thanRGFX_STATUS_OK;function-handle-unmade, aFUNCTION_HANDLE_CREATEwhose function the platform made none of, answered refused;pipeline-finish-failed, a pipeline create whose make's second step failed after its first made every answer of its reply, its draws and dispatches making what the finish left again at their encode (graphics/decode/mod.rs);stage-create-refused, a compute pipeline create held for its stage's fill and answered refused, once a create (graphics/compile.rs); the dispatch pre-pass'sdispatch-prepass-handed, the dispatches' pipelines it handed to its compile threads,dispatch-prepass-no-variant, a dispatch the platform would make nothing for, handed none,dispatch-prepass-past-most, those past a buffer's most, left to its walk,dispatch-prepass-dropped, those no thread took by the walk's end, dropped,dispatch-prepass-made-on-walk, those the walk made itself, anddispatch-prepass-waited, the walks' ends that waited for those being made, withdispatch-prepass-wait-nstheir nanoseconds waited anddispatch-prepass-wait-max-nsthe longest (graphics/decode/prepass.rs);read-only-pages-buffers, the no-copy buffers it made over pages their process maps read-only, andread-only-pages-kib, their bytes' sum in KiB, rounded up: a copy of each on every host, whose GPU writes are dropped (rt_platform/buffer.rs, "Read-only memory");read-only-pages-writes, a copy into or a fill of such a buffer where the platform makes it over the pages themselves, a write that reaches pages Metal leaves as they are (a diagnostic:graphics/decode/surface_pages.rs);no-copy-buffers, the no-copy buffers it made, andbuffer-escaped-gpu-address,-argument-encoder,-resource-idand-residency-set, those whose identity the guest noted escaped, by the act, withbuffer-escaped-read-only-pages, those of them over a copy of their pages, andescaped-copy-commits, the command buffers begun of a process that held such an escaped copy: no degradation, docs/graphics-kext/design.md, "A buffer's escaped identity"), its VA-API video's on the rt platform on Windows (rt-video-gpu-copy-declined, a picture the CPU copied, the GPU's copy declined;video-pictures-undrawn, a picture whose draw into a cache's planes over Direct3D 11 textures failed, which the CPU's copy landed there instead;video-drawn-waits-polled, a draw or a clear into such planes whose wait on its fence's event failed, which polled the fence's value instead,video-drawn-waits-queried, one whose signal of its fence was refused, which waited on an event query instead, andvideo-drawn-waits-held, one the GPU finished only past the device's deadline, in the hold after it;video-pictures-drawn, a picture drawn into a cache's planes over Direct3D 11 textures, andvideo-drawn-kib, the KiB of their crops: one GPU pass a picture that a Mac does not make;video-drawn-spares-usedandvideo-drawn-spares-missed, such a cache's surfaces that used a spare made ahead and those made on the guest's ring-0 thread,video-drawn-spares-waited, those that waited for the spare being made for them, withvideo-drawn-spares-wait-nstheir nanoseconds waited andvideo-drawn-spares-wait-max-nsthe longest wait, andvideo-drawn-spares-madeandvideo-drawn-spares-dropped, the spares made and those dropped untaken: no degradation), its VA-API video's on the rt platform on Linux (video-pictures-gpu-copied, a picture the GPU copied into its output's device caches from a scratch the driver's video processing wrote, andvideo-gpu-copied-kib, the KiB of their crops: one GPU pass a picture that a Mac does not make), its NVDEC video's on Linux (video-pictures-gpu-gathered, a VideoToolbox decoder's 4:4:4 picture the GPU wrote into its surface's two planes from the decoder's scratch: one GPU pass a picture that a Mac does not make, andvideo-gpu-gathers-failed, such a pass that ended in an error, its picture failing, as each of a lost device's does: a failure path), its video's on Linux (video-pictures-cpu-converted, a VideoToolbox decoder's picture the CPU wrote into its surface's two planes from a host surface of another layout: VA-API's packed 4:2:2 and 4:4:4 samples of HEVC's range extensions, and NVDEC's three 4:4:4 planes where the GPU's gather does not take them; one CPU pass a picture that a Mac does not make), its VideoToolbox paravirtual decoders' (video-vt-pictures-gpu-copied, a picture the GPU copied into the guest's lent surface, on a Mac host from VideoToolbox's IOSurface and on Linux from a scratch VA-API's video processing wrote where the driver declined the surface in place, andvideo-vt-gpu-copied-kib, the KiB of its planes' rows: one GPU pass a picture that a Mac does not make, docs/video/bugs.md D29;video-vt-surface-imports-madeandvideo-vt-surface-imports-reused, the imports of an IOSurface's memory made for a picture's copy, or kept from an earlier picture and used for it; andvideo-vt-pictures-cpu-copied, a picture the CPU copied there instead, the GPU's copy not taken: the fallback, a degradation) and its decodes' (video-landing-failure-carried, a picture whose copy or draw into its output's caches failed after its command buffer completed at its decode, the session's next decode failing in its stead;video-landing-failure-untold, such a picture of the session's last decode, with no next decode to fail in its stead, so the guest is never told;video-landing-stall-held, a picture that failed to land while the hardware's work ran past its deadline, its failure held until the device is done with the work;video-cache-acquire-refused, a plane of a picture that failed to land whose device cache's acquire the platform refused; and each picture a decode handed the guest, by its class:video-pictures-handed-landed, one that landed in its output,video-pictures-handed-failed, one that failed to land or whose decode was refused at its take, andvideo-pictures-handed-undecoded, one that no decode ran for), its video's GPU work whose wait failed (none on the rt platform, whose waits return once the work finished, a lost device's in an error: the bounds are guards), each a failure path (video_host::OutOfUse:video-staging-ended, a host video session whose staging ended at a second copy into or out of its device caches whose wait failed, each later picture or frame that stages a plane failing;video-nvdec-gathers-endedandvideo-xyuv-gathers-ended, a VideoToolbox decoder whose 4:4:4 writes by the GPU ended at a second pass whose wait failed, or on the XYUV route a second driver's write that stalled, its later 4:4:4 pictures copied by the CPU;video-gpu-copies-ended, a VA-API decode session whose GPU copies of its pictures from a scratch into their device caches ended at a second copy whose wait failed, its later pictures copied by the CPU), its NVDEC decodes' (video-pictures-past-registration, a picture whose plane ran past the bytes CUDA's registration kept for its memory's identity pinned, a registration of an earlier mapping of another length: never written by the GPU, copied by the CPU; a guard, since the device's reset ends the identities of the region's blocks), its VA-API encodes' (video-encode-quality-level-adjusted, a session whose driver refused the quality level asked and coded at the nearest it takes, or at its own: one a session), its NVENC encodes' (video-nvenc-copy-refused, a frame whose GPU copy into NVENC's input the platform refused, uploaded by the CPU), its encodes' sources (video-encode-fills-from-plane, a frame read from its source's plane images, its cache's surface's, rather than its cache's buffer: by NVENC's filler's copy, VA-API's fill kernel or a staging copy for an upload), VideoToolbox's paravirtual path's (vt-lends, the lends of the guest's surfaces itsVT_MESSAGEs gave the host,vt-lends-live-most, the most the host held at once, andvt-lends-given-back, those the host's sentrelsgave back: no degradation,graphics.rs'sVT_LENDS; andvt-lends-dropped-held, those the host dropped with norelsnaming them, which the guest's kext holds to its stop: a leak of its 64 lends;vt-message-refused, aVT_MESSAGEwhose bytes or surfaces lie outside the guest RAM the host maps, answered malformed;vt-message-unread, a message a session could not read, carried out no further;vt-decode-failedandvt-encode-failed, a decode or an encode that failed, the guest answered its status;vt-decode-stall-held, such a decode that failed while the hardware's work into the guest's surface ran past its deadline, its answer held until the device is done with the work;vt-encoder-open-failed, an encoder session the arm made no encoder for, refused at its start; andvt-encoder-property-refused, a property set the running encoder cannot take, answered its status, the property keeping its value:graphics/vt.rs,paravirt), the rt platform's on Windows (rt-d3d11-surfaces, the surfaces over Direct3D 11 textures it made, andrt-refused-d3d11-surface, those it refused), and the contexts' Private takes' (private-take-queued, a take that waited behind its context's earlier one;private-take-sourced, one its worker took from the source, andprivate-take-sourced-us, the source's time for them in microseconds;private-take-spanandprivate-take-span-us, those of them longer than the guest's 16 MiB block, an object's own span, and the source's time for them;private-take-lane-us-most, the longest a take held the thread that carried it out),managed-at-copy-unkept, theManagedbuffers' creates at their CPU copies' addresses that the platform made at others, kept there (docs/graphics-kext/design.md, "Managed buffers at their copies"),destroys-at-rt-address-in-flight-<kind>, the objects made at the platform's own address, a pin it did not keep or none, whoseOBJECT_DESTROYcame while a command buffer of their context was posted or running, by the kind of make (a diagnostic, no degradation:graphics/decode/unkept.rs, "Destroys in flight"), the trims of the heap after heavy pipeline makes on Linux with glibc (heap-trims,heap-trim-us, their time in microseconds, andheap-trim-returned-kib, the resident KiB they handed back: no degradation,os/linux/heap_trim.rs), the display's (display-view-refused, a draw of the display that kept the window's last frame, or a read of it that answered black, because the platform refused the display's view of the texture it shows, or the texture over the scanout's pixels a draw that scales the scanout samples:graphics/sink.rs, "The display's view" and "Sizes";display-table-refused, a colour's table whose draw the platform refused, kept for its colour, read and drawable format, whose draws took the colour's pass: "The colour as a table";display-frame-refused, a frame of the window the platform refused a pass or a command of, not presented, the window keeping its last complete frame: "A refused encode"), the surfaces' device caches' (surface-copy-refused, a copy of the host's own between a cache, its shapes, its wide home and its pages that the platform refused a command or the encoder of, counted at each refusal and made again only at the guest's next use, download or release: what it was to move is left as not copied, so aSURFACE_DOWNLOADwhose copy into the pages was refused, or given no command buffer, or whose cache's buffer was refused its memory, is answered failed (RGFX_STATUS_REFUSED) where the pages lack a write of the cache's, where it was answered done over the pages' older bytes before, and a fill, or a copy into a shape or a wide home, refused for a command buffer, or a fill there given no command buffer, fails it with Metal'sMTLCommandBufferErrorInternal, where a cache's refused memory fails it withMTLCommandBufferErrorOutOfMemory;surface-fence-refused, a writers' fence update at a guest encoder's end that the platform refused, which the host's copies of the encoder's writes wait for, so its command buffer fails with the internal error:graphics/decode/surface_cache.rs, "Refused copies"; andsurface-carry-refused, a deferred block'sSURFACE_PAGESwhose runs are not whole guest pages summing to its surface's bytes in the guest's RAM, or carry no page, answeredRGFX_STATUS_INVALID_ARGUMENTwith nothing made, withsurface-carry-refused-bytes, those surfaces' bytes summed:graphics/decode/mod.rs;pages-block-overlaps, a pages block whose runs met another live pages block's as its import was made, once a block, andpages-block-overlaps-live-most, the most such blocks live at once:graphics/decode/surface_pages/overlaps.rs), the pool's (pool-host-memory-refused, a take of host memory refused, the host giving no memory or the device not importing it:pool/host_memory_blocks.rs; and its takes' and zeroer's work:pool-take-zeroed-bytes, the bytes the take workers zeroed,pool-take-zero-skipped-prezeroed-bytes, a carve's bytes they did not zero as the zeroer had,pool-zeroed-ahead-bytes, the bytes the zeroer zeroed ahead of their takes,pool-zero-write-nsandpool-zero-write-max-ns, its writes' nanoseconds and the longest,pool-zero-hold-max-ns,pool-zero-hold-pick-max-nsandpool-zero-hold-mark-max-ns, its longest hold of the pool's lock for one chunk and of each of its parts,pool-zero-holds-over-50us, its holds longer than 50 µs, withpool-zero-long-hold-pick-nsandpool-zero-long-hold-mark-nstheir parts' nanoseconds,pool-take-claim-waits, the takes that waited for the zeroer's claimed chunk, withpool-take-claim-wait-nsandpool-take-claim-wait-max-ns, andpool-take-waits, the takes answered, withpool-take-wait-ns,pool-take-wait-queue-ns,pool-take-wait-growth-ns,pool-take-wait-zero-nsandpool-take-wait-growth-source-ns, their waits and its parts, each with its-max-ns, the longest:pool.rs,pool/takes.rs), and the guest's slow answers' (slow-answer-over-make, a ring-0 answer that went on its ring a frame, 16.7 ms, or more after the device read its command, during which a make of rt's pool ran, andslow-answer-over-make-max-nsthe longest;slow-answer-first-use-waits, the compute dispatches' first-use waits,rt-first-use-variant-waitsand their share ofrt-first-use-unfinished-waits, that met any such answer: no degradation,graphics/slow_answers.rs), and the guest's pipeline creates' waits for their replies (pipeline-create-replies, the replies posted;pipeline-create-reply-nsandpipeline-create-reply-max-ns, each create's nanoseconds from the host's take of it off ring 0 to its reply's post, summed, and the longest;pipeline-create-replies-over-16ms, those of 16.7 ms or more;pipeline-create-waiting-ns, the nanoseconds during which at least one create waited, the waits' union: no degradation,graphics/create_waits.rs); a boot's degradations are read from its last such line.reims-vgpu INFO reims_vgpu_vulkan::core::logging: lines repeated since the last count: <n> more of <file>:<line>[ [<kind>]] (<target>: <the first line's message>); …is how many lines of each kind the logger wrote at debug since its last such line. Besides, every minute where the counts changed since the library last wrote them (answer::COUNTS_REWRITE, on a thread the process's first device starts), the counts line alone is written again, so a process killed or crashed, which writes nothing at its end, leaves counts at most a minute old in its log. -
The pacing line. At a host's ask for the counts, after them, the library writes its build,
reims-vgpu: build <commit> on metal2vulkan <commit>, and, where the ask before it was 2 to 60 s earlier (reims-ctl reportasks twice, 10 s apart), one line over the span between the two asks (reims_vgpu_vulkan::pacing, whose doc says what each field counts and how each OS's thread times are read):reims-vgpu: pacing over 10.0 s: presents 59.9/s, interval p50 16.7 ms p99 17.9 ms; gpu per frame p50 4.1 ms p99 9.8 ms, busy 24%; cpu vcpu 112% (4 threads, busiest 98%), ours 79% (decoder 40% busiest 30%, completion 12%, window 8%, video 0%, m2v-submit 10%, graphics-compile 9%), rest 20%. Presents are each display's shows; the GPU's time is the command buffers' own GPU timestamps, merged where they overlap, per frame and as a share of the span; CPU is a percent of one core, of QEMU's vCPU threads, of ours by role (and our other threads by name), and of the rest of the process. Read it for a slow app, taken while it lags, beside the guest's owntop -o cpu -l 2(its second sample), which names the guest's processes that use the vCPUs:- guest-CPU-bound: the vCPU threads are pinned (one near 100% for a single-threaded app), while the GPU's time and our threads are low;
- GPU-side: the GPU's time per frame fills the present interval,
and
busynears 100%; - ours on the CPU: one of our threads is pinned, a role's busiest near 100%.
A diagnostic, like the counts: nothing decides on it.
-
No line at info or above fires per present, frame, draw, command buffer, ring message, interrupt or other per-event path: such a line is debug or trace, under a target of its own where a tool counts it (
reims_vgpu::graphics::shown,::libraryand::queues, which the lane gate's boots log at debug). Info keeps state changes (modes, the display between the scanout and a surface, starts and stops, a new kind of degradation) and summaries, at most once a minute. -
QEMU's
reims-graphics-pcisays a failure the guest can repeat witherror_report_once. -
The guest's kexts log a failure a caller can repeat once a boot per kind (
rgfxFirstCalls,guest/kext/src/RgfxTrace.hpp), and the Metal bundle once a process per kind (rgfxLogFirst,guest/bundle/src/RgfxLogOnce.hpp); the kind is the site, and a status, selector or reason where the site has several. Their summaries (the rings' room, the releases, the dormant blocks, the swaps, the surface copies) come at most once a minute, and a bring-up trace logs its first calls alone. The bundle's os_log lines go to its own subsystem,ai.aneesiqbal.reims-graphics, categorybundle(RgfxLog.hpp), solog config --subsystem ai.aneesiqbal.reims-graphicssets the level they are kept and persisted at. Its Objective-C sources log throughrgfxLogLine, at the default level, which the log store keeps, with the whole line public: an NSLog argument that is an object or a string made at run time reads<private>in macOS 26's log. Its lines startRGFX:.
-
- Tests sit in
mod testsbeside the code and are named by behaviour. - Integers: std spells wrapping, overflowing, widening and sign
reinterpretation (
wrapping_add,overflowing_mul,u64::from,cast_signed).core::numholds the rest:div0/rem0for a divisor the guest or host can make zero,Truncate::low_u32/u16/u8,ToUsize/ToU64(lossless on the 64-bit target),const_u64for layout constants,align_up_wrapping,add_u64_into_u32andrefresh_16_16. An integer result the guest sees goes through the rule ofnumthat names it: a mask bit throughbit32,bit64orbit64_set(the shift mod the width), a narrow field's widening throughzero_extend_16,sign_extend_16orsign_extend_32, and a copy between aliased mappings throughforward_copy. Division by a constant takes aNonZerodivisor built in a const block,x / const { NonZeroU64::new(8).unwrap() }, whichinteger_division_remainder_usedaccepts. A float conversion is anasat its site under#[expect(clippy::as_conversions, reason = "…")]. - Default rustfmt. A lint is lowered with
#[expect(lint, reason = "…")]on the narrowest item, in place of anallowwith a comment. - The option ROM's C (
firmware/) follows EDK2's style and the UEFI specification's names instead (architecture 11.4). Its registers carry the wire header's names (RGFX_REG_DOORBELL). - Branches are prefixed
steelbrain/. Commits follow AGENTS.md (emoji prefix, imperative, 72-column subject, body wrapped at 80 explaining why).