Contents

makeBuffer(length:options:offset:)

Creates a buffer at a specified offset on the heap.

Declaration

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

  • 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.

See Also

Creating buffers from a heap