A Rust-based tool to convert Apple Metal's AIR/LLVM IR into Vulkan SPIR-V without invoking LLVM's llc.

Stars

163

7-day growth

No data

Forks

7

Open issues

2

License

LGPL-3.0

Last updated

2026-07-26

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It provides a native Rust solution for cross-platform shader translation from Metal to Vulkan, filling a gap for developers needing to reuse Metal shaders on Vulkan backends without relying on external LLVM toolchain.

Who it is for

  • Game developers targeting both Metal and Vulkan
  • Graphics engine developers needing cross-platform shader compatibility
  • Researchers in GPU intermediate representation translation
  • Developers of cross-platform graphics applications on Apple platforms

Use cases

  • Translating Metal compute or graphics shaders to SPIR-V for Vulkan execution
  • Integrating into build pipelines for cross-platform rendering
  • Experimenting with shader translation and reflection metadata generation
  • Porting Metal-based applications to Vulkan

Strengths

  • Native Rust implementation reduces dependency on LLVM tools
  • Supports multiple shader stages (vertex, fragment, compute, passthrough)
  • Includes both a CLI and a library API
  • Optional serde support for reflection metadata

Considerations

  • Project is in alpha (0.x series) with unstable API and output
  • Only supports sanitized LLVM bitcode, not arbitrary Metal source
  • Coverage relies on synthetic tests, not real-world shader validation

README quick start

metal2vulkan

Alpha. This project is early and under active development. The public API, CLI flags, reflection layout details, and SPIR-V output may change without a stable semver guarantee while the crate is in the 0.x series. Treat it as research-quality: useful for experimentation and integration pilots, not a frozen interface.

Translate Metal AIR (LLVM bitcode / sanitized .ll) to Vulkan SPIR-V using a native Rust emitter. Production translation does not invoke LLVM llc.

Features

  • Native AIR/LLVM-IR → OpCapability Shader / Logical GLSL450 SPIR-V
  • Stage interface lowering for vertex, fragment, compute (kernel), and passthrough
  • Library API plus a CLI compatible with simple in → out.spv harnesses
  • Optional serde feature for reflection metadata JSON
  • Optional workspace package for local Metal oracle / Vulkan executor experiments

Install

# CLI
cargo install metal2vulkan

# Library (Cargo.toml)
metal2vulkan = "0.1"

CLI

metal2vulkan   --stage vertex|fragment|passthrough|kernel
# optional interface metadata JSON (requires --features serde)
metal2vulkan in.ll out.spv --stage kernel --emit-meta out.json
  • Success: prints a line containing PASS, writes SPIR-V, exits 0
  • Failure: prints FALLBACK, exits non-zero

On failure the CLI writes a repro bundle under $TMPDIR/metal2vulkan-repros (override with METAL2VULKAN_REPRO_DIR).

Example

cargo run --example translate_native -- path/to/shader.ll kernel out.spv

Library

use metal2vulkan::passes::Stage;
use std::path::Path;

fn translate_ll(sanitized_ll: &str) -> Result, String> {
    let tmp = std::env::temp_dir().join("m2v-scratch");
    std::fs::create_dir_all(&tmp).ok();
    metal2vulkan::translate_sanitized_native(sanitized_ll, Stage::Kernel, Path::new(&tmp))
}

See crate docs (cargo doc --open), docs/ARCHITECTURE.md for the pipeline, and docs/REFLECTION.md for how consumers read binding metadata after a convert. Repository layout and the developer loop are in CONTRIBUTING.md. How to stay confident while refactoring (harvest, hash ledgers, A/B) is in docs/VALIDATION.md.

Coverage policy

Grammar and lowering behavior is locked with synthetic Rust tests. This repository does not ship third-p

Description

Translate Metal AIR / LLVM IR to Vulkan SPIR-V with a native Rust emitter

Related repositories

Similar projects matched by category, topics, and programming language.

l0ng-ai
Featured
l0ng-ai GitHub avatar

tty7

tty7 is a fast, GPU-accelerated terminal workbench with persistent sessions, built-in input tools, SSH support, and coding agent awareness.

Developer ToolsCLI & Terminal
359
steelbrain
Featured
steelbrain GitHub avatar

reims-vgpu

reims-vgpu is an experimental virtual GPU for macOS guests that uses QEMU to decode the guest's GPU command stream and execute it through Metal or Vulkan, leveraging the built-in AppleParavirtGPU driver without requiring custom kexts.

Desktop Apps
143
m-novotny
Featured
m-novotny GitHub avatar

memguard-rs

A Rust library that provides secure memory handling primitives including zeroization on drop, memory locking, constant-time comparison, and compile-time guarded regions, with zero dependencies and no_std support.

Embedded & IoTSecurity
131