<!--
{
  "documentType" : "article",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/tracking-the-resource-residency-of-argument-buffers",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Tracking the resource residency of argument buffers"
}
-->

# Tracking the resource residency of argument buffers

Optimize resource performance within an argument buffer.

## Discussion

The Metal driver can’t automatically track the residency of argument buffer resources, but you can track it manually.

### Track argument buffer resource residency manually

Call an [`MTLRenderCommandEncoder`](/documentation/Metal/MTLRenderCommandEncoder) or [`MTLComputeCommandEncoder`](/documentation/Metal/MTLComputeCommandEncoder) method:

- For individual resources, call [`useResource(_:usage:stages:)`](/documentation/Metal/MTLRenderCommandEncoder/useResource(_:usage:stages:)) or [`useResource(_:usage:)`](/documentation/Metal/MTLComputeCommandEncoder/useResource(_:usage:)).
- For all resources in a heap, call [`useHeap(_:stages:)`](/documentation/Metal/MTLRenderCommandEncoder/useHeap(_:stages:)) or [`useHeap(_:)`](/documentation/Metal/MTLComputeCommandEncoder/useHeap(_:)).

These methods perform two important functions:

- They add argument buffer resources to the set of resources that the render or compute pass needs resident.
- They ensure that argument buffer resources are in a format that’s compatible with the required function operation, as an [`MTLResourceUsage`](/documentation/Metal/MTLResourceUsage) value specifies.

The methods with a `stages` parameter also insert dependency hazards, similar to [`MTLFence`](/documentation/Metal/MTLFence) instances for that stage.

Call these methods before issuing any draw or dispatch calls that may access the specified resources.

> Note:
> To track resource access and dependency hazards, use ``doc://com.apple.metal/documentation/Metal/MTLFence`` instances.
> 
> If all the required resources aren’t resident when executing a render or compute pass, the associated ``doc://com.apple.metal/documentation/Metal/MTLCommandBuffer`` instance fails.

---

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)