Instance Method

newFunctionWithName:constantValues:completionHandler:

Asynchronously generates a specialized shader function.

Required.

Declaration

- (void)newFunctionWithName:(NSString *)name constantValues:(MTLFunctionConstantValues *)constantValues completionHandler:(void (^)(id<MTLFunction> function, NSError *error))completionHandler;

Parameters

name

The name of the specialized function.

constantValues

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.

completionHandler

A block of code invoked when the compilation and creation of a specialized function is completed.

function

A specialized function, or nil if an error occurred.

error

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.

Discussion

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.

Required.

- newFunctionWithName:constantValues:error:

Synchronously generates a specialized shader function.

Required.