Contents

MTLArgumentEncoder

An interface you can use to encode argument data into an argument buffer.

Declaration

protocol MTLArgumentEncoder : NSObjectProtocol

Mentioned in

Overview

An MTLArgumentEncoder instance encodes buffers, textures, samplers, and inlined constant data into an argument buffer. An MTLBuffer instance represents the argument buffer that you set as the encoding destination by calling the setArgumentBuffer(_:offset:) method.

The recommended way to declare an argument buffer is to define its structure in your Metal shading language code. You can assign the argument buffer to a function’s specific buffer index. To create an encoder for this type of argument buffer, call one of the following MTLFunction methods:

If you construct your shaders dynamically at runtime, you can still construct argument buffers as parameters for the shader. Define each argument separately and then add it to an array of MTLArgumentDescriptor instances. To create an encoder for this type of argument buffer, call the makeArgumentEncoder(arguments:) method of the MTLDevice class.

Topics

Creating an argument buffer

Encoding buffers

Encoding textures

Encoding samplers

Encoding pipeline states

Encoding inlined constant data

Encoding indirect command buffers

Encoding acceleration structures

Encoding function tables

Creating a nested argument encoder

Querying alignment

Identifying the argument encoder

Instance Methods

See Also

Argument buffers