The planner widened the job-id rule from the published crates' rustdoc to the four prose docs a
reader takes measurements from. Each lab job id (m3-max-NNNN, and the bare job numbers beside
them) and each commit sha comes out; the ids stay in the commit messages that already carry them.
A measurement keeps the card, driver and OS its sentence names. Where an id was the only basis a
sentence named, the sentence now says what was measured and on what:
- the runtime README's identity-domains paragraph cited five plays of recorded streams; it now
states what the states-only plays of the 26 kept replay streams on lavapipe show: each makes
every pipeline state its stream makes, and none of their render or compute states is refused,
a refusal under the identity domains among them (the plays of jobs m3-max-83458, -83494, -83695,
-83889 and -83954, each printing refused 0);
- the probe lists name the cards ("probes on the RTX 3090, the Iris Xe, lavapipe and the RX 7900
XTX"; "probes on a Radeon Pro 5300M and a UHD Graphics 630, both macOS 26.7.1");
- sentences that compared runs by id compare them by order ("failed in one run and passed in two
others"), and "the same job" is "the same run";
- "rt at <sha>" and "players built from <sha>" become what that build was ("a build of the runtime
that copied a texture over any import"), or go where the card and driver already say it;
- VALIDATION.md's harness count reads "the harness on lavapipe".
Two README tables lose their Job column (the import-cost table and the guest-buffers table). The
edited paragraphs are rewrapped at 100 columns; a token diff against the parent shows only the
ids, the shas, the two columns and the rewordings above.
submit.rs's three citations of two probe commits (06860a3848 and b15b306d2f) become "measured
with a probe build of the runtime" (and, for the split probe, "that timed each command buffer");
the IN_FLIGHT and infos comments are rewrapped at 100 columns.
So it does not grow back, scripts/api-docs first fails when the four docs name a job id
(`m3-max-NNNN`, or `job NNNN`); CONTRIBUTING.md, API.md's description of the script and ci.yml's
comment on its step say so.
docs/CONFORMANCE-COVERAGE.md is unchanged: its generator has no job column. Its 1772 lines with an
id are all in its last section, The ledger, which quotes the last field of known-gaps-rt.tsv; the
ids are in the ledger's own sentences, which the ruling keeps out.
Not widened, per the ruling: the ledger, known-gaps-rt.tsv, results.py, test comments and the
unpublished crates. The OS is not added to measurements whose sentence named a card and driver
but no OS.
Verified on the CPU with no device, job m3-max-84430 at this commit's tree: cargo fmt --check 0;
the workspace's rustdoc with -D warnings 0; scripts/api-docs 0, and 1 with a job id planted in
docs/VALIDATION.md, naming the planted line (the tree clean after its restore); the refusal
surface's --check 0; the 13 tests that read these docs passed (feature_enables, the floor, the
accepted differences, the precision-note catalogue, the consumer's objects and the guide's
example). Before the commit, no line of the four docs matched the check's pattern, and rustfmt
--check passed on submit.rs.
13 KiB
Contributing
How to build, test and change metal2vulkan. AGENTS.md holds the project's rules; they bind people too.
Prerequisites
-
rustup.
rust-toolchain.tomlpins the nightly this tree builds with (rustup installs it on first use); the published crates promise the stablerust-versionin their manifests (1.98). -
cargo-nextest:
cargo install cargo-nextest --locked. -
The external tools the tests and validation use (the libraries run none):
llvm-as(LLVM 21 or newer) for the.llfixtures, andllvm-disfor validation's harvest and fixture tooling;spirv-valandspirv-asfrom SPIRV-Tools;xcrun metal-ason macOS, for the.air.llfixtures (tests that need it skip elsewhere);spirv-cross, for the checks of the MSL MoltenVK would write. Without it they printSKIPPED;METAL2VULKAN_TEST_REQUIRE_SPIRV_CROSS=1makes its absence a failure.
Each is found on
PATHor throughMETAL2VULKAN_<TOOL>(METAL2VULKAN_LLVM_AS,METAL2VULKAN_SPIRV_VAL, ...). With Homebrew on macOS, LLVM is keg-only:PATH=/opt/homebrew/opt/llvm/bin:$PATH. -
A Vulkan driver or a Mac with Metal only for the device tests and authored-case runs (docs/VALIDATION.md).
Layout
.
├── crates/
│ ├── metal2vulkan/ # the translator library and the CLI (feature `cli`)
│ │ ├── src/ # src/tests/: tests that reach internal items
│ │ ├── tests/ # integration tests through the public API, golden tables
│ │ └── examples/ # api_preview.rs, which docs/API.md quotes
│ ├── metal2vulkan-air/ # the AIR front end
│ ├── metal2vulkan-runtime/ # the runtime, the Metal API on Vulkan (README)
│ ├── metal2vulkan-validation/ # unpublished: cases, executors, corpus tools
│ │ ├── fixtures/public/ # our own synthetic fixtures (.ll, .air.ll, .metal, .spvasm)
│ │ ├── profiles/ # committed Khronos device profiles
│ │ └── corpus/ # authored cases and observations (local/ is private, ignored)
│ ├── metal2vulkan-conformance/ # unpublished: the Metal conformance suite
│ ├── metal2vulkan-devtools/ # unpublished: tool runner, fixture assemblers
│ └── metal2vulkan-harness/ # unpublished: the runtime's compute harness (crate docs)
├── docs/ # guides and generated references
├── scripts/ # developer utilities and generators
├── Cargo.toml # the virtual workspace
├── LICENSE # the notice: GPL-2.0-or-later OR LGPL-3.0-or-later
└── LICENSE-* # the texts it names: GPL v2, LGPL v3, and GPL v3
The loop
cargo fmt --all
cargo clippy --workspace --all-targets --all-features -- -D warnings
RUSTDOCFLAGS='-D warnings' cargo doc --workspace --all-features --no-deps
scripts/api-docs # the translator's API reference; fails on a link to a hidden item or a job id
cargo nextest run -p metal2vulkan -p metal2vulkan-air -p metal2vulkan-runtime -p metal2vulkan-devtools -p metal2vulkan-harness --all-features
cargo nextest run -p metal2vulkan-validation --all-features
cargo nextest run -p metal2vulkan-conformance --all-features
cargo test --workspace --all-features --doc
None of these opens a device. Device tests compile only under --cfg m2v_gpu or
--cfg m2v_cpu_icd, and on a GPU the tests that fault it, hold it for long or allocate toward its
limits only with --cfg m2v_gpu_hazards too (docs/VALIDATION.md).
metal2vulkan-runtime's device tests run under the Khronos validation layer and fail without it: point
VK_LAYER_PATH at the layer's directory (scripts/validation-layer; docs/VALIDATION.md, "The
validation layer under metal2vulkan-runtime's device tests"). On a machine that has no layer,
METAL2VULKAN_TEST_UNVALIDATED=1 runs them without it, and the run says so.
CI runs the device tests, the conformance replay and public case qualification on lavapipe in the
container image scripts/lavapipe-image builds from one Arch Linux Archive date, pinned by
scripts/lavapipe-image/pin, and re-recording the conformance ledger's llvmpipe rows on another
lavapipe moves that pin and the ledger's # llvmpipe: line in the same commit.
To build the command:
cargo build --release -p metal2vulkan --features cli
A debugger session that needs variables builds with --profile debugger (full debug info for the
workspace and its dependencies). Dev builds keep only line tables.
Many trees on one machine
Parallel worktrees and one-shot builds write a lot to disk. Three scripts keep that down:
scripts/lean-tree worktree PATH BRANCH STARTadds a full worktree whosecrates/metal2vulkan-validation/corpus/observations(1.5 GiB of the 1.6 GiB tracked tree) are copy-on-write clones of the main worktree's; git rewrites only the files that differ atSTART.scripts/lean-tree snapshot REV DIRextracts a tree without the observations (pass--with-observationsfor one that runs validation).scripts/seed-target new TARGET SEED WORKTREEstarts a target directory as a copy-on-write clone of a seed, so only the workspace's crates compile.scripts/seed-target save TARGET SEED WORKTREEmakes the seed from an idle warm target. Keep one seed per set ofRUSTFLAGS.scripts/xctrace-run TRACE ARGS...records with Instruments and removes the rawinstruments*.ktracefiles a recording leaves in the temp dir, an aborted one included.
Builds are incremental. Every compile goes through scripts/rustc-wrapper, which hands it to
kache when kache is on PATH (outside CI) and to rustc
otherwise; kache restores matching compiles from its local store and imports incremental state
between worktrees. RUSTC_WRAPPER= (empty) builds without it.
Keep each worktree's target directories inside it: Cargo's default target/, and
target/gpucfg for RUSTFLAGS='--cfg m2v_gpu' (a target of its own, since RUSTFLAGS is in the
build fingerprint). kache imports incremental state only between targets inside their worktrees;
a CARGO_TARGET_DIR outside the worktree neither gives nor takes it. seed-target new takes such
a path too (scripts/seed-target new WORKTREE/target SEED WORKTREE).
The matrix
After a landing on development, run the matrix on its tip:
scripts/matrix/matrix run development # or a sha; --legs 1002:744c,lavapipe for some legs
scripts/matrix/matrix show development # the verdicts already attached to it
It dispatches every leg through potluck at priority 5, waits for them, writes the commit's note
under refs/notes/matrix, and prints one verdict line per leg; it exits 0 only when every leg
passes. --dry-run prints the legs and their nodes and dispatches nothing. Runs never overlap: a
second one refuses to start. It keeps its state (its own checkout, workspaces, measured job sizes,
each run's job logs and note) in ~/.cache/metal2vulkan-matrix/, and reads the lab's builders from
~/.config/metal2vulkan/matrix.json (the script's header has the format).
docs/VALIDATION.md has the legs and the rules.
Where tests go
- A test that names an internal item is a unit test of its crate: under
src/tests/(or its module's owntests), naming items throughcrate::. Run one file withcargo nextest run -p metal2vulkan --all-features --lib -E 'test(/^tests::<file>::/)'. crates/metal2vulkan/tests/holds integration tests through the public API only.crates/metal2vulkan/tests/api_surface.rspins every public name of the translator. A new public item gets its row there.- Fixtures are synthetic and ours, under
crates/metal2vulkan-validation/fixtures/public/. A new fixture's rows incrates/metal2vulkan/tests/public_fixture_expectations_engine.tsvare blessed from the test rather than written by hand, withcargo nextest run -p metal2vulkan --all-features --run-ignored ignored-only -E 'test(bless_engine_inventory)'(on macOS, which has every assembler); the parts name every moved cell and every new or gone row first, so read those before blessing. Its golden printout undertests/air_input/is blessed withcargo test -p metal2vulkan --all-features --lib tests::air_input -- --ignored. - The manifests set
autobins = false: a new binary needs its own[[bin]]table.
Golden output hashes and SEMANTICS_VERSION
src/tests/golden_hashes.rs pins a hash of the final SPIR-V (or the refusal class) of every public
fixture entry point on every committed profile, in crates/metal2vulkan/tests/golden_hashes.tsv.
cache::SEMANTICS_VERSION is part of every cache key, so a change that moves a cell while its
fixture and profile are unchanged must bump SEMANTICS_VERSION
(crates/metal2vulkan/src/cache/mod.rs) in the same change. New, removed or edited fixtures and
profiles need only the bless. The table records SEMANTICS_VERSION as it was at its bless (its
semantics line), which a bump alone leaves unchanged. A cell that moved under an unchanged fixture
and profile while SEMANTICS_VERSION is still the table's fails the check as a missing bump, and
the bless on development refuses it; once SEMANTICS_VERSION is above the table's, the same cell
is a bless due.
The tables are re-blessed on development after merges, so a change need not carry its own bless.
One command blesses both (on macOS, which has xcrun metal-as):
PATH=/opt/homebrew/opt/llvm/bin:$PATH cargo nextest run -p metal2vulkan --all-features \
--run-ignored ignored-only -E 'test(bless_golden_hashes)'
Never merge a table by hand: after a merge take development's tables and bless again. The other
versions move the same way when their behavior changes: ARTIFACT_FORMAT_VERSION (the artifact
encoding) and RUNTIME_VERSION (what the runtime does with an unchanged artifact).
Generated docs
Edit the source, then regenerate:
| Doc | Generator | Source |
|---|---|---|
docs/REFUSALS.md, crates/metal2vulkan-runtime/src/error/basis.rs |
python3 scripts/refusal-surface/refusal_surface.py (--check to verify, --missing-basis and --missing-reach to list the gaps, --selftest for the basis parse's and the generator's own cases) |
the code's refusal types, the Basis: line each refusal's doc comment ends with; reach.tsv beside the script |
docs/METAL-COVERAGE.md |
python3 scripts/metal-coverage/coverage.py (--check to verify) |
scripts/metal-coverage/coverage.tsv |
docs/CONFORMANCE-COVERAGE.md |
python3 scripts/conformance-coverage/coverage.py (--check to verify, --selftest for the option-space axis's own tests) |
the suite's sources, its committed recordings, scripts/metal-coverage/coverage.tsv, objc2_metal.tsv, and the generated Metal enum tables |
crates/metal2vulkan/src/spv.rs, crates/metal2vulkan/src/spirv_binary/table.rs |
scripts/regen-spirv-grammar/regen-spirv-grammar.sh |
Khronos SPIRV-Headers' grammar JSON, and items.txt beside the script |
crates/metal2vulkan-validation/profiles/*.json |
scripts/regen-device-profiles/ |
gpuinfo reports and local captures |
crates/metal2vulkan/tests/api_signatures.tsv is written the same way: the signature-level public
surface of the three published crates, by
python3 scripts/api-signatures/signatures.py --bless (--check to verify, --selftest for the
derivation's own tests), from those crates' sources alone.
crates/metal2vulkan/tests/api_signatures.rs says what it pins, what it cannot see, and what
blessing it asserts; a removed or changed line is a breaking change of a published crate.
Three docs are checked by tests. docs/REFUSALS.md must be the surface the sources state, and
every variant of the runtime's refusal enums must end its doc comment with a Basis: line that says
where the belief that Metal refuses that input comes from and cites its evidence
(crates/metal2vulkan/tests/refusal_surface.rs, which says what it cannot see; a basis that is
not settled is Basis: unknown (why), never nothing); docs/API.md must list every degrade code
with its category and quote examples/api_preview.rs verbatim in its rust blocks; and
docs/METAL-COVERAGE.md must carry the coverage table's totals.
Changes
- Follow AGENTS.md: structure over names, honest refusals, one form per Vulkan capability, tests for every fixed bug class.
- One concern per commit when practical; run
cargo fmt --allfirst. - Update the docs a consumer reads when what they describe changes:
docs/API.mdandexamples/api_preview.rsfor the translator's API, the runtime's README and rustdoc for the runtime,docs/HOWTO.mdfor integration,docs/ARCHITECTURE.mdfor the translator's stages,README.mdfor the command line. CHANGELOG.mdlists releases in a few lines each; add to the top, unreleased version.
License
metal2vulkan is dual-licensed, GPL-2.0-or-later OR LGPL-3.0-or-later, at the recipient's choice
(LICENSE). Contributions are accepted under the same dual license: a change you submit
can be redistributed and modified under either.
The license files sit at the root and, because cargo packages each crate from its own directory,
as copies in every published crate (crates/metal2vulkan and crates/metal2vulkan-air). Change
them at the root and copy them over; a validation test (published_crates) holds every copy equal
to the root's file
and the notice's SPDX line equal to the manifests' license.