Protocol

MTLFunction

An object representing a public shader function in the library.

Declaration

@protocol MTLFunction

Overview

A MTLFunction object is considered a specialized function if it contains 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 precompiled, nonspecialized function, call the newFunctionWithName: method.

Topics

Identifying Shader Functions

device

The device object that created the shader function.

Required.

label

A string that identifies the shader function.

Required.

functionType

The shader function’s type.

Required.

name

The function’s name.

Required.

MTLFunctionType

The type of a top-level Metal function.

Identifying the Tessellation Patch

patchType

The tessellation patch type of a post-tessellation vertex function.

Required.

patchControlPointCount

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

Required.

MTLPatchType

Types of tessellation patches that can be inputs of a post-tessellation vertex function.

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.

MTLAttribute

An object that describes an attribute defined in the stage-in argument for a shader.

MTLVertexAttribute

An object that represents an attribute of a vertex function.

Retrieving Function Constants

functionConstantsDictionary

A dictionary of function constants for a specialized function.

Required.

Creating Argument Encoders

- newArgumentEncoderWithBufferIndex:

Creates an argument encoder for an argument buffer that is one of this function's arguments.

Required.

- newArgumentEncoderWithBufferIndex:reflection:

Creates an argument encoder and returns reflection information for an argument buffer that is one of this function's arguments

Required.

Relationships

Inherits From