Protocol

MTLBlitCommandEncoder

An encoder that encodes memory copying, filtering, and fill commands.

Declaration

@protocol MTLBlitCommandEncoder

Overview

The MTLBlitCommandEncoder protocol defines the interface for objects that can encode resource-copying commands into a command buffer. Use these commands to manage the contents of textures and buffers.

Data copying operations may be necessary for image processing and texture effects, such as blurring or reflections. You also use these operators to access image data that is rendered offscreen.

Your app does not define classes that implement this protocol. To create a MTLBlitCommandEncoder object, call the blitCommandEncoder method of the MTLCommandBuffer object into which you want to encode blit commands. Next, call methods on the MTLBlitCommandEncoder object to enqueue blit commands. Finally, call endEncoding to finish the encoding process.

Topics

Copying Data Between Buffers

- copyFromBuffer:sourceOffset:toBuffer:destinationOffset:size:

Encodes a command to copy data from a source buffer into a destination buffer.

Required.

Copying Between Textures and Buffers

- copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:

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

Required.

- copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:options:

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

Required.

MTLBlitOption

Options for controlling a blit operation.

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.

- 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.

Generating Buffer and Texture Data

- fillBuffer:range:value:

Encodes a command to fill a buffer with a constant value in each byte.

Required.

- generateMipmapsForTexture:

Encodes a command to generate mipmaps for a texture from the base mipmap level up to the maximum level.

Required.

Working with Indirect Command Buffers

- copyIndirectCommandBuffer:sourceRange:destination:destinationIndex:

Encodes a command to copy commands from an indirect command buffer into another indirect command buffer.

Required.

- optimizeIndirectCommandBuffer:withRange:

Encodes a command to optimize a range in the indirect command buffer to improve performance.

Required.

- resetCommandsInBuffer:withRange:

Encodes a command to reset a range of commands in an indirect command buffer.

Required.

Synchronizing Managed Resources to the CPU

- synchronizeResource:

Encodes a command to synchronize the contents of a managed resource from the GPU to the CPU.

Required.

- synchronizeTexture:slice:level:

Encodes a command to synchronize part of a managed texture from the GPU to the CPU.

Required.

Performing Fence Operations

- updateFence:

Updates the given fence to capture all GPU work enqueued by the command encoder up to this specific point.

Required.

- waitForFence:

Prevents further GPU commands from being enqueued by the command encoder until the given fence is reached.

Required.

Optimizing Texture Access Performance

- optimizeContentsForGPUAccess:

Encodes a command to optimize a texture for better performance when the GPU accesses it.

Required.

- optimizeContentsForGPUAccess:slice:level:

Encodes a command to optimize part of a texture for better performance when the GPU accesses it.

Required.

- optimizeContentsForCPUAccess:

Encodes a command to optimize a texture for better performance when the CPU accesses it.

Required.

- optimizeContentsForCPUAccess:slice:level:

Encodes a command to optimize part of a texture for better performance when the CPU accesses it.

Required.

Managing GPU Execution Data

- sampleCountersInBuffer:atSampleIndex:withBarrier:

Encodes a command to sample hardware counters at this point in the blit pass and store the samples into a counter sample buffer.

Required.

- resolveCounters:inRange:destinationBuffer:destinationOffset:

Resolves the data stored in a set of samples and copies it into a buffer.

Required.

- getTextureAccessCounters:region:mipLevel:slice:resetCounters:countersBuffer:countersBufferOffset:

Retrieves information about texture access patterns from the GPU.

Required.

- resetTextureAccessCounters:region:mipLevel:slice:

Resets the GPU's texture access data.

Required.

Relationships

Inherits From

See Also

Resources

Setting Resource Storage Modes

Set a storage mode that defines the memory location and access permissions of a resource.

Copying Data to a Private Resource

Use a blit command encoder to copy buffer or texture data to a private resource.

Synchronizing a Managed Resource

Synchronize the contents of a managed resource for the CPU or GPU.

Transferring Data Between Connected GPUs

Use high-speed connections between GPUs to transfer data quickly.

Reducing the Memory Footprint of Metal Apps

Learn best practices for using memory efficiently in iOS and tvOS.

MTLResource

An allocation of memory that is accessible to a GPU.

MTLResourceStateCommandEncoder

An encoder that encodes commands that modify resource configurations.

Buffers

Create and manipulate unstructured GPU resources.

Textures

Create and manipulate structured GPU resources.

Indirect Command Buffers

Recoup encoding time by reusing commands, or create a GPU-driven rendering pipeline by generating commands on the GPU.

Heaps

Create a single allocation of memory from which you can suballocate resources.

Synchronization

Manage access to resources in your app to avoid data hazards.