Contents

MTLCommandEncoder

An encoder that writes GPU commands into a command buffer.

Declaration

protocol MTLCommandEncoder : NSObjectProtocol

Mentioned in

Overview

Don’t implement this protocol yourself; instead you call methods on an MTLCommandBuffer instance to create command encoders. Command encoder instances are lightweight instances that you re-create every time you need to send commands to the GPU.

There are many different kinds of command encoders, each providing a different set of commands that can be encoded into the buffer. A command encoder implements the MTLCommandEncoder protocol and an additional protocol specific to the kind of encoder being created.

Protocol

Task

Mtlrendercommandencoder

Graphics rendering

Mtlcomputecommandencoder

Computation

Mtlblitcommandencoder

Memory management

Mtlparallelrendercommandencoder

Multiple graphics rendering tasks encoded in parallel.

While a command encoder is active, it has the exclusive right to append commands to its command buffer. Once you finish encoding commands, call the endEncoding() method to finish encoding the commands. To write further commands into the same command buffer, create a new command encoder.

You can call the insertDebugSignpost(_:), pushDebugGroup(_:), and popDebugGroup() methods to put debug strings into the command buffer and to push or pop string labels used to identify groups of encoded commands. These methods don’t change the rendering or compute behavior of your app; the Xcode debugger uses them to organize your app’s rendering commands in a format that may provide insight into how your app works.

Topics

Ending command encoding

Annotating the command buffer with debug information

Identifying the command encoder

Instance Methods

See Also

Submitting work to a GPU with Metal