Anees Iqbal 3338acecb5 Reflect AIR constexpr sampler state
Reserve translator-owned constexpr samplers inside the sampler descriptor\nband instead of allowing framebuffer-fetch bindings to push them into the\ncolor-input range. Decode the full two-word AIR sampler state and expose it\nthrough reflection schema version 3 so Vulkan consumers can create the exact\nimmutable sampler rather than guessing from the emitted descriptor.

Keep emission and reflection ordering aligned by the stable AIR sampler\nglobal suffix, and cover the pipe25 shape with runtime sampler, two static\nsamplers, and a framebuffer-fetch color input.

Verified with:\n- cargo test --workspace --all-features -- --test-threads=1\n- cargo clippy --workspace --all-targets --all-features -- -D warnings
2026-07-24 02:23:35 +03:00
2026-07-24 02:23:35 +03:00
2026-07-22 13:15:24 +03:00
2026-07-24 02:23:35 +03:00
2026-07-22 13:15:24 +03:00
2026-07-22 13:15:24 +03:00
2026-07-22 13:15:24 +03:00
2026-07-23 19:54:20 +03:00
2026-07-22 13:15:24 +03:00

metal2vulkan

License: LGPL-3.0-or-later

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 <in.air|.ll> <out.spv> --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<Vec<u8>, 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-party captured shaders. Prefer reduced .ll fixtures that name structural properties. Optional private system-metallib harvest and hash-only drift pins are documented in docs/VALIDATION.md.

spirv-val coverage is not the same as correct end-to-end pixels.

License

Licensed under the GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later).

Metal is a trademark of Apple Inc. metal2vulkan is an independent project and is not affiliated with, sponsored by, or endorsed by Apple Inc.

S
Description
No description provided
Readme
1.7 GiB
0 Stars 1 Watchers 0 Forks
Languages
Rust 61.3%
LLVM 31.7%
Metal 3%
Objective-C 2.2%
Python 1.2%
Other 0.5%