Render Passes

Update 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

Render Passes

class MTLRenderPassDescriptor

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

Render Targets

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.

class MTLRenderPassAttachmentDescriptor

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

class MTLRenderPassColorAttachmentDescriptor

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

class MTLRenderPassDepthAttachmentDescriptor

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

class MTLRenderPassStencilAttachmentDescriptor

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

Sample Positions

Positioning Samples Programmatically

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.

Frame Dependency Graphs

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.

See Also

Rendering

Creating and Sampling Textures

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

Render Pipelines

Specify how graphics primitives should be rendered.

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 that it can be simultaneously encoded from multiple threads.

Model I/O

Specify precise locations within the textures associated with graphics processing.

Presentation Objects

Use user interface elements to display your Metal content.