Metal

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Metal is Apple’s low-level graphics and compute API for iOS, iPadOS, macOS, tvOS and visionOS. It gives an app direct access to the GPU of an iPhone, an iPad, a Mac with Apple silicon, an Apple TV or an Apple Vision Pro, with a small set of object types, a shading language that is C++ (the Metal Shading Language, MSL) and tools built into Xcode. This sub-section teaches Metal 4, the generation that arrived with the 26 operating systems, together with the Metal 3 equivalent where code must still run on older devices, and it covers MetalKit, MetalFX, Metal Performance Shaders, ray tracing, mesh shaders, the debugging tools, porting from other platforms and visionOS. It follows one running example, the Metal Bookshelf, from a first triangle to a small game, and it says plainly where Metal stands in 2026: the only supported low-level graphics API on Apple platforms, with OpenGL deprecated since 2018, and an API that is still gaining features every year, with machine learning now part of the frame. The pages build on the general pages of Graphics & Games; read those first if the rendering pipeline or the transformation chain are new to you.

What Metal and its neighbours are

Name What it is

Metal

The GPU API: devices, command queues, command buffers, encoders, pipeline states and resources. Metal 4 adds a new core API with the MTL4 types next to the older MTL types.

Metal Shading Language (MSL)

The C++-based language of the shaders, compiled by the Metal Toolchain into a library that the app loads at run time.

MetalKit

Helpers for apps: MTKView to host a drawable, MTKTextureLoader to load images and MTKMesh to build meshes from Model I/O.

MetalFX and Metal Performance Shaders

Upscaling, frame interpolation and denoising, and a library of tuned image, linear algebra and neural-network kernels, with MPSGraph for graphs of them.

SwiftUI, RealityKit and SceneKit

Higher levels. SwiftUI shows an MTKView and applies shader effects, RealityKit draws entity scenes with Metal underneath, and SceneKit is in maintenance. They are named here, not taught.

Vulkan, OpenGL and WebGPU

The other graphics APIs. On Apple platforms MoltenVK and KosmicKrisp translate Vulkan to Metal, Safari implements WebGPU on top of it, and OpenGL is deprecated.

Metal gives you the GPU and little else: you manage the resources, the synchronisation and the frame pacing, and you decide what a scene is. That is why most games use an engine that already speaks Metal, and why learning Metal first makes an engine’s behaviour predictable. The reasoning about when each layer pays off is in Choosing an API or Engine.

Where Metal sits

Timeline from 2014 to 2026 with Metal, Metal 2, the deprecation of OpenGL, Apple silicon Macs, Metal 3, hardware ray tracing on A17 and M3, residency sets, Metal 4 and MSL 4.1 with Xcode 27
Figure 1. Specifications, hardware and API milestones, 2014 to 2026

Metal appeared in 2014 for iOS, before Direct3D 12 and Vulkan, as one of the first modern explicit APIs. Metal 2 (2017) and Metal 3 (2022) added argument buffers, MetalFX, mesh shaders and fast resource loading, and Apple deprecated OpenGL and OpenGL ES in 2018. Hardware ray tracing came with the A17 and M3 in 2023, residency sets in 2024 and Metal 4 in 2025. What each release changed is on What’s New in Metal 4.

Five stacked layers from the app with SwiftUI and RealityKit, through MetalKit and the helper frameworks, Metal itself, the Metal driver and system, to the Apple silicon GPU
Figure 2. The layers between an Apple app and the GPU

The same layers appear in the general Graphics APIs vs Game Engines page. Apple silicon matters for how you write Metal: the GPU shares memory with the CPU and renders in tiles, which the page GPU Architecture and TBDR explains and which later pages use again and again.

Version baseline

The facts below were checked on 1 November 2026 against the official pages cited in the last column. Items that follow a release can change, so check them again before relying on them.

Item Version and status Source

API generation

Metal 4, announced at WWDC25 and available from iOS, iPadOS, macOS, tvOS and visionOS 26.0. The MTL4 types (MTL4CommandQueue, MTL4CommandBuffer, MTL4Compiler, MTL4ArgumentTable, MTL4MachineLearningCommandEncoder and MTLTensor) can be adopted one at a time next to the older MTL types.

Understanding the Metal 4 core API

Shading language

MSL 4.1, with the specification dated 4 June 2026. MTLLanguageVersion.version4_1 is available from the 27 operating systems and version4_0 from the 26 ones.

Metal Shading Language Specification, MTLLanguageVersion

Metal 4 hardware

A14 Bionic or later (iPhone, iPad and Apple TV), a Mac with Apple silicon (M1 or later) and Apple Vision Pro.

Metal

Toolchain

Xcode 27 with Swift 6.4 and the 27 SDKs. It needs an Apple-silicon Mac on macOS 26.6 or later. The Metal Toolchain is a separately downloaded Xcode component, as it has been since Xcode 26.

Xcode 27 release notes

Intel phase-out

MTLStorageMode.managed, MTLGPUFamily.mac2 and .common3 are deprecated in the 27 operating systems, and with macOS 27 as the deployment target ARCHS_STANDARD drops x86_64.

MTLStorageMode.managed

GPU families

apple7 is the A14 and M1, apple8 the A15, A16 and M2, apple9 the A17, M3 and M4. Check the Feature Set Tables for later chips. The Metal 3 and Metal 4 families are .metal3 and .metal4.

MTLGPUFamily, Metal Feature Set Tables

WWDC26 additions

Quantised tensor formats, support for the Neural Accelerators of the M5 Pro and M5 Max, MetalFX neural upscaling and denoising, Game Porting Toolkit 4 and the command-line tools gpucapture, gpudebug and metalperftrace.

What’s new in Metal, Metal developer tools

Deprecated

MTLFeatureSet (use supportsFamily(_:), iOS 16 and macOS 13), MPSRayIntersector (use acceleration structures, iOS 17 and macOS 14), PVRTC texture formats (iOS 18 and macOS 15), and OpenGL and OpenGL ES (iOS 12 and macOS 10.14).

The per-symbol pages under Metal documentation

Still current

MTKView, MTLArgumentEncoder, MTLResidencySet (iOS 18 and macOS 15), CAMetalDisplayLink (iOS 17 and macOS 14), mesh pipelines and MTLIOCommandQueue (iOS 16 and macOS 13).

The same pages

When to choose what

flowchart TD A[Draw 3D graphics on an Apple platform] --> B{Need your own renderer or to learn the GPU?} B -- yes --> C[Metal 4 with MetalKit and MSL] B -- no --> D{Scene, physics and tools ready made?} D -- yes --> E{Mostly Apple platforms?} E -- yes --> F[RealityKit, or SceneKit for old projects] E -- no --> G[Unity, Unreal or another engine, which use Metal underneath] D -- no --> H{Existing OpenGL or DirectX code?} H -- yes --> I[Port with the migration sample, metal-cpp or Game Porting Toolkit] H -- no --> C C -.-> J[Metal 3 path keeps older devices working]

Choose Metal when you are building a renderer or an engine feature, when you need compute, ray tracing, mesh shaders or machine learning in the frame, or when you want the least overhead on Apple hardware. Choose RealityKit or an engine when the scene, the physics and the tools matter more than control. Choose a port when the code exists already: Apple’s OpenGL migration sample, metal-cpp and Game Porting Toolkit are covered on Migrating from OpenGL and metal-cpp and Game Porting. The general criteria are in Choosing an API or Engine.

What’s covered

Orientation

Page Covers

What’s New in Metal 4

Metal 4 on the 26 operating systems, MSL 4.1 on the 27 ones, the WWDC26 additions, the hardware matrix and incremental adoption.

What Has Changed Since the Older Metal Guides

The corrections for the two books, row by row.

Foundations

Page Covers

Setup: Xcode and the Project

Xcode 27, the Metal Toolchain component, a multiplatform SwiftUI target, .metal files, the metallib build and the limits of the Simulator.

GPU Architecture and TBDR

Unified memory, SIMD groups, tile-based deferred rendering, GPU families and supportsFamily.

Math for 3D

The simd types, column-major matrices and normalised device coordinates with z from 0 to 1.

Core API

Page Covers

Hello Triangle with Metal 4

The device, the Metal 4 queue, allocator, command buffer, render pass, pipeline, argument table, drawable and present, with the Metal 3 equivalent.

MetalKit, MTKView and SwiftUI

An MTKView through a representable, its delegate, CAMetalLayer, CAMetalDisplayLink and frames in flight.

The Metal Render Pipeline

Vertex fetch, the rasteriser, the fragment stage, blending, depth and stencil, pipeline states and MTL4Compiler.

The Metal Shading Language

MSL 4.x syntax, address spaces, attributes, structs shared through a bridging header and function constants.

Buffers and Vertex Descriptors

Buffers, storage modes, vertex descriptors and indexed draws.

Transforms and Camera

The model-view-projection chain, perspective and orthographic cameras, and arcball and first-person cameras.

Textures and Samplers

MTKTextureLoader, mipmaps, samplers, ASTC and BC, and sRGB.

Models with Model I/O and USD

Model I/O, USD and USDZ, submeshes and materials.

Lighting Fundamentals in Metal

Phong and Blinn-Phong, normals and several lights.

PBR Materials in Metal

Cook-Torrance, normal, roughness and metallic maps, and an overview of skinning.

Render Passes and Load/Store Actions in Metal

Load and store actions, multipass rendering, MSAA resolve and memoryless targets.

Shadows in Metal

Shadow maps, cascades and percentage-closer filtering.

Deferred and Tile Shading

The G-buffer, tile shaders, imageblocks and forward-plus.

Synchronization and Barriers

Events, shared events, fences, Metal 4 barriers and residency sets.

Compute and GPU-driven rendering

Page Covers

Compute Kernels

Kernels, grids, threadgroups, SIMD-group functions and dispatchThreads.

Particles

A compute particle update and an instanced draw.

Image Processing, Metal Performance Shaders and MPSGraph

Post-processing, MPS filters and MPSGraph.

Argument Buffers and Bindless Resources

Tiers, gpuResourceID and gpuAddress, argument tables, heaps and residency sets.

GPU-Driven Rendering and Indirect Command Buffers

Indirect command buffers, GPU culling, visibility results and instancing.

Mesh Shaders

Object and mesh functions, meshlets and level of detail.

Tessellation in Metal

Patches, factors, post-tessellation vertex functions and when mesh shaders replace them.

Advanced rendering

Page Covers

Ray Tracing in Metal

Primitive and instance acceleration structures, intersectors, intersection queries and functions, curves, motion blur, hybrid shadows and reflections, and hardware ray tracing on A17 and M3 or later.

Image-Based Lighting and HDR in Metal

Image-based lighting and EDR and HDR output.

MetalFX: Upscaling, Frame Interpolation and Denoising

Spatial, temporal and neural upscaling, frame interpolation and denoising, with jitter and motion vectors.

Machine Learning in Metal 4

MTLTensor, the machine-learning encoder, tensor operations in shaders and quantised tensors.

Resource Loading and Streaming

MTLIOCommandQueue, sparse textures and heaps.

Shader Compilation and Pipeline Caching

MTL4Compiler, binary archives, dynamic libraries and function stitching.

Tools, platforms and porting

Page Covers

Debugging and Profiling Metal

Frame capture, the dependency viewer, the shader debugger, validation, the Performance HUD, Metal System Trace, counters, heat maps and the command-line tools.

Performance Best Practices

Bandwidth, memory footprint, tile-based deferred rendering tips and frame pacing.

metal-cpp and Game Porting

metal-cpp, the Metal shader converter, Game Porting Toolkit 4 and the Windows developer tools.

Metal on visionOS

Compositor Services, LayerRenderer, stereo rendering, foveation and hover effects.

SwiftUI Shaders and RealityKit Interop

A short bridge to the SwiftUI shader effects and to the low-level mesh and texture interop of RealityKit.

Migrating from OpenGL

Apple’s migration sample and a concept mapping from OpenGL to Metal.

Metal Cheat Sheet

The one-page A4 summary and the PDF to download.

Coverage map

Official documentation areas

Area Official documentation Pages

Overview

The Metal pages on developer.apple.com: overview, what is new, resources and sample code, covering the positioning of Metal, machine learning and graphics, and the hardware

What’s New in Metal 4, GPU Architecture and TBDR

Essentials

Understanding the Metal 4 core API, drawing a triangle with Metal 4, performing calculations on a GPU and using Metal to draw a view’s contents: queues, reusable command buffers, allocators, argument tables and barriers

Hello Triangle with Metal 4, Compute Kernels, MetalKit, MTKView and SwiftUI

Devices and submission

GPU devices and work submission: MTLDevice, queues, events, shared events and frames in flight

Hello Triangle with Metal 4, Synchronization and Barriers

Encoders

Render, compute, machine-learning and blit passes, indirect command encoding, and ray tracing with acceleration structures

Render Passes and Load/Store Actions in Metal, GPU-Driven Rendering and Indirect Command Buffers, Ray Tracing in Metal

Resources

Resource fundamentals, buffers, textures, memory heaps, resource loading and synchronisation: storage modes, heaps, residency sets, MTLIOCommandQueue, sparse textures and fences

Buffers and Vertex Descriptors, Textures and Samplers, Resource Loading and Streaming, Argument Buffers and Bindless Resources

Shader compilation

The Metal 4 compilation API, shader libraries, function specialisation, binary archives and dynamic libraries: MTL4Compiler, function constants and stitching

Shader Compilation and Pipeline Caching, The Metal Shading Language

Presentation

Onscreen presentation, HDR and EDR, and game windows on macOS: CAMetalLayer, drawables and CAMetalDisplayLink

MetalKit, MTKView and SwiftUI, Image-Based Lighting and HDR in Metal

MetalKit, MSL, MetalFX and MPS

The MetalKit reference (MTKView, MTKTextureLoader, MTKMesh), the MSL specification, MetalFX (upscaling, interpolation and denoising) and Metal Performance Shaders with MPSGraph

MetalKit, MTKView and SwiftUI, The Metal Shading Language, MetalFX, Image Processing, Metal Performance Shaders and MPSGraph

Machine learning on the GPU

The samples "Running a machine learning model on the GPU timeline" and "Running inline ML operations in a shader with Metal 4", and the Metal Performance Primitives guide: MTLTensor, the ML encoder and tensor operations

Machine Learning in Metal 4

Tools

The Metal developer tools page and the Xcode Metal developer workflows: frame capture, the dependency viewer, the shader debugger, validation, the Performance HUD, Metal System Trace, counters, the shader cost graph, heat maps and the command-line tools

Debugging and Profiling Metal, Performance Best Practices

Apple silicon

Porting your Metal code to Apple silicon and tailoring apps for tile-based deferred rendering: memoryless targets, tile shaders and imageblocks

GPU Architecture and TBDR, Deferred and Tile Shading, Render Passes and Load/Store Actions in Metal

Games and porting

The Apple games pages, Game Porting Toolkit, the Metal shader converter and metal-cpp: DXIL to metallib

metal-cpp and Game Porting, Migrating from OpenGL

visionOS

The Compositor Services framework: LayerRenderer, stereo and foveated rendering

Metal on visionOS

SwiftUI shaders

The SwiftUI shader documentation (link only): colorEffect, distortionEffect and layerEffect

SwiftUI Shaders and RealityKit Interop

Samples and WWDC

The Metal sample code library (deferred lighting, forward-plus with tile shaders, mesh-shader level of detail, order-independent transparency, argument buffers, indirect command buffers, ray-traced reflections, sparse textures and the OpenGL migration) and the WWDC25 and WWDC26 sessions

The pages above, each of which cites the samples and sessions it uses

Concepts from the books

The two books are listed in the section bibliography. The short names are MBT (Caroline Begbie and Marius Horga, Metal by Tutorials, 4th edition) and CLA (Janie Clayton, Metal Programming Guide). Each cell lists the chapters that contribute the concept, and the last column the pages that cover it. The books are consulted references: no text, figure or code is copied from them, and where a book and the official documentation disagree the documentation is followed.

Concept MBT CLA Pages

First app and view

1 and 3

3 and 8

Hello Triangle with Metal 4, MetalKit, MTKView and SwiftUI

Pipeline, shaders and MSL

3, 4 and 7

5 and 7

The Metal Render Pipeline, The Metal Shading Language

Buffers, vertex descriptors and storage

2 and 4

6

Buffers and Vertex Descriptors

Math, transforms and camera

5, 6 and 9

4 and 9

Math for 3D, Transforms and Camera

Models and USD

2

11

Models with Model I/O and USD

Textures and samplers

8

6 and 12

Textures and Samplers

Lighting, PBR, image-based lighting and reflection and refraction

10, 11, 21, 22 and 29

9

Lighting Fundamentals in Metal, PBR Materials in Metal, Image-Based Lighting and HDR in Metal

Render passes and multipass rendering

12

13

Render Passes and Load/Store Actions in Metal

Shadows, including soft shadows and ambient occlusion

13 and 28

-

Shadows in Metal

Deferred and tile-based deferred rendering

14 and 15

-

Deferred and Tile Shading, GPU Architecture and TBDR

Compute and particles

16 to 18

15 and 16

Compute Kernels, Particles

Tessellation and terrain

19

14

Tessellation in Metal, Mesh Shaders

Post-processing, MPS and machine vision

20 and 30

16 to 18

Image Processing, Metal Performance Shaders and MPSGraph

Animation and skinning

23 and 24

9

PBR Materials in Metal

2D drawing, scene graphs and instancing

31

8 and 10

GPU-Driven Rendering and Indirect Command Buffers, Hello Triangle with Metal 4

Heaps and argument buffers

25

6

Argument Buffers and Bindless Resources

Indirect command buffers and GPU-driven rendering

26

-

GPU-Driven Rendering and Indirect Command Buffers

Ray-based rendering (raymarching and signed distance fields)

27 to 29

-

Ray Tracing in Metal

Neural networks on the GPU

-

19 and 20

Machine Learning in Metal 4

Profiling and best practices

31 and 32

partly

Debugging and Profiling Metal, Performance Best Practices

Official concepts missing from the books

Neither book covers Metal 4, and several features that every current program uses were introduced after both were written. Mesh shaders are only mentioned in MBT. They are covered from the official documentation.

Concept Pages

The whole Metal 4 core API

What’s New in Metal 4, Hello Triangle with Metal 4

Hardware ray tracing with acceleration structures

Ray Tracing in Metal

Mesh shaders

Mesh Shaders

MetalFX in depth

MetalFX

Residency sets

Synchronization and Barriers, Argument Buffers and Bindless Resources

Fast resource loading and sparse textures

Resource Loading and Streaming

gpuResourceID argument buffers

Argument Buffers and Bindless Resources

Binary archives, dynamic libraries and stitching

Shader Compilation and Pipeline Caching

CAMetalDisplayLink

MetalKit, MTKView and SwiftUI

Tensors and the machine-learning encoder

Machine Learning in Metal 4

metal-cpp, Game Porting Toolkit and the shader converter

metal-cpp and Game Porting

Compositor Services

Metal on visionOS

The Performance HUD, shader validation, heat maps and the command-line tools

Debugging and Profiling Metal

Where the books are out of date, the page that covers the concept says so, and What Has Changed Since the Older Metal Guides collects the corrections.

Reading path

flowchart TD A[What is new in Metal 4, setup] --> B[GPU architecture, math] B --> C[Hello triangle, MTKView, render pipeline, MSL] C --> D[Buffers, transforms, textures, models] D --> E[Lighting, PBR, passes, shadows] E --> F[Deferred and tile shading, synchronisation] F --> G[Compute, particles, image processing] G --> H[Argument buffers, ICBs, mesh shaders, tessellation] H --> I[Ray tracing, IBL, MetalFX, machine learning] I --> J[Streaming, shader compilation] J --> K[Debugging, performance, porting, visionOS] L[What changed since older guides] -.-> A M[Cheat sheet] -.-> K

The Metal Bookshelf running example

The Bookshelf scene of the section landing page, described in The Bookshelf scene and shared assets, is built as a multiplatform SwiftUI app hosting an MTKView, with a Metal 4 path, a Metal 3 fallback and a visionOS target. The model and the textures are the shared bookshelf.glb and the files in the same folder. The pages grow the app in ten stages, and the shader structs are shared between Swift and MSL through a bridging header.

Ten stages in two rows, a triangle, a lit textured book, the shelf as USDZ, PBR and a shadow, many books, dust particles, ray-traced reflections, temporal upscaling, the Sort the shelf game and a visionOS version
Figure 3. The ten stages from a triangle to an immersive space
  1. a triangle (Hello Triangle with Metal 4)

  2. a textured, lit, rotating book with the model-view-projection chain and Blinn-Phong (Transforms and Camera, Textures and Samplers and Lighting Fundamentals in Metal)

  3. the shared shelf as USDZ through Model I/O (Models with Model I/O and USD)

  4. physically based materials and a shadow map (PBR Materials in Metal and Shadows in Metal)

  5. many books with instancing, then argument buffers and an indirect command buffer with GPU culling (Argument Buffers and Bindless Resources and GPU-Driven Rendering and Indirect Command Buffers)

  6. compute dust particles (Particles)

  7. ray-traced reflections on a glossy shelf (Ray Tracing in Metal)

  8. MetalFX temporal upscaling (MetalFX)

  9. a tiny game, "Sort the shelf": pick books with a ray query and drag them into order (Ray Tracing in Metal)

  10. the immersive visionOS version through Compositor Services (Metal on visionOS)

Bibliography

Books

The Metal pages draw on two books. The books are consulted references for concept coverage: no text, figure or code is copied from them, and where a book and the official documentation disagree the documentation is followed. The complete entries, with every other source of the section, are in the section bibliography.

  • Caroline Begbie and Marius Horga, Metal by Tutorials: Beginning Game Engine Development with Metal, 4th edition, Kodeco, about 2023: Kodeco. It teaches Metal 3.

  • Janie Clayton, Metal Programming Guide: Tutorial and Reference via Swift, Addison-Wesley, 2017, ISBN 978-0-13-466894-9: InformIT.