Instance Method

newFunctionWithName:

Returns an object representing a shader function in the library.

Required.

Declaration

- (id<MTLFunction>)newFunctionWithName:(NSString *)functionName;

Parameters

functionName

The name of the function.

Return Value

A MTLFunction, or nil if the named function is not found in the library.

Discussion

If you call this method to retrieve a function that does not use function constants, it returns a MTLFunction object that you can use to build a render or compute pipeline.

If you call this method to retrieve a function that uses function constants to specialize its behavior, the returned function can be used only to query the functionConstants property for the list of function constants. It cannot be used to build a render or compute pipeline. To get a specialized object that can be used to create a pipeline object, call the newFunctionWithName:constantValues:completionHandler: method or newFunctionWithName:constantValues:error: to generate a specialized function.

See Also

Finding Shader Functions

- newFunctionWithName:constantValues:completionHandler:

Asynchronously generates a specialized shader function.

Required.

- newFunctionWithName:constantValues:error:

Synchronously generates a specialized shader function.

Required.