<!--
{
  "availability" : [
    "macOS: 26.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CompositorServices",
  "identifier" : "/documentation/CompositorServices/LayerRenderer/Drawable",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Compositor Services",
      "CompositorServices"
    ],
    "preciseIdentifier" : "c:@S@cp_drawable_t"
  },
  "title" : "LayerRenderer.Drawable"
}
-->

# LayerRenderer.Drawable

A type that provides the textures and information you need to draw a frame of content.

```
struct Drawable
```

## Overview

When you draw a frame of content, the frame’s  [`LayerRenderer.Drawable`](/documentation/CompositorServices/LayerRenderer/Drawable) type provides
the actual textures and rendering information you need.
Do as much work as possible in advance to prepare for rendering, and retrieve the
[`LayerRenderer.Drawable`](/documentation/CompositorServices/LayerRenderer/Drawable) only when you’re ready to start encoding commands into your Metal command buffers.
The system recycles frames and their drawables for efficiency,
so if you retrieve the drawable too early, it might not be ready to use.

Use the drawable’s [`LayerRenderer.Drawable.View`](/documentation/CompositorServices/LayerRenderer/Drawable/View) instances to determine where to draw your content in the provided textures.
After you finish encoding your content, call [`encodePresent(commandBuffer:)`](/documentation/CompositorServices/LayerRenderer/Drawable/encodePresent(commandBuffer:))
to add a presentation notification to your command buffer.
This command tells Compositor Services when to display the frame,
and is essential for displaying your frame on time.

## Topics

### Getting the views

[`var views: [LayerRenderer.Drawable.View]`](/documentation/CompositorServices/LayerRenderer/Drawable/views)

An array of viewports that tell you how to draw to the drawable’s textures

[`struct View`](/documentation/CompositorServices/LayerRenderer/Drawable/View)

A type that provides information on how to render content into the frame’s textures.

### Accessing the device orientation

[`var deviceAnchor: DeviceAnchor?`](/documentation/CompositorServices/LayerRenderer/Drawable/deviceAnchor)

The device position and orientation you used to render the frame.

### Getting the render textures

[`var colorTextures: [any MTLTexture]`](/documentation/CompositorServices/LayerRenderer/Drawable/colorTextures)

An array of color textures to use to render the current frame.

[`var depthTextures: [any MTLTexture]`](/documentation/CompositorServices/LayerRenderer/Drawable/depthTextures)

An array of depth textures to use to render the current frame.

### Enqueueing a command buffer

[`func encodePresent(commandBuffer: any MTLCommandBuffer)`](/documentation/CompositorServices/LayerRenderer/Drawable/encodePresent(commandBuffer:))

Encodes a notification event to the specified command buffer to present the drawable’s content onscreen.

### Getting the rasterization rate map

[`var rasterizationRateMaps: [any MTLRasterizationRateMap]`](/documentation/CompositorServices/LayerRenderer/Drawable/rasterizationRateMaps)

The rasterization rate maps to use when rendering the frame.

[`var flippedRasterizationRateMaps: [any MTLRasterizationRateMap]`](/documentation/CompositorServices/LayerRenderer/Drawable/flippedRasterizationRateMaps)

The rasterization rate maps that are flipped around the y-axis.

### Getting the projection matrix

[`enum AxisDirectionConvention`](/documentation/CompositorServices/AxisDirectionConvention)

Constants that indicate the axis and direction to use for a perspective projection matrix.

### Accessing pixel depth information

[`var depthRange: simd_float2`](/documentation/CompositorServices/LayerRenderer/Drawable/depthRange)

The distances to the far and near clipping planes from the person viewing the content, in meters.

### Managing the state machine

[`var state: LayerRenderer.Drawable.State`](/documentation/CompositorServices/LayerRenderer/Drawable/state-swift.property)

The current operational state of a drawable instance.

[`enum State`](/documentation/CompositorServices/LayerRenderer/Drawable/State-swift.enum)

The state of ownership for the drawable.

### Synchronizing the drawing operation

[`var frameTiming: LayerRenderer.Frame.Timing`](/documentation/CompositorServices/LayerRenderer/Drawable/frameTiming)

The timing information for the drawable’s frame.

[`var presentationFrameIndex: CompositorFrameIndex`](/documentation/CompositorServices/LayerRenderer/Drawable/presentationFrameIndex)

The sequential index of a drawable’s frame.

### Retrieving the target

[`var target: LayerRenderer.Drawable.Target`](/documentation/CompositorServices/LayerRenderer/Drawable/target-swift.property)

Returns a value that indicates the target of the drawable type.

[`enum Target`](/documentation/CompositorServices/LayerRenderer/Drawable/Target-swift.enum)

The target where the drawable will be displayed/used.

### Creating a drawable

[`init()`](/documentation/CompositorServices/LayerRenderer/Drawable/init())

Creates an uninitialized drawable.

### Adding a render context

  <doc://controlling-metal-rendering-immersion-level>

[`struct RenderContext`](/documentation/CompositorServices/LayerRenderer/Drawable/RenderContext)

An object the compositer uses for rendering all effects associated with a layer renderer drawable.

[`func addRenderContext(commandBuffer: any MTLCommandBuffer) -> LayerRenderer.Drawable.RenderContext`](/documentation/CompositorServices/LayerRenderer/Drawable/addRenderContext(commandBuffer:))

Adds and returns a render context to a `LayerRenderer.Drawable` providing a metal command buffer.

[`func addRenderContext() -> LayerRenderer.Drawable.RenderContext`](/documentation/CompositorServices/LayerRenderer/Drawable/addRenderContext())

Adds and returns a render context to a `LayerRenderer.Drawable` that draws any content required by the compositor.

### Structures

[`struct TrackingArea`](/documentation/CompositorServices/LayerRenderer/Drawable/TrackingArea)

### Instance Properties

[`var isContentCaptureProtected: Bool`](/documentation/CompositorServices/LayerRenderer/Drawable/isContentCaptureProtected)

Returns whether content capture is protected and it is safe to
draw content that should be protected from capture.

[`var trackingAreasTextures: [any MTLTexture]`](/documentation/CompositorServices/LayerRenderer/Drawable/trackingAreasTextures)

Use the returned texture in your render pipeline to store the tracking areas ID
used for hover effects and indirect gestures. The layer’s texture topology determines
the layout and content for each texture. The drawable’s views contain
information about how those views map to the textures.

### Instance Methods

[`func addTrackingArea(identifier: LayerRenderer.Drawable.TrackingArea.Identifier) -> LayerRenderer.Drawable.TrackingArea`](/documentation/CompositorServices/LayerRenderer/Drawable/addTrackingArea(identifier:))

Returns a tracking area which is create on the drawable’s list of tracking areas.

[`func computeProjection(convention: AxisDirectionConvention, viewIndex: Int) -> matrix_float4x4`](/documentation/CompositorServices/LayerRenderer/Drawable/computeProjection(convention:viewIndex:))

[`func encodePresent()`](/documentation/CompositorServices/LayerRenderer/Drawable/encodePresent())

Encodes a notification event to the specified command buffer to present
the drawable’s content onscreen.

## Relationships

### Conforms To

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)