Instance Method


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



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



The memory address from which to copy the initial data.


The size of the new buffer, in bytes. This is also the number of bytes that are copied from the pointer argument.


Specifies the behavior of the new buffer.

Return Value

A new MTLBuffer object that contains the data copied from the pointer argument.


The storage allocation of the new MTLBuffer object is not the same as the storage allocation of the pointer argument.

MTLBuffer objects created with this method are CPU-accessible and can be specified with a storageModeShared or storageModeManaged storage mode, but not a storageModePrivate storage mode.


Resource Options

struct MTLResourceOptions

Optional arguments used to set the behavior of a resource.

See Also

Creating Buffers

var maxBufferLength: Int

The maximum size of a buffer, in bytes.


func makeBuffer(length: Int, options: MTLResourceOptions) -> MTLBuffer?

Allocates a new zero-filled buffer of a given length.


Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software