An object used to encode data into an argument buffer.
SDKs
- iOS 11.0+
- macOS 10.13+
- Mac Catalyst 13.0+
- tvOS 11.0+
Framework
- Metal
Declaration
@protocol MTLArgumentEncoder
Overview
A MTLArgument
object encodes buffers, textures, samplers, and inlined constant data into an argument buffer. The argument buffer itself is represented by a MTLBuffer
object that you set as the encoding destination by calling the set
method.
The recommended way to declare an argument buffer is to define its structure in your Metal shading language code. The argument buffer can then be directly assigned to a specific buffer index of a function. 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 MTLArgument
objects. To create an encoder for this type of argument buffer, call the new
method of the MTLDevice
class.