Format:Metal library
| Vendor | Apple |
|---|---|
| Magic | MTLB |
| Extensions | .metallib |
| On this wiki | Facts · Code · Notes · Topics |
Apple's compiled shader library (.metallib, default.metallib in app bundles), recognised by the magic 'MTLB' at offset 0; it holds one or more functions as Apple-GPU or AIR (LLVM bitcode) code, with a function list and per-function tags.
Overview
Metal apps for macOS and iOS ship their shaders as default.metallib inside the app bundle (built by the metal and metallib tools from .metal sources). Recognition is by the first four bytes 'MTLB'.
Contents
Unverified: the library has a header with the target platform and OS version, a function list (each function named, with type vertex / fragment / kernel), and a per-function entry containing an AIR module (LLVM bitcode, starting with the 'BC' 0xC0DE magic or wrapper 0x0B17C0DE) and tag-length-value records such as the hash and the entry name. I have not read an open parser's source for this page; verify field offsets against an open tool before use.
Reversing
The AIR bitcode can be loaded with an LLVM version close to Apple's (llvm-dis may fail on newer metadata). Unverified: practical details.
See Technique:Compiled GPU shader formats, Format:DXIL for another LLVM-bitcode shader format.