<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLFunctionConstant",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(cs)MTLFunctionConstant"
  },
  "title" : "MTLFunctionConstant"
}
-->

# MTLFunctionConstant

A constant that specializes the behavior of a shader.

```
class MTLFunctionConstant
```

## Overview

Don’t create an [`MTLFunctionConstant`](/documentation/Metal/MTLFunctionConstant) instance directly. Instead, the list of function constants for a function by querying the `functionConstants` property of an [`MTLFunction`](/documentation/Metal/MTLFunction) instance.

An [`MTLFunctionConstant`](/documentation/Metal/MTLFunctionConstant) instance should only be obtained from a nonspecialized function created with the [`makeFunction(name:)`](/documentation/Metal/MTLLibrary/makeFunction(name:)) method. You only need an [`MTLFunctionConstant`](/documentation/Metal/MTLFunctionConstant) instance if you don’t have sufficient information to create an [`MTLFunctionConstantValues`](/documentation/Metal/MTLFunctionConstantValues) instance used to create a specialized function with the [`makeFunction(name:constantValues:)`](/documentation/Metal/MTLLibrary/makeFunction(name:constantValues:)) or [`makeFunction(name:constantValues:completionHandler:)`](/documentation/Metal/MTLLibrary/makeFunction(name:constantValues:completionHandler:)) method.

## Topics

### Reading the function constant’s properties

[`name`](/documentation/Metal/MTLFunctionConstant/name)

The name of the function constant.

[`type`](/documentation/Metal/MTLFunctionConstant/type)

The data type of the function constant.

[`index`](/documentation/Metal/MTLFunctionConstant/index)

The index of the function constant.

[`required`](/documentation/Metal/MTLFunctionConstant/required)

A Boolean value indicating whether the function constant needs to be provided to specialize the function.



---

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)