<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShaders",
  "identifier" : "/documentation/MetalPerformanceShaders/MPSFColorConversion/init(device:start:end:functionName:sourceRange:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSFColorConversion(im)initWithDevice:startColorSpace:endColorSpace:functionName:sourceRange:options:error:"
  },
  "title" : "init(device:start:end:functionName:sourceRange:options:)"
}
-->

# init(device:start:end:functionName:sourceRange:options:)

```
convenience init(device: any MTLDevice, start: CGColorSpace, end: CGColorSpace, functionName name: String, sourceRange: UnsafePointer<MPSFunctions_AABB>?, options: MPSFColorConversionOptions = []) throws
```

## Parameters

`device`

A valid MTLDevice where the conversion will be used

`start`

The CGColorSpaceRef for the input data to the conversion

`end`

The CGColorSpaceRef for the output data from the conversion

`name`

The name of the Metal Shading Language function to build.

`sourceRange`

If not NULL, the range limit guarantees that the input
texels to the MTLFunction will not appear outside the given axis aligned
bounding box. This, in combination with precision limits (see options), may
allow for a faster conversion calculation.  If a rangeLimit is provided, the
result of the conversion involving out of range inputs is undefined.

`options`

Options to use when building the conversion

## Return Value

On success, a valid MPSFunctionsConversion object. If the conversion can’t be done,
for example because it consumes or produces more than four channels, nil will be
returned, and an appropriate error code created.

## Discussion\abstract initialize a new MPSFunctionsConversion object
\discussion Builds a MPSFunctionsConverison object from a starting and ending colorspace.
Kicks off an asynchronous compilation task to build a MTLFunction appropriate
for the device. Calling the .function or .error propertywill stop and wait for it.
Since the compilation task may take a few milliseconds, your application should
create the MPSFunctionsConversion object as soon as it knows the conversion will
be needed.

```
         If you would like to make use of  sRGB, PQ and HLG, MTLPixelFormat
         variants to take advantage of hardware features to produce linear color
         from these colorspaces, use the result of CGColorSpaceCreateLinearized(start)
         here instead and configure your MTLTexture to the appropriate variant MTLPixelFormat,
         using a texture view or new base pixel format.
```

---

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)