<!--
{
  "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/MTLArgumentEncoder/makeArgumentEncoderForBuffer(atIndex:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLArgumentEncoder(im)newArgumentEncoderForBufferAtIndex:"
  },
  "title" : "makeArgumentEncoderForBuffer(atIndex:)"
}
-->

# makeArgumentEncoderForBuffer(atIndex:)

Creates a new argument encoder for a nested argument buffer.

```
func makeArgumentEncoderForBuffer(atIndex index: Int) -> (any MTLArgumentEncoder)?
```

## Parameters

`index`

The index of a nested argument-buffer within the argument buffer.
The value corresponds to either the index ID of a declaration in
Metal Shading Language (MSL) or the [`index`](/documentation/Metal/MTLArgumentDescriptor/index) property of
an [`MTLArgumentDescriptor`](/documentation/Metal/MTLArgumentDescriptor) instance.

## Return Value

An argument encoder targeting the nested argument buffer.

## Discussion

If an argument buffer contains nested argument buffers in its structure, then each nested argument buffer needs to use its own [`MTLArgumentEncoder`](/documentation/Metal/MTLArgumentEncoder) object to encode its individual resources.

---

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)