The Metal rail was the last thing on this device still drawing through QEMU's
Cocoa display. That made the one measurement a `--backend both` binary exists for
— the same guest stream through native Metal and through MoltenVK, with one
variable changed — a comparison across two different display stacks: two
compositors, two present cadences, two input paths, and a frame that differed
between the rails with no way to say which layer changed it.
So the Metal rail gets a presenter of its own. `backend/metal/window.rs` is a
`CAMetalLayer` on the window's own `NSView` and a one-triangle render pass that
fits the published frame into the next drawable; it is reached through the six
`Backend::window_*` methods the previous commit introduced, so the window itself
learns nothing about which rail it is talking to. Both rails now fill one window,
one event loop, one viewport and one input path.
Three decisions worth naming:
* **CPU bytes, always.** This rail retains no texture past the encode that
produced it, so there is no resident for a present to name and
`WindowResident` still carries no Metal variant. That is not a step down: the
Cocoa path read the same frame back through host memory before this window
existed, so nothing here adds a copy.
* **A render pass, not a blit encoder.** The frame has to be aspect-fitted and
`MTLBlitCommandEncoder` cannot scale. The viewport is `aspect_fit` — the same
function the pointer path maps through, so presentation and input stay one
unit — and the pass's clear colour is the letterbox.
* **A sublayer, not the view's layer.** `setLayer:` makes a view layer-hosted,
and winit's view is already layer-backed; handing AppKit's own layer over puts
two owners on one object. Hosting underneath is also what MoltenVK does for a
`VkSurfaceKHR` here, so the two rails end up presenting through the same kind
of layer. `addSublayer:` retains, so the presenter removes itself on drop —
without that, detaching leaves the last frame frozen on a live layer.
`host-window` no longer implies `backend-vulkan`; it names the windowing stack
and nothing else, and each rail's surface half travels with that rail's feature.
The meson `metal` arm builds it, and `vm/boot-arm64.sh` now chooses
`-display none` for the device rather than for one of its rails.
Four raw-Metal calls this needed are added checked, in the module that exists
for exactly that: `newLibraryWithSource:` (metal-0.33 asserts on a nil library,
inside a frame the event loop calls, where a panic aborts the process),
`newFunctionWithName:`, `newRenderPipelineStateWithDescriptor:`. The NSError
text walk the first two need was already written twice and is now written once.
Verified live, arm64/macos-13/reims-vgpu-mmio, `REIMS_VGPU_RAIL=metal` on a
`--backend both` build: `display=reims-host-window backend_rail=metal`, the
window opens at 1920x1080, 144 frames published across the boot with
`dropped=0`, and no `metal_window_*` refusal in the whole run. The guest settles
to `draws=0` at an idle desktop and a QMP pointer move brings it straight back
(`draws=42`) with the window publishing fresh frames — so the quiet is an idle
guest, not a wedged one.
The picture itself is checked by rendering, not by looking: this host's display
was asleep and every screen capture came back black, so the two new tests run the
presenter's real encode into a readable texture. A 2x2 source into a 2x2 target
lands every destination pixel centre on a source texel centre, so orientation is
an exact comparison rather than a tolerance; a 2x1 into a 2x2 proves the fit and
that the bars are the clear. Both would have caught a flipped `uv` or a viewport
that quietly covered the whole target — neither of which any counter reports.
Also: feature matrix green on all five cells, `cargo test` green on metal,
vulkan+host-window and both+host-window (1381 / 2179 / 2260 lib tests).