---
title: "setBuffer(_:offset:index:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlargumentencoder/setbuffer(_:offset:index:)"
---

# setBuffer(_:offset:index:)

Encodes a reference to a buffer into the argument buffer.

## Declaration

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

## Parameters

- `buffer`: A buffer the method encodes.
- `offset`: A byte offset for buffer.
- `index`: The index of a buffer within the argument buffer. The value corresponds to either the index ID of a declaration in Metal Shading Language (MSL) or the doc://com.apple.metal/documentation/Metal/MTLArgumentDescriptor/index property of an doc://com.apple.metal/documentation/Metal/MTLArgumentDescriptor instance.

## See Also

### Encoding buffers

- [setBuffers(_:offsets:range:)](metal/mtlargumentencoder/setbuffers(_:offsets:range:).md)
