Metal (API)
More actions
| Metal | |
|---|---|
| Information | |
| Type | Graphics and compute API |
| Developer | Apple |
| Operating System | iOS, iPadOS, macOS, tvOS, visionOS |
| Website | https://developer.apple.com/metal/ |
Metal is a low-level graphics and compute application programming interface (API) developed by Apple. It provides applications with access to a GPU for rendering images and executing parallel calculations. Apple's Metal framework is available on iOS, iPadOS, macOS, tvOS and visionOS; individual functions and GPU features have their own availability requirements.[1]
For immersive applications on Apple Vision Pro, Metal can supply a custom renderer while Compositor Services supplies display textures and frame timing, and ARKit supplies tracking information. This division lets an application implement its own graphics pipeline rather than use the higher-level RealityKit renderer.[2] An original IEEE VIS 2024 study used Metal shaders to implement immersive GPU volume rendering on Vision Pro.[3]
History and API generations
Apple introduced Metal with the iOS 8 developer SDK on 2 June 2014, initially describing it as a graphics technology for the A7 chip.[4] Its original developer presentation described explicit GPU work submission and moving expensive shader compilation and state preparation away from repeated draw calls as design goals.[5] Apple announced Metal support for the Mac as part of OS X El Capitan on 8 June 2015.[6]
At WWDC25, Apple presented Metal 4 as an extension of the existing Metal framework with a new command structure, different resource-binding mechanisms and additional machine-learning facilities. The presentation identified M1 and later chips and A14 Bionic and later chips as supporting hardware. Those hardware descriptions do not replace checks for operating-system and individual feature availability.[7][8]
Apple's Metal update page, checked on 12 October 2026, continued to describe developments under Metal 4, including quantized tensor formats and scale factors, MetalFX temporal upscaling changes, and Game Porting Toolkit 4. These are distinct updates to GPU computation, related image-processing technology and development tools.[9]
Graphics and compute architecture
A Metal application creates objects representing its GPU, resources, pipeline configurations and submitted work. The device interface is the starting point for inspecting GPU capabilities and creating subsidiary objects. Objects associated with one Metal device generally need to be used with that same device.[10]
| Component | Role |
|---|---|
MTLDevice |
Represents a GPU and provides interfaces for capability inspection and object creation.[10] |
MTLBuffer |
Stores unformatted bytes. The application and its shaders must agree on the data layout, such as an array of floating-point values.[11] |
MTLTexture |
Stores image data with a defined pixel format and dimensional structure. Textures can supply shader inputs, receive shader outputs or act as render-pass attachments.[12] |
| Pipeline state | Holds a configuration for graphics or compute processing, including shader functions. Preparing pipeline state can require compilation, so applications can retain and reuse it.[13] |
| Command encoder | Records task-specific commands, such as drawing or dispatching a compute workload, into a command buffer.[13] |
| Command buffer and queue | Group encoded work and submit it for GPU execution. Submission is asynchronous rather than an immediate execution of each API call.[13] |
In the original MTLCommandQueue model, an application obtains an MTLCommandBuffer from a queue, creates encoders, records commands and commits the buffer. That command buffer is single-use after commitment. Scheduled and completed handlers let the application observe its progress while performing other CPU work.[13]
Metal 4 introduces independent MTL4CommandQueue and MTL4CommandBuffer types. The device creates command buffers, and a compatible queue submits them. A buffer can be reused, while a MTL4CommandAllocator supplies memory for its encoded commands. The MTL4ComputeCommandEncoder combines compute, blit and acceleration-structure work previously handled by separate encoder types. Resource bindings reside in argument tables rather than individual encoder binding calls.[14]
Metal 4 treats resources as untracked for hazard management. Applications must synchronize conflicting accesses, for example by placing a barrier between a compute pass that writes a texture and a fragment stage that reads it. Metal events can also coordinate work between original and Metal 4 queues, permitting incremental adoption within one application.[14]
Shaders and compilation
The Metal Shading Language (MSL) is the GPU programming language used with Metal. It is a variant of C++ designed for graphics and parallel computation. The host application prepares resources and submits work through the API; shader functions execute on the GPU. Apple's array-addition sample illustrates a compute kernel running over a grid of threads, with each thread adding one pair of array elements. Compute grids can have one, two or three dimensions and are divided into threadgroups.[11]
A graphics renderer configures a graphics pipeline with its vertex and fragment functions, associates resources with a render pass and encodes drawing commands. Apple's Metal 4 triangle sample implements both original and Metal 4 renderers and selects between them by checking supportsFamily(.metal4). The two paths draw the same scene using different API generations.[15]
Metal 4's MTL4Compiler gives applications explicit control over shader and pipeline compilation. It supports synchronous or asynchronous requests, quality-of-service scheduling and workflows that capture pipeline configurations for reuse in binary archives. Flexible pipeline states can share common compilation work before specializing remaining properties. These facilities address when compilation occurs as well as the work required to prepare a pipeline.[16]
Metal 4 also adds tensors and a machine-learning command encoder for model inference alongside rendering and compute passes. Smaller operations can be expressed within shaders using Metal performance primitives. These are programming facilities, rather than an automatic machine-learning stage applied to every scene.[7]
Resources and memory
On Apple GPUs, the CPU and GPU share system memory, but a resource's storage mode still determines access. Shared resources permit CPU and GPU access. Private resources permit GPU access and are suitable for GPU-produced intermediate data. Memoryless storage is available for temporary textures in GPU tile memory, such as a depth attachment whose contents are needed only during a pass; it does not apply to buffers.[17]
Resources also need correct lifetimes. In Apple's Metal 4 triangle sample, each in-flight frame has its own vertex buffer and command allocator. The renderer waits until the GPU has finished using an allocator before reusing it, even though the command-buffer object itself can be reused after submission.[15]
Applications should check the required GPU family and operating-system API availability rather than assume a uniform set of capabilities. Apple documents both family-level checks and checks for features that vary within a family. Renderers can provide alternate paths or reduced functionality when a required feature is unavailable.[8]
Immersive rendering on visionOS
visionOS applications using a custom Metal renderer can declare a SwiftUI ImmersiveSpace containing a CompositorLayer. Compositor Services provides a LayerRenderer that supplies frame timing, drawable textures and per-view information. A custom configuration can specify texture layouts, pixel formats and foveation, subject to the capabilities reported by the layer.[18]
These components divide the work of an immersive application:
| Component | Responsibility |
|---|---|
| SwiftUI | Defines the application scene and immersive-space presentation.[2] |
| Compositor Services | Supplies the rendering session, textures, frame timing and presentation interface.[18] |
| Metal | Encodes and executes the custom renderer's GPU work.[1] |
| ARKit | Provides device/world tracking and hand tracking for applications that adopt the corresponding providers.[2] |
| RealityKit | Provides higher-level rendering as another approach to immersive content, with GPU implementation details handled by the framework.[1] |
Immersion styles
Metal rendering through Compositor Services supports full and mixed immersion. Full immersion replaces the surrounding visual environment with rendered content; mixed immersion displays virtual content with passthrough. Apple's WWDC24 explanation of mixed immersion requires appropriate premultiplied-alpha color output, depth values and per-view projection information. Compositor Services expects reverse-Z depth, and the renderer must provide correct depth values for compositing. ARKit scene understanding can supply information for placing content or implementing occlusion against the environment.[19]
Progressive immersion lets the wearer adjust a portal into rendered content using Vision Pro's Digital Crown. Adopting it requires additional render-context and stencil-mask work by the application. The system smooths and fades the portal edge. Apple's documentation restricts this path to the layered texture layout, so it is a configuration requirement rather than an arbitrary display effect.[20]
Frame timing and stereo views
An immersive renderer separates scene updates from the submission of pose-dependent drawing work. Compositor Services reports an optimal input time, rendering deadline and presentation time. Apple's original explanation states that CPU and GPU rendering work must finish before the deadline; otherwise, the compositor uses a previous frame. This makes timely work submission part of the rendering contract.[2]
The renderer obtains drawables, predicts the device pose for presentation using ARKit, associates the device anchor with each drawable and encodes presentation with its GPU commands. Each view needs its own camera transform and projection. The system can compensate for movement between the predicted and actual device anchor when displaying the rendered frame.[18]
Layered layout stores views in different slices of an array texture; dedicated layout uses separate textures; shared layout assigns viewports within one texture slice. The supported layout is queried from the layer rather than assumed to be identical in the simulator and on a headset.[2] Metal's vertex amplification can direct shared vertex data to multiple outputs, with view mappings for texture layers or viewports. The application must check support for its amplification count and configure its shaders and pipeline accordingly.[21]
Foveation and interaction
When the layer supports foveated rendering, Compositor Services provides a variable rasterization rate map describing which parts of a texture are rendered at different resolutions. Peripheral regions can use lower resolution than the central region. The renderer needs to query foveation support and use the supplied map in its rendering configuration.[22][18]
WWDC25 introduced dynamic render quality for foveated rendering. An application sets a maximum quality for its session and can adjust runtime quality within that limit. Higher quality expands the high-resolution region and increases texture size, memory requirements and power use. The transition between quality values takes time. This mechanism needs profiling against the application's content rather than a fixed quality setting for every scene.[23]
In visionOS 26, Metal immersive applications can adopt system-provided hover effects. The application registers tracking areas and writes their identifiers into an integer texture alongside its rendered color and depth. The system performs gaze testing and highlighting outside the application. Metal shaders cannot obtain the wearer's current gaze location through this mechanism, but the application can respond to spatial gestures associated with an object.[24]
Remote rendering from a Mac
Apple's WWDC25 session also presented macOS spatial rendering: a Mac application uses SwiftUI's RemoteImmersiveSpace, Compositor Services, ARKit and Metal to render immersive content for Vision Pro. The wearer accepts the connection on the headset. A remote device identifier connects the Mac's ARKit session to the Vision Pro device, and the application checks whether remote scenes are supported. The session describes full and progressive immersion for this Mac workflow.[23]
Research and performance analysis
Hrycak, Lewakis and Krüger's 2024 volume-visualization study compared a slice-based renderer in a shared space with a Metal-based GPU ray caster in full immersion. Its implementation included early ray termination, clipping and lighting. In its tested arrangement, with a single dataset near the center of the display, foveation provided little or no performance gain; the authors observed greater benefit when datasets occupied peripheral regions. These findings describe that renderer and the visionOS version investigated, rather than all Metal workloads or current framework restrictions.[3]
Xcode's Metal development tools provide separate methods for checking API correctness, shader errors and performance. API Validation checks incorrect API use; Shader Validation checks problems such as invalid memory accesses. The Metal debugger supports inspection of resources, dependencies and individual shaders, while the Metal system trace in Instruments shows CPU/GPU work and memory use over time.[25]
Instruments' Game Performance template combines Metal events with CPU profiling, thread scheduling, thermal state and display events. It is intended to locate frame-time interruptions and their causes. This analysis distinguishes GPU rendering work from delays elsewhere in the application or system.[26]
Development interfaces and portability
Metal-cpp is Apple's C++ interface to Metal's Objective-C classes, constants and enumerations. It lets a renderer written in C++ call Metal through a corresponding C++ namespace. The interface follows Cocoa allocation rules; its C++ objects do not receive automatic reference counting, so integrating it requires attention to object ownership.[27]
Vulkan applications can use MoltenVK, a portability implementation that maps a subset of Vulkan graphics and compute functionality to Metal. Its shader converter translates SPIR-V into MSL. The project's documentation describes both mapped and synthesized features and remaining differences from the Vulkan specification. This is an explicit translation layer with documented limitations.[28]
See also
References
- ↑ 1.0 1.1 1.2 "Metal". Apple Developer Documentation. https://developer.apple.com/documentation/metal. Retrieved 2026-10-12.
- ↑ 2.0 2.1 2.2 2.3 2.4 "Discover Metal for immersive apps". Apple Developer, WWDC23. 2023. https://developer.apple.com/videos/play/wwdc2023/10089/. Retrieved 2026-10-12.
- ↑ 3.0 3.1 Camilla Hrycak; David Lewakis; Jens Krüger (2024). "Investigating the Apple Vision Pro Spatial Computing Platform for GPU-Based Volume Visualization". 2024 IEEE Visualization and Visual Analytics (VIS). doi:10.1109/VIS55277.2024.00044. https://www.cgvis.de/publications/2024/hrycak_2024_vision1.pdf. Retrieved 2026-10-12.
- ↑ "Apple Releases iOS 8 SDK With Over 4,000 New APIs". Apple Newsroom. 2014-06-02. https://www.apple.com/newsroom/2014/06/02Apple-Releases-iOS-8-SDK-With-Over-4-000-New-APIs/. Retrieved 2026-10-12.
- ↑ "Working with Metal: Overview". Apple Developer, WWDC14. 2014. https://developer.apple.com/videos/play/wwdc2014/603/. Retrieved 2026-10-12.
- ↑ "Apple Announces OS X El Capitan with Refined Experience & Improved Performance". Apple Newsroom. 2015-06-08. https://www.apple.com/ca/newsroom/2015/06/08Apple-Announces-OS-X-El-Capitan-with-Refined-Experience-Improved-Performance/. Retrieved 2026-10-12.
- ↑ 7.0 7.1 "Discover Metal 4". Apple Developer, WWDC25. 2025. https://developer.apple.com/videos/play/wwdc2025/205/. Retrieved 2026-10-12.
- ↑ 8.0 8.1 "Detecting GPU features and Metal software versions". Apple Developer Documentation. https://developer.apple.com/documentation/metal/detecting-gpu-features-and-metal-software-versions. Retrieved 2026-10-12.
- ↑ "What’s new in Metal". Apple Developer. https://developer.apple.com/metal/whats-new/. Retrieved 2026-10-12.
- ↑ 10.0 10.1 "MTLDevice". Apple Developer Documentation. https://developer.apple.com/documentation/metal/mtldevice. Retrieved 2026-10-12.
- ↑ 11.0 11.1 "Performing calculations on a GPU". Apple Developer Documentation. https://developer.apple.com/documentation/metal/performing-calculations-on-a-gpu. Retrieved 2026-10-12.
- ↑ "Textures". Apple Developer Documentation. https://developer.apple.com/documentation/metal/textures. Retrieved 2026-10-12.
- ↑ 13.0 13.1 13.2 13.3 "Setting up a command structure". Apple Developer Documentation. https://developer.apple.com/documentation/Metal/setting-up-a-command-structure. Retrieved 2026-10-12.
- ↑ 14.0 14.1 "Understanding the Metal 4 core API". Apple Developer Documentation. https://developer.apple.com/documentation/Metal/understanding-the-metal-4-core-api. Retrieved 2026-10-12.
- ↑ 15.0 15.1 "Drawing a triangle with Metal 4". Apple Developer Documentation. https://developer.apple.com/documentation/metal/drawing-a-triangle-with-metal-4. Retrieved 2026-10-12.
- ↑ "Using the Metal 4 compilation API". Apple Developer Documentation. https://developer.apple.com/documentation/metal/using-the-metal-4-compilation-api. Retrieved 2026-10-12.
- ↑ "Choosing a resource storage mode for Apple GPUs". Apple Developer Documentation. https://developer.apple.com/documentation/metal/choosing-a-resource-storage-mode-for-apple-gpus. Retrieved 2026-10-12.
- ↑ 18.0 18.1 18.2 18.3 "Drawing fully immersive content using Metal". Apple Developer Documentation. https://developer.apple.com/documentation/CompositorServices/drawing-fully-immersive-content-using-metal. Retrieved 2026-10-12.
- ↑ "Render Metal with passthrough in visionOS". Apple Developer, WWDC24. 2024. https://developer.apple.com/videos/play/wwdc2024/10092/. Retrieved 2026-10-12.
- ↑ "Controlling Metal rendering immersion level". Apple Developer Documentation. https://developer.apple.com/documentation/compositorservices/controlling-metal-rendering-immersion-level. Retrieved 2026-10-12.
- ↑ "Improving rendering performance with vertex amplification". Apple Developer Documentation. https://developer.apple.com/documentation/metal/improving-rendering-performance-with-vertex-amplification. Retrieved 2026-10-12.
- ↑ "supportsFoveation". Apple Developer Documentation. https://developer.apple.com/documentation/compositorservices/layerrenderer/capabilities/supportsfoveation. Retrieved 2026-10-12.
- ↑ 23.0 23.1 "What’s new in Metal rendering for immersive apps". Apple Developer, WWDC25. 2025. https://developer.apple.com/videos/play/wwdc2025/294/. Retrieved 2026-10-12.
- ↑ "Rendering hover effects in Metal immersive apps". Apple Developer Documentation. https://developer.apple.com/documentation/compositorservices/rendering_hover_effects_in_metal_immersive_apps. Retrieved 2026-10-12.
- ↑ "Metal developer workflows". Apple Developer Documentation. https://developer.apple.com/documentation/xcode/metal-developer-workflows. Retrieved 2026-10-12.
- ↑ "Analyzing the performance of your Metal app". Apple Developer Documentation. https://developer.apple.com/documentation/xcode/analyzing-the-performance-of-your-metal-app/. Retrieved 2026-10-12.
- ↑ "Get started with Metal-cpp". Apple Developer. https://developer.apple.com/metal/cpp/. Retrieved 2026-10-12.
- ↑ "MoltenVK". KhronosGroup, GitHub. https://github.com/KhronosGroup/MoltenVK. Retrieved 2026-10-12.