Render advanced 3D graphics and perform data-parallel computations using graphics processors.


Graphics processors (GPUs) are designed to quickly render graphics and perform data-parallel calculations. Use the Metal framework when you need to communicate directly with the GPUs available on a device. Apps that render complex scenes or that perform advanced scientific calculations can use this power to achieve maximum performance. Such apps include:

  • Games that render sophisticated 3D environments

  • Video processing apps, like Final Cut Pro

  • Data-crunching apps, such as those used to perform scientific research

Metal works hand-in-hand with other frameworks that supplement its capability. Use MetalKit to simplify the task of getting your Metal content onscreen. Use Metal Performance Shaders to implement custom rendering functions or to take advantage of a large library of existing functions.

Many high level Apple frameworks are built on top of Metal to take advantage of its performance, including Core Image, SpriteKit, and SceneKit. Using one of these high-level frameworks shields you from the details of GPU programming, but writing custom Metal code enables you to achieve the highest level of performance.


GPU Devices

Access GPU device(s) at runtime, which form the basis of Metal development.

Getting the Default GPU

Select the system's default GPU device on which to run your Metal code.

protocol MTLDevice

A GPU that you use to draw graphics or do parallel computation.

Choosing GPUs on Mac

Select one or more GPUs on which to run your Metal code by considering GPU capabilities, power, or performance characteristics.

Command Setup

Set up infrastructure to execute your custom code on the GPU.

Setting Up a Command Structure

Discover how Metal executes commands on a GPU.

Devices and Commands

Demonstrates how to access and interact with the GPU.

Labeling Metal Objects and Commands

Assign meaningful labels to your Metal objects and commands so you can easily identify them in the call list of a captured frame.

protocol MTLCommandQueue

A queue that organizes the order in which command buffers are executed by the GPU.

protocol MTLCommandBuffer

A container that stores encoded commands that are committed to and executed by the GPU.

protocol MTLCommandEncoder

An encoder that writes GPU commands into a command buffer.

Advanced Command Setup

Organize your commands for maximum concurrency and minimal dependencies.


Render graphics by issuing draw calls, and choose a presentation object if you're drawing to the screen.

Hello Triangle

Demonstrates how to render a simple 2D triangle.

Basic Buffers

Demonstrates how to manage hundreds of vertices with a vertex buffer.

Basic Texturing

Demonstrates how to load image data and texture a quad.

protocol MTLRenderCommandEncoder

The object to use for encoding commands for a render pass.

protocol MTLParallelRenderCommandEncoder

An object that splits up a single render pass so it can be simultaneously encoded from multiple threads.

Render Pass

A collection of commands that updates a set of render targets.

Render Pipeline

A specification for how graphics primitives should be rendered.

Vertex Data

Points that specify precise locations within the textures associated with graphics processing.

Presentation Objects

Various user interface elements you use to display your Metal content onscreen.

Parallel Computation

Process arbitrary calculations in parallel on the GPU.

Hello Compute

Demonstrates how to perform data-parallel computations using the GPU.

About Threads and Threadgroups

Learn how Metal organizes compute-processing workloads.

Calculating Threadgroup and Grid Sizes

Calculate the optimum sizes for threadgroups and grids when dispatching compute-processing workloads.

class MTLComputePipelineDescriptor

An object that configures new MTLComputePipelineState objects.

protocol MTLComputePipelineState

An object that contains the compute function and configuration state used in a compute pass.

protocol MTLComputeCommandEncoder

An encoder that encodes your app's compute commands.

Custom Functions

Write your GPU code in the Metal Shading Language.

GPU Functions & Libraries

Load GPU functions with a library object and introspect shaders at runtime.

Resource Management

Define the data that composes your app's content.

protocol MTLBlitCommandEncoder

An encoder that moves resources between the CPU and GPU.

Resource Objects

Data structures you use to manage your app's computational or graphical data.

Resource Dimensions

Define the origin, size, or rectangular region of your app's resources.


Tools, Profiling, and Debugging

Build a Metal function library at the command line, or use Xcode to debug issues, and improve performance.


See a collection of graphics techniques and experiment with their companion sample code.

Deferred Lighting

Demonstrates how to implement a deferred lighting renderer that takes advantage of unique Metal features.

Reflections with Layer Selection

Demonstrates how to use layer selection to reduce the number of render passes needed for a reflective object.

LOD with Function Specialization

Demonstrates how to use specialized functions to select a level of detail based on dynamic conditions.


Mixing Metal and OpenGL Rendering in a View

Draw with Metal and OpenGL in the same view using an interoperable texture.

See Also