<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLHeap/makeBuffer(length:options:offset:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLHeap(im)newBufferWithLength:options:offset:"
  },
  "title" : "makeBuffer(length:options:offset:)"
}
-->

# makeBuffer(length:options:offset:)

Creates a buffer at a specified offset on the heap.

```
func makeBuffer(length: Int, options: MTLResourceOptions = [], offset: Int) -> (any MTLBuffer)?
```

## Parameters

`length`

The size of the buffer, in bytes.

`options`

Options that describe the properties of the buffer.

`offset`

The distance, in bytes, to place the buffer relative to the start of the heap.

## Return Value

A new buffer, or `nil` if the heap is not a placement heap.

## Discussion

You can call the method with the following restrictions:

- The heap’s type needs to be [`MTLHeapType.placement`](/documentation/Metal/MTLHeapType/placement)
- The buffer’s storage mode option needs to match the heap’s [`storageMode`](/documentation/Metal/MTLHeap/storageMode) property
- The buffer’s CPU cache mode option needs to match the heap’s [`cpuCacheMode`](/documentation/Metal/MTLHeap/cpuCacheMode) property

Use the [`heapBufferSizeAndAlign(length:options:)`](/documentation/Metal/MTLDevice/heapBufferSizeAndAlign(length:options:)) method to determine the required size and alignment. If you don’t align the buffer correctly or it extends past the end of the heap, the behavior is undefined.

> Note:
> The new buffer can implicitly alias the underlying memory of other resources already in the heap within the overlapping half-open range of `[offset, offset + requiredSize)`.

---

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)