MTLArgumentEncoder
An interface you can use to encode argument data into an argument buffer.
Declaration
protocol MTLArgumentEncoder : NSObjectProtocolMentioned 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
setRenderPipelineState(_:index:)setRenderPipelineStates(_:range:)setComputePipelineState(_:index:)setComputePipelineStates(_:with:)setComputePipelineState(_:at:)setComputePipelineStates(_:range:)
Encoding inlined constant data
Encoding indirect command buffers
Encoding acceleration structures
Encoding function tables
setVisibleFunctionTable(_:index:)setIntersectionFunctionTable(_:index:)setIntersectionFunctionTables(_:range:)setVisibleFunctionTables(_:range:)
Creating a nested argument encoder
Querying alignment
Identifying the argument encoder
Instance Methods
See Also
Argument buffers
Improving CPU performance by using argument buffersManaging groups of resources with argument buffersTracking the resource residency of argument buffersIndexing argument buffersRendering terrain dynamically with argument buffersEncoding argument buffers on the GPUUsing argument buffers with resource heapsMTLArgumentDescriptorMTLAttributeStrideStatic