MTLFunctionConstantValues
A set of constant values that specialize a graphics or compute GPU function.
Declaration
class MTLFunctionConstantValuesOverview
An MTLFunctionConstantValues instance sets constant values for function constants. You declare function constants with the [[ function_constant(index) ]] attribute in MSL (Metal Shading Language) source code. See the Metal Shading Language specification for more information.
With an MTLFunctionConstantValues instance, you can set each constant value individually with an index or a name, or set multiple constant values with an index range.
You can apply a single MTLFunctionConstantValues instance to multiple MTLFunction instances of any kind, such as a vertex function and a fragment function. When you create a specialized function, subsequent changes to its constant values have no effect. However, you can reset, add, or modify a constant value in your MTLFunctionConstantValues instance and reuse it to create another MTLFunction instance.