Instance Method

setVertexBytes(_:length:index:)

Sets a block of data for the vertex shader.

Required.

Declaration

func setVertexBytes(_ bytes: UnsafeRawPointer, length: Int, index: Int)

Parameters

bytes

The memory address from which to copy the data.

length

The number of bytes to copy.

index

The index in the buffer argument table.

Discussion

Using this method is equivalent to creating a new MTLBuffer object from the specified data and then binding it to the vertex shader, with the setVertexBuffer(_:offset:index:) method. However, this method avoids the overhead of creating a buffer to store your data; instead, Metal manages the data.

Use this method for single-use data smaller than 4 KB. Create a MTLBuffer object if your data exceeds 4 KB in length or persists for multiple uses.

See Also

Specifying Arguments for a Vertex Function

func setVertexBuffer(MTLBuffer?, offset: Int, index: Int)

Sets a buffer for the vertex function.

Required.

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

Sets an array of buffers for the vertex function.

func setVertexBufferOffset(Int, index: Int)

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

Required.

func setVertexSamplerState(MTLSamplerState?, index: Int)

Sets a sampler for the vertex function.

Required.

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

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

Required.

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

Sets multiple samplers for the vertex function.

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

Sets a sampler state for the vertex function in a range of indices in the sampler state argument table, with clamp values for the level of detail.

func setVertexTexture(MTLTexture?, index: Int)

Sets a texture for the vertex function.

Required.

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

Sets an array of textures for the vertex function.

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