Contents

MTLFunction

A interface that represents a public shader function in a Metal library.

Declaration

protocol MTLFunction : NSObjectProtocol, Sendable

Overview

Use MTLFunction instances to specify which shaders a Metal pipeline calls when the GPU executes commands that specify that pipeline. For more information on creating pipeline states, see MTLRenderPipelineDescriptor and MTLComputePipelineDescriptor.

An MTLFunction instance is a specialized function if the shader contains function constants, otherwise it is a nonspecialized function.

Don’t use standard allocation and initialization techniques to create an MTLFunction instance. Instead, use the function creation methods provided by the MTLLibrary protocol. To create a nonspecialized function, call the makeFunction(name:) method.

To create a specialized function, call one of these MTLLibrary methods:

MTLFunction instances can use a significant amount of memory; release any strong references to them after you finish creating pipeline instances.

Topics

Identifying shader functions

Identifying the tessellation patch

Retrieving function attributes

Retrieving function constants

Creating argument encoders

See Also

Shader functions