Instance Method

setVertexBufferOffset(_:index:)

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

Required.

Declaration

func setVertexBufferOffset(_ offset: Int, index: Int)

Parameters

offset

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

index

The index in the buffer argument table.

Discussion

Call this method to change the offset you specified when binding a single buffer with the setVertexBuffer(_:offset:index:) method or multiple buffers with the setVertexBuffers(_:offsets:with:) method. You can also use this method to specify a data offset after binding data directly to the vertex shader with the setVertexBytes(_:length:index:) method. Don’t rebind a buffer or block of data if you’re only updating its offset.

For buffers in the device address space, align the offset to the data type consumed by the vertex shader (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 vertex shader, 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 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 setVertexBytes(UnsafeRawPointer, length: Int, index: Int)

Sets a block of data for 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.