<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLResource",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLResource"
  },
  "title" : "MTLResource"
}
-->

# MTLResource

An allocation of memory accessible to a GPU.

```
protocol MTLResource : MTLAllocation
```

## Overview> Important:
> Don’t implement this protocol yourself. Create resources by calling methods on ``doc://com.apple.metal/documentation/Metal/MTLDevice``, ``doc://com.apple.metal/documentation/Metal/MTLBuffer``, or ``doc://com.apple.metal/documentation/Metal/MTLTexture``.

When you execute commands on the GPU, those commands can only affect memory allocated as [`MTLResource`](/documentation/Metal/MTLResource) objects. Only the [`MTLDevice`](/documentation/Metal/MTLDevice) that created these resources can modify them. Different resource types have different uses. The most common resource types are buffers ([`MTLBuffer`](/documentation/Metal/MTLBuffer)), which are linear allocations of memory, and textures ([`MTLTexture`](/documentation/Metal/MTLTexture)), which hold structured image data.

## Topics

### Identifying the resource

[`device`](/documentation/Metal/MTLResource/device)

The device object that created the resource.

[`label`](/documentation/Metal/MTLResource/label)

A string that identifies the resource.

### Reading memory and storage properties

[`cpuCacheMode`](/documentation/Metal/MTLResource/cpuCacheMode)

The CPU cache mode that defines the CPU mapping of the resource.

[`storageMode`](/documentation/Metal/MTLResource/storageMode)

The location and access permissions of the resource.

[`hazardTrackingMode`](/documentation/Metal/MTLResource/hazardTrackingMode)

A mode that determines whether Metal tracks and synchronizes resource access.

[`resourceOptions`](/documentation/Metal/MTLResource/resourceOptions)

The storage mode, CPU cache mode, and hazard tracking mode of the resource.

[`MTLCPUCacheMode`](/documentation/Metal/MTLCPUCacheMode)

Options for the CPU cache mode that define the CPU mapping of the resource.

[`MTLStorageMode`](/documentation/Metal/MTLStorageMode)

Options for the memory location and access permissions for a resource.

[`MTLHazardTrackingMode`](/documentation/Metal/MTLHazardTrackingMode)

Options that control whether Metal automatically tracks and prevents memory hazards for resources.

### Setting the purgeable state of the resource

[`setPurgeableState(_:)`](/documentation/Metal/MTLResource/setPurgeableState(_:))

Specifies or queries the resource’s purgeable state.

[`MTLPurgeableState`](/documentation/Metal/MTLPurgeableState)

The purgeable state of the resource.

### Managing heap resources

[`heapOffset`](/documentation/Metal/MTLResource/heapOffset)

The distance, in bytes, from the beginning of the heap to the first byte of the resource, if you allocated the resource on a heap.

[`heap`](/documentation/Metal/MTLResource/heap)

The heap on which the resource is allocated, if any.

[`makeAliasable()`](/documentation/Metal/MTLResource/makeAliasable())

Allows future heap resource allocations to alias against the resource’s memory, reusing it.

[`isAliasable()`](/documentation/Metal/MTLResource/isAliasable())

A Boolean value that indicates whether future heap resource allocations may alias against the resource’s memory.

### Querying the allocated size

[`allocatedSize`](/documentation/Metal/MTLResource/allocatedSize)

The size of the resource, in bytes.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)