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

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.

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 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.

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 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.

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.


Tools, Profiling, and Debugging

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

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.

See Also