<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIContext/render(_:to:commandBuffer:bounds:colorSpace:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Image"
    ],
    "preciseIdentifier" : "c:objc(cs)CIContext(im)render:toMTLTexture:commandBuffer:bounds:colorSpace:"
  },
  "title" : "render(_:to:commandBuffer:bounds:colorSpace:)"
}
-->

# render(_:to:commandBuffer:bounds:colorSpace:)

Renders a region of an image to a Metal texture.

```
func render(_ image: CIImage, to texture: any MTLTexture, commandBuffer: (any MTLCommandBuffer)?, bounds: CGRect, colorSpace: CGColorSpace)
```

## Parameters

`image`

A Core Image image object.

`texture`

The destination Metal texture object.

`commandBuffer`

The Metal command buffer into which to schedule Core Image rendering tasks.

`bounds`

The rectangle in the destination texture to draw into.

`colorSpace`

The color space of the destination texture.

## Discussion

If you specify `nil` for the `commandBuffer` parameter, Core Image manages its own Metal command buffer. To combine Core Image rendering with other Metal rendering tasks—for example, to use Core Image filters on textures whose content is generated by a Metal render-to-texture operation, or to use Core Image output later in the same Metal rendering pass—pass the same <doc://com.apple.documentation/documentation/Metal/MTLCommandBuffer> object you use for those tasks.

Rendering to a Metal texture requires a Metal-based context created with the [`init(mtlDevice:)`](/documentation/CoreImage/CIContext/init(mtlDevice:)-swey) or [`init(mtlDevice:options:)`](/documentation/CoreImage/CIContext/init(mtlDevice:options:)-26usb) method. Calling this method on any other context raises an exception. This method renders only to Metal textures whose texture type is <doc://com.apple.documentation/documentation/Metal/MTLTextureType/type2D> and whose <doc://com.apple.documentation/documentation/Metal/MTLTexture/sampleCount> value is 1.

---

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)