Fundamental Metal Concepts
Metal provides a single, unified programming interface and language for both graphics and data-parallel computation workloads. Metal enables you to integrate graphics and computation tasks much more efficiently without needing to use separate APIs and shader languages.
The Metal framework provides the following:
Low-overhead interface. Metal is designed to eliminate “hidden” performance bottlenecks such as implicit state validation. You get control over the asynchronous behavior of the GPU for efficient multithreading used to create and commit command buffers in parallel.
For details on Metal command submission, see Command Organization and Execution Model.
Memory and resource management. The Metal framework describes buffer and texture objects that represent allocations of GPU memory. Texture objects have specific pixel formats and may be used for texture images or attachments.
For details on Metal memory objects, see Resource Objects: Buffers and Textures.
Integrated support for both graphics and compute operations. Metal uses the same data structures and resources (such as buffers, textures, and command queues) for both graphics and compute operations. In addition, the Metal shading language supports both graphics and compute functions. The Metal framework enables resources to be shared between the runtime interface, graphics shaders, and compute functions.
For details on writing apps that use Metal for graphics rendering or data-parallel compute operations, see Graphics Rendering: Render Command Encoder or Data-Parallel Compute Processing: Compute Command Encoder.
Precompiled shaders. Metal shaders can be compiled at build time along with your app code and then loaded at runtime. This workflow provides better code generation as well as easier debugging of shader code. (Metal also supports runtime compilation of shader code.)
For details on working with Metal shaders from your Metal framework code, see Functions and Libraries. For details on the Metal shading language itself, see Metal Shading Language Guide.
A Metal app cannot execute Metal commands in the background, and a Metal app that attempts this is terminated.