Protocol

MTLFunction

A programmable graphics or compute function executed by the GPU.

Declaration

@protocol MTLFunction

Overview

A MTLFunction object is considered a specialized function if it contain function constants, otherwise it is considered a non-specialized function. Specialized functions are compiled at runtime because they must evaluate constant values for each of its function constants; non-specialized functions are compiled when their respective library is built.

Do not use standard allocation and initialization techniques to create a MTLFunction object. Instead, use the function creation methods provided by the MTLLibrary protocol. To compile and create a specialized function, call one of these MTLLibrary methods:

To fetch a pre-compiled, non-specialized function, call the newFunctionWithName: method.

Topics

Identifying the Function

device

The device from which this function was created.

Required.

functionType

The type of this Metal function: vertex shader, fragment shader, or compute function.

Required.

name

The name of the function in the Metal shading language.

Required.

label

A string that identifies this object.

Required.

Identifying the Patch

patchType

The patch type of the post-tessellation vertex function.

Required.

patchControlPointCount

The number of patch control points in the post-tessellation vertex function.

Required.

Creating Argument Encoders

newArgumentEncoderWithBufferIndex:

Creates a new argument encoder for a specific graphics or compute function.

Required.

newArgumentEncoderWithBufferIndex:reflection:

Creates a new argument encoder for a specific graphics or compute function, with additional function reflection data.

Required.

Retrieving Function Attributes

vertexAttributes

An array that describes the vertex input attributes to a vertex function.

Required.

stageInputAttributes

An array that describes the input attributes to the function.

Required.

Retrieving Function Constants

functionConstantsDictionary

A dictionary of function constants for a specialized function.

Required.

Constants

MTLFunctionType

The type of a top-level Metal function.

MTLPatchType

The patch type of a post-tessellation vertex function.

Relationships

Inherits From