<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLComputeCommandEncoder/useResource(_:usage:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLComputeCommandEncoder(im)useResource:usage:"
  },
  "title" : "useResource(_:usage:)"
}
-->

# useResource(_:usage:)

Ensures kernel calls that the system encodes in subsequent commands have access to a resource.

```
func useResource(_ resource: any MTLResource, usage: MTLResourceUsage)
```

## Parameters

`resource`

An [`MTLResource`](/documentation/Metal/MTLResource) instance used in an argument buffer.

`usage`

How the compute pass can access data, including [`read`](/documentation/Metal/MTLResourceUsage/read) and [`write`](/documentation/Metal/MTLResourceUsage/write) permission.

    For applicable resources, you may be able to prevent the GPU from unnecessarily decompressing color attachments on some devices by setting     `usage`     to [`read`](/documentation/Metal/MTLResourceUsage/read)    .

## Discussion

You can make a resource *resident* (available in GPU memory) for the remaining duration of the compute pass by calling this method. Call the method before encoding function calls that may access the `resource` through an argument buffer. The method ensures the resource is in a format that’s compatible with the kernels that depend on it.

> Note:
> You don’t need to call this method if you bind a resource for compute kernels to access.

The method also informs Metal when to apply hazard tracking for a resource you create with [`MTLHazardTrackingMode.tracked`](/documentation/Metal/MTLHazardTrackingMode/tracked). For a resource you create with [`MTLHazardTrackingMode.untracked`](/documentation/Metal/MTLHazardTrackingMode/untracked), you need to apply an [`MTLFence`](/documentation/Metal/MTLFence) or an [`MTLEvent`](/documentation/Metal/MTLEvent) to account for potential reading and writing hazards.

You can reconfigure an individual resource’s `usage` options for subsequent draw calls in the same render pass by calling this method again.

Apps typically call this method for a resource in an argument buffer as a part of their *bindless* implementation. For more information about argument buffers and bindless implementations, see [Improving CPU performance by using argument buffers](/documentation/Metal/improving-cpu-performance-by-using-argument-buffers) and [Go bindless with Metal 3](https://developer.apple.com/videos/play/wwdc2022/10101/), respectively.

---

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)