---
title: "setVertexBytes(_:length:index:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlrendercommandencoder/setvertexbytes(_:length:index:)"
---

# setVertexBytes(_:length:index:)

Creates a buffer from bytes and assigns it to an entry in the vertex shader argument table.

## Declaration

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

## Parameters

- `bytes`: A pointer to argument data the method copies to an doc://com.apple.metal/documentation/Metal/MTLBuffer and assigns to an entry in the vertex shader argument table for buffers.
- `length`: The number of bytes the method copies from the bytes pointer.
- `index`: An integer that represents the entry in the vertex shader argument table for buffers that stores a record of the doc://com.apple.metal/documentation/Metal/MTLBuffer the method creates from bytes.

## Discussion

Discussion The method is equivalent to creating an MTLBuffer instance that contains the same data as bytes and calling the setVertexBuffer(_:offset:index:) method. However, this method avoids the overhead of creating a buffer to store your data; instead, Metal manages the data. important: Only call this method for single-use data that’s smaller than 4 KB. For data that’s more than 4 KB, create an MTLBuffer instance and pass it to setVertexBuffer(_:offset:index:). By default, the buffer at each index is nil.

## See Also

### Assigning buffers

- [setVertexBuffer(_:offset:index:)](metal/mtlrendercommandencoder/setvertexbuffer(_:offset:index:).md)
- [setVertexBuffer(_:offset:attributeStride:index:)](metal/mtlrendercommandencoder/setvertexbuffer(_:offset:attributestride:index:).md)
- [setVertexBuffers(_:offsets:range:)](metal/mtlrendercommandencoder/setvertexbuffers(_:offsets:range:).md)
- [setVertexBuffers(_:offsets:attributeStrides:range:)](metal/mtlrendercommandencoder/setvertexbuffers(_:offsets:attributestrides:range:).md)
- [setVertexBytes(_:length:attributeStride:index:)](metal/mtlrendercommandencoder/setvertexbytes(_:length:attributestride:index:).md)
- [setVertexBufferOffset(_:index:)](metal/mtlrendercommandencoder/setvertexbufferoffset(_:index:).md)
- [setVertexBufferOffset(offset:attributeStride:index:)](metal/mtlrendercommandencoder/setvertexbufferoffset(offset:attributestride:index:).md)
