Instance Method

optimizeIndirectCommandBuffer(_:range:)

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

Declaration

func optimizeIndirectCommandBuffer(_ buffer: MTLIndirectCommandBuffer, range: Range<Int>)

Parameters

buffer

The indirect command buffer to optimize.

range

The range of commands to optimize.

Discussion

Often, indirect command buffers are filled by compute functions executing on the GPU. Because compute functions are encoding commands in parallel, they must sometime reset commands or set the same parameter state in multiple commands. Optimizing an indirect command buffer removes some empty commands and redundant parameter state from the indirect command buffer, improving performance when commands in the indirect command buffer are executed.

Any range within a buffer that is optimized must be treated as opaque data. It is illegal to execute commands within the buffer with a start index that is inside the optimized range. Executing commands with any start index other than the start of the optimized region results in undefined behavior. It is legal to cross optimized ranges or to execute a range of commands that ends within an optimized range. You must reset the optimized range before new commands can be encoded into the buffer.

See Also

Working with Indirect Command Buffers

func copyIndirectCommandBuffer(MTLIndirectCommandBuffer, sourceRange: Range<Int>, destination: MTLIndirectCommandBuffer, destinationIndex: Int)

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

func resetCommandsInBuffer(MTLIndirectCommandBuffer, range: Range<Int>)

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software