Contents

makeFunction(name:constantValues:completionHandler:)

Asynchronously creates a specialized shader function.

Declaration

func makeFunction(name: String, constantValues: MTLFunctionConstantValues, completionHandler: @escaping  @Sendable ((any MTLFunction)?, (any Error)?) -> Void)
func makeFunction(name: String, constantValues: MTLFunctionConstantValues) async throws -> any MTLFunction

Parameters

  • name:

    The name of the specialized function.

  • constantValues:

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

  • completionHandler:

    A block of code that Metal calls after it creates the specialized function.

    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 Metal created the specialized function with warnings. If Metal created the function without errors or warnings, this error object is nil.

Discussion

Function constant values are first looked up by their index, then by their name. Metal ignores any values that don’t correspond to a function constant in the named function without generating errors or warnings.

See Also

Creating shader function instances