---
title: MTLBlitCommandEncoder
framework: metal
role: symbol
role_heading: Protocol
path: metal/mtlblitcommandencoder
---

# MTLBlitCommandEncoder

Encodes commands that copy and modify resources for a single blit pass.

## Declaration

```swift
protocol MTLBlitCommandEncoder : MTLCommandEncoder
```

## Mentioned in

Copying data into or out of mipmaps Understanding the Metal 4 core API Converting a GPU’s counter data into a readable format Sampling GPU data into counter sample buffers Transferring data between connected GPUs

## Overview

Overview Create a blit encoder by calling one of the factory methods on an MTLCommandBuffer instance, such as makeBlitCommandEncoder(). A blit command encoder adds commands to a command buffer that modify resources in various ways, including: Filling buffers with repeating bytes Generating mipmaps for textures Copying data between buffers Copying data between textures Copying data between a texture and a buffer Managing the contents of indirect command buffers Synchronizing buffers, textures, and other resources between the CPU and GPU Improving runtime performance for resources by optimizing their memory layout for the GPU or CPU You typically use these commands to move data between a resource that uses private storage and another resource that uses CPU-accessible storage. Some apps also use them to apply image-processing and texture effects, such as blurring or reflections, or to render and work with offscreen image data. When you finish encoding blit commands, finalize the blit pass into the command buffer by calling the encoder’s endEncoding() method. Command stages Most blit commands apply to one stage within a pass. The following table shows which stages apply to each command:  |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |  For more information about stages and synchronization, see MTLStages and Resource synchronization.

## Topics

### Filling buffers

- [fill(buffer:range:value:)](metal/mtlblitcommandencoder/fill(buffer:range:value:).md)

### Generating texture mipmaps

- [generateMipmaps(for:)](metal/mtlblitcommandencoder/generatemipmaps(for:).md)

### Copying buffer data to another buffer

- [copy(from:sourceOffset:to:destinationOffset:size:)](metal/mtlblitcommandencoder/copy(from:sourceoffset:to:destinationoffset:size:).md)

### Copying texture data to another texture

- [copy(from:to:)](metal/mtlblitcommandencoder/copy(from:to:).md)
- [copy(from:sourceSlice:sourceLevel:to:destinationSlice:destinationLevel:sliceCount:levelCount:)](metal/mtlblitcommandencoder/copy(from:sourceslice:sourcelevel:to:destinationslice:destinationlevel:slicecount:levelcount:).md)
- [copy(from:sourceSlice:sourceLevel:sourceOrigin:sourceSize:to:destinationSlice:destinationLevel:destinationOrigin:)](metal/mtlblitcommandencoder/copy(from:sourceslice:sourcelevel:sourceorigin:sourcesize:to:destinationslice:destinationlevel:destinationorigin:).md)
- [copy(from:sourceOrigin:sourceDimensions:to:destinationOrigin:destinationDimensions:)](metal/mtlblitcommandencoder/copy(from:sourceorigin:sourcedimensions:to:destinationorigin:destinationdimensions:).md)

### Copying buffer data to a texture

- [copy(from:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:to:destinationSlice:destinationLevel:destinationOrigin:)](metal/mtlblitcommandencoder/copy(from:sourceoffset:sourcebytesperrow:sourcebytesperimage:sourcesize:to:destinationslice:destinationlevel:destinationorigin:).md)
- [copy(from:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:to:destinationSlice:destinationLevel:destinationOrigin:options:)](metal/mtlblitcommandencoder/copy(from:sourceoffset:sourcebytesperrow:sourcebytesperimage:sourcesize:to:destinationslice:destinationlevel:destinationorigin:options:).md)

### Copying texture data to a buffer

- [copy(from:sourceSlice:sourceLevel:sourceOrigin:sourceSize:to:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:)](metal/mtlblitcommandencoder/copy(from:sourceslice:sourcelevel:sourceorigin:sourcesize:to:destinationoffset:destinationbytesperrow:destinationbytesperimage:).md)
- [copy(from:sourceSlice:sourceLevel:sourceOrigin:sourceSize:to:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:options:)](metal/mtlblitcommandencoder/copy(from:sourceslice:sourcelevel:sourceorigin:sourcesize:to:destinationoffset:destinationbytesperrow:destinationbytesperimage:options:).md)

### Optimizing textures for GPU access

- [optimizeContentsForGPUAccess(texture:)](metal/mtlblitcommandencoder/optimizecontentsforgpuaccess(texture:).md)
- [optimizeContentsForGPUAccess(texture:slice:level:)](metal/mtlblitcommandencoder/optimizecontentsforgpuaccess(texture:slice:level:).md)

### Optimizing textures for CPU access

- [optimizeContentsForCPUAccess(texture:)](metal/mtlblitcommandencoder/optimizecontentsforcpuaccess(texture:).md)
- [optimizeContentsForCPUAccess(texture:slice:level:)](metal/mtlblitcommandencoder/optimizecontentsforcpuaccess(texture:slice:level:).md)

### Synchronizing managed resources

- [synchronize(resource:)](metal/mtlblitcommandencoder/synchronize(resource:).md)
- [synchronize(texture:slice:level:)](metal/mtlblitcommandencoder/synchronize(texture:slice:level:).md)

### Preventing resource access conflicts

- [waitForFence(_:)](metal/mtlblitcommandencoder/waitforfence(_:).md)
- [updateFence(_:)](metal/mtlblitcommandencoder/updatefence(_:).md)

### Managing indirect command buffers

- [copyIndirectCommandBuffer(_:sourceRange:destination:destinationIndex:)](metal/mtlblitcommandencoder/copyindirectcommandbuffer(_:sourcerange:destination:destinationindex:).md)
- [resetCommandsInBuffer(_:range:)](metal/mtlblitcommandencoder/resetcommandsinbuffer(_:range:).md)
- [optimizeIndirectCommandBuffer(_:range:)](metal/mtlblitcommandencoder/optimizeindirectcommandbuffer(_:range:).md)

### Sampling counters

- [sampleCounters(sampleBuffer:sampleIndex:barrier:)](metal/mtlblitcommandencoder/samplecounters(samplebuffer:sampleindex:barrier:).md)
- [resolveCounters(_:range:destinationBuffer:destinationOffset:)](metal/mtlblitcommandencoder/resolvecounters(_:range:destinationbuffer:destinationoffset:).md)

### Managing sparse texture access counters

- [getTextureAccessCounters(_:region:mipLevel:slice:resetCounters:countersBuffer:countersBufferOffset:)](metal/mtlblitcommandencoder/gettextureaccesscounters(_:region:miplevel:slice:resetcounters:countersbuffer:countersbufferoffset:).md)
- [resetTextureAccessCounters(_:region:mipLevel:slice:)](metal/mtlblitcommandencoder/resettextureaccesscounters(_:region:miplevel:slice:).md)

### Instance Methods

- [copy(from:sourceOrigin:sourceDimensions:sourcePlane:to:destinationOrigin:destinationDimensions:destinationPlane:)](metal/mtlblitcommandencoder/copy(from:sourceorigin:sourcedimensions:sourceplane:to:destinationorigin:destinationdimensions:destinationplane:).md)

## Relationships

### Inherits From

- [MTLCommandEncoder](metal/mtlcommandencoder.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Encoding a blit pass

- [MTLBlitOption](metal/mtlblitoption.md)
