---
title: "copy(sourceBuffer:sourceOffset:destinationBuffer:destinationOffset:size:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtl4computecommandencoder/copy(sourcebuffer:sourceoffset:destinationbuffer:destinationoffset:size:)"
---

# copy(sourceBuffer:sourceOffset:destinationBuffer:destinationOffset:size:)

Encodes a command that copies data from a buffer instance into another.

## Declaration

```swift
func copy(sourceBuffer: any MTLBuffer, sourceOffset: Int, destinationBuffer: any MTLBuffer, destinationOffset: Int, size: Int)
```

## Parameters

- `sourceBuffer`: An doc://com.apple.metal/documentation/Metal/MTLBuffer instance the command copies data from.
- `sourceOffset`: A byte offset within sourceBuffer the command copies from.
- `destinationBuffer`: An doc://com.apple.metal/documentation/Metal/MTLBuffer instance the command copies data to.
- `destinationOffset`: A byte offset within destinationBuffer the command copies to.
- `size`: The number of bytes the command copies from sourceBuffer to destinationBuffer.
