<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLBlitCommandEncoder/copyIndirectCommandBuffer(_:sourceRange:destination:destinationIndex:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "s:So21MTLBlitCommandEncoderP5MetalE012copyIndirectB6Buffer_11sourceRange11destination0J5IndexySo011MTLIndirectbG0_p_SnySiGSoAH_pSitF"
  },
  "title" : "copyIndirectCommandBuffer(_:sourceRange:destination:destinationIndex:)"
}
-->

# copyIndirectCommandBuffer(_:sourceRange:destination:destinationIndex:)

Encodes a command that copies commands from one indirect command buffer into another.

```
func copyIndirectCommandBuffer(_ buffer: any MTLIndirectCommandBuffer, sourceRange: Range<Int>, destination: any MTLIndirectCommandBuffer, destinationIndex: Int)
```

## Parameters

`buffer`

An indirect command buffer the command copies from.

`sourceRange`

The range of commands in the source buffer to copy.
The source range needs to start on a valid execution point.

`destination`

Another indirect command buffer the command copies to.

`destinationIndex`

An index in `destination` where the command copies content from `source` to. The destination index needs to be a valid execution point with enough remaining space in `destination` to accommodate `sourceRange.count` indexes.

## Discussion

You can copy commands from one indirect command buffer to another, but only a compatible one. You can create compatible indirect command buffers by passing [`MTLIndirectCommandBufferDescriptor`](/documentation/Metal/MTLIndirectCommandBufferDescriptor) instances with the same configuration to the [`makeIndirectCommandBuffer(descriptor:maxCommandCount:options:)`](/documentation/Metal/MTLDevice/makeIndirectCommandBuffer(descriptor:maxCommandCount:options:)) method of [`MTLDevice`](/documentation/Metal/MTLDevice).

---

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)