Commit Graph
16 Commits
Author SHA1 Message Date
Anees Iqbal 54591f34ca 🐎 Write a dist file only where its bytes changed
cargo xtask dist wrote every file of its tree on each run, the archive and
the header included, so every make qemu recompiled reims-graphics-pci.c and
relinked the 358 MB qemu-system-x86_64 even when nothing had changed.

Every file dist writes now goes through one helper, replace_if_changed: a
file that already holds the bytes keeps its mtime and gets only its mode;
one that changed is removed and written anew, as install did. For the bytes
to come out the same, the archive is packed in the target dir's
dist-localized with zero dates (ar's D on Linux, libtool -D on macOS) and
installed from there, and on macOS the dylib is renamed and signed on a copy
there before it is installed.
2026-11-13 09:49:33 -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 c44ad4f5a6 ✅ Expect the dist tree at DEFAULT_OUT in the macOS dist test
dist_writes_the_tree_and_renames_the_dylib expected target/dist, but the dist
tree's default has been target/dist-vulkan (DEFAULT_OUT) since the Metal
platform's deletion, so the test failed on every Mac. It now expects
DEFAULT_OUT, the constant the code uses.
2026-11-08 01:38:23 -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 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 9da252e40b 🔥 Delete apple-gfx's option ROM from firmware and the dist tree
apple-gfx-pci loaded ReimsVgpu.rom, its UEFI driver, as its default romfile;
with apple-gfx gone the driver, its sources and its build go, and cargo xtask
dist installs no ROM and names none in reims-vgpu.pc (QEMU stops reading its
optionrom variable). The firmware builds only the reims-graphics device's ROM,
which reims-ctl carries: OptionRom.S keeps the layout ReimsGraphicsRom.S
includes, with no apple-gfx-pci identity to fall back on.

The prebuilt ROM's bytes are unchanged (sha256 749434f8, rebuilt on the Mac):
only its record moves, for the Makefile and the two assembler files it names.
2026-11-07 18:21:42 -08:00
Anees Iqbal 3db95eb188 🔥 Cut the C API down to the reims-graphics device
QEMU keeps only reims-graphics-pci.c's calls once apple-gfx goes: the ten
rvg_graphics_device_* functions, rvg_status_message, the window's and the
cursor's types and the memory map the device's config names. Everything of
Apple's paravirt device goes from the header: the device, its displays and
frames, the IOSurface, video and scaler devices, trace ranges, the log hook,
the dirty source, suspend and resume, and their status codes, pins and the
xtask smoke that drove them.

The C API is no longer additive-only: the status codes are renumbered to the
five the graphics calls return, rvg_status_message keeping a message for each,
and the struct versions the paravirt hosts needed go, so a struct_size below
the library's is refused. The window config keeps its mode, the one field the
graphics device reads; the cursor and memory-map types move beside the
graphics device. rvg_graphics_device_mmio_write goes too, QEMU calling only
the taking write, which now carries the plain write's contract.
2026-11-07 18:21:42 -08:00
Anees Iqbal eb04234e17 ✅ Check the guest's prebuilt kext set in cargo xtask check
`make -C guest prebuilt-check` hashes guest/prebuilt and the sources it was
built from against guest/prebuilt/sources.toml, on any host, and fails
where the set reims-ctl embeds went stale. It runs beside the ROM's check,
since the library's checks would not reach a change to the wire header the
set is built against.
2026-11-05 22:58:51 -08:00
Anees Iqbal bf69e0fee1 🆕 Carry the reims-graphics option ROM prebuilt, with its record
QEMU's reims-graphics-pci has no default option ROM, and reims-ctl is to
name one for every x86-64 VM on reims-vgpu's own device, on hosts that
build no firmware. firmware/prebuilt/ReimsGraphics.rom is the ROM `make -C
firmware prebuilt` builds on a Mac (Apple clang 21.0.0, Homebrew lld 23.1.4;
the bytes are the compiler's), and ReimsGraphics.toml records its sha256
and that of every file it was built from, the wire header among them.

`make -C firmware prebuilt-check` (firmware/prebuilt.sh --check) hashes the
ROM and those files against the record on any host, with no compiler, and
`cargo xtask check` runs it: the wire header is the library's, whose checks
would otherwise never see the ROM go stale.
2026-11-05 22:58:51 -08:00
Anees Iqbal 8836f3946a 📝 Fix the intra-doc links rustdoc finds broken [ci skip]
rustdoc, on macOS and the Linux target, in public and private docs,
found 55 broken intra-doc links beside those of the commit before, and 8
redundant explicit ones. Each now names the item it means: a link to a
test-only helper, or to an item rustdoc cannot see from the doc or that
only another OS has, becomes the plain name; one to an item out of the
doc's scope takes its path; an ambiguous name takes its kind (a module,
or a function by its parentheses); and links to items gone name what the
code does now (the vaapi backend's frames are copied through read_back
and FrameReadBack::copy_to; the graphics decoder lets a message go at
end_message; the gate's waits and lane moves are their _offering forms,
the plain ones being the tests'). The links the ycbcr module made to an
'answer' that never resolved are dropped.
2026-11-05 21:59:34 -08:00
Anees Iqbal fd497ebd82 🐛 Build dist's SDL with its flags where kache caches build scripts
cargo xtask dist builds SDL again with the flags that give its classes the
library's names and keep its globals uncommon (-fno-common), for macOS 11.0.
Where the build runs through kache (dev-env.sh), kache serves a build
script's run from its store by the inputs Cargo reruns it for, and SDL's
script declares none of those flags, so a run of a build with no flags, from
any target directory on the host, was served in its place. A dev dist then
failed its archive check: SDL's _b_inModeTransition and _mach_base_info were
common symbols, left global, and its objects were built for the SDK's macOS
(measured on the M3 Max, after a dev test build had built SDL there).

dist's build now turns kache's build-script cache off with an [env] entry,
KACHE_BUILD_SCRIPT_CACHE=0, which the rustc wrapper and the scripts see, so
its build scripts run as without kache, and a run with the library's flags
is not served to another build either.
2026-11-05 21:59:32 -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 66fab0adf9 🐎 Build incrementally, with kache 2's incremental state
The owner asked for Rust's incremental cache and kache 2.0.0's. dev-env.sh
no longer sets CARGO_INCREMENTAL=0 or KACHE_ADAPTIVE_INCREMENTAL=0, and unsets
both where a shell kept them, and `cargo xtask check` runs its cargo steps in
the environment it starts in, so a check run again after a fix rebuilds what
the fix changed. Each host's kache configuration turns on adaptive and seeded
incremental state: kache compiles a unit being edited incrementally, and a
new worktree's first incremental compile of it imports a compatible one's
state (rustc 1.98 or later). docs/development.md says how, and that kache 2
compiles through its daemon, which builds now start.
2026-11-03 23:44:11 -08:00
Anees Iqbal 6e20652eea 🐎 Build lean, and share builds between worktrees through kache
Each worktree's check compiled everything again with full debuginfo and
incremental caches no rebuild used. The dev profile keeps line tables for
the workspace and none for its dependencies, the check builds without
incremental caches, and builds go through kache where it is installed, so
a worktree's first build reuses what another tree built, build scripts
included. Tests read the tree's paths at run time, so a build is the same
in every tree.

scripts/new-worktree.sh makes a worktree from clones of the main checkout's
suite files, and AGENTS.md says a profiling run removes its traces.

Source: 53a4a8edd b568f382e 0c7a0eabc 72c24f74b 10051ba78 8f415697a 73d557f71
        bde4220b6 46c7c6b23
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 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