<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLIOCommandBuffer",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLIOCommandBuffer"
  },
  "title" : "MTLIOCommandBuffer"
}
-->

# MTLIOCommandBuffer

A command buffer that contains input/output commands that work with files in the file systems and Metal resources.

```
protocol MTLIOCommandBuffer : NSObjectProtocol
```

## Overview

Add commands an input/output command buffer to load assets from the file system directly into Metal resources. Your app can then use those resources with other commands it submits to [`MTLCommandQueue`](/documentation/Metal/MTLCommandQueue).

## Topics

### Loading assets

[`load(_:offset:size:sourceHandle:sourceHandleOffset:)`](/documentation/Metal/MTLIOCommandBuffer/load(_:offset:size:sourceHandle:sourceHandleOffset:))

Encodes a command that loads data from a file handle into a GPU buffer.

[`load(_:slice:level:size:sourceBytesPerRow:sourceBytesPerImage:destinationOrigin:sourceHandle:sourceHandleOffset:)`](/documentation/Metal/MTLIOCommandBuffer/load(_:slice:level:size:sourceBytesPerRow:sourceBytesPerImage:destinationOrigin:sourceHandle:sourceHandleOffset:))

Encodes a command that loads data from a file handle into a GPU texture.

[`loadBytes(_:size:sourceHandle:sourceHandleOffset:)`](/documentation/Metal/MTLIOCommandBuffer/loadBytes(_:size:sourceHandle:sourceHandleOffset:))

Encodes a command that loads data from a file handle into CPU-accessible memory buffer.

### Adding a barrier

[`addBarrier()`](/documentation/Metal/MTLIOCommandBuffer/addBarrier())

Encodes a barrier into the command buffer.

### Synchronizing a command buffer

[`signalEvent(_:value:)`](/documentation/Metal/MTLIOCommandBuffer/signalEvent(_:value:))

Encodes a command that signals a shared event to other parts of your app.

[`waitForEvent(_:value:)`](/documentation/Metal/MTLIOCommandBuffer/waitForEvent(_:value:))

Encodes a command that pauses the command buffer’s execution until another part of your app signals a shared event.

### Adding final commands

[`copyStatus(buffer:offset:)`](/documentation/Metal/MTLIOCommandBuffer/copyStatus(buffer:offset:))

Encodes a command that writes the input/output command buffer’s status to a buffer.

[`addCompletedHandler(_:)`](/documentation/Metal/MTLIOCommandBuffer/addCompletedHandler(_:))

Adds a closure that Metal calls immediately after the GPU finishes executing the commands in the input/output command buffer.

### Submitting a command buffer

[`commit()`](/documentation/Metal/MTLIOCommandBuffer/commit())

Submits the command buffer to the queue for execution on the GPU.

[`enqueue()`](/documentation/Metal/MTLIOCommandBuffer/enqueue())

Reserves a place for the input/output command buffer in the input/output command queue without committing the command buffer.

### Canceling a command buffer

[`tryCancel()`](/documentation/Metal/MTLIOCommandBuffer/tryCancel())

Submits a request to abandon a command buffer the queue is currently running.

### Waiting for a command buffer

[`waitUntilCompleted()`](/documentation/Metal/MTLIOCommandBuffer/waitUntilCompleted())

Blocks the current thread until the GPU finishes executing the input/output command buffer and all of its completion handlers.

### Checking the state of a command buffer

[`status`](/documentation/Metal/MTLIOCommandBuffer/status)

Represents the state of the input/output command buffer.

[`error`](/documentation/Metal/MTLIOCommandBuffer/error)

Stores the details of an error when the GPU experienced a problem with the input/output command buffer.

### Debugging a command buffer

[`label`](/documentation/Metal/MTLIOCommandBuffer/label)

An optional name for the input/output command buffer.

[`pushDebugGroup(_:)`](/documentation/Metal/MTLIOCommandBuffer/pushDebugGroup(_:))

Sets the current name for this input/output command encoder by adding it to the top of the debug name stack.

[`popDebugGroup()`](/documentation/Metal/MTLIOCommandBuffer/popDebugGroup())

Restores the previous name for this input/output command encoder by removing the top item of the debug name stack.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)