Commit Graph
76 Commits
Author SHA1 Message Date
YXC0915 2df30ffea9 🆕 Pin the organization runtime dependencies [skip ci]
Resolve metal2vulkan and reims-util from the maintained Reims-Go repositories. The new Vulkan pin establishes a suspend baseline for these build inputs.
2026-12-03 02:53:58 +08:00
Anees Iqbal e922d910ca 🐛 Mark a borderless window full screen to the Windows shell
On a Windows host with the taskbar set to hide itself, a borderless window
let the taskbar come up over it when the pointer met the screen's bottom edge.
The window is SDL's desktop full screen, a popup over its monitor's rect, but
SDL 3.4.18 never tells the shell a window is full screen: it makes the
taskbar list only for a window's progress.

The window now marks itself full screen through the shell's documented call,
ITaskbarList2::MarkFullscreenWindow, once SDL has made it so as it shows, and
takes the mark away before it hides at the display's end. The taskbar list is
made and initialised as its contract asks (CoCreateInstance of
CLSID_TaskbarList on the UI thread, which made the window, with COM
initialised there, then HrInit) and is held while the mark is. A step Windows
refuses is logged, and the window opens as before. Linux and macOS are
unchanged.

What changes for the host: a borderless window on Windows keeps an auto-hide
taskbar down while it is active. features.md gains the entry, with its manual
check on a Windows host.
2026-11-26 20:21:25 -08:00
Anees Iqbal 20c3300733 ⬆️ Build on metal2vulkan development 7c1baad228
Moves the runtime pin from ce998742d7 to 7c1baad228, on metal2vulkan's
development, for its overlapping texture copies and its stage bound.

For the guest:
- A copyFromTexture between overlapping regions of one texture now copies, as
  from the source before the copy, where rt refused it before (TextureCopy).
- A kernel past the stage bound (an entry weight over 99,109, the bound the
  translator refused at ce998742d7 as StageSize) is still not made. rt now
  compiles such a kernel only in a helper process, which the library does not
  run yet, so rt refuses it as StageUnfilled. Where rt makes a VkPipeline at
  the state's make (a tiled or square kernel, or one with a required size or a
  declared bound of threads), the make fails as before: nil and an NSError in
  rt's domain, code 0. A kernel with neither a required size nor a declared
  bound now gets a state, and each of its dispatches is refused and skipped,
  counted, where its make failed before. The stage helper's batch fills both.
- A render stage past the bound is refused by rt (StageSize, RenderStage)
  where the translator refused it before: the make fails as before.

For the host: these refusals count as rt-refused-gap, under StageUnfilled or
StageSize, where they counted as rt-refused-translation, Translation-StageSize.
rt's prepare_dispatch now answers a stage refusal, which the pre-pass leaves to
the dispatch. SEMANTICS_VERSION goes from 2256 to 2257, so the pipeline caches
are keyed afresh and the first boot after the move compiles cold. rt's floor
now requires pipelineCreationCacheControl. The runtime takes sha2 0.11, already
in the lock.
2026-11-21 06:47:44 -08:00
Anees Iqbal 4983793687 🐛 Make no Vulkan call on rt's lost device from a display's window
rt makes one device and no new one after a loss. Yet once the device was
lost, a display's window kept its swapchain going: the frame that ended
lost made the swapchain stale, and each draw after it, every 8 ms, asked
vkCreateSwapchainKHR for a new one, which answered VK_ERROR_DEVICE_LOST and
was asked again. On the Windows mini's UHD 630 a boot lost rt's device about
60 s in, and after some minutes of these calls one died in Intel's driver, an
access violation (a write of 0x338) in igvk64.dll on the window's thread,
which ended QEMU. The calls are valid on a lost device, but none can do
anything there.

The device is now known lost (DeviceLoss::is_lost) once one of its command
buffers fails lost, a frame's command buffer ends with rt's lost-device
error, or one of the swapchain's own calls answers VK_ERROR_DEVICE_LOST (one
place, answer_seen, where rt's coming report of a consumer's loss goes).
From then on the swapchain makes no create, take, wait, present or remake,
and commits no clear at a retire: each draw answers Acquired::Lost, and only
its end's destroys reach the device. The window's render thread keeps that
presenter to the window's end (Drawn::Lost), so the window keeps showing the
last frame it presented and draws no more, and the sink makes no presenter
or surface on a lost device.

What the host sees: after a loss the window stays open with its last frame,
one line says the device is lost and the window stops presenting, and the
process no longer dies in the window's thread. A window opened after the loss
stays empty. The guest's work fails as it did. No test held the old retries;
new tests cover the swapchain (on a headless surface), the presenter and the
sink.
2026-11-20 13:49:17 -08:00
Anees Iqbal 2834c057ee 🐛 Drop the dependencies cargo no longer resolves from the lock
The pin's lock kept serde under metal2vulkan and metal2vulkan-air, and
serde_derive under serde, which cargo's resolve at metal2vulkan 82e7c39216
does not list: a build rewrote those three lines (the pin's lint job,
m3-max-59328). The lock now holds what that resolve writes, still with no
source lines for the metal2vulkan packages. What builds is unchanged.
2026-11-20 09:46:43 -08:00
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
Anees Iqbal 8a4fc60779 🔥 Delete the testkit's reader of recorded Metal answers
core::testkit::metal_answers read Metal's answers recorded beside the old
platform's tests, the long ones as xz files through lzma-rs. Those tests and
their answer files went with VulkanPlatform, so nothing calls it and no
answer file is tracked. lzma-rs, byteorder, crc and crc-catalog leave the
lock with it.
2026-11-20 08:29:28 -08:00
Anees Iqbal 1ef5403e51 🔥 Delete VulkanPlatform and the metal2vulkan-runtime crate
RtPlatform, over metal2vulkan-rt, has been the library's platform since the
`rt` feature went on by default; VulkanPlatform, over metal2vulkan-runtime,
built only without it. This deletes VulkanPlatform, every module only it
used, the metal2vulkan-runtime dependency, and the `rt` feature with its cfg
arms in reims-vgpu-vulkan, reims-vgpu and reims-vgpu-c. Every handle was
already made on RtPlatform, so neither the guest nor the host sees a change;
the C header, QEMU, the guest's sets, the ROM and reims-ctl are untouched.

The tests of the deleted code go with it. The on_vulkan tests that held the
old platform now hold rt. The 15 that rt fails are ignored, each with the gap
rt names: texture buffers, a texture over a buffer or an IOSurface plane, a
rasterization rate map, visibility result modes, a kernel's stage input,
tessellation, a buffer of 0 bytes, a texture at the guest's resource ID, and
the guest's class, which rt is not told.

.config/nextest.toml drops the overrides of the deleted tests, and
lane-gate.sh reads the pin from metal2vulkan-rt's line.
2026-11-20 06:50:02 -08:00
Anees Iqbal 621054cba6 🆕 Build our side of metal2vulkan-rt's seam on rt at the pin
The dry link of metal2vulkan-rt found three gaps on our side of its seam.
13 of 178 compute pipelines were refused with IndicesNotGranted, because
we granted rt no sampler indices. rt gives a block back by its handle, but
the pool names blocks by number. And rt's copies between a buffer and a
texture take no MTLBlitOption.

This links rt at the same commit as the runtime it replaces and builds each
gap's answer. No path of the library's reaches it before the cutover.
Unit tests run it on the GPU each test host holds.

- reims-vgpu-vulkan's seam::SamplerIds grants rt the device's whole
  sampler range (1 to 3,999) once, and numbers each compute and render
  state's samplers through rt's sampler_ids callback. A sampler equal to
  one a live state holds shares its ID, any other takes the lowest free
  ID. IDs go back after rt's state does, and a failed creation holds none.
- seam::blit maps options 0 to rt's copy_from_buffer and
  copy_from_texture_to_buffer. Any other value is BlitError::Options, with
  nothing recorded.
- reims-vgpu's pool::rt_blocks::RtBlocks is the pool's BlockSource over
  rt. It keeps each block handle by its number and gives the handle back
  on release. The block length and the zero mark are left as they are.
2026-11-18 18:59:40 -08:00
Anees Iqbal 0287abaf13 ⬆️ Build on metal2vulkan c471372f87's runtime
Moves the runtime from 9ce951f521 to c471372f87 (RUNTIME 2359 -> 2378;
SEMANTICS_VERSION 2124 -> 2125). The runtime's crate now turns on the
translator's serde feature for its repro bundles, so the lock adds serde to
metal2vulkan and metal2vulkan-air and serde_derive to serde. A device's
shader cache directory is now an Option (RUNTIME 2360: a memory-only device
has none), so the shader cache test expects the platform's directory. What
it brings:
- RUNTIME 2377: on Windows, long Shared, write-combined and Managed buffers
  and ICB records take fresh pages where the device imports host pointers and
  found no import tax, as on Linux and macOS, so a recovery keeps an ICB's
  records there too.
- RUNTIME 2375, 2373, 2378: making a texture, heap, view or buffer compiles no
  kernel; its own moves and decode kernels are made at first use or before
  the submission's lock.
- SEMANTICS 2125, RUNTIME 2376: a rate map's region copy records one row.
- RUNTIME 2363, 2365, 2369, 2371: compute dispatches reuse a plan made for
  another grid of their class, take sampler states only where needed, hold
  their pipeline objects by address and keep 16 plans a state.
- RUNTIME 2361, 2364, 2368, 2370, 2372, 2374: host RAM copies and encoders:
  kept plans are found as runs merge and bind their table from a buffer,
  a copy's imports are one flat list, and runs of one resource and dirty
  pages are noted as one use.
- RUNTIME 2360, 2362, 2366, 2367: a missing shader cache directory makes a
  memory-only device, a copy queue's buffer keeps commit order behind a held
  batch, repro bundles at a creation refusal (off by default), and a device
  made with its least queue plan reserves only what that plan reserves.
metal2vulkan's round at c471372f87 lists the degradation kinds added since
the last pin (none, per its notes); the boots' degradation counts show what
guests reach.
2026-11-15 12:51:53 -08:00
Anees Iqbal b507f52b2e 🆕 Read the fuzzers' CPU time on Windows too
The video crate's tests did not build for Windows: the fuzzers' harness
(codec/fuzz_support.rs) bounds each input by its CPU time, which it read
through clock_gettime alone. On Windows it now reads the calling thread's or
the process's kernel and user times, GetThreadTimes and GetProcessTimes, which
count in 100 ns units. The harness's OS code moves into files of their own,
fuzz_support/unix.rs and windows.rs, as conventions.md asks: the Unix clock and
SIGABRT report as they were, and on Windows no abort report, since abort there
is a fast fail and raises no signal. libc becomes a Unix-only dev-dependency.
2026-11-15 09:47:37 -08:00
Anees Iqbal 258a27dc5d 🆕 Name the library's build by a file's ID and times on Windows
The device keeps its pipeline answers under the identity of the library's
build: the executable's path, device, inode, size and times, read with Unix's
MetadataExt. That reading moves to graphics/answers/unix.rs as it was, and
Windows gets its own in graphics/answers/windows.rs: the volume's serial
number, the 128-bit file ID, the size, and the creation, last write and
change times (GetFileInformationByHandleEx), seven words after the path as on
Unix. A file written again in place differs in its change time, and one
renamed over it in its ID too, as a new inode does on Unix.
2026-11-15 07:44:23 -08:00
Anees Iqbal 7c672c67f8 🆕 Give the C API its Windows forms: a section's handle, an event
On Windows the host's guest RAM is a view of a pagefile-backed section and
QEMU's EventNotifier is a manual-reset event, so the two items that take the
host's OS handles get a form of Windows's own, under #if defined(_WIN32)
(cbindgen's [defines] maps cfg(windows) to it):
- RvgMemoryRangeFile is {void *handle; uint32_t flags; uint64_t offset;}, 24
  bytes; the create checks that a view the library may write maps the range's
  bytes from offset (MapViewOfFile, unmapped at once) and duplicates the
  handle (memory/windows.rs, with its tests);
- rvg_graphics_device_set_doorbell takes the event's handle.
A Windows device makes no bell, so it is handed neither route function.
Linux and macOS keep their forms and checks, under #if !defined(_WIN32); the
header's text changes there only by those guards and docs, and nothing the
guest or the host sees changes.
2026-11-15 06:43:52 -08:00
Anees Iqbal b4b4be76d9 🆕 Read the clocks on Windows, as macOS answers them
The first piece of the Vulkan platform's OS module for Windows, which the
port needs for the library to run there (os/windows.rs, built on Windows
alone; the module's other services follow in their own commits).

WindowsClock is core's Clock:
- The monotonic clock is the interrupt time (QueryInterruptTimePrecise,
  100 ns units). It counts the time the host sleeps, as macOS's
  CLOCK_MONOTONIC_RAW and Linux's CLOCK_BOOTTIME do.
- The wall clock is GetSystemTimePreciseAsFileTime, in nanoseconds since
  the Unix epoch.
- Timed waits answer as libc++'s do on macOS, read on the deadline's own
  clock, as LinuxClock's do.

Linux and macOS build nothing new.
2026-11-15 06:19:49 -08:00
Anees Iqbal 6a27b551b7 ⬆️ Build on metal2vulkan 74e6846f93's runtime
Moves the runtime from the v0.2.0 release, d9236a8a11, to 74e6846f93
(RUNTIME_VERSION 2342 -> 2344; SEMANTICS_VERSION stays 2122). What it brings:
- RUNTIME 2343: a GPU time its calibration still places beyond 20 us is
  announced and counted, as the degradation kind
  loosely-calibrated-gpu-times. The answer module places it with the other
  GPU-time kinds, relayed: the run's length the guest reads stays exact, and
  gpu_times_from_host leaves it unreachable. Nothing ends the process on it.
- RUNTIME 2344: Device::new_command_queue_for_copies, a queue on the copy
  engine where the device has one fit for it (NVIDIA; None elsewhere), which
  nothing of ours calls yet, and consecutive buffer copies between the same
  two buffers merged into one vkCmdCopyBuffer on every queue.
- The runtime builds for Windows: libc on unix hosts only and windows-sys on
  Windows (the lock's one new edge), its Linux-only items gated.
No device answer, GPU family, feature query or fatal path changes, so no
guest boot is owed by AGENTS.md; the merge legs run every test.
2026-11-15 06:18:58 -08:00
Anees Iqbal 32d9927a77 🎨 Read the device's monotonic clock through one module per OS
The device stamps HOST_TIME, each VBLANK and its other times on the host's
monotonic clock, which two private copies of a CLOCK_MONOTONIC read gave
(device.rs and keep.rs). They become one clock module, picked per OS as
docs/conventions.md asks: unix.rs keeps CLOCK_MONOTONIC on Linux and macOS,
so the guest reads the same clock there, and windows.rs reads the
performance counter, the host time domain Vulkan's calibrated timestamps
name on Windows (VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_KHR), for the
Windows host port. windows-sys (0.61.2, already reachable through the
lock's windows-link) carries the Win32 calls, each crate naming the API
areas it uses.
2026-11-15 05:05:59 -08:00
Anees Iqbal b157365a1e ⬆️ Build on metal2vulkan v0.2.0 (d9236a8a11)'s runtime
Moves the runtime from ce54ad8b25 to the v0.2.0 release, d9236a8a11
(RUNTIME_VERSION 2342, SEMANTICS_VERSION 2122, ARTIFACT_FORMAT_VERSION
523). It adds no degradation kind. Two of our tests follow its answers:
the policy's exact forms name its new indirect_records field, and the
two-plane YCbCr argument-buffer write test checks 500 like the other
formats now that the runtime writes those slots through. The accuracy
ledger gains the row for the indirect-records policy.

Checked, at the owner's word, with one cold boot of the x86-64 macOS 26
guest on the RTX 5080 over this tree and vendor/qemu's 2026-11-13 move.
2026-11-15 02:35:03 -08:00
Anees Iqbal c772b67ad0 🔥 Drop objc2-io-surface, which nothing uses since the surfaces went
The deletion of the host-OS surfaces removed os/macos/iosurface.rs, the
crate's one user of objc2-io-surface, and left the dependency behind, so
cargo warned of an unused dependency on every macOS build. It goes from
the Vulkan crate's manifest, the workspace's and the crate's lock entry;
the package itself stays in the lock, as another objc2 crate depends on
it. Nothing the guest or host observes changes.
2026-11-14 09:58:05 -08:00
Anees Iqbal fd591f5039 🎨 Fold reims-vgpu-core into reims-vgpu-vulkan as its core module
The Vulkan crate is the library's only platform since the Metal platform
went, and every crate that links core links the Vulkan crate too, so core
needs no crate of its own. Its files move unchanged under
reims_vgpu_vulkan::core (crate::core in the Vulkan crate), the module the
video crate's layout already uses; its #[macro_export] macros stay at the
crate's root, so reims_vgpu_core::metal_check! is reims_vgpu_vulkan's now.
core's lint set is the module's inner attributes, as it was the crate's.
Nothing the guest or the host observes changes, and reims_vgpu.h is the
same. Core's log lines name reims_vgpu_vulkan::core:: as their target in
place of reims_vgpu_core::, so reims-ctl's example filter says so.

The testkit feature is the Vulkan crate's, reims-vgpu-vulkan/testkit, and
the crate's integration tests turn it on through a dev-dependency on the
crate itself, as core's dependents turned core's on. core's tests keep
their paths below core:: in the Vulkan crate's unit tests, and cargo xtask
check's x86_64-apple-darwin leg runs those alone: -p reims-vgpu-vulkan
--lib -E 'test(/^core::/)'. The tests that run themselves again in a child
name themselves below core:: too (a child given a name that matches no
test runs nothing and passes), and the memory map's tests take the lines
of the targets below reims_vgpu_vulkan::core::memory.

The macOS test that declares _exit now declares it safe, as the testkit
does: rustc's clashing_extern_declarations compares the declarations
within one crate.
2026-11-08 01:55:07 -08:00
Anees Iqbal 6fb33ecd27 🎨 Rename the reims-graphics crate to reims-vgpu-graphics
The crate that holds the reims-graphics device's wire and transport now
carries the library's prefix, as reims-vgpu-video does: its directory is
crates/reims-vgpu-graphics, its package reims-vgpu-graphics, and its Rust
path and log target reims_vgpu_graphics. The guest's, the option ROM's and
Ambrosia's Makefiles include the wire header from the new directory, and the
prebuilt records name it there.

Nothing changes for the guest or the host. The device keeps its name
(reims-graphics, QEMU's reims-graphics-pci, PCI 1234:5247), and the wire
header keeps its file name and RGFX_ symbols. The C API header is unchanged,
and the prebuilt kexts and option ROM are byte-identical; only the records'
paths and source hashes move. A log filter names the crate's lines by its
new target (REIMS_VGPU_LOG=info,reims_vgpu_graphics=trace), a diagnostic.
2026-11-08 01:37:50 -08:00
Anees Iqbal f2d65f5e3b 🔥 Delete the window's drawable path
On macOS a FrameSink could draw into each drawable the render thread took of
the layer (`draw`, with `device` and `render_target_only` to set the layer up),
or present through a presenter of its own (`presents`, `presenter`). Only the
Metal platform's sink drew into drawables, and it is gone: the one sink left,
the Vulkan platform's, presents through its swapchain, answering no device, a
draw that drew nothing, and drawables that take transfers. So macOS's FrameSink
is now Linux's, `presenter` and `guest_cursor_position`; the render thread
always draws through the presenter; and the layer is set up as it was for that
sink: no device (the swapchain sets it), not framebuffer-only. The sink's two
per-OS impls become one, and reims-vgpu no longer links objc2-quartz-core, its
objc2 and objc2-metal only in its macOS tests.

Nothing changes for the guest or the host. The view's layer test now checks
the one setup there is (`a_layer_is_bgra8_opaque_and_takes_transfers`); a
window whose display ended before it opened, which draws nothing, no longer
sets its layer framebuffer-only. features.md keeps every entry and guard.
2026-11-07 23:42:06 -08:00
Anees Iqbal 38ebf4d913 🔥 Delete the Metal platform
The owner's order: the library runs on the Vulkan platform alone. On Linux
it already did; on a Mac it now builds over MoltenVK, for development and
tests, and ships nowhere. crates/reims-vgpu-metal goes whole, with its
workspace entry and every use:

- reims-vgpu: platform/metal.rs, graphics::metal (the macOS sink),
  display_cost.rs and cfg(vulkan_platform) go; DefaultPlatform is
  VulkanPlatform everywhere, and the Vulkan crate and the runtime are plain
  dependencies. `vulkan` stays as an empty feature for the builds that name
  it.
- reims-vgpu-window: the AppKit side's message layer, clock and threads
  are the Vulkan crate's (reims_vgpu_vulkan::os::msg, OsClock, OsThreads).
- reims-vgpu-vulkan: the macOS OS layer moves in from the Metal crate, cut
  to what is used (msg.rs, clock, threads, Mach VM, IOSurface,
  autorelease); shaders.metal moves here, without the XR10 paging kernels
  nothing calls since the paravirt protocol went. shaders.metallib and
  no_draw.metallib are compiled again on the M3 Max with metallibs.toml.
- reims-vgpu-c: Plat is VulkanPlatform; `vulkan` stays as an empty feature.
  The C API's header does not change.
- xtask dist builds the Vulkan platform on every OS into dist-vulkan, and
  refuses `--platform metal`; check tests one feature set everywhere. The
  Makefile's RUST_DIST follows.

The tests whose oracle was the Metal platform keep its answers: each Metal
leg was run on the M3 Max (macOS 27.0.1) before the crate went, and its
answers are the test's fixed expected values, in text files beside each
test (metal_answers/, large ones as a digest or in an xz companion), read
by core's testkit::metal_answers. They are Metal's, never to be rewritten
from this library's own output. Tests that only measured the Metal platform,
or duplicated a literal-checked Vulkan test, go.
2026-11-07 23:22:28 -08:00
Anees Iqbal f3b120ad16 🎨 Collapse the video crates into reims-vgpu-video
The host's video was five crates: core, codec, conformance, and the VA-API
and NVIDIA backends, with the examples and tools split between two of them.
One device uses them, from one library. They become one crate,
crates/reims-vgpu-video, with the modules core, codec, vaapi and nvidia, the
last two built on Linux alone. The conformance readers and writers, which only
the examples use, stay a crate of their own beside it, at
crates/reims-vgpu-video/conformance (reims-vgpu-video-conformance). The files
move with git mv, their paths rewritten, with no re-exports left behind. The
NVIDIA examples build on every host, as a stub off Linux.

Dead code goes with them: NVDEC's VP9 path and the codecs nothing asks it for
(NvdecCodec is H.264 and HEVC), and the Vulkan platform's listing of the
host's GPUs (host_gpus::hardware_gpus and gpu_device_gpu), which nothing
called, with its serde_json dependency.

AGENTS.md, development.md, docs/video and the nextest filter name the one
crate.
2026-11-07 21:32:05 -08:00
Anees Iqbal b0ff714f2b 🔥 Delete Vulkan Video, the graphics device's third video arm
The owner's order: the host's video is VA-API's and NVDEC's alone. Vulkan
Video was the third arm the reims-graphics device's video tried, after NVDEC
and VA-API.

- reims-vgpu-video-vulkan goes whole, with its examples and checks, and
  reims-vgpu's arm over it (graphics/vulkan/video.rs). The chooser tries
  NVDEC, then VA-API, and offers no video where neither takes the device.
- The Vulkan platform makes its devices with no video-decode queue, no
  queue reserved for the arm's copies and none of Vulkan Video's
  extensions, which only the arm used.
- reims-vgpu drops ash, which only the arm used.
- What only the arm or the deleted paravirt devices used goes from the
  shared crates: core's GuestSurface, GuestHold, PlaneDestination and
  PlaneSource with the splits that made them, and GuestTarget's hold,
  with_hold, written_size and TargetPlane::end_of; the codec crate's
  raise_mv_lengths, which mended NVIDIA's Vulkan Video SPS; and the
  conformance crate's AV1 and VP9 track readers. Zero copy keeps its
  import of a stalled write alone, as no host hold is given it.
2026-11-07 19:52:31 -08:00
Anees Iqbal 1b7eda226c 🆕 Decode the reims-graphics device's video on VA-API
The owner's call: host video runs on VA-API on AMD and Intel GPUs, and
on NVDEC on NVIDIA's, not on Vulkan Video. The device's video chooser
had NVDEC and Vulkan Video alone, so on every GPU but NVIDIA's the
guest's H.264 and HEVC went to Vulkan Video.

The chooser now tries VA-API second, on the render node of the runtime
device's own GPU (host_gpus::render_node_of), whatever its vendor. The
arm answers the driver's VLD profiles, formats and sizes, decodes each
access unit through the VA crate's H264Decoder and HevcDecoder in a
host-signalled session, and lands each picture one of two ways. The
first is the driver's video processing writing the output's pages in
place, where they lie in one memory a dma-buf is made of and the
driver's import check takes their layout. Otherwise the picture is read
back and copied by the CPU, the first reason logged once a session. A
session holds no more pictures unlanded than the decoder's spare
surfaces, and the display's open logs its driver, its time and thread,
and its import answers.

Measured in cold boots of an x86-64 macOS guest (decode_md5, H.264 and
HEVC 8 and 10 bits up to 4K, odd sizes, a soak), 2026-11-07:
- Radeon 780M (radeonsi, Mesa 26.2.6): 843 and 440 stream decodes
  right, none wrong; H.264 1080p 1164 to 1173 fps and HEVC 1080p 984 to
  985;
- Iris Xe (iHD 26.3.5): 688 stream decodes right, none wrong; H.264
  1080p 332 fps and HEVC 1080p 384;
- no 'reims-vgpu: fatal' line in either.
Every picture was copied by the CPU there: the frames VideoToolbox
hands the decoder have CoreVideo's own layout, each plane 32 bytes into
its page and rows of the width rounded up a little (1376 bytes at
1366), which neither driver's video processing writes: radeonsi wants
rows and planes 256 bytes apart, iHD the luma at a page's first byte.
2026-11-07 19:03:06 -08:00
Anees Iqbal 1357a08711 🆕 Decode the graphics device's video on NVDEC on an NVIDIA GPU
On Linux, the runtime device's NVIDIA GPU, which CUDA opens by its PCI
address, decodes the reims-graphics device's H.264 and HEVC on NVDEC, in a
host video session: the caps are NVDEC's own answers, the access unit is read
in place at any alignment, and a picture lands in the output's pages by one
GPU copy into their view registered with CUDA, or is read back and copied by
the CPU where the pages are not to be had so. The chooser tries this arm
first and falls to Vulkan Video, and a GPU that is not NVIDIA's declines with
one line and loads no CUDA.

A session holds no more pictures unlanded than the decoder has surfaces to
spare: a decode past them waits for the oldest to land, which waits only for
the hardware.
2026-11-07 19:03:06 -08:00
Anees Iqbal d4a7ec4a68 🔥 Delete the paravirt video devices' host side
The VideoToolbox (106b:1a03) and M2 scaler (106b:1a0b) devices go with the
rest of Apple's paravirt (owner, 2026-11-07), and host video is VA-API and
NVDEC/NVENC alone. So this deletes their host side from the video crates:
- the VideoToolbox backend crate;
- video-core's host session, `vtpv` wire format, statuses, JPEG engine,
  motion estimation, scaler, encoder backend and fuzzers, and its macOS
  IOSurface lend;
- the codec crate's AV1, VP9 and JPEG parsers and the encoders' host
  session half;
- the conformance suite, which drove the host session: md5, mp4 and
  mp4_write stay, for the examples;
- VA-API's backend, AV1, VP9 and JPEG decoders and the JPEG engine's
  conversions, with their examples, checks and libva constants;
- NVIDIA's decoder and encoder backends, JPEG and motion parts, AV1 and VP9
  accelerators, and the decode sessions and examples built on them.

What the reims-graphics device's video arms build on stays: video-core's
runtime, locks, guest surfaces, device memory and device waits, the H.264
and HEVC codecs and encoders, VA-API's binding, decoders, encoder, copy
back and zero copy, and NVDEC, NVENC and CUDA. Zero copy on VA-API and
NVDEC's decoding are called by nothing until those arms land, and say so
with an expected dead_code.

The VA-API test of a wait in vaSyncSurface on a held GPU ran a JPEG
conversion; it now runs an NV12 to NV12 video-processing run, as the
staged copy back's and zero copy's. Cargo.lock loses the packages nothing
uses now, loom among them, as core's dropped in the parent commit.
2026-11-07 18:21:43 -08:00
Anees Iqbal 8b91272bc8 🔥 Drop the dependencies nothing reads
Cargo warned of three on Linux: reims-vgpu-core's bitflags, which no code of it
reads; the workspace's proptest, which no crate names; and the VideoToolbox
backend's codec crate, which only its macOS module reads. The first two go,
and the codec crate becomes a macOS dependency of the backend.
2026-11-07 05:16:12 -08:00
Anees Iqbal 4ea9311040 🐛 List reims-vgpu's optional Vulkan deps in Cargo.lock
Effort commit 6c171a10f made metal2vulkan-runtime and reims-vgpu-video-vulkan
optional dependencies of reims-vgpu, but the lock's dependency list for
reims-vgpu never named them, so every build that may write the lock rewrote
it. The lock now lists both. It keeps metal2vulkan's git source lines out,
as the committed lock does: it resolves --locked under a local patch of the
pinned rev.
2026-11-05 21:59:30 -08:00
Anees Iqbal 47e1136828 🐎 Find Annex B start codes with memchr's vectorized search
Every H.264 and HEVC picture the Vulkan decoders take is Annex B, and its
NAL units are split at their start codes by a search over each byte: on
msi's RTX 5080 the host's parse of a picture took 39 us p50 at 1080p and
87 us at 2160p (decode-perf run 1), growing with the picture's bytes.

memchr's memmem search finds the same start codes at 32 to 37 GB/s on the
M3 Max over the lane gate's streams, against 2.6 for the byte-wise window:
about 1 us of a 1080p picture's 34 KB, and 2.5 of a 2160p one's 86 KB,
rather than 13 and 33. memchr was already in the lock, through the regex
crates.
2026-11-05 21:59:28 -08:00
Anees Iqbal 770f363739 🆕 Decode H.264 on Vulkan Video into images the caller supplies
The product will decode the guest's H.264 on the GPU it draws with, through
metal2vulkan's own device, straight into the GPU copies of the guest's
IOSurfaces, which the guest's Metal then samples per plane. VA-API and NVDEC
decode into surfaces of their own, which would need a copy into those
images.

reims-vgpu-video-vulkan is the codec crate's H.264 decoder over Vulkan Video
(VK_KHR_video_queue, _decode_queue, _decode_h264), 8-bit 4:2:0 progressive
as that decoder takes it:
- VideoDevice runs on another's instance, device and decode queue
  (from_raw), or makes its own with a graphics and a video-decode queue,
  VK_KHR_video_maintenance1 and unifiedImageLayoutsVideo where present, and
  says why where no device decodes H.264 (create);
- h264_capabilities answers per profile from
  vkGetPhysicalDeviceVideoCapabilitiesKHR, for the guest's answers;
- each picture decodes into a SurfaceImage its SurfaceSource gives (NV12,
  optimal, mutable format with extended usage, shared between the graphics
  and decode families), which is also its DPB slot, as the 5080 offers only
  DPB_AND_OUTPUT_COINCIDE; never copied. Layouts stay GENERAL with unified
  layouts, else each decode leaves its target in the DPB layout;
- the session's parameters object holds the stream's SPSs and PPSs as std
  structures, made again where one changes; the DPB's references map to
  slots, a lost frame's stand-in sharing its source's;
- each decode signals the decoder's timeline semaphore, whose value each
  picture names; what a decode in flight uses goes only once it is passed;
- DecodeImages and Picture::read_back serve the tests and tools.

examples/vulkan-h264-framemd5 prints each frame's NV12 MD5 as the VA-API
backend's does, and tools/h264-check.sh runs it over the VA-API check's
streams and references.
2026-11-05 21:59:21 -08:00
Anees Iqbal 46324049a2 🐎 Take a command buffer on its doorbell's thread
rvg_graphics_device_mmio_write_taking is rvg_graphics_device_mmio_write,
except that a DOORBELL write of a command queue's ring first offers the
queue's next COMMAND_BUFFER to the host on the writing thread. Under QEMU
that thread is the guest's vCPU. Where the buffer asks for its CB_SUBMITTED
and nothing need be waited for, the vCPU takes it: it makes the buffer's
command buffer, posts its CB_SUBMITTED onto the queue's completion ring and
raises the queue's vector. It then hands the rest to the queue's service
thread, which walks and commits the buffer before it takes anything more of
the queue's. The guest's commitAndWaitUntilSubmitted no longer waits for
that thread to wake, which costs about 85 us on msi's host, the exit of an
idle CPU from its deep C-state.

Nothing on the vCPU waits. Every lock the take needs is tried: the queue's
claim, which its service thread holds from its take of a message to the
hand-over; the queue's submission ring; the control submission ring; the
compile table; and the decoder. Where any is held, the buffer stays on the
ring and the write wakes the queue's thread, as rvg_graphics_device_mmio_write
does. It also stays there where:
- a ring-0 message published before it is not carried out yet;
- it waits for an event, or a buffer before it holds its queue;
- a pipeline it names is compiling;
- a device cache it uses wants a fill, or a wait for one;
- its queue holds 48 command buffers made and not completed (the
  platform's commandBuffer waits at 64);
- it does not ask for its CB_SUBMITTED.
The CB_SUBMITTED's post on the vCPU waits for nothing either. Where the
completion ring is busy or full, the service thread posts it before the
walk, where the post is today.

The decoder's lock is taken on the vCPU and let go on the service thread
after the commit. So every message the guest sends after it sees the
CB_SUBMITTED is carried out after the buffer's commit, as it is today.

Class: FREE. Only the thread that posts a buffer's CB_SUBMITTED and its
timing change. Each queue's events keep its order: the vCPU takes only
while the service thread holds none of the queue's messages, and the
service thread carries out what the vCPU took before it takes the next.
The interrupt still follows its ring write on the same thread.

The C API gains the function, additively: the header and api.md list it,
and section 5 names the calling thread for raise_interrupt inside it, which
must not wait for a lock the host holds while it calls the function.
rvg_graphics_device_mmio_write and its "Calls back: never" are unchanged,
and so are the pins (re-recorded, no difference). The decoder's lock
crosses threads through parking_lot's arc_lock and send_guard.
2026-11-05 21:59:21 -08:00
Anees Iqbal 1f57dd0cd0 🆕 Key libraries by content, and keep them on the host
Every process that loads QuartzCore's shaders sent the whole library over
the region, and the host built it again. Now the bundle takes the AIR slice's
content key (SHA-256 of the .metallib without its bitcode section, whose
functions the HASH tags name) and asks the host first with LIBRARY_LOOKUP.
On a hit the new id is bound to the library the device made for any process,
and no bytes cross. On a miss the slice goes as before, now with its key.

The host keeps a library under a key only where it computed that key from
the bytes itself, checked every HASH tag against its bitcode, and found the
functions cover the bitcode section. Every AIR metallib of macOS 27's system
covers it. A lookup can then only bind content with that key, on Metal as on
the Vulkan platform. A wrong key makes the library uncached. Libraries no id
names stay in a 64 MiB least-recently-released list, so a restarted
WindowServer still hits.

Library creates are now answered with COMPLETE, and the kext waits for the
answer (for a region-streamed library, its last chunk), so a refusal is nil
and an NSError at newLibrary*, as in Metal. They are made on the compile pool,
off the control thread. A pipeline create that names a library still being
made waits for it on its compile thread, and a destroy of such a library
keeps ring order.
2026-11-05 21:58:30 -08:00
Anees Iqbal 9ba5f92c7b 🆕 Add the stage 3 host decoder's first slice (state objects)
The host side of the stage 3 Metal-call stream begins: GraphicsDecoder, in
the reims-vgpu graphics module, generic over the Platform, so it drives Metal
on macOS and the Vulkan platform on Linux.

This slice carries out the descriptor-free state objects and object destroy:
EVENT_CREATE, FENCE_CREATE, SHARED_EVENT_CREATE and QUEUE_CREATE each map
straight to a GpuDevice call, and the decoder keeps an obj_id -> handle table
that a destroy drops (releasing the object, since handles are refcounted).
These objects need none of the resource manager's paging or validity
machinery, so the table is the whole of their lifetime; the memory resources
and the command-buffer encoder stream, which do, follow and reuse
reims-vgpu-core's resources::manager.

Unit-tested against the testkit's fake platform: each create calls the
platform once and holds its handle, a destroy drops it (and a destroy of an
id the host never made is not an error), and an unknown command and a short
message are reported. Not yet wired into GraphicsDevice's ring loop. Adds
zerocopy to reims-vgpu to read the wire records.
2026-11-05 21:58:29 -08:00
Anees Iqbal 59df0ffbb5 🆕 Add the reims-graphics device to the C API
QEMU drives devices through the C API, so the graphics device gets seven
functions there: create and release, the region QEMU maps as BAR 2, BAR 0's
reads and writes, the doorbell file QEMU's ioeventfd fills, and the bus
reset. Its two callbacks raise the MSI-X vector and ask QEMU's dirty log
whether the guest wrote the scanout. Both run on the device's threads with
no lock of the library's held, so QEMU may take the BQL inside them, and no
function waits for those threads.

The additions are strictly additive (docs/api.md section 1): new functions,
types and constants, and status 17, RVG_ERR_HOST_RESOURCES, for a host that
refuses the region's memory, a pipe or a thread. The C harness calls each new
function and drives one GET_DISPLAYS through the region to its interrupt.
2026-11-05 21:58:28 -08:00
Anees Iqbal c13f8acb62 🆕 Show the reims-graphics display in a window of the library's
GraphicsDevice puts the reims-graphics host side behind the Rust API, with
its display in a library window, so a host gets the whole device from one
object as it gets apple-gfx's display.

The window keeps its size, and the display offers the guest that size in
pixels at the host screen's rate, telling it when the person resizes: the
guest's scanout then matches the drawable, and the sink blits it 1:1. The
sink imports the device's region once as a no-copy buffer on the platform
(Metal, or the Vulkan platform's runtime) and blits the scanout out of it
into each drawable, so the GPU reads the guest's pixels in place and the CPU
copies nothing. The buffer's deallocator holds the region, keeping it mapped
until the GPU lets it go. The guest's cursor image becomes the host's cursor
over the window.

The scanout is shown again only where the host's dirty log says the guest
wrote it, which the host answers through scanout_written.
2026-11-05 21:58:28 -08:00
Anees Iqbal 3aad9dbd61 🆕 Add the reims-graphics device's host side
The device's host side runs in the host's process, which maps its region into
the guest as BAR 2: private anonymous memory zeroed with stores, as RADV
imports no shared mapping. It answers the registers, takes the control
submission ring on a thread of its own with the consumer_idle handshake, so a
busy ring takes no doorbell, and answers on the completion ring, raising
MSI-X vector 0 only where the guest armed it. A refresh thread at the
display's rate asks the host's dirty log whether the guest wrote the scanout
and has the screen show it only then, sends VBLANK while it is on, and tells
the guest a new mode with DISPLAY_CHANGED.

No callback of the host's runs inside a call of the host's or under a lock of
the device's, and nothing the host calls waits for the threads, so QEMU's
callbacks may take the BQL. The design leaves open what a broken ring, a full
completion ring and an unsolicited event's seqno do: a broken ring is left
until a reset, the control thread waits for room (a VBLANK with no room is
dropped), and an event that answers nothing carries seqno 0.
2026-11-05 21:58:28 -08:00
Anees Iqbal d1958aecfa 🆕 Add the reims-graphics wire format and its C header
The guest's kext and option ROM are built in parallel and need the device's
wire format before the host side exists: its registers, the region's layout,
the rings' header and the control commands and events of the design's stage
2 wire protocol. They live in a new crate, reims-graphics, which will hold the
device's host side too, and cbindgen writes them into
include/reims_graphics_wire.h, which cargo xtask header --check keeps equal
to its output, as it does reims_vgpu.h.

Two fixes to the design's tables: a control ring's byte ring is 32 KiB, the
largest power of two after its 256-byte header in its 64 KiB (64 KiB less the
header is no power of two), and a pad's header is its type and size alone,
since the bytes left before a ring's end may be 8. A u64 that would follow a
u32 at an offset not a multiple of 8 has a reserved u32 before it, so C and
Rust lay the records out alike.
2026-11-05 21:58:28 -08:00
Anees Iqbal 95644d758d 🆕 Add the VideoToolbox and M2 scaler devices to the library and QEMU
A macOS guest hands its VideoToolbox sessions, and its
IOSurfaceAccelerator's scaling and conversion, to the host through two
virtio-PCI devices, 106b:1a03 and 106b:1a0b, as Virtualization.framework
gives them. The library gains their host side, VideoDevice and
ScalerDevice over core's host session and scaler, and QEMU their
transports, apple-videotoolbox-pci and apple-m2scaler-pci, with no
properties of their own.

The library picks each device's backend itself and logs why, on the GPU
apple-gfx-pci's device runs on, taken from the runtime's identity of it:
NVDEC and NVENC on an NVIDIA GPU, else VA-API on its render node, and
VideoToolbox on macOS. The scaler device exists on every host and refuses
its features where it cannot transform; a guest message over 16 MiB is
answered -12904 unread.

For the host: the C API gains rvg_video_device_* and rvg_scaler_device_*,
additively. For the guest: a VM given the devices has the host's video
decode, encode and scaling.

Source: c5b409362 375acb462 8be7593eb fbbeebfb2 e3d5616a4 60d08c4f4 c4c476643
        fe105edcb 36a6a82c6 ee2b1ca71 d7d5cfede b15f40717 a07ffd70b bfe6b8338
        7433026a9 0030b24a7 64497f931 76acbacc7 3bf366e81 6d3b97a59 fa5b4aafc
        401e0b727 1af53ce1a 0fa52d070 ce6eab571 33b40ae4a 82beaf64a ef26f02e1
        08bb763c4 5ff2dd73f 62e19c8ef ce406ddb2 fd92f66c4 52fba93c9 e179dc0bd
        b5f40ad74 d01bbdc9e 950a7e024 601c23067 9857b1fc8 b427bebfb 55a1d96e7
        a0243edfc ef54c395f c23c83073 bc6fcdaa7 1b783baca
2026-10-26 12:24:31 +02:00
Anees Iqbal 89cf86b649 ⬆️ Build on metal2vulkan bde1abe95b's runtime
Move the runtime from 62cad6be54 to bde1abe95b, its development at its green
gate (runtime version 1496 to 1499; the shader caches miss once).
Cargo.lock takes sha2 0.11 and the crates it needs, and stays stripped of
the runtime's source lines.

For the guest: a fast-math state blending into BGR10_XR_sRGB or
RGB10A8_2P_XR10_sRGB beyond the narrow blends is made, where it died (a
tester's RTX 4080 at WindowServer's aegir_luna_fsh); one GPU pool block per
queue ends the completed-handler lag under the terrain demo; out-of-range
threadgroup, alloca and constant indices read the last element. No
degradation kind or policy field moved, so DIES, HEARD, REIMS_VGPU_EXACT
and the accuracy ledger stand.

Source: 5983391e2
2026-10-26 12:24:31 +02:00
Anees Iqbal 565e650907 🆕 Allocate the library's memory with jemalloc on the shipped targets
On x86-64 Linux and arm64 macOS the C API's crate makes jemalloc the global
allocator, so every Rust allocation in the library, metal2vulkan's runtime's
among them, goes through it. FIFO 1's commands allocate memory that the
runtime's threads free, and glibc refills its arena for each such block on
the allocating thread: on ms01's Iris Xe a Finder drag ran at 36 frames/s
under glibc and 42 with jemalloc preloaded into QEMU.

jemalloc's symbols stay prefixed, so QEMU's C code, the drivers and Apple's
frameworks keep the system's malloc. On macOS jemalloc is built with no
malloc zone (the workspace's cargo config), as its zone would otherwise
register ahead of the system's in every host that links the archive whole.
No block crosses between the two allocators: the suspend bytes the host is
handed go back through rvg_bytes_free, and the blocks the Metal platform
gives NSData and dispatch_data to free are malloc's own. Nothing the guest
or the host observes changes.

A Mac's `cargo xtask check` type-checks Linux with no Linux C toolchain, so
it points jemalloc's build script at an empty archive for that target, as it
leaves SDL unbuilt there: nothing links.
2026-10-14 12:41:46 +03:00
Anees Iqbal e17d3c2460 🎨 Record the lock against a local metal2vulkan checkout
A [patch] in a .cargo/config.toml above the checkout points metal2vulkan
at a local tree, which drops the three git source lines from Cargo.lock.
Committing that keeps the owner's tree clean while the patch is active.
Without the patch, cargo writes the lines back from the pinned rev, and the
lock regenerates byte for byte as before; --locked builds need the patch or
a regenerated lock.
2026-10-11 22:33:09 +03:00
Anees Iqbal 98fe2a3bd5 🆕 Replace the tree with libreims_vgpu and its C API
This repository now holds libreims_vgpu, a Rust library that is the host
side of the paravirtualized GPU macOS guests drive, in place of Apple's
ParavirtualizedGraphics.framework: the library and its C API
(reims_vgpu.h), the PCI device's option ROM, QEMU's apple-gfx on that API
(vendor/qemu), the behaviour-lock suite that drives the C API as QEMU
does, and reims-ctl, the VM manager users run. README.md says what it is
and how it is laid out, and AGENTS.md how to change it.

Every file of the earlier tree is replaced. vendor/qemu moves to the
steelbrain/reims-vgpu branch of the same public repository.
2026-10-11 20:27:17 +03:00
Anees IqbalandClaude Opus 5 423806da57 testkit: share the allocation counter, and measure the rail's warm draw with it
The counting allocator the model's structural-zero suite carried is wanted by
the rail's suite too --- two of the plan's required zeros, "heap allocations
per steady-state draw" and "full binding-table rebuilds on an unchanged draw",
are the rail's. A second copy of a `GlobalAlloc` is a second thing to get
subtly wrong, which is the same argument that put the capture's loaders in
this crate rather than in three. So it moves to `testkit::allocations`, and
`AGENTS.md` says the crate carries instruments as well as fixtures.

The rail's suite measures three things. An unchanged draw --- the one the
plan's zero is about --- asks `BindingTable::is_clean` and nothing else, and
that is zero trips with the bindings still readable afterwards, which is what
makes "unchanged" mean the contents survived rather than that they were
dropped. A draw that did rebind two slots costs the same on a 512-slot table
as on a 31-slot one, which is the whole value of the dirty set; the three
trips it does cost are `take_dirty`'s replacement masks, one per binding kind,
and the test names them so the number is a recorded fact rather than a
tolerance. Sixteen frames of take-submit-recycle over a fixed descriptor ring
cost nothing at all, which is what a pool that was supposed to remove a
per-frame heap cost has to be able to say.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-02 06:23:17 +03:00
Anees IqbalandClaude Opus 5 896d6d8ab2 sampler: six tables for one descriptor, and the guest ordinal that reaches all of them
The first replacement subsystem a guest actually runs through. Until now
production consumed two modules of `reims-vgpu-vulkan` (`queues`, `memory`) and
nothing of `reims-vgpu-core`; a sampler was decoded to engine enums by
`translate::sampler`, restricted by `vulkan_conformed_sampler` beside the cache,
spelled back into Vulkan by five more functions, and refused for two
capabilities at a third site. Six places to keep in step about one
`MTLSamplerDescriptor`, and the only thing they could do to each other was
disagree about which ordinal means what.

Now the ordinals travel as the guest wrote them from decode to the sampler
cache, `reims_vgpu_core::sampler::SamplerShape::checked` is the one parse, and
`reims_vgpu_vulkan::sampler::plan` is the one decision. `translate/sampler.rs`
keeps only `PRESENT_BLIT_FILTER`, which translates nothing.

**The protocol layer conformed where it used to refuse.** It rejected any
unnormalized-coordinate declaration that broke the restriction both APIs place
on one; production conformed it and drew. Refusing is the wrong half: both APIs
state the restriction as a requirement on the caller, so a declaration that
breaks it already left the documented region and what Metal's driver did with
it is not knowable — while every field the conformance changes is one an
unnormalized sampler cannot consult (no derivative, so no level and no
anisotropy; no period, so no repeat). The comparison stays a refusal, because
it changes *what the shader reads* and no nearby sampler reads the same thing.
It also checked the R axis, which `-01075` does not name and a 2D-only sampler
never consults — that alone would have refused the common `r_address = Repeat`.

Two production behaviours change deliberately, both toward the guest:

- Anisotropy above one on a host without `samplerAnisotropy` was a decline that
  cost the whole draw. It is now clamped, which is what Metal does and what the
  device has no way to refuse honestly — the difference is sharpness, not a
  wrong image.
- Two disagreeing border modes on one sampler used to bind transparent black
  silently, giving one axis a border the guest did not ask for. It is now a
  typed refusal on the always-on channel: Vulkan has one border per sampler and
  picking one is a soft wrong edge that reads as a filtering artefact.

`SamplerAnisotropyUnsupported`, `SamplerMirrorClampToEdgeUnsupported` and
`SamplerUnnormalizedCompare` are replaced by two delegating variants, so the
layer that owns a refusal is the layer that names it. Four `TranslateReason`
ordinal variants and seven `DrawPreparationDecline` variants go with them —
an unknown `MTLSamplerAddressMode` is refused by the layer that knows where
that enum ends, not by the layer that copies it.

The three tests deleted with `translate/sampler.rs` are not lost: enum totality
is `protocol::sampler`'s round-trip sweep, and both documented collapses are
asserted in `vulkan::sampler`. What this site keeps is the *join* — that the
cache key reaches those layers as the declaration the guest wrote, which a test
on either side alone cannot see. A new sweep asserts every unnormalized
declaration the protocol admits satisfies all six `VkSamplerCreateInfo` VUIDs,
because the two rules are stated in different vocabularies and neither side can
assume the other agrees.

Verified: feature-matrix all arms warnings=0 (Metal arm included — it compiles
`types.rs` too); `reims-vgpu` vulkan lib 2115 pass serially; vulkan crate 468+8;
protocol 371; clippy and rustdoc clean on all four crates. Warning set on the
vulkan arm is byte-identical to before the change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-01 16:36:40 +03:00
Anees Iqbal 73703ba58c vulkan: the rail becomes a crate, starting with the layer that places memory
`reims-vgpu-vulkan` exists. The architecture names one layer as the sole
executor of the semantic model and the only place host capabilities become
placement and transfer policy, and "only place" is a claim a module boundary
cannot hold — a placement decision one `use` away from device state will
eventually read some. So it is a crate whose dependency list says what it may
see: `ash`, `reims-vgpu-core`, the refusal vocabulary, and the operator
switches. No QEMU, no device model, no guest-RAM ownership, no decode.

Its first content is `backend/vulkan/caps/memory_topology.rs`, moved whole and
unchanged apart from `crate::observe::fail` becoming `reims_vgpu_observe::fail`.
That module *is* "host capabilities become placement policy": it classifies
unified against discrete from two structural signals, never a device name, and
selects a memory type by preference with the required flags always as the
fallback — so a misclassification is a performance bug and never a correctness
one. It brings its own seventeen tests and the synthetic device shapes they run
against.

The rest of `caps/` cannot follow yet and the reason is worth recording:
`device_features.rs` reads `backend::vulkan::translate::pixel` in production
code, and `translate/` in turn reaches `runtime::census`, `runtime::decode`,
`runtime::spirv_vertex_input` and `engine`. The legacy backend is woven into the
runtime by 284 references across 25 modules; extracting it piecemeal produces a
`caps` split across two crates, which is worse than either end state. It leaves
at the cutover, and what grows here before then is the replacement executor.

`fixtures` is `pub` rather than behind a `testing` feature: the consumer that
needs it is in another crate, and a feature would either pull this rail into a
Metal-only test build or fork the fixtures — a second answer to what an AMD
APU's memory looks like.

Counts: the vulkan arm 2209 -> 2192 and the replacement crates 532 -> 552, which
is the same seventeen tests on the other side of a crate boundary. The
replacement-crates matrix cell now names the testkit and the rail too, so
neither can empty quietly.
2026-09-01 11:37:19 +03:00
Anees Iqbal cf42142b63 testkit: how a suite reaches the capture is one crate, not three copies
Three suites read Apple's captured records — the wire crate's layout tests, the
model's fixture oracle, and the device's decoder tests — and each carried its
own `fixtures()`, its own `unhex()`, and its own spelling of where the files
live. Two wrote the directory as `{manifest}/../reims-vgpu-wire/fixtures` and
one as `{manifest}/fixtures`, which is the same directory only as long as nobody
moves a crate.

The presence probe was already shared, by `include!`-ing one file from three
build scripts, with a comment arguing a build-dependency crate for twenty lines
would cost more than it carries. That was true while twenty lines was all there
was to share. `reims-vgpu-testkit` now carries the whole of "how a suite reaches
the capture" — the probe, the loaders, the hex helper, and one answer for the
directory — so `include!` across a directory boundary stops being the mechanism
and the twenty lines stop being the whole crate.

`oracle/fixture_presence.rs` is deleted; the three build scripts take the
testkit as a build-dependency and the three suites take it as a dev-dependency.
Counts: replacement crates lib 508 -> 532.

Unrelated and pre-existing: `-p reims-vgpu-wire --test oracle_fixtures` fails 12
of 35 against the capture currently on this machine — manifest rows and the
capture disagree about several compute selectors. Confirmed identical at the
parent commit in a throwaway worktree, so it is not from this change; it is a
stale capture or a stale row set and it wants its own investigation.
2026-09-01 11:29:55 +03:00
Anees Iqbal 63a93c79fd protocol: one vocabulary, one crate — reims-vgpu-contract is absorbed
The last four modules cross — `pixel_format`, `mipmap`, `iosurface_pages`, and
the `checked` glob — and with nothing left in it, `reims-vgpu-contract` is
deleted rather than left as a shim.

Two crates had the same job under two names: "backend-neutral vocabulary" and
"the layer that assigns meaning to a wire tag" are one description. Two crates
for it means two places to look for a rule and two places for it to drift, and
the device was already writing both spellings — `crate::contract::pixel_format`
next to `reims_vgpu_protocol::extent` — for facts at the same altitude. There is
one spelling now: `crate::protocol::`, across 88 files, tests and conformance
included.

The moved modules take `alloc` imports because protocol is `no_std`, and
protocol takes a dev-dependency on observe with `std` on, because their tests
assert what a refusal *renders* as and rendering is the sink's half. Resolver 2
keeps that feature out of builds that do not compile tests — but `--all-targets`
does compile them, so the existing matrix cell would let a `std::` into the
library unnoticed. A `protocol / no_std library` cell at `--lib` scope is what
notices.

Counts: support crates lib 351 -> 270, replacement crates 425 -> 508, and
`reims-vgpu` itself unchanged at 2138 lib tests.

AGENTS.md's ownership list is updated for both new crates, including
`reims-vgpu-core`, which it had never named.
2026-09-01 11:15:27 +03:00
Anees Iqbal 3881a15a1d protocol: three more contract modules, and the two dependencies they need
`draw`, `gva` and `gva_resolve` move across. With them, `reims-vgpu-protocol`
gains the two dependencies the absorption always implied:

- `reims-vgpu-paging`, because `gva_resolve` is the mapping between the guest
  page-table walk's statuses and the fail channel's vocabulary, and neither of
  those crates can carry it.
- `reims-vgpu-observe` with `default-features = false` — `Decline` and
  `Refusal` and nothing else. Taking the vocabulary without the sink is what
  keeps this crate `no_std`, and it is the dependency the whole layering
  argument was about.

`mipmap` was moved and then moved back: it reads `pixel_format`, which builds
two lazy lookup tables through `std::sync::OnceLock`. Splitting the format
vocabulary from texel conversion is a real decision — converting bytes is an
executor's job, naming a format is not — and it deserves its own commit rather
than being smuggled in behind a mechanical move.

Counts: replacement crates lib 420 -> 425, support crates 356 -> 351.
2026-09-01 11:08:06 +03:00
Anees IqbalandClaude Opus 5 20140505cf memory: the guest-RAM bound becomes a crate, so the bound is structural
`runtime/guest_ram.rs` moves to `reims-vgpu-memory` and is re-exported under
the path every caller already writes, so no call site moved.

The module's claim has always been that nothing above it can name a byte of
guest RAM except through an import that is alive and a slice that has been
bounds-checked against it. Inside one crate that was a discipline; as a crate it
is a compiler's answer. `reims-vgpu-memory` depends on the contract, the paging
runs and the observe channel and on nothing else — it cannot see a resource
table, a Vulkan handle, a QEMU structure or the device model, so there is no
second way to answer "how big is this" and nowhere for a raw pointer and an
offset to escape together.

Four `#[cfg(feature = "backend-vulkan")]` gates go with it. They were dead-code
suppression for the Metal-only build, not a statement about a rail, and in a
library crate a `pub` item is never dead — so the footprint's allocation
identity, page membership, span and release store are simply public now. That is
one fewer place where a `cfg` looks like it is answering "which rail is
running".

20 tests move with the module: reims-vgpu 2158 -> 2138, reims-vgpu-memory 20.
Feature matrix all arms warnings=0 with the new crate in the support-crate cell;
clippy and rustfmt clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-01 10:32:37 +03:00