Resource fundamentals
Control the common attributes of all Metal memory resources, including buffers and textures, and how to configure their underlying memory.
Overview
A resource is a memory asset, such as an MTLBuffer or MTLTexture, that a GPU can access (see Buffers and Textures).
You can either allocate a resource from an MTLDevice instance or an MTLHeap instance (see Memory heaps). Metal sets a resource’s hazardTrackingMode property to MTLHazardTrackingMode.default if you don’t select another tracking mode. The default value depends on what Metal instance creates the resource.
Each resource your app creates typically uses one of these storage modes:
- MTLStorageMode.private
Apps can only access resources in private storage from the GPU.
- MTLStorageMode.shared
Apps can access resources in shared storage from both the CPU and the GPU.
- MTLStorageMode.managed
Apps can access resources in managed storage from both the CPU and the GPU, just like shared storage. However, the GPU backs resources in managed mode with memory in private storage.
Private mode resources give your app optimization opportunities that shared mode resources don’t. Managed mode resources also give your app the same opportunities and allow your to app access them from the CPU.
Topics
Resource management
Setting resource storage modesChoosing a resource storage mode for Apple GPUsChoosing a resource storage mode for Intel and AMD GPUsCopying data to a private resourceSynchronizing a managed resource in macOSTransferring data between connected GPUsReducing the memory footprint of Metal apps
Residency sets
View pools
Tensors
MTLTensorMTLTensorDescriptorMTLTensorExtentsMTLTensorReferenceTypeMTLTensorUsageMTLTensorDomainMTLTensorBindingMTLTensorErrorMTLTensorError.CodeMTLTensorDataTypeMTLTensorDomainMTL_TENSOR_MAX_RANK
Sparse resources
MTLBufferSparseTierMTL4CopySparseBufferMappingOperationMTL4UpdateSparseBufferMappingOperationMTLTextureSparseTierMTL4CopySparseTextureMappingOperationMTL4UpdateSparseTextureMappingOperation