---
title: "copyIndirectCommandBuffer(_:sourceRange:destination:destinationIndex:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlblitcommandencoder/copyindirectcommandbuffer(_:sourcerange:destination:destinationindex:)"
---

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

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

## Declaration

```swift
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

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 instances with the same configuration to the makeIndirectCommandBuffer(descriptor:maxCommandCount:options:) method of MTLDevice.

## See Also

### Managing indirect command buffers

- [resetCommandsInBuffer(_:range:)](metal/mtlblitcommandencoder/resetcommandsinbuffer(_:range:).md)
- [optimizeIndirectCommandBuffer(_:range:)](metal/mtlblitcommandencoder/optimizeindirectcommandbuffer(_:range:).md)
