System requirements
Metal shader converter requires macOS 13 Ventura and Xcode 15, or later.
Metal shader converter for Windows requires Microsoft Windows 10 and Microsoft Visual Studio 2019, or later.
Metal libraries built using Metal shader converter tools require a device that supports Argument Buffers Tier 2, running macOS 14 Sonoma, iOS 17 or later. If you build a Metal library for earlier OS versions, not all features will be supported.
Downloads
Your first conversion
Command line
The Metal shader converter executable offers several options to customize code generation. In its most basic form, Metal shader converter takes a DXIL file as input and produces a metallib.
% metal-shaderconverter shader.dxil -o shader.metallib
Dynamic library (libmetalirconverter)
libmetalirconverter offers a C interface for easy integration into C, C++, Objective-C, and Swift codebases.
IRCompiler* compiler = IRCompilerCreate();
IRCompilerSetEntryPointName(compiler, "MainVS");
IRObject* dxil = IRObjectCreateFromDXIL(bytecode, size, IRBytecodeOwnershipNone);
IRError* error = nullptr;
IRObject* outIR = IRCompilerAllocCompileAndLink(compiler, NULL, dxil, &error);
IRMetalLibBinary* metallib = IRMetalLibBinaryCreate();
IRObjectGetMetalLibBinary(outIR, stage, metallib);
size_t metallibSize = IRMetalLibGetBytecodeSize(metallib);
uint8_t* metallibBytes = new uint8_t[metallibSize];
IRMetalLibGetBytecode(metallib, metallibBytes);
delete [] metallibBytes;
IRMetalLibBinaryDestroy(metallib);
IRObjectDestroy(dxil);
IRObjectDestroy(outIR);
IRCompilerDestroy(compiler);
Supported shader models
| Shader model |
Notable features |
| SM6.0 | Wave intrinsics, 64-bit integers |
| SM6.1 | Barycentrics (linear interpolation) |
| SM6.2 | 16-bit scalar types |
| SM6.3 | Ray tracing |
| SM6.4 | Packed dot-product intrinsics |
| SM6.5 | Mesh and Amplification shaders |
| SM6.6 | Dynamic resources, compute derivatives, IsHelperLane |
Version history
| Version |
Highlights |
| 4.0 | 2D compute derivatives; NaN/Inf optimization on by default |
| 3.1 | libmetalirconverter on iOS |
| 3 | Function constants, framebuffer fetch, Metal intersection function buffers, non-array texture types by default |
| 2 | Shader debug info, globally-coherent memory, ray generation as compute kernels |
| 1.1 | Ray tracing shaders |
| 1 | Initial release |