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

# makeBuffer(bytes:length:options:)

Allocates a new buffer of a given length and initializes its contents by copying existing data into it.

## Declaration

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

## Parameters

- `pointer`: A pointer to the starting memory address the method copies the initialization data from.
- `length`: The size of the new buffer, in bytes, and the number of bytes the method copies from pointer.
- `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

## Return Value

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

## See Also

### Creating buffers

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