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

# MTLBuffer

A resource that stores data in a format defined by your app.

```
protocol MTLBuffer : MTLResource
```

## Overview

An [`MTLBuffer`](/documentation/Metal/MTLBuffer) instance can be used only with the [`MTLDevice`](/documentation/Metal/MTLDevice) that created it. Don’t implement this protocol yourself; instead, use the following [`MTLDevice`](/documentation/Metal/MTLDevice) methods to create `MTLBuffer` instances:

- [`makeBuffer(length:options:)`](/documentation/Metal/MTLDevice/makeBuffer(length:options:)) creates a `MTLBuffer` instance with a new storage allocation.
- [`makeBuffer(bytes:length:options:)`](/documentation/Metal/MTLDevice/makeBuffer(bytes:length:options:)) creates a `MTLBuffer` instance by copying data from an existing storage allocation into a new allocation.
- [`makeBuffer(bytesNoCopy:length:options:deallocator:)`](/documentation/Metal/MTLDevice/makeBuffer(bytesNoCopy:length:options:deallocator:)) creates a `MTLBuffer` instance that reuses an existing storage allocation and does not allocate any new storage.

The Metal framework doesn’t know anything about the contents of an [`MTLBuffer`](/documentation/Metal/MTLBuffer), just its size. You define the format of the data in the buffer and ensure that your app and your shaders know how to read and write the data. For example, you might create a struct in your shader that defines the data you want to store in the buffer and its memory layout.

If you create a buffer with a managed resource storage mode ([`MTLStorageMode.managed`](/documentation/Metal/MTLStorageMode/managed)), you need to call [`didModifyRange:`](/documentation/Metal/MTLBuffer/didModifyRange:) to tell Metal to copy any changes to the GPU.

## Topics

### Creating a texture that shares buffer data

[`makeTexture(descriptor:offset:bytesPerRow:)`](/documentation/Metal/MTLBuffer/makeTexture(descriptor:offset:bytesPerRow:))

Creates a texture that shares its storage with the buffer.

### Reading the buffer’s data on the CPU

[`contents()`](/documentation/Metal/MTLBuffer/contents())

Gets the system address of the buffer’s storage allocation.

### Synchronizing data to the GPU for managed buffers

[`didModifyRange(_:)`](/documentation/Metal/MTLBuffer/didModifyRange(_:))

Informs the GPU that the CPU has modified a section of the buffer.

[`didModifyRange:`](/documentation/Metal/MTLBuffer/didModifyRange:)

Informs the GPU that the CPU has modified a section of the buffer.

### Debugging buffers

[`addDebugMarker(_:range:)`](/documentation/Metal/MTLBuffer/addDebugMarker(_:range:))

Adds a debug marker string to a specific buffer range.

[`addDebugMarker:range:`](/documentation/Metal/MTLBuffer/addDebugMarker:range:)

Adds a debug marker string to a specific buffer range.

[`removeAllDebugMarkers()`](/documentation/Metal/MTLBuffer/removeAllDebugMarkers())

Removes all debug marker strings from the buffer.

### Reading buffer length

[`length`](/documentation/Metal/MTLBuffer/length)

The logical size of the buffer, in bytes.

### Creating views of buffers on other GPUs

[`makeRemoteBufferView(_:)`](/documentation/Metal/MTLBuffer/makeRemoteBufferView(_:))

Creates a remote view of the buffer for another GPU in the same peer group.

[`remoteStorageBuffer`](/documentation/Metal/MTLBuffer/remoteStorageBuffer)

The buffer on another GPU that the buffer was created from, if any.



---

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)