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 makeHeap(descriptor:) 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

var device: MTLDevice

The device object that created the heap.

Required.

var label: String?

A string that identifies the heap.

Required.

Querying Heap Properties

var type: MTLHeapType

The heap's type.

Required.

var storageMode: MTLStorageMode

The heap's storage mode.

Required.

var cpuCacheMode: MTLCPUCacheMode

The heap's CPU cache mode.

Required.

var hazardTrackingMode: MTLHazardTrackingMode

The heap's hazard tracking mode.

Required.

var resourceOptions: MTLResourceOptions

The options for resources created by the heap.

Required.

var size: Int

The total size of the heap, in bytes.

Required.

var usedSize: Int

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

Required.

var currentAllocatedSize: Int

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

Required.

func maxAvailableSize(alignment: Int) -> Int

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

Required.

enum MTLHeapType

The options you use to choose the heap type.

Setting the Purgeable State of the Resource

func setPurgeableState(MTLPurgeableState) -> MTLPurgeableState

Sets the purgeable state of the heap.

Required.

Creating Resources on the Heap

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.

class MTLHeapDescriptor

An object you use to configure new heap objects.

struct MTLSizeAndAlign

The size and alignment of a resource, in bytes.