---
title: "setObjectBuffer(_:offset:index:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlrendercommandencoder/setobjectbuffer(_:offset:index:)"
---

# setObjectBuffer(_:offset:index:)

Assigns a buffer to an entry in the object shader argument table.

## Declaration

```swift
func setObjectBuffer(_ buffer: (any MTLBuffer)?, offset: Int, index: Int)
```

## Parameters

- `buffer`: An doc://com.apple.metal/documentation/Metal/MTLBuffer instance the command assigns to an entry in the object shader argument table for buffers.
- `offset`: An integer that represents the location, in bytes, from the start of buffer where the object shader argument data begins. See the https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf to check for offset alignment requirements for buffers in device and constant address space.
- `index`: An integer that represents the entry in the object shader argument table for buffers that stores a record of buffer and offset.

## Mentioned in

Improving CPU performance by using argument buffers

## Discussion

Discussion By default, the texture at each index is nil.

## See Also

### Assigning buffers for object shaders

- [setObjectBuffers(_:offsets:range:)](metal/mtlrendercommandencoder/setobjectbuffers(_:offsets:range:).md)
- [setObjectBytes(_:length:index:)](metal/mtlrendercommandencoder/setobjectbytes(_:length:index:).md)
- [setObjectBufferOffset(_:index:)](metal/mtlrendercommandencoder/setobjectbufferoffset(_:index:).md)
