Files
reims-vgpu/docs/accuracy-ledger.md
T
Anees Iqbal 11055c78d5 ⬆️ Build on metal2vulkan development 82e7c39216
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.
2026-11-20 09:41:45 -08:00

11 KiB
Raw Blame History

Accuracy ledger

A ledger, not a journal: rows are edited in place. It lists where the Vulkan platform's answers can differ from Metal's. The platform (RtPlatform, over metal2vulkan-runtime) has no switches: no fast or exact form to choose, and no policy by device. What differs is of three kinds:

  • the device's own answers: values the host's GPU computes (its maths, sampling, conversions, blends and resolves), which the contract makes the device's own (AGENTS.md, "The contract"), each with its bound where one was measured;
  • what the platform has not built, and what rt refuses: answered as Metal's call answers where it fails, and counted;
  • the loss of the device, which rt never recovers from.

The process ends only where Metal ends it, or where the platform has no form for a raw value the guest sends (the Vulkan crate's answer, metal_reads_near_null and unrepresentable). REIMS_VGPU_STRICT=1 ends it where the host runs out of memory, mappings, files or commit charge, where by default the platform answers as Metal's call answers when memory runs out; the Vulkan crate's tests run strict.

The device's own answers

Where the device computes a value, the value is the device's. The bounds below were measured before the platform ran on rt, on the drivers each names, against Metal's answers; none has been measured again on rt.

The device's answer Bound against Metal's
The device's sampler (filter, footprint, level, anisotropy, sRGB, comparisons) linear filter 1 code, sRGB 1.83; the rest unmeasured
The device's conversion of a texel's codes 1 f32 ulp (8/16-bit), 0.18 code (5/6-bit packed)
The device's fixed-function conversion of a normalized vertex attribute's codes (UCharNormalized through Short4Normalized, UChar4Normalized_BGRA, Int1010102Normalized, UInt1010102Normalized) 1 f32 ulp at some codes on a driver whose conversion multiplies by the reciprocal; Metal's and Vulkan's rule is the correctly rounded quotient
Device maths library, division, fma Vulkan's precision table (e.g. Atan 4096 ulp) against Metal's 4-6
Device NaN bits; device min/max/clamp NaN bits, ±0 and denormal picks; on ANV and RADV a half read from its bits widens by the device's conversion, every value but a NaN exact, a NaN's bits the device's (ANV quiets a signalling one)
Device dot, mix, fast::sqrt dot (3n−1)·2^-24·Σ, mix 2^-21, sqrt 4.5 ulp
Device half rounding, widening and folding; a half texel's NaN AMD and Intel (RADV, ANV) round a computed half through an f32→f16→f32 conversion pair under Vulkan's 16-bit float controls (round to nearest even, denormals and signed zeros kept), which the spec makes exact (0 mismatches outside NaN inputs over every half and every half +, −, × pair on Iris Xe, the 780M and the 7900 XTX). The RTX 5080 rounds exactly (8192 of 8192 narrowed sums are Metal's). The RTX 3090, on the same 615.71.09 driver, and lavapipe drop the rounding: a half result keeps float precision, its differences compounding across operations. A value past half's range stays finite until a half store saturates it to infinity. Elsewhere 1 half ulp. NaN bits; half denormals may flush
The device's blend of a safe-math half output into a blended 16-bit float attachment at the largest operand: 16-bit float 2.5 half ulps on NVIDIA (blend-colour factors), 2 on AMD, Intel and lavapipe; 32-bit float 1 ulp on NVIDIA, 2 elsewhere
The device's decode of a 16-bit float texel (R16Float, RG16Float, RGBA16Float, RGBX16Float) that a half or float read answers a NaN texel reads as the decode's NaN, where Metal hands back the texel's own code; RADV's reads keep the texel's bits; every other value the texel's
The device's lines at width 1, which cover the pixel the driver chooses where a line runs through a vertex two pixels' diamonds share, as Vulkan's open diamond leaves it such a pixel, and the rest of a line that runs along such vertices, a row or a column from Metal's lower pixel: NVIDIA covers the other pixel, lavapipe leaves out a strip's first pixel where it starts on one; RADV and ANV not measured
The device's AVERAGE resolve of a multisampled colour attachment whose format has Metal's resolve rule at 2 and 4 samples a unorm, snorm or packed 16-bit channel within one code of Metal's and an sRGB one within two (NVIDIA at 4 samples; one elsewhere) on RADV, ANV, NVIDIA and lavapipe, each rounding an 8-bit tie down; a float channel in its last bits, unbounded; wholly at a NaN or infinite sample

What the platform has not built, and what rt refuses

The platform's pieces are built one by one. A call that reaches a piece not built yet answers as Metal's call answers where it fails (a nil object, a failed creation with an NSError, zeros from a getter, a command that encodes nothing), counted under rt-unbuilt-<piece>, the process's first of each piece with a line on stderr naming the call (crates/reims-vgpu-vulkan/src/rt_platform/unbuilt.rs, Unbuilt::ALL). A boot's degradation counts line lists every unbuilt piece it reached, with how many times. The pieces, by code:

Code What is not built
rt-unbuilt-buffer a Private buffer made with contents (newBufferWithDescriptor: with bytes): nil
rt-unbuilt-iosurface-texture a texture over a plane of an IOSurface of a format that reads beside its plane (a two-plane YCbCr or XR10 format over a surface of two planes or more): nil
rt-unbuilt-shared-texture shared textures and their handles (newSharedTextureWithDescriptor:): nil
rt-unbuilt-heap sparse heaps: nil
rt-unbuilt-mesh-pipeline mesh render pipeline states: nil and an NSError
rt-unbuilt-function-table function handles and visible function tables: nil
rt-unbuilt-argument-layout argument encoders' layouts (newArgumentEncoderWithArguments: and a function's): nil
rt-unbuilt-render-command indirect draws, indexed patch draws, mesh draws, tile dispatches, resolve textures, visibility results, and private settings other than Metal's default: nothing encoded
rt-unbuilt-compute-command an indirect dispatchThreads and an indirect stage-in region: nothing encoded
rt-unbuilt-predication command predication: a start encodes nothing, an end answers NO
rt-unbuilt-protection protection options other than 0: the command buffer runs as one with none
rt-unbuilt-fill-texture fillTexture:level:slice:region:bytes:length:: nothing encoded
rt-unbuilt-blit a texture fill with a colour, a buffer fill with a 4-byte pattern of more than one byte value, and copies with blit options: nothing encoded
rt-unbuilt-render-pass layered rendering, imageblock and threadgroup memory lengths, tile sizes and sample positions of a render pass: the pass renders without them
rt-unbuilt-rate-map rasterization rate maps: a layer's creation answers nil
rt-unbuilt-icb indirect command buffers, and the reservation of their resource indices: nil
rt-unbuilt-dynamic-library dynamic libraries (newDynamicLibrary:error:): nil
rt-unbuilt-resource-type a reservation of resource indices of a type other than 0, 1 and 5: nothing reserved
rt-unbuilt-tessellation-factor-scale a tessellation factor scale other than 1: patch draws read the factors unscaled

A call of a built piece that rt refuses (a limit, Metal's own refusal, a gap of rt's, a failed Vulkan call) answers the same way, counted under the error's kind, rt-refused-<kind> (RtRefusal::ALL: loader, below-floor, vulkan, metal, limit, no-such-block, thread, translation, gap, quiesced, no-device, other), its first line naming the call and rt's error. A texture rt makes none of for its pixel format is counted under its format's code instead, rt-refused-texture-format-<n>; a pipeline state's imageblock length rt refuses, rt-refused-imageblock-length; and a heap texture rt refuses on its place in its block, rt-refused-heap-texture-place. The boot diagnostics (rt_platform/diag.rs, lines that start reims-vgpu: rt-diag) add what the call asked of rt where its site names it.

The loss of the device

What runs instead of Metal's answer Where
The loss of rt's VkDevice is never recovered from, where Metal's device survives its GPU's recovery: rt makes its device once (crates/reims-vgpu-vulkan/src/rt_platform/swapchain.rs, "No device recovery"). Of the work the loss ends, the earliest submitted command buffer rt ends in flight fails as the hang, Timeout (2), once for the device, and every other as a victim, Internal (1), never DeviceRemoved (11) (crates/reims-vgpu-vulkan/src/rt_platform/command.rs). Every later commit ends at once, Internal (1), its handlers run (metal2vulkan-runtime's CommandBuffer::commit), and a wait for a shared event's value that lost work owed answers false (its SharedEvent::wait_until_signaled_value). rt checks for no loss where it makes an object: a new one is made where the driver's Vulkan calls make it, and any call rt refuses after the loss answers as Metal's call answers where it fails, a nil object or nothing, counted under rt-refused-<kind> (crates/reims-vgpu-vulkan/src/rt_platform/unbuilt.rs); none of its GPU work runs. The window presents no frame after the loss: a frame whose command buffer did not run is never presented (RtSwapchain::present), and a take the lost device fails ends its presenter's draws, a new presenter made at most 3 times in a row before the window stays as it is (crates/reims-vgpu/src/graphics/rt_window.rs, crates/reims-vgpu-window/src/present.rs). The guest's presents are still answered at the display's refreshes, a failed command buffer finishing as a completed one does (crates/reims-vgpu/src/graphics.rs, Presented; crates/reims-vgpu/src/graphics/present.rs). Nothing on the platform ends the process at the loss or after it: the guest runs on, every command buffer failing, until the VM ends. The first command buffer that fails with the device lost writes one line on stderr, once for the device, naming the GPU (its name, PCI vendor and device IDs) and how many command buffers were committed and not complete then, and each command buffer that fails so is counted, rt-device-lost (crates/reims-vgpu-vulkan/src/rt_platform/command.rs, "A lost device's line"); rt itself writes nothing at a loss. What the guest's apps and compositor do with these codes is not measured. Two rt walks lost their device while the platform answered 11 (DeviceRemoved) for every command buffer the loss ended: m3-max-53777 on an RTX 3090 and m3-max-54078 on an RX 7900 XTX. In each, the guest's running app logged nothing for its last ~3 minutes until the walk stopped it device loss