---
title: MTLFunctionConstant
framework: metal
role: symbol
role_heading: Class
path: metal/mtlfunctionconstant
---

# MTLFunctionConstant

A constant that specializes the behavior of a shader.

## Declaration

```swift
class MTLFunctionConstant
```

## Overview

Overview Don’t create an MTLFunctionConstant instance directly. Instead, the list of function constants for a function by querying the functionConstants property of an MTLFunction instance. An MTLFunctionConstant instance should only be obtained from a nonspecialized function created with the makeFunction(name:) method. You only need an MTLFunctionConstant instance if you don’t have sufficient information to create an MTLFunctionConstantValues instance used to create a specialized function with the makeFunction(name:constantValues:) or makeFunction(name:constantValues:completionHandler:) method.

## Topics

### Reading the function constant’s properties

- [name](metal/mtlfunctionconstant/name.md)
- [type](metal/mtlfunctionconstant/type.md)
- [index](metal/mtlfunctionconstant/index.md)
- [required](metal/mtlfunctionconstant/required.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Compile-time variant functions

- [MTLFunctionConstantValues](metal/mtlfunctionconstantvalues.md)
