A constant used to specialize the behavior of a shader.


class MTLFunctionConstant : NSObject


Don’t create a MTLFunctionConstant object directly. Instead, the list of function constants for a function by querying the functionConstants property of a MTLFunction object.

A MTLFunctionConstant object should only be obtained from a nonspecialized function created with the makeFunction(name:) method. You only need a MTLFunctionConstant object if you don’t have sufficient information to create a MTLFunctionConstantValues object used to create a specialized function with the makeFunction(name:constantValues:) or makeFunction(name:constantValues:completionHandler:) method.


Reading the Function Constant's Properties

var name: String

The name of the function constant.

var type: MTLDataType

The data type of the function constant.

var index: Int

The index of the function constant.

var required: Bool

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


Inherits From

Conforms To

See Also

Function Variants

class MTLFunctionConstantValues

A set of constant values used to specialize a graphics or compute function.