status
The command buffer’s current state.
Declaration
var status: MTLCommandBufferStatus { get }Mentioned in
Discussion
Each command buffer can be in any one of the following states:
State | Meaning |
|---|---|
A command buffer’s initial state, which indicates its command queue isn’t reserving a place for it. [Image] You can modify a command buffer in this state by encoding commands to it, or by adding a state change handler. | |
A command buffer’s second state, which indicates its command queue is reserving a place for it. [Image] You can modify a command buffer in this state by encoding commands to it, or by adding a state change handler. | |
A command buffer’s third state, which indicates the command queue is preparing to schedule the command buffer by resolving its dependencies. [Image] You can’t modify a command buffer in this state. | |
A command buffer’s fourth state, which indicates the command buffer has its resources ready and is waiting for the GPU to run its commands. [Image] You can’t modify a command buffer in this state. | |
A command buffer’s successful, final state, which indicates the GPU finished running the command buffer’s commands without any problems. | |
A command buffer’s unsuccessful, final state, which indicates the GPU stopped running the buffer’s commands because of a runtime issue. |
The first two states (MTLCommandBufferStatus.notEnqueued and MTLCommandBufferStatus.enqueued) both indicate that you can encode commands to the command buffer. You do this by creating an encoder that indirectly adds commands for a pass (see Command encoder factory methods) to the command buffer. Command buffers also have some methods that directly encode commands between passes, such as encodeSignalEvent(_:value:) and present(_:).
Each command buffer’s state can only change to a state below it in the table, and ends its life cycle at either MTLCommandBufferStatus.completed or MTLCommandBufferStatus.error.