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

# makeBuffer(length:options:)

Creates a buffer the method clears with zero values.

## Declaration

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

## Parameters

- `length`: The size of the new buffer, in bytes.
- `options`: An doc://com.apple.metal/documentation/Metal/MTLResourceOptions instance that sets the buffer’s storage and hazard-tracking modes. See doc://com.apple.metal/documentation/Metal/resource-fundamentals and doc://com.apple.metal/documentation/Metal/setting-resource-storage-modes for more information.

## Mentioned in

Copying data to a private resource Setting resource storage modes

## Return Value

Return Value A new MTLBuffer instance if the method completed successfully; otherwise nil.

## See Also

### Creating buffers

- [maxBufferLength](metal/mtldevice/maxbufferlength.md)
- [makeBuffer(bytes:length:options:)](metal/mtldevice/makebuffer(bytes:length:options:).md)
- [makeBuffer(bytesNoCopy:length:options:deallocator:)](metal/mtldevice/makebuffer(bytesnocopy:length:options:deallocator:).md)
