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.



Learning Basic Tasks in Metal

Get familiar with Metal through a series of sample code projects.

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

The Metal interface to 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.

Enhancing Frame Capture by Using Labels

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 command buffers to be executed by a GPU.

protocol MTLCommandBuffer

A container that stores encoded commands for the GPU to execute.

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.

Basic Buffers

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

Creating and Sampling Textures

Load image data into a texture and apply it to a quadrangle.

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 used to customize how a new compute pipeline state object is compiled.

protocol MTLComputePipelineState

An object that contains a compiled compute pipeline.

protocol MTLComputeCommandEncoder

An object used to encode commands in a compute pass.


Write your GPU code in the Metal Shading Language.


Organize your shaders into libraries.


Retrieve information about rendering and compute functions.


Create objects to hold GPU data.

Setting Resource Storage Modes

Set a storage mode that defines the memory location and access permissions of a resource.

Transferring Data Between Connected GPUs

Use high-speed connections between GPUs to transfer data quickly.

protocol MTLResource

An allocation of memory that is accessible to a GPU.

protocol MTLBlitCommandEncoder

An encoder that encodes memory copying, filtering, and fill commands.


Create and manipulate unstructured GPU resources.


Create and manipulate structured GPU resources.


Create a single allocation of memory from which you can suballocate resources.


Manage access to resources in your app to avoid data hazards.


Developing Metal Apps that Run in Simulator

Prototype and test your Metal apps in Simulator.

Supporting Simulator in a Metal App

Modify Metal Apps to Run in Simulator.

Frame Capture Debugging Tools

Analyze and optimize your app performance at runtime.

Using Metal System Trace in Instruments to Profile Your App

Smooth out your frame rate by checking for issues in your app's CPU and GPU utilization.

Reducing the Memory Footprint of Metal Apps

Learn best practices for using memory efficiently in iOS and tvOS.


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.

Dynamic Terrain with Argument Buffers

Demonstrates how to use argument buffers to render a dynamic terrain in real time with a GPU-driven pipeline.


Mixing Metal and OpenGL Rendering in a View

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

Basic Geometric Types

Structures used to define sizes, positions, and areas.

struct MTLOrigin

A location of a pixel in an image or texture relative to the upper-left corner, whose coordinates are (0,0).

struct MTLRegion

A rectangular block of pixels in an image or texture, defined by its upper-left corner and its size.

struct MTLSize

A set of dimensions that declare the size of an object, such as an image, texture, threadgroup, or grid.

func MTLOriginMake(Int, Int, Int) -> MTLOrigin

Returns the location of a pixel in an image or texture.

func MTLRegionMake1D(Int, Int) -> MTLRegion

Returns a 1D region for image or texture data.

func MTLRegionMake2D(Int, Int, Int, Int) -> MTLRegion

Returns a 2D, rectangular region for image or texture data.

func MTLRegionMake3D(Int, Int, Int, Int, Int, Int) -> MTLRegion

Returns a 3D, cubic region for image or texture data.

func MTLSizeMake(Int, Int, Int) -> MTLSize

Returns the specified size of an object, such as a texture or threadgroup.


class MTLCounterSampleBufferDescriptor

A description of how to create a counter sample buffer.



protocol MTLCounter

A descriptor for a single counter.

protocol MTLCounterSampleBuffer

An object that stores counter samples.

protocol MTLCounterSet

A set of counters to sample.


See Also

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software