<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTL4ComputeCommandEncoder/copyCommands(sourceBuffer:sourceRange:destinationBuffer:destinationIndex:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "s:So25MTL4ComputeCommandEncoderP5MetalE12copyCommands12sourceBuffer0H5Range011destinationI00K5IndexySo011MTLIndirectcI0_p_SnySiGSoAI_pSitF"
  },
  "title" : "copyCommands(sourceBuffer:sourceRange:destinationBuffer:destinationIndex:)"
}
-->

# copyCommands(sourceBuffer:sourceRange:destinationBuffer:destinationIndex:)

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

```
func copyCommands(sourceBuffer: any MTLIndirectCommandBuffer, sourceRange: Range<Int>, destinationBuffer: any MTLIndirectCommandBuffer, destinationIndex: Int)
```

## Parameters

`sourceRange`

The range of commands in `sourceBuffer` to copy.
The copy operation requires that the source range starts at a valid execution point.

`destinationIndex`

An index in `destinationBuffer` into where the command copies content to. The copy operation requires
that the destination index is a valid execution point with enough space left in `destinationBuffer`
to accommodate `sourceRange.count` commands.

---

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)