Metal binary archives
Distribute precompiled GPU-specific binaries as part of your app to avoid runtime compilation of Metal shaders.
Overview
Metal supports the widest range of devices available by compiling to Metal intermediate representation (Metal IR), but this comes with a tradeoff. Metal IR libraries are smaller and more flexible, but your app still needs to compile shader functions for the device’s GPU at runtime. This isn’t always desirable; for example, you might want to precompile shaders you use for visual presentation while your app performs other loading or setup. When you’re ready to increase the size of your application bundle in exchange for avoiding runtime compilation, you can precompile shaders to binary archives. Binary archives are GPU-specific slices you ship individually or as part of a larger Metal library.
The Metal translator is part of the Metal compiler that produces binary archives from a combination of Metal IR and a JSON representation of your app’s pipeline state. You run the Metal translator with the metal-tt command in Terminal.
To get the most out of binary archives and the Metal translator, read the articles below in order, starting with Creating binary archives from device-built pipeline state objects.