---
title: "setBuffers(_:offsets:range:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlcomputecommandencoder/setbuffers(_:offsets:range:)"
---

# setBuffers(_:offsets:range:)

Binds multiple buffers to the buffer argument table at once, allowing compute kernels to access their data on the GPU.

## Declaration

```swift
func setBuffers(_ buffers: [(any MTLBuffer)?], offsets: [Int], range: Range<Int>)
```

## Parameters

- `buffers`: The doc://com.apple.metal/documentation/Metal/MTLBuffer instances to bind to the buffer argument table.
- `offsets`: An array of offsets, each of which specifies where the data begins, in bytes, from the start of its corresponding buffer.
- `range`: The argument table indices to bind each of the buffers to, in the order they appear.

## Discussion

Discussion important: This method requires that the length of buffers and offsets are equal to the length of range. For buffers binding to an argument using the device address space, align the offset to the data type’s size. The maximum size for an offset is 16 bytes. For buffers in the constant address space, the minimum alignment depends on the hardware running your app. See the Metal feature set tables (PDF) for information on each Apple GPU family. Rebinding an already bound buffer causes a Metal error.

## See Also

### Binding buffers

- [setBuffer(_:offset:index:)](metal/mtlcomputecommandencoder/setbuffer(_:offset:index:).md)
- [setBuffer(_:offset:attributeStride:index:)](metal/mtlcomputecommandencoder/setbuffer(_:offset:attributestride:index:).md)
- [setBuffers(_:offsets:attributeStrides:range:)](metal/mtlcomputecommandencoder/setbuffers(_:offsets:attributestrides:range:).md)
- [setBufferOffset(_:index:)](metal/mtlcomputecommandencoder/setbufferoffset(_:index:).md)
- [setBufferOffset(offset:attributeStride:index:)](metal/mtlcomputecommandencoder/setbufferoffset(offset:attributestride:index:).md)
