<!--
{
  "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/init(mtlDevice:options:)-26usb",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core Image"
    ],
    "preciseIdentifier" : "c:objc(cs)CIContext(cm)contextWithMTLDevice:options:"
  },
  "title" : "init(mtlDevice:options:)"
}
-->

# init(mtlDevice:options:)

Creates a Core Image context using the specified Metal device and options.

```
init(mtlDevice device: any MTLDevice, options: [CIContextOption : Any]? = nil)
```

## Parameters

`device`

The Metal device object to use for rendering.

`options`

A dictionary that contains options for creating a [`CIContext`](/documentation/CoreImage/CIContext) object. You can pass any of the keys defined in [`CIContextOption`](/documentation/CoreImage/CIContextOption) along with the appropriate value.

## Return Value

A Core Image context.

## Discussion

Use this method to choose a specific Metal device for rendering when a system contains multiple Metal devices. To create a Metal-based context using the system’s default Metal device, use the [`contextWithOptions:`](/documentation/CoreImage/CIContext/contextWithOptions:) method.

---

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)