Metal (API)
By Apple
Metal is Apple's low-level graphics and compute application programming interface, providing near-direct access to the GPU on Apple's devices for rendering graphics and running parallel compute workloads. It replaced Apple's use of OpenGL…
Definition
Metal is Apple's low-level graphics and compute application programming interface, providing near-direct access to the GPU on Apple's devices for rendering graphics and running parallel compute workloads. It replaced Apple's use of OpenGL and OpenCL on its platforms, giving developers finer, more explicit control over GPU resources, memory, and command scheduling, with substantially lower driver overhead than older, higher-level, immediate-mode graphics APIs.
Overview
Metal was introduced to address a growing performance gap between older, higher-level graphics APIs like OpenGL and the way modern GPU hardware is actually organized, with explicit command buffers, parallel command encoding, and manual memory management. OpenGL's driver had to infer a great deal of intent from a stream of stateful function calls, which introduced overhead and made performance unpredictable, especially for demanding game and graphics workloads on mobile hardware. Mechanically, Metal exposes GPU work through explicit objects: command buffers hold encoded instructions, command encoders translate rendering or compute calls into those instructions, and pipeline state objects precompile shader and rendering configuration ahead of time rather than validating it at every draw call. This explicit model lets an application prepare and submit work from multiple CPU threads concurrently, and lets the GPU driver do far less runtime interpretation than older immediate-mode APIs, which is where much of Metal's performance advantage comes from. Among low-level graphics APIs, Metal is Apple's counterpart to Vulkan, from the Khronos Group, and DirectX 12, from Microsoft, all of which emerged around the same period with similar goals of exposing explicit, multi-threaded GPU control. Metal is exclusive to Apple's platforms, meaning code written for it does not run on Windows, Linux, or Android without a translation layer, whereas Vulkan is cross-platform. In exchange for that lock-in, Metal integrates tightly with Apple's specific GPU architectures, including the unified memory model on Apple Silicon, letting the CPU and GPU share memory without explicit copies. In practice, Metal underlies graphics rendering in games, creative applications like Final Cut Pro, and machine learning frameworks on Apple hardware through Metal Performance Shaders, a library of tuned compute kernels for tasks like matrix multiplication and image processing. Frameworks such as PyTorch and TensorFlow use Metal as a backend to accelerate model training and inference on Macs with Apple Silicon GPUs. Metal's central limitation is its platform exclusivity: it is a strong choice for anything targeting only macOS, iOS, iPadOS, or visionOS, but a poor one for cross-platform software, which typically needs a portability layer or a separate Vulkan or DirectX implementation instead. Its explicit, low-level programming model also demands more upfront engineering effort than higher-level abstractions, so many developers instead use game engines like Unity or Unreal that target Metal internally rather than writing directly against the API. Even so, understanding Metal's underlying model remains useful for performance debugging, since engine-level profiling tools ultimately surface Metal's own command buffers and GPU counters.
Specification
- Low-level, explicit access to GPU rendering and compute pipelines
- Multi-threaded command encoding for reduced driver overhead
- Precompiled pipeline state objects avoiding runtime shader validation
- Metal Performance Shaders library for tuned compute kernels
- Tight integration with Apple Silicon's unified memory architecture
- Used as an acceleration backend for machine learning frameworks
- Exclusive support across macOS, iOS, iPadOS, and visionOS
- Successor to OpenGL and OpenCL on all Apple platforms