The macOS 27 work packet: the M3 Max moved to macOS 27.0.1, where MoltenVK gives it the M4's deviceID. Its measurements, its MoltenVK profile, its Metal rows (now the C3 reference) and its MoltenVK venue rows are taken again, and the tests follow. Read Metal's NotMipmapped anisotropic footprint through MoltenVK at level 0: On macOS 27 Metal's anisotropic filter reads a sampler without a mip filter differently once its level clamp reaches 1/64: the runtime's NotMipmapped form (nearest mip, lod [0, 0.25]) handed MoltenVK an anisotropic footprint that was not Metal's NotMipmapped one, and the anisotropic lane failed on the M3 Max under macOS 27.0.1. Through Metal's own sampler (VkProperty::MetalSampler) with anisotropy and equal min and mag filters the sampler now clamps to [0, 0]: with equal filters the level has no filter left to choose, and Metal answers that sampler as NotMipmapped bit for bit. With filters that differ no clamp reads Metal's answer at maxAnisotropy 2 to 16; that stays a known gap in docs/FAST-PATHS.md. RUNTIME_VERSION moves (renumbered once for the composed batch): a run of an unchanged artifact samples differently. Verified: metal::sampler unit tests (24, including the new metals_own_anisotropic_sampler_reads_not_mipmapped_at_level_zero) at a release build; runtime_lane::anisotropic_filter::anisotropic_samples_answer_within_ their_bounds_of_metals passes on the M3 Max, macOS 27.0.1, MoltenVK 1.4.1 (it failed at the round's first composed tree and at61a2efc7d3). Take the M3 Max's macOS 27 measurements on MoltenVK's shared Apple identity: MoltenVK's deviceID on an Apple GPU is the macOS release and the GPU's highest families (MVKPhysicalDevice::getHighestGPUCapability), so under macOS 27.0.1 the M3 Max reports 0x1B000209, the M4's identity, and takes the M4's driver facts. The owner's rule: an answer fact holds on the shared identity only where measured on both GPUs; a cost fact follows the M3 Max. - MetalNormStorageWrites and DepthTestKeepsDenormals, measured on the M4: re-measured on the M3 Max under macOS 27.0.1 with the fact taken, every channel and texel Metal's; kept, the evidence in their docs. - GraphicsCubeGradientRoute stays measured on the macOS 26.7 identity alone; the shared identity's graphics route stays unmeasured. - The interlocked pass: on the M3 Max under macOS 27.0.1 split ran about a quarter faster than whole (wall 721-769 us against 974-1045, GPU 671-719 against 914-964, two runs of three rounds of 30 frames at 1920x1080 RGBA16Float), so the shared identity's row moves from InterlockedPassWholeFaster to InterlockedPassSplitNoSlower. The M4's own measurement (whole faster) is in the row's doc and in docs/FAST-PATHS.md's known gaps. RUNTIME_VERSION 1190 on this branch covers it. - APPLE_M3_MAX and APPLE_M4 say what the deviceID is. Verified: the facts and timings on the M3 Max (macOS 27.0.1, MoltenVK 1.4.1) through runtime-lane tests at the round's first composed tree with these facts; the device::tests::driver_facts unit tests run at the rebased tip before landing. Hold the degrade-notice lane to the resolves the device actually makes: passes_degrade_once_per_kind expected the exact resolve and the device's rounded one to be announced wherever the driver's RGBA8Unorm average at 4 samples is measured as Metal's, assuming a texture of 8 samples exists. The M3 Max (macOS 27.0.1, MoltenVK 1.4.1) makes none at 8 samples, so neither is announced there, and the lane failed. The filter now expects those two where the average is not measured as Metal's or where the device makes an 8-sample texture. Verified: runtime_lane::degrade_notices::passes_degrade_once_per_kind passes on the M3 Max (it failed at61a2efc7d3and the round's first composed tree). Write the tessellation test's vertex output as Metal's compiler does: authored_tessellation_executes_native_patch_inputs hand-writes its AIR, and its post-tessellation output carried metadata Metal's compiler does not write (Xcode 27, every macOS target 13 to 27 checked): air.location_index on a vertex output. Our AIR reader refused it (Abi(UnknownKey) for air.location_index on a vertex output), as it should for a key the compiler never writes there. The output now carries air.vertex_output with its user(locn0) name, its type name and its argument name, as the compiler emits it. Verified: metal::tests::graphics::authored_tessellation_executes_native_ patch_inputs passes on the M3 Max, macOS 27.0.1 (it failed at61a2efc7d3and the round's first composed tree). Wrap the driver-facts claims test's doc at the line width: The interlocked-pass sentence the shared-identity commit rewrote ran past the 100-column doc width. No other change. Hold the unmeasured-identity test to the macOS 27 identity's split form: an_unmeasured_identity_takes_its_drivers_defects_alone still expected the moltenvk-m4 capture to take InterlockedPassWholeFaster, which the shared macOS 27 identity no longer does (it takes InterlockedPassSplitNoSlower, the M3 Max's measurement). Found by the device::tests::driver_facts run at the rebased tip. Name the format where the formats capture and the product's query differ: the_formats_capture_is_the_product_queried_formats_of_the_venue_device compared every format's masks without naming the format, so a failure on the M3 Max showed two masks and no format. Each assert now names it. Test-only. Capture the M3 Max's MoltenVK profile under macOS 27.0.1: The reference Mac runs macOS 27.0.1 (26A434) now. Its moltenvk-m3 capture (vulkaninfo --json and corpus-vulkan --capture-formats, Homebrew MoltenVK 1.4.1, vulkan-tools 1.4.350.1) is regenerated through scripts/regen-device-profiles. Only the identity moved: MoltenVK's deviceID on an Apple GPU is the macOS release and the GPU family, so the M3 Max now reports 0x1B000209 (452985353), the M4's identity, and every capability, limit and format mask is as before. c3-venues.json declares the new identity. The two captures now differ only in allocation sizes, which no translation reads, so they derive one translation key: - candidate::platform::profiles: a run on the M4 held to the M3 Max venue stops on the device name alone (the venue's identity guard, not product behaviour), and proceeds where the venue allows the M4. - c3::tests: the M4's capture passes check_profiles as a second device of the venue; the list still refuses it for naming the M3 Max's Metal environment. - device::tests::driver_facts: moltenvk-m3 takes the shared identity's facts; the macOS 26.7 identity (APPLE_M3_MAX), measured but with no committed capture now, moves to MEASURED_WITHOUT_PROFILE and keeps its coverage through a description at that deviceID, graphics cube route included. - tests::engine_sampler_unk: the graphics cube route's test builds the M3 Max under macOS 26.7 the same way. Docs: API.md and profiles/README.md say what MoltenVK's deviceID is. Golden hashes and expectation rows that hold moltenvk-m3's translation key are left for the round's bless. Verified: the capture on the M3 Max (regen_device_profiles.py --only moltenvk-m3, check_device_profiles.py); the unit tests above run at a build of this branch before landing. Record the Metal rows of the M3 Max under macOS 27.0.1: The reference Mac's Metal answers, apple-m3-max-macos27.0.1 (Apple M3 Max, 40 GPU cores, macOS 27.0.1 26A434, Xcode 27A266a, Metal toolchain 32023.921, ORACLE_ABI metal-literal-resources-v48): corpus-metal --batch over every case the 26.7 environment holds, in three maclock holds of about 6.5 minutes, then --batch-install. 2227 cases ran: 2223 qualified, 4 reference gaps (the simdgroup_matrix 16x16 cases, GPUFamily10, as on 26.7), no failure. The 26.7 rows stay. Against the 26.7 rows: no status changed and 8 outputs moved, every one a cube-gradient case with identical AIR and inputs (a54af728, 315ca8b0, 391fac4d, 6ce71712, ae7aa91b, b3e5b4ef, dd39e2e5, 649c204a). Those 8 ran a second time identically. Every other case answers as on 26.7. Expect the M3 Max's and the M4's MoltenVK captures to share a fingerprint: fingerprints_distinguish_committed_profiles listed only the two Intel captures as sharing a fingerprint, kept apart for the Apple GPUs by the graphics cube route measured on the M3 Max's macOS 26.7 deviceID. Under macOS 27 MoltenVK gives the M3 Max and the M4 one deviceID, and the captures differ only in allocation sizes, so moltenvk-m3 and moltenvk-m4 now derive one fingerprint; the test lists the pair. Found by device::tests at a build of this branch; device:: (104) and tests::engine_sampler_unk (8) pass with it on the release build. Make the M3 Max under macOS 27.0.1 the C3 reference Metal environment: The reference Mac runs macOS 27.0.1 (26A434), and its Metal rows are committed (apple-m3-max-macos27.0.1). The switch: - c3-references.json: the primary is apple-m3-max-macos27.0.1 (Apple M3 Max, 40 cores, 27.0.1, 26A434, Xcode 27A266a, Metal toolchain 32023.921). - c3-venues.json: the MoltenVK venue's device compares with it. - runtime_lane::METAL_ENVIRONMENT, the reference and venue tests, and scripts/rerecord-venue's default name it. - The parity lines: record_metal and the sequences' record_metal on the M3 Max under macOS 27.0.1. The four scenarios recorded 68, 240, 95 and 36 records; the 64 sequence seeds 8534 records, 0 differences from the model and no Metal-side gap (seeds 32, 51 and 62 crashed Metal's driver under 26.7; they run under 27.0.1). The 26.7 lines and rows stay. Verified on the M3 Max (release, --cfg m2v_gpu, the validation layer on): runtime_lane::driver_deviations::cube_gradients_through_an_anisotropic_ sampler_answer_as_metal passes against the 27 rows (MoltenVK answers Metal 27's cube gradients; it failed against the 26.7 rows); parity::tests:: committed_records_are_current and the 14 parity and sequence lanes pass (their 2 recorders are ignored); the c3::, candidate::platform::profiles::, candidate::engine::guards:: and parity::tests:: modules pass (98 tests). Record the M3 Max's MoltenVK venue under macOS 27.0.1 at product 15b6df4e2bd0: Rows and refusals recorded by one build (executor vulkan-engine-v181, product 15b6df4e2bd0cb440724ffe07ba95f1ccf6d0a5dd7fb5055598e70c877596734, semantics 1698, oracle metal-literal-resources-v48) at this commit's product, on the Apple M3 Max under macOS 27.0.1 (MoltenVK 1.4.1, deviceID 0x1B000209). They are judged against the apple-m3-max-macos27.0.1 Metal rows and were installed by scripts/rerecord-commit --no-commit. No later commit changes the product, so every row installed here stays current. - apple-m3-max-moltenvk (moltenvk): 4389 rows, 56 refusals, over 2223 cases in two legs - stated: 2168 match, 23 mismatch, 31 refused, 1 failed - robustness-off: 2175 match, 23 mismatch, 25 refused Against the macOS 26.7 rows, per case and leg: - Of the earlier matches, 2965 still match, none mismatches, and 1 failed (below). - 13 earlier mismatches and 13 earlier refusals now match; 38 mismatches and 42 refusals remain. - 1374 runs had no 26.7 row: 1352 match, 14 refused, 8 mismatch. The 8 are the robustness-off leg of four linked-single radix13 and radix15 zero-write cases whose stated leg was already a mismatch, and both legs of the two new cases quad-broadcast-first-in-an-arm-metal-speculates and quad-broadcast-first-in-a-fragment-arm-metal-speculates. The failed run is authored-four-iteration-loop (3cf0a3f024a5), stated leg. Metal's compiler connection was interrupted while it compiled the compute pipeline (XPC_ERROR_CONNECTION_INTERRUPTED after MoltenVK's retries), on both the first try and the --retry-failed run. Its robustness-off leg matches, and under 26.7 it matched in both legs. Its stated slot keeps the 26.7 row, which C3 reads as stale. Two msl-4-1 cases the venue's selection did not include also keep 26.7 rows that read stale. Verified: - corpus-moltenvk --batch-report reads this_build=yes for the out directory at the recording tree and at the round's final tree (the table bless after this commit), which adds only tests, test tables and docs. - corpus-status --c3 prints the same report at both trees. The MoltenVK slots (stated, then robustness-off) read: match 2168 and 2175, reviewed 10 and 10, mismatch 13 and 13, refused 25 and 19, ray tracing out of scope 6 and 6, stale 3 and 1. Versions: RUNTIME_VERSION 1205 -> 1211. RUNTIME_VERSION moves: MoltenVK's NotMipmapped anisotropic footprint is read at level 0, and the macOS 27 Apple identity takes InterlockedPassSplitNoSlower. crates/metal2vulkan-validation/runtime-sources.sha256 holds e74792b15fd66114fb4efcc8e281318bfe1e16a3b8532e90d737834ea5a2add3, the hash of this tree's runtime inputs (runtime-pin.py, which reproduces build.rs's). Version numbers quoted above are the values the work's branch built with. Each part's Verified lines name the tree it ran at.
metal2vulkan
metal2vulkan runs Metal shaders and Metal programs on Vulkan. It reads Metal AIR (a metallib, or AIR bitcode) and compiles it into Vulkan pipelines, and it offers the Metal API itself on top of a Vulkan device.
Alpha. The API, the command line, the pipeline JSON and the emitted SPIR-V may change during the
0.xseries. Version your cached outputs.
The crates
| Crate | Directory | What it is |
|---|---|---|
metal2vulkan |
crates/metal2vulkan |
The translator. A Metal-shaped API (device, library, pipeline descriptors, binding plans) that compiles compute, render, tessellation, tile and mesh pipelines for a described Vulkan device: SPIR-V per stage, one pipeline layout, fixed-function state, and per-draw descriptor writes and push constants. The cli feature builds the metal2vulkan command. |
metal2vulkan-runtime |
crates/metal2vulkan-runtime |
The Metal API on Vulkan: devices, command queues and buffers, encoders, buffers, textures, heaps, pipeline states and events, run on a Vulkan device through ash. It uses only the translator's public API. |
metal2vulkan-air |
crates/metal2vulkan-air |
The AIR front end: the metallib container, the bitcode reader, a typed IR, AIR's metadata ABI, intrinsics and canonicalization. For tools that read AIR without translating it. |
metal2vulkan-validation |
crates/metal2vulkan-validation |
Not published. Authored cases run on Metal and on Vulkan and compared, and bounded audits over a private corpus. |
metal2vulkan-devtools |
crates/metal2vulkan-devtools |
Not published. The external-tool runner and fixture assemblers the tests share. |
The three published crates share one version and are released together; metal2vulkan pins
metal2vulkan-air exactly.
What the translator promises:
- Typed refusals. Input the device cannot run exactly fails with an error that names the Metal feature and what would make it work. It never returns a module that computes something else.
- Recorded differences. Where a pipeline gives a near-equivalent of Metal's answer, its artifact records a precision note, and the runtime announces it once with a stable code.
- Fast by default. Off Apple's GPUs, choices that trade exactness for speed take the device's native form; each has an opt-in exact switch (docs/FAST-PATHS.md).
- Bounded work. Every compile runs under a deadline, a cancellation token and deterministic work and memory caps.
Install
0.2.0 is not on crates.io yet (crates.io has 0.1.0, an unrelated earlier design). Depend on a git revision:
[dependencies]
metal2vulkan = { git = "https://github.com/steelbrain/metal2vulkan", rev = "<sha>" }
# For the Metal API on Vulkan:
metal2vulkan-runtime = { git = "https://github.com/steelbrain/metal2vulkan", rev = "<sha>" }
Features of metal2vulkan, none needed by the library:
serde: serialization of the API's plain-data values.ash: conversions to and fromash::vk, andDeviceDescription::query, which reads a physical device.cli: themetal2vulkancommand (enablesserde).
Requirements: Rust 1.98 or newer. The libraries run no external tool. The runtime opens the Vulkan loader at run time and needs a Vulkan 1.2 device.
Command line
cargo install --git https://github.com/steelbrain/metal2vulkan metal2vulkan --features cli
The command compiles one pipeline of a metallib, an AIR bitcode module or an LLVM text module
(.ll) for the device a Khronos profiles JSON describes, and writes its SPIR-V:
# A kernel: one module.
metal2vulkan library.metallib kernel.spv --profile device.json --function my_kernel
# A render pipeline: one module per stage (pipeline.vert.spv, pipeline.frag.spv).
metal2vulkan shaders.air pipeline.spv --profile device.json \
--function vertex_main --fragment fragment_main --vertex-descriptor vertex.json \
--color-format 0:BGRA8Unorm --depth-format Depth32Float
# The pipeline's layout, interface, dependencies and stages as JSON.
metal2vulkan kernel.ll kernel.spv --profile device.json --emit-meta kernel.json
--profileis required: the crate ships no device description. Any Khronos profiles JSON works;crates/metal2vulkan-validation/profiles/has examples, from a bare Vulkan 1.2 device to desktop GPUs and MoltenVK.- Without
--functionit compiles the library's only kernel or vertex function. A kernel with--color-formatcompiles as a tile pipeline. A post-tessellation vertex function adds.tesc.spvand.tese.spvmodules. - A compile that needs a pipeline input fails naming it and the option that supplies it:
--constant ID:TYPE:VALUEfor a function constant,--stage-input FILEor--vertex-descriptor FILEfor a stage-input or vertex descriptor (as JSON). - A
.llinput is assembled withllvm-as(LLVM 21 or newer). Each module written is checked withspirv-valwhen it is found, under the environments the library states for the device;--no-spirv-valskips it. Both tools come fromPATH, or fromMETAL2VULKAN_LLVM_ASandMETAL2VULKAN_SPIRV_VAL. - Success prints a line with
PASSand exits 0. Failure printsmetal2vulkan: FALLBACK (<why>), writes nothing, and exits 2; a failure after the inputs are read also writes a repro bundle under$TMPDIR/metal2vulkan-repros(orMETAL2VULKAN_REPRO_DIR). metal2vulkan --helplists every option.
Library
The flow follows Metal's object lifecycle: describe the device, parse a library, compile a pipeline, then plan and instantiate each dispatch or draw.
use metal2vulkan::device::{Device, DeviceDescription, DevicePolicy};
use metal2vulkan::library::Library;
use metal2vulkan::pipeline::{ComputePipelineDescriptor, FunctionDescriptor, StageSource};
use metal2vulkan::Budget;
let description = DeviceDescription::from_khronos_json(&profile_json, None)?;
let device = Device::new(description, DevicePolicy::default())?;
let library = Library::parse(&metallib_bytes)?;
let kernel = FunctionDescriptor::new(library.function("my_kernel")?);
let descriptor = ComputePipelineDescriptor::new(StageSource::Function(kernel));
let pipeline = device.compile_compute_pipeline(&descriptor, &Budget::standard())?;
// pipeline.stage.spirv, pipeline.layout, pipeline.interface: create the Vulkan objects from these,
// then pipeline.plan(...) and plan.instantiate_dispatch(...) per dispatch.
docs/API.md walks the whole flow on a runnable example,
examples/api_preview.rs:
cargo run -p metal2vulkan --example api_preview # needs llvm-as on PATH
For the runtime, start at its README.
Documentation
| Document | Read it when |
|---|---|
| docs/API.md | You use the translator's API: devices, libraries, pipelines, binding, caching, errors; and the runtime's degrade notices |
| Runtime README | You use the Metal API on Vulkan |
| docs/HOWTO.md | You integrate: tools, caching, failures, isolation, the runtime's shader cache |
| docs/RUNTIME-PORTING.md | You port Metal calls (Objective-C or metal-rs) to the runtime |
| docs/FAST-PATHS.md | You need every speed-for-accuracy default and its exact switch |
| docs/METAL-COVERAGE.md | You ask whether a Metal API item is covered |
| docs/REFUSALS.md | You ask what Metal accepts that the code refuses |
| docs/ARCHITECTURE.md | You change the translator |
| docs/VALIDATION.md | You check behavior against Metal |
| CONTRIBUTING.md | You build and test the repository |
The rustdoc of each crate (cargo doc --workspace --all-features --open) documents every public
item; each runtime item names its Metal counterpart.
Shaders in this repository
The repository ships no third-party shaders. Tests use synthetic fixtures written for it. Passing
spirv-val shows a module is valid, not that it computes what Metal computes; that claim needs the
authored validation cases (docs/VALIDATION.md).
License
metal2vulkan is dual-licensed: you can redistribute it and/or modify it under the terms of either of these licenses, at your choice (LICENSE):
- the GNU General Public License, version 2, or (at your option) any later version;
- the GNU Lesser General Public License, version 3, or (at your option) any later version. It incorporates the terms of the GNU General Public License, version 3.
As an SPDX expression: GPL-2.0-or-later OR LGPL-3.0-or-later. Each published crate carries the
notice and the three texts.
Metal is a trademark of Apple Inc. metal2vulkan is an independent project and is not affiliated with, sponsored by, or endorsed by Apple Inc.