A set of constant values used to specialize a graphics or compute function.
- iOS 10.0+
- macOS 10.12+
- Mac Catalyst 13.0+
- tvOS 10.0+
MTLFunction object sets constant values for function constants. Function constants are declared with the
[[ function attribute in Metal shading language source code. Refer to the Metal Shading Language Guide for more information.
Single constant values can be set individually by index or name. Multiple constant values can be set together with an index range.
MTLFunction object can be applied to multiple
MTLFunction objects (for example, a vertex function and a fragment function). After a specialized function has been created, any changes to its constant values have no further effect on it. However, you can reset, add, or modify any constant values in the
MTLFunction object and reuse it to create another