---
title: "makeFunction(name:constantValues:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtllibrary/makefunction(name:constantvalues:)"
---

# makeFunction(name:constantValues:)

Synchronously creates a specialized shader function.

## Declaration

```swift
func makeFunction(name: String, constantValues: MTLFunctionConstantValues) throws -> any MTLFunction
```

## Parameters

- `name`: The name of the specialized function.
- `constantValues`: The set of constant values for the function constants. The compiler can’t compile the function if any value is invalid for the function constants it requires.

## Return Value

Return Value A new MTLFunction instance if the method completes successfully; otherwise Swift throws an error and Objective-C returns nil.

## Discussion

Discussion Function constant values are first looked up by their index, then by their name. The compiler ignores any values that don’t correspond to a function constant in the named function, and doesn’t generate errors or warnings.

## See Also

### Creating shader function instances

- [makeFunction(name:)](metal/mtllibrary/makefunction(name:).md)
- [makeFunction(name:constantValues:completionHandler:)](metal/mtllibrary/makefunction(name:constantvalues:completionhandler:).md)
- [makeFunction(descriptor:completionHandler:)](metal/mtllibrary/makefunction(descriptor:completionhandler:).md)
- [makeFunction(descriptor:)](metal/mtllibrary/makefunction(descriptor:).md)
