Class

CAMetalLayer

A layer that manages a pool of Metal drawables.

Overview

To use Metal for rendering in your app, use this class as the backing layer for a view by returning it from your view’s layerClass class method. To render the layer’s content, use the nextDrawable() method to retrieve a texture, then use it as a render target in a Metal rendering pipeline. After rendering each frame, you present the new content for display with the present(_:) or present(_:atTime:) method of the command buffer you used for rendering.

Topics

Configuring the Metal Layer

var pixelFormat: MTLPixelFormat

The pixel format of textures for rendering layer content.

var framebufferOnly: Bool

A Boolean value that determines whether the layer’s textures are restricted for use as framebuffer attachments.

var drawableSize: CGSize

The size, in pixels, of textures for rendering layer content.

var colorspace: CGColorSpace?

The color space of the rendered content.

var presentsWithTransaction: Bool

A Boolean value that determines whether the layer presents its content using a Core Animation transaction.

var wantsExtendedDynamicRangeContent: Bool

Enables extended dynamic range values on the screen.

var displaySyncEnabled: Bool

A Boolean value that determines whether the Metal layer and it's drawables are synchronized with the display's refresh rate.

var allowsNextDrawableTimeout: Bool

A Boolean value that determines whether Metal drawables are allowed to time out or wait indefinitely.

var maximumDrawableCount: Int

An integer value that controls the number of Metal drawables in the resource pool managed by Core Animation.

Obtaining a Metal Drawable

func nextDrawable()

Returns a Metal drawable.

Obtaining the Metal Device

var device: MTLDevice?

The Metal device responsible for the layer’s drawable resources.

Relationships

Inherits From

Conforms To

See Also

Metal and OpenGL

protocol CAMetalDrawable

A displayable resource that can be rendered or written to by Metal.

class CAEAGLLayer

A layer that supports drawing OpenGL content in iOS and tvOS applications.

class CAOpenGLLayer

CAOpenGLLayer provides a layer suitable for rendering OpenGL content.

class CARenderer

A layer that allows an application to render a layer tree into a Core OpenGL (CGL) context.