---
title: "init(mtlDevice:options:)"
framework: coreimage
role: symbol
role_heading: Initializer
path: "coreimage/cicontext/init(mtldevice:options:)-26usb"
---

# init(mtlDevice:options:)

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

## Declaration

```swift
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 doc://com.apple.coreimage/documentation/CoreImage/CIContext object. You can pass any of the keys defined in doc://com.apple.coreimage/documentation/CoreImage/CIContextOption along with the appropriate value.

## Return Value

Return Value A Core Image context.

## Discussion

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: method.

## See Also

### Creating a Context for GPU-Based Rendering

- [init(mtlDevice:)](coreimage/cicontext/init(mtldevice:)-swey.md)
- [init(mtlCommandQueue:)](coreimage/cicontext/init(mtlcommandqueue:)-7dtqk.md)
- [init(mtlCommandQueue:options:)](coreimage/cicontext/init(mtlcommandqueue:options:)-6i3me.md)
