---
title: "copy(sourceTexture:sourceSlice:sourceLevel:destinationTexture:destinationSlice:destinationLevel:sliceCount:levelCount:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtl4computecommandencoder/copy(sourcetexture:sourceslice:sourcelevel:destinationtexture:destinationslice:destinationlevel:slicecount:levelcount:)"
---

# copy(sourceTexture:sourceSlice:sourceLevel:destinationTexture:destinationSlice:destinationLevel:sliceCount:levelCount:)

Encodes a command that copies slices of a texture to slices of another texture.

## Declaration

```swift
func copy(sourceTexture: any MTLTexture, sourceSlice: Int, sourceLevel: Int, destinationTexture: any MTLTexture, destinationSlice: Int, destinationLevel: Int, sliceCount: Int, levelCount: Int)
```

## Parameters

- `sourceTexture`: A doc://com.apple.metal/documentation/Metal/MTLTexture texture that the command copies data from. To read the source texture contents, you need to set its doc://com.apple.metal/documentation/Metal/MTLTexture/isFramebufferOnly property to doc://com.apple.documentation/documentation/Swift/false prior to drawing into it.
- `sourceSlice`: A slice within sourceTexture the command uses as a starting point to copy data from. Set this to 0 if sourceTexture isn’t a texture array or a cube texture.
- `sourceLevel`: A mipmap level within sourceTexture.
- `destinationTexture`: Another doc://com.apple.metal/documentation/Metal/MTLTexture the command copies the data to that has the same doc://com.apple.metal/documentation/Metal/MTLTexture/pixelFormat and doc://com.apple.metal/documentation/Metal/MTLTexture/sampleCount as sourceTexture. To write the contents into this texture, you need to set its doc://com.apple.metal/documentation/Metal/MTLTexture/isFramebufferOnly property to doc://com.apple.documentation/documentation/Swift/false.
- `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 mipmap level you reference needs to have the same size as the sourceTexture slice’s mipmap at sourceLevel.
- `sliceCount`: The number of slices the command copies so that it satisfies the conditions that the sum of sourceSlice and sliceCount doesn’t exceed the number of slices in sourceTexture and the sum of destinationSlice and sliceCount doesn’t exceed the number of slices in destinationTexture.
- `levelCount`: The number of mipmap levels the command copies so that it satisfies the conditions that the sum of sourceLevel and levelCount doesn’t exceed the number of mipmap levels in sourceTexture and the sum of destinationLevel and levelCount doesn’t exceed the number of mipmap levels in destinationTexture.

## See Also

### Encoding texture copy commands

- [copy(sourceTensor:sourceOrigin:sourceDimensions:destinationTensor:destinationOrigin:destinationDimensions:)](metal/mtl4computecommandencoder/copy(sourcetensor:sourceorigin:sourcedimensions:destinationtensor:destinationorigin:destinationdimensions:).md)
- [copy(sourceTexture:destinationTexture:)](metal/mtl4computecommandencoder/copy(sourcetexture:destinationtexture:).md)
- [copy(sourceTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:destinationTexture:destinationSlice:destinationLevel:destinationOrigin:)](metal/mtl4computecommandencoder/copy(sourcetexture:sourceslice:sourcelevel:sourceorigin:sourcesize:destinationtexture:destinationslice:destinationlevel:destinationorigin:).md)
