Protocol

MTLHeap

A memory pool from which you can suballocate resources.

Declaration

@protocol MTLHeap

Overview

Don’t implement this protocol yourself; instead, to create a heap, configure a MTLHeapDescriptor object and call the newHeapWithDescriptor: method of a MTLDevice object.

You suballocate resources from a heap and make them aliasable or non-aliasable. A sub-allocated resource is non-aliased by default, preventing future resources allocated from the heap from using its memory. Resources are aliased when they share the same memory allocation on a heap.

All resources sub-allocated from the same heap share the same storage mode and CPU cache mode. You can make heaps purgeable, but not the resources allocated from the heap; they can only reflect the heap’s purgeability state.

Topics

Identifying the Heap

device

The device object that created the heap.

Required.

label

A string that identifies the heap.

Required.

Querying Heap Properties

type

The heap's type.

Required.

storageMode

The heap's storage mode.

Required.

cpuCacheMode

The heap's CPU cache mode.

Required.

hazardTrackingMode

The heap's hazard tracking mode.

Required.

resourceOptions

The options for resources created by the heap.

Required.

size

The total size of the heap, in bytes.

Required.

usedSize

The size of all resources currently in the heap, in bytes.

Required.

currentAllocatedSize

The size, in bytes, of the current heap allocation.

Required.

- maxAvailableSizeWithAlignment:

The maximum size of a resource, in bytes, that can be currently allocated from the heap.

Required.

MTLHeapType

The options you use to choose the heap type.

Setting the Purgeable State of the Resource

- setPurgeableState:

Sets the purgeable state of the heap.

Required.

Creating Resources on the Heap

- newBufferWithLength:options:

Creates a buffer on the heap.

Required.

- newTextureWithDescriptor:

Creates a texture on the heap.

Required.

- newBufferWithLength:options:offset:

Creates a buffer at a specified offset on the heap.

Required.

- newTextureWithDescriptor:offset:

Creates a texture at a specified offset on the heap.

Required.

Relationships

Inherits From

See Also

Essentials

Image Filter Graph with Heaps and Fences

Demonstrates how to use heaps and fences to optimize a multistage image filter.

MTLHeapDescriptor

An object you use to configure new heap objects.

MTLSizeAndAlign

The size and alignment of a resource, in bytes.