Render Pass

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

Overview

The draw commands you encode with a single render command encoder correspond to a single render pass. Therefore, there's a 1:1 relationship between a render command encoder and a render pass.

On macOS, one of the ways that render passes surface in a Metal rendering workflow is when a group of draws must finish before another group of draws starts. For example, the Deferred Lighting sample code renders in two passes:

  1. Graphical elements are rendered to an offscreen texture

  2. The offscreen texture is analyzed and translated to a final rendering to the screen

Deferred Lighting employs a two-pass rendering strategy on macOS because the render targets differ across the two passes: offscreen texture, versus the screen. Also, the first set of render targets is input to the second render pass, and thererfore the second render pass is dependent on the completion of the work done by the first render pass.

Topics

Descriptor

MTLRenderPassDescriptor

A group of render targets that hold the results of a render pass.

Render Target

A texture that's drawn to in a render pass.

Setting Load and Store Actions

Set actions that define how a render pass loads and stores a render target.

MTLRenderPassAttachmentDescriptor

A render target that serves as the output destination for pixels generated by a render pass.

MTLRenderPassColorAttachmentDescriptor

A color render target that serves as the output destination for color pixels generated by a render pass.

MTLRenderPassDepthAttachmentDescriptor

A depth render target that serves as the output destination for depth pixels generated by a render pass.

MTLRenderPassStencilAttachmentDescriptor

A stencil render target that serves as the output destination for stencil pixels generated by a render pass.

Programmable Sample Positions

Using Programmable Sample Positions

Configure the position of samples when rendering to a multisampled render target.

Handling MSAA Depth with Programmable Sample Positions

Use depth render targets and programmable sample positions effectively.

Dependency Viewing

Viewing Your Frame Graph

View your render passes as a flow chart to inspect resource dependencies and understand which commands wait on others to complete.

Sample Code

See how render passes are used in an example app.

Deferred Lighting

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

See Also

Graphics

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.

MTLRenderCommandEncoder

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

MTLParallelRenderCommandEncoder

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

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.