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

# setFragmentBuffer(_:offset:index:)

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

## Declaration

```swift
func setFragmentBuffer(_ 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 fragment shader argument table for buffers.
- `offset`: An integer that represents the location, in bytes, from the start of buffer where the fragment 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 fragment 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 buffer at each index is nil.

## See Also

### Assigning buffers

- [setFragmentBuffers(_:offsets:range:)](metal/mtlrendercommandencoder/setfragmentbuffers(_:offsets:range:).md)
- [setFragmentBytes(_:length:index:)](metal/mtlrendercommandencoder/setfragmentbytes(_:length:index:).md)
- [setFragmentBufferOffset(_:index:)](metal/mtlrendercommandencoder/setfragmentbufferoffset(_:index:).md)
