Files
metal2vulkan/scripts/regen-spirv-grammar
Anees Iqbal 8b78eaca3b Expand macOS 26 AIR translation coverage
Overhaul the validation workflow around sharded authored cases, dependency-exact observations, incremental indexed corpus audits, bounded parallel translation, and native Metal/Vulkan comparison.\n\nExpand native AIR lowering, reflection, linked-function specialization, resource and stage-interface support, and structural CFG/pointer repair across the harvested macOS 26 corpus. Add exact intrinsic inventory, distributed 16x16x16 matrix lowering, explicit opaque tensor linkage, and regression coverage for the newly supported feature classes.\n\nThe final corpus verification accounts for all 88,819 indexed AIR modules under the current product fingerprint: 65,355 translate and validate directly, 23,464 require exact authored linkage, and zero fail or remain unresolved.
2026-08-13 21:46:27 +02:00
..

regen-spirv-grammar

Regenerates the checked-in SPIR-V decoder / grammar tables from the Khronos SPIR-V core grammar JSON, using the public rspirv autogen tool as a generator. The generator is not a runtime dependency of metal2vulkan.

What gets rewritten

Output Role
src/spirv_binary/decode_generated.rs Enum bit-decoder methods
src/spirv_binary/error_generated.rs Decoder error variants
src/spirv_binary/parse_generated.rs Operand parse dispatch
src/spirv_binary/grammar_generated.rs Core instruction table
src/spirv_disassemble_generated.rs Operand disassembly
src/spirv_operand_display_generated.rs Display for Operand

Hand-written crate code (parser.rs, decoder.rs, grammar.rs, …) is not touched.

Defaults (locked to the spirv crate pin)

  • rspirv tag: rspirv-0.13.0 (ships spirv 0.4.0+sdk-1.4.341.0)
  • SPIRV-Headers tag: vulkan-sdk-1.4.341.0

Override with RSPIRV_REF / HEADERS_REF if you deliberately bump both together with Cargo.toml's spirv dependency.

The script caches both repositories under .cache/rspirv-autogen. Set METAL2VULKAN_AUTOGEN_CACHE to use a different cache directory. It requires git, cargo, rustfmt, and Python 3, and requires network access when fetching missing revisions.

Run

./scripts/regen-spirv-grammar/regen-spirv-grammar.sh
cargo test -p metal2vulkan --lib spirv_module -- --test-threads=1

The script runs cargo fmt --all. Review every generated diff and update the spirv dependency and locked revisions together.

Provenance

  • Source of truth: Khronos spirv.core.grammar.json (SPIRV-Headers).
  • Generator: rspirv-autogen (Apache-2.0 tool; not linked into this crate).
  • Checked-in artifacts: mechanical output of that generation + small renames for this crate's API (WORD_BYTES, Operand, core-only OperandKind). They are not a vendored copy of the rspirv library sources.