---
title: "makeBuffer(length:options:offset:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlheap/makebuffer(length:options:offset:)"
---

# makeBuffer(length:options:offset:)

Creates a buffer at a specified offset on the heap.

## Declaration

```swift
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

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

## Discussion

Discussion You can call the method with the following restrictions: The heap’s type needs to be MTLHeapType.placement The buffer’s storage mode option needs to match the heap’s storageMode property The buffer’s CPU cache mode option needs to match the heap’s cpuCacheMode property Use the 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).

## See Also

### Creating buffers from a heap

- [makeBuffer(length:options:)](metal/mtlheap/makebuffer(length:options:).md)
