Files
reims-vgpu/docs/conventions.md
T
Anees Iqbal 35cea45c0e 📝 Say how a kind drops its values, and the logger's cap [ci skip]
The rule said a kind is the cause's text up to its first digit, quote or
`;`, but not what that is for, that rt's error text can carry a value before
any of those, nor that the kinds the logger tells apart are capped. It now
says a number or an address makes no kind of its own, that where the code
holds rt's error the kind is its class (unbuilt::class and classed), and
that the logger tells apart the first 256 kinds (logging::KINDS_KEPT), the
lines of kinds past them written at debug and counted together.

(cherry picked from commit 68a51193973bf4207f37e2a4b5c3ee4f44b6a768)
2026-12-03 11:27:16 -08:00

33 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 PG prefixes, no Objective-C class names, no dealloc/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.
  • Modules are named by responsibility (graphics/decode/cmdbuf.rs, memory/mapping.rs, display/pipeline.rs), never after -init or an Objective-C class. One module style: foo.rs beside foo/ (D44).
  • Code for one OS goes in files of its own (the window crate's native/macos/, native/linux/ and native/windows.rs, the Vulkan crate's os/macos.rs, os/linux.rs and os/windows.rs, the graphics crate's clock/, region/ and wake/, each unix.rs and windows.rs, the C API's ffi/catch/{macos,linux}.rs, Linux's of which Windows takes), which the module above them picks with #[cfg(target_os = ...)] (or unix and windows), rather than in cfgs 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's native/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 its cfgs 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's gpuAddress is its Vulkan device address, and a gpuResourceID a 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 without KVM_CAP_ARM_CACHEABLE_PFNMAP_SUPPORTED; the C API's pool_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-rt under 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.
  • 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 no pub 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 Drop that 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 a kind, 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> and rt-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> (its PrecisionNote::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 its x-write-counts property is set, as reims-ctl report does 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 other rt-… codes; its stages' stage-unfilled-make and stage-unfilled-dispatch, a pipeline state's make and a dispatch rt refused for a stage whose compile is not in its store, and stage-skipped-failed and stage-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-id and decode-no-function, the messages it did not carry out, by why (DecodeError; decode-no-function is 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), and decode-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, an UPLOADS_WRITTEN record of no Managed buffer, or past one, dropped, its command buffer running on, and managed-texture-two-copies, a Managed texture 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 than RGFX_STATUS_OK; function-handle-unmade, a FUNCTION_HANDLE_CREATE whose 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's dispatch-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, and dispatch-prepass-waited, the walks' ends that waited for those being made, with dispatch-prepass-wait-ns their nanoseconds waited and dispatch-prepass-wait-max-ns the longest (graphics/decode/prepass.rs); read-only-pages-buffers, the no-copy buffers it made over pages their process maps read-only, and read-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, and buffer-escaped-gpu-address, -argument-encoder, -resource-id and -residency-set, those whose identity the guest noted escaped, by the act, with buffer-escaped-read-only-pages, those of them over a copy of their pages, and escaped-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, and video-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, and video-drawn-kib, the KiB of their crops: one GPU pass a picture that a Mac does not make; video-drawn-spares-used and video-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, with video-drawn-spares-wait-ns their nanoseconds waited and video-drawn-spares-wait-max-ns the longest wait, and video-drawn-spares-made and video-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, and video-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, and video-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 video's on a Mac host (video-vt-pictures-gpu-copied, a picture the GPU copied into the guest's lent surface from VideoToolbox's IOSurface, and video-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-made and video-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; and video-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, and video-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-ended and video-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 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 its VT_MESSAGEs gave the host, vt-lends-live-most, the most the host held at once, and vt-lends-given-back, those the host's sent rels gave back: no degradation, graphics.rs's VT_LENDS; and vt-lends-dropped-held, those the host dropped with no rels naming them, which the guest's kext holds to its stop: a leak of its 64 lends; vt-message-refused, a VT_MESSAGE whose 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-failed and vt-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; and vt-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, and rt-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, and private-take-sourced-us, the source's time for them in microseconds; private-take-span and private-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, the Managed buffers' 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, whose OBJECT_DESTROY came 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, and heap-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 a SURFACE_DOWNLOAD whose 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's MTLCommandBufferErrorInternal, where a cache's refused memory fails it with MTLCommandBufferErrorOutOfMemory; 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"; and surface-carry-refused, a deferred block's SURFACE_PAGES whose runs are not whole guest pages summing to its surface's bytes in the guest's RAM, or carry no page, answered RGFX_STATUS_INVALID_ARGUMENT with nothing made, with surface-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, and pages-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-ns and pool-zero-write-max-ns, its writes' nanoseconds and the longest, pool-zero-hold-max-ns, pool-zero-hold-pick-max-ns and pool-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, with pool-zero-long-hold-pick-ns and pool-zero-long-hold-mark-ns their parts' nanoseconds, pool-take-claim-waits, the takes that waited for the zeroer's claimed chunk, with pool-take-claim-wait-ns and pool-take-claim-wait-max-ns, and pool-take-waits, the takes answered, with pool-take-wait-ns, pool-take-wait-queue-ns, pool-take-wait-growth-ns, pool-take-wait-zero-ns and pool-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, and slow-answer-over-make-max-ns the longest; slow-answer-first-use-waits, the compute dispatches' first-use waits, rt-first-use-variant-waits and their share of rt-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-ns and pipeline-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 report asks 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 own top -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 busy nears 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, ::library and ::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-pci says a failure the guest can repeat with error_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, category bundle (RgfxLog.hpp), so log config --subsystem ai.aneesiqbal.reims-graphics sets the level they are kept and persisted at. Its Objective-C sources log through rgfxLogLine, 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 start RGFX:.

  • Tests sit in mod tests beside 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::num holds the rest: div0/rem0 for a divisor the guest or host can make zero, Truncate::low_u32/u16/u8, ToUsize/ToU64 (lossless on the 64-bit target), const_u64 for layout constants, align_up_wrapping, add_u64_into_u32 and refresh_16_16. An integer result the guest sees goes through the rule of num that names it: a mask bit through bit32, bit64 or bit64_set (the shift mod the width), a narrow field's widening through zero_extend_16, sign_extend_16 or sign_extend_32, and a copy between aliased mappings through forward_copy. Division by a constant takes a NonZero divisor built in a const block, x / const { NonZeroU64::new(8).unwrap() }, which integer_division_remainder_used accepts. A float conversion is an as at 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 an allow with 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).