Instance Method

setBuffer(_:offset:index:)

Sets a buffer for the compute function.

Required.

Declaration

func setBuffer(_ buffer: MTLBuffer?, offset: Int, index: Int)

Parameters

buffer

The MTLBuffer object to set in the argument table.

offset

Where the data begins, in bytes, from the start of the buffer.

index

An index in the buffer argument table.

Discussion

For buffers in the device address space, align the offset to the data type consumed by the compute function (which is always less than or equal to 16 bytes).

For buffers in the constant address space, align the offset to 256 bytes in macOS. In iOS, align the offset to the maximum of either the data type consumed by the compute function, or 4 bytes. A 16-byte alignment is safe in iOS if you don't need to consider the data type.

See Also

Specifying Arguments for a Compute Function

func setBuffers([MTLBuffer?], offsets: [Int], range: Range<Int>)

Sets an array of buffers for the vertex function.

func setBufferOffset(Int, index: Int)

Sets where the data begins in a buffer already bound to the compute shader.

Required.

func setBytes(UnsafeRawPointer, length: Int, index: Int)

Sets a block of data for the compute shader.

Required.

func setSamplerState(MTLSamplerState?, index: Int)

Sets a sampler for the compute function.

Required.

func setSamplerState(MTLSamplerState?, lodMinClamp: Float, lodMaxClamp: Float, index: Int)

Sets a sampler for the compute function, specifying clamp values for the level of detail.

Required.

func setSamplerStates([MTLSamplerState?], range: Range<Int>)

Sets an array of sampler states in a range of indices in the sampler state argument table.

func setSamplerStates([MTLSamplerState?], lodMinClamps: [Float], lodMaxClamps: [Float], range: Range<Int>)

Sets multiple samplers for the compute function, specifying clamp values for the level of detail of each sampler.

func setTexture(MTLTexture?, index: Int)

Sets a texture for the compute function.

Required.

func setTextures([MTLTexture?], range: Range<Int>)

Sets an array of textures for the compute function.

func setThreadgroupMemoryLength(Int, index: Int)

Sets the size of a block of threadgroup memory.

Required.

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