Instance Method

copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:

Encodes a command to copy image data from a slice of a source texture into a slice of a destination texture.

Required.

Declaration

- (void)copyFromTexture:(id<MTLTexture>)sourceTexture sourceSlice:(NSUInteger)sourceSlice sourceLevel:(NSUInteger)sourceLevel sourceOrigin:(MTLOrigin)sourceOrigin sourceSize:(MTLSize)sourceSize toTexture:(id<MTLTexture>)destinationTexture destinationSlice:(NSUInteger)destinationSlice destinationLevel:(NSUInteger)destinationLevel destinationOrigin:(MTLOrigin)destinationOrigin;

Parameters

sourceTexture

The source texture for the copy operation. The value must not be a framebufferOnly texture.

sourceSlice

The slice of the source texture.

sourceLevel

The mipmap level of the source texture.

sourceOrigin

The origin of the portion of the source texture where the copying starts.

sourceSize

The number of source pixels, in width, height, and depth, to copy to the destination texture. When you copy between 1D textures, height and depth must be 1. When you copy between 2D textures, depth must be 1.

destinationTexture

The destination texture for the copy operation. The value must not be a framebufferOnly texture.

destinationSlice

The slice of the destination texture.

destinationLevel

The mipmap level of the destination texture.

destinationOrigin

The destination texture origin where the copying starts.

Discussion

Use sourceSlice and sourceLevel together to select a single image of the source texture. Use destinationSlice and destinationLevel to select a single image of the destination texture.

The source and destination textures must have the same pixel format and the same sample count. For compressed pixel formats, align the copy region to that pixel format's block size. Overlapping regions within a single texture produce undefined results.

This method cannot be used with a subregion of a texture that has a PVRTC pixel format. The method can be used if you are copying an entire texture with a PVRTC pixel format.

See Also

Copying Data Between Textures

- copyFromTexture:toTexture:

Encodes a command to copy a texture's data to another texture.

Required.

- copyFromTexture:sourceSlice:sourceLevel:toTexture:destinationSlice:destinationLevel:sliceCount:levelCount:

Encodes a command to copy a subset of texture data to another texture.

Required.