Instance Method

commit()

Commits the command buffer for execution.

Required.

Declaration

func commit()

Discussion

After you call the commit() method, the MTLDevice schedules and executes the commands in the command buffer. If you haven’t already enqueued the command buffer with a call to enqueue(), calling this function also enqueues the command buffer. The GPU executes the command buffer after any command buffers enqueued before it on the same command queue.

You can only commit a command buffer once. You can’t commit a command buffer if the command buffer has an active command encoder. Once you commit a command buffer, you may not encode additional commands into it, nor can you add a schedule or completion handler.

See Also

Scheduling and Executing Commands

func enqueue()

Reserves a place for the command buffer on the associated command queue.

Required.

func addScheduledHandler(MTLCommandBufferHandler)

Registers a block of code that Metal calls immediately after it schedules the command buffer for execution on the GPU.

Required.

func addCompletedHandler(MTLCommandBufferHandler)

Registers a block of code that Metal calls immediately after the GPU finishes executing the commands in the command buffer.

Required.

func waitUntilScheduled()

Blocks execution of the current thread until the command buffer is scheduled.

Required.

func waitUntilCompleted()

Blocks execution of the current thread until execution of the command buffer is completed.

Required.

typealias MTLCommandBufferHandler

A block of code invoked when a command buffer is scheduled for execution or has completed execution.