---
title: "makeArgumentEncoderForBuffer(atIndex:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlargumentencoder/makeargumentencoderforbuffer(atindex:)"
---

# makeArgumentEncoderForBuffer(atIndex:)

Creates a new argument encoder for a nested argument buffer.

## Declaration

```swift
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 doc://com.apple.metal/documentation/Metal/MTLArgumentDescriptor/index property of an doc://com.apple.metal/documentation/Metal/MTLArgumentDescriptor instance.

## Return Value

Return Value An argument encoder targeting the nested argument buffer.

## Discussion

Discussion If an argument buffer contains nested argument buffers in its structure, then each nested argument buffer needs to use its own MTLArgumentEncoder object to encode its individual resources.
