<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLRenderCommandEncoder/setFragmentBuffer(_:offset:index:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLRenderCommandEncoder(im)setFragmentBuffer:offset:atIndex:"
  },
  "title" : "setFragmentBuffer(_:offset:index:)"
}
-->

# setFragmentBuffer(_:offset:index:)

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

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

## Parameters

`buffer`

An [`MTLBuffer`](/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     [Metal feature set tables (PDF)](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`.

## Discussion

By default, the buffer at each index is `nil`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)