Instance Method


Synchronously generates a specialized shader function.



- (id<MTLFunction>)newFunctionWithName:(NSString *)name constantValues:(MTLFunctionConstantValues *)constantValues error:(NSError * _Nullable *)error;



The name of the specialized function.


The set of constant values assigned to the function constants. Compilation fails if you do not provide valid constant values for all required function constants.


A pointer to an error object that describes compilation problems, if any. This object contains compiler errors if the specialized function is nil, and compiler warnings if the specialized function was created with warnings. If the specialized function was created successfully, without errors or warnings, this error object is nil.

Return Value

A specialized function, or nil if an error occurred.


Function constant values are first looked up by their index, then by their name. Any values that do not correspond to a function constant in the named function are ignored (without generating errors or warnings).

See Also

Finding Shader Functions

- newFunctionWithName:

Returns an object representing a shader function in the library.


- newFunctionWithName:constantValues:completionHandler:

Asynchronously generates a specialized shader function.


Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software