<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLFunction/makeArgumentEncoder(bufferIndex:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLFunction(im)newArgumentEncoderWithBufferIndex:"
  },
  "title" : "makeArgumentEncoder(bufferIndex:)"
}
-->

# makeArgumentEncoder(bufferIndex:)

Creates an argument encoder for an argument buffer that’s one of this function’s arguments.

```
func makeArgumentEncoder(bufferIndex: Int) -> any MTLArgumentEncoder
```

## Parameters

`bufferIndex`

The index of an argument buffer in the function’s argument list. This method fails if the specified index doesn’t correspond to an argument buffer.

## Discussion

Resources encoded into an argument buffer by the [`MTLArgumentEncoder`](/documentation/Metal/MTLArgumentEncoder) object need to match the structure of the argument buffer located at the specified buffer index. If you want to interpret a regular structure as an argument buffer, at least one of the members of the structure needs to have an `[[id(n)]]` attribute.

---

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)