Contents

MTLRenderPassAttachmentDescriptor

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

Declaration

class MTLRenderPassAttachmentDescriptor

Mentioned in

Overview

Use an MTLRenderPassAttachmentDescriptor instance to configure an individual render target of a framebuffer. Each MTLRenderPassAttachmentDescriptor instance specifies one texture that a graphics rendering pass can write into.

Typically, you don’t directly create MTLRenderPassAttachmentDescriptor instances. Instead, the MTLRenderPassDescriptor instance creates a default set of attachment instances. For each attachment that you intend to use as a render target, retrieve the MTLRenderPassAttachmentDescriptor instance from the render pass descriptor and configure its properties for use during this rendering pass.

You need to set the attachment’s texture property. The level, slice, and depthPlane properties specify the mipmap level, slice, and depth plane (for 3D textures) of the texture, respectively.

The loadAction and storeAction properties specify actions to perform at the start and end of a rendering pass for the attachment, respectively. For example, if you set the loadAction property of an attachment to MTLLoadAction.clear, then the contents of the texture fill with a value for the type of attachment at the start of the rendering pass.

There are specific MTLRenderPassAttachmentDescriptor subclasses for color, depth, and stencil attachments. Each subclass provides additional properties to configure for that kind of attachment. The table below provides the list of subclasses.

Attachment type

Descriptor subclass

Color

Mtlrenderpasscolorattachmentdescriptor

Depth

Mtlrenderpassdepthattachmentdescriptor

Stencil

Mtlrenderpassstencilattachmentdescriptor

Multisampling

To perform multisampled antialiased rendering, you use two textures. Attach to the texture property a MTLTextureType.type2DMultisample texture, and a 2D or cube texture to the resolveTexture property. When a rendering command executes, it renders to the multisample texture. At the end of the render pass, the GPU resolves the contents of the multisample texture and writes the results into the resolve texture. The resolveLevel, resolveSlice, and resolveDepthPlane properties specify where the resolved image is written to. The attachment’s storeAction property determines what happens to the multisample texture after the GPU resolves its data.

Topics

Specifying the texture for the attachment

Specifying rendering pass actions

Specifying the texture to resolve multisample data

See Also

Configuring a render command encoder