<!--
{
  "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/copy(sourceBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:destinationTexture:destinationSlice:destinationLevel:destinationOrigin:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "s:So25MTL4ComputeCommandEncoderP5MetalE4copy12sourceBuffer0G6Offset0G11BytesPerRow0gjK5Image0G4Size18destinationTexture0O5Slice0O5Level0O6Origin7optionsySo9MTLBuffer_p_S3iSo7MTLSizeaSo10MTLTexture_pS2iSo9MTLOriginaSo13MTLBlitOptionVtF"
  },
  "title" : "copy(sourceBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:destinationTexture:destinationSlice:destinationLevel:destinationOrigin:options:)"
}
-->

# copy(sourceBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:destinationTexture:destinationSlice:destinationLevel:destinationOrigin:options:)

Encodes a command to copy image data from a buffer into a texture with options for special texture formats.

```
func copy(sourceBuffer: any MTLBuffer, sourceOffset: Int, sourceBytesPerRow: Int, sourceBytesPerImage: Int, sourceSize: MTLSize, destinationTexture: any MTLTexture, destinationSlice: Int, destinationLevel: Int, destinationOrigin: MTLOrigin, options: MTLBlitOption = [])
```

## Parameters

`sourceBuffer`

An [`MTLBuffer`](/documentation/Metal/MTLBuffer) instance the command copies data from.

`sourceOffset`

A byte offset within `sourceBuffer` the command copies from. Set this value to
a multiple of `destinationTexture's` pixel size, in bytes.

`sourceBytesPerRow`

The number of bytes between adjacent rows of pixels in `sourceBuffer`. Set this value to
a multiple of `destinationTexture's` pixel size, in bytes, and less than or equal to
the product of `destinationTexture's` pixel size, in bytes, and the largest pixel width
`destinationTexture's` type allows. If `destinationTexture` uses a compressed pixel format,
set `sourceBytesPerRow` to the number of bytes between the starts of two row blocks.

`sourceBytesPerImage`

The number of bytes between each 2D image of a 3D texture. Set this value to a
multiple of `destinationTexture's` pixel size, in bytes, or `0`
if `sourceSize's` [`depth`](/documentation/Metal/MTLSize/depth) value is `1`.

`sourceSize`

An [`MTLSize`](/documentation/Metal/MTLSize) instance that represents the size of the region in
`destinationTexture`, in pixels, that the command copies data to, starting at
`destinationOrigin`. Assign `1` to each dimension that’s not relevant to
`destinationTexture`. If `destinationTexture` uses a compressed pixel format,
set `sourceSize` to a multiple of `destinationTexture's` [`pixelFormat`](/documentation/Metal/MTLTexture/pixelFormat)
block size. If the block extends outside the bounds of the texture, clamp
`sourceSize` to the edge of the texture.

`destinationTexture`

An [`MTLTexture`](/documentation/Metal/MTLTexture) instance the command copies data to. In order to copy the contents into
the destination texture, set its [`isFramebufferOnly`](/documentation/Metal/MTLTexture/isFramebufferOnly) property to
<doc://com.apple.documentation/documentation/Swift/false> and don’t
use a combined depth/stencil [`pixelFormat`](/documentation/Metal/MTLTexture/pixelFormat).

`destinationSlice`

A slice within `destinationTexture` the command uses as its starting point for
copying data to. Set this to `0` if `destinationTexture` isn’t a texture array
or a cube texture.

`destinationLevel`

A mipmap level within `destinationTexture` the command copies data to.

`destinationOrigin`

An [`MTLOrigin`](/documentation/Metal/MTLOrigin) instance that represents a location within `destinationTexture`
that the command begins copying data to. Assign `0` to each dimension that’s not
relevant to `destinationTexture`.

`options`

An [`MTLBlitOption`](/documentation/Metal/MTLBlitOption) value that applies to textures with applicable pixel formats,
such as combined depth/stencil or PVRTC formats. If `destinationTexture's`
[`pixelFormat`](/documentation/Metal/MTLTexture/pixelFormat) is a combined depth/stencil format, set `options` to
either [`depthFromDepthStencil`](/documentation/Metal/MTLBlitOption/depthFromDepthStencil) or
[`stencilFromDepthStencil`](/documentation/Metal/MTLBlitOption/stencilFromDepthStencil), but not both.
If `destinationTexture's` [`pixelFormat`](/documentation/Metal/MTLTexture/pixelFormat) is a PVRTC format, set
`options` to [`rowLinearPVRTC`](/documentation/Metal/MTLBlitOption/rowLinearPVRTC).

---

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)