Instance Property

buffers

The buffer mutability options for a compute pipeline's kernel function.

Declaration

var buffers: MTLPipelineBufferDescriptorArray { get }

Discussion

This property holds an array of MTLPipelineBufferDescriptor objects, with each array index corresponding to the same index in the buffer argument table for the compute pipeline's kernel function.

Metal can perform additional optimizations if you guarantee that neither the CPU nor the GPU will modify a buffer's contents between the time the buffer is set in a function's argument table and the time its associated command buffer completes execution. Use immutable buffers as much as possible, for either regular buffers or argument buffers.

Listing 1

Setting the mutability for a buffer at a specific index of a kernel function

// Compute setup
// Set mutability for buffer at index 9
MTLComputePipelineDescriptor *computeDescriptor = [MTLComputePipelineDescriptor new];
computeDescriptor.buffers[9].mutability = MTLMutabilityImmutable;
// Compute pass
// Set immutable buffer at index 9
id <MTLComputeCommandEncoder> computeEncoder = [_commandBuffer computeCommandEncoder];
[computeEncoder setBuffer:_buffer offset:0 atIndex:9];

See Also

Specifying the Compute Function and Associated Data

var computeFunction: MTLFunction?

The compute function to be compiled into the pipeline state object.

var threadGroupSizeIsMultipleOfThreadExecutionWidth: Bool

A Boolean that indicates whether the threadgroup size must always be a multiple of the thread execution width.

var maxTotalThreadsPerThreadgroup: Int

The maximum number of threads allowed for a threadgroup dispatched to the compute function.

var stageInputDescriptor: MTLStageInputOutputDescriptor?

The organization of input and output data for the compute function.

class MTLPipelineBufferDescriptor

An object that contains the mutability options for buffers used in a render or compute pass.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software