<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Cinematic",
  "identifier" : "/documentation/Cinematic/CNRenderingSession-1hzh8",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Cinematic"
    ],
    "preciseIdentifier" : "s:9Cinematic18CNRenderingSessionC"
  },
  "title" : "CNRenderingSession"
}
-->

# CNRenderingSession

An object representing the context in which rendering occurs.

```
class CNRenderingSession
```

## Topics

### Structures

[`struct Attributes`](/documentation/Cinematic/CNRenderingSession-1hzh8/Attributes)

The rendering session asset attributes.

[`struct FrameAttributes`](/documentation/Cinematic/CNRenderingSession-1hzh8/FrameAttributes)

Controls the focus distance and aperture of the rendering for the frames.

### Initializers

[`init(commandQueue: any MTLCommandQueue, sessionAttributes: CNRenderingSession.Attributes, preferredTransform: CGAffineTransform, quality: CNRenderingQuality)`](/documentation/Cinematic/CNRenderingSession-1hzh8/init(commandQueue:sessionAttributes:preferredTransform:quality:))

Intializes an object for a rendering session.

### Instance Properties

[`let commandQueue: any MTLCommandQueue`](/documentation/Cinematic/CNRenderingSession-1hzh8/commandQueue)

The command queue of a Metal device that creates the command buffer.

[`let preferredTransform: CGAffineTransform`](/documentation/Cinematic/CNRenderingSession-1hzh8/preferredTransform)

The preferred transform of the rendered image for display purposes.

[`let quality: CNRenderingQuality`](/documentation/Cinematic/CNRenderingSession-1hzh8/quality)

The quality of rendering desired for a session.

[`let sessionAttributes: CNRenderingSession.Attributes`](/documentation/Cinematic/CNRenderingSession-1hzh8/sessionAttributes)

Rendering session attributes for a Cinematic asset.

### Instance Methods

[`func encodeRender(to: any MTLCommandBuffer, frameAttributes: CNRenderingSession.FrameAttributes, sourceImage: CVReadOnlyPixelBuffer, sourceDisparity: CVReadOnlyPixelBuffer?, destinationImage: CVPixelBuffer) -> Bool`](/documentation/Cinematic/CNRenderingSession-1hzh8/encodeRender(to:frameAttributes:sourceImage:sourceDisparity:destinationImage:)-3rknf)

Encode a command to render a shallow depth of field (SDoF) image to a pixel buffer.

[`func encodeRender(to: any MTLCommandBuffer, frameAttributes: CNRenderingSession.FrameAttributes, sourceImage: CVPixelBuffer, sourceDisparity: CVPixelBuffer, destinationImage: CVPixelBuffer) -> Bool`](/documentation/Cinematic/CNRenderingSession-1hzh8/encodeRender(to:frameAttributes:sourceImage:sourceDisparity:destinationImage:)-58mjy)

Encode a command to render a shallow depth of field (SDoF) image to a pixel buffer.

[`func encodeRender(to: any MTLCommandBuffer, frameAttributes: CNRenderingSession.FrameAttributes, sourceImage: CVReadOnlyPixelBuffer, sourceDisparity: CVReadOnlyPixelBuffer?, destinationLuma: any MTLTexture, destinationChroma: any MTLTexture) -> Bool`](/documentation/Cinematic/CNRenderingSession-1hzh8/encodeRender(to:frameAttributes:sourceImage:sourceDisparity:destinationLuma:destinationChroma:)-5ukp9)

Encode a command to render a shallow depth of field (SDoF) image to two metal textures as luma and chroma.

[`func encodeRender(to: any MTLCommandBuffer, frameAttributes: CNRenderingSession.FrameAttributes, sourceImage: CVPixelBuffer, sourceDisparity: CVPixelBuffer, destinationLuma: any MTLTexture, destinationChroma: any MTLTexture) -> Bool`](/documentation/Cinematic/CNRenderingSession-1hzh8/encodeRender(to:frameAttributes:sourceImage:sourceDisparity:destinationLuma:destinationChroma:)-9kvia)

Encode a command to render a shallow depth of field (SDoF) image to two metal textures as luma and chroma.

[`func encodeRender(to: any MTLCommandBuffer, frameAttributes: CNRenderingSession.FrameAttributes, sourceImage: CVReadOnlyPixelBuffer, sourceDisparity: CVReadOnlyPixelBuffer?, destinationRGBA: any MTLTexture) -> Bool`](/documentation/Cinematic/CNRenderingSession-1hzh8/encodeRender(to:frameAttributes:sourceImage:sourceDisparity:destinationRGBA:)-1gaox)

Encode a command to render a shallow depth of field (SDoF) image to a metal texture as RGBA.

[`func encodeRender(to: any MTLCommandBuffer, frameAttributes: CNRenderingSession.FrameAttributes, sourceImage: CVPixelBuffer, sourceDisparity: CVPixelBuffer, destinationRGBA: any MTLTexture) -> Bool`](/documentation/Cinematic/CNRenderingSession-1hzh8/encodeRender(to:frameAttributes:sourceImage:sourceDisparity:destinationRGBA:)-3ff9)

Encode a command to render a shallow depth of field (SDoF) image to a metal texture as RGBA.

### Type Properties

[`static var destinationPixelFormatTypes: [OSType]`](/documentation/Cinematic/CNRenderingSession-1hzh8/destinationPixelFormatTypes)

A static number representing the video compositor’s required pixel buffer attributes context dictionary when implementing video compositing.

[`static var sourcePixelFormatTypes: [OSType]`](/documentation/Cinematic/CNRenderingSession-1hzh8/sourcePixelFormatTypes)

The static pixel format types supported for the output destination.

---

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)