<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLCounterSampleBuffer/resolveCounterRange(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "s:So22MTLCounterSampleBufferP5MetalE19resolveCounterRangey10Foundation4DataVSgSnySiGKF"
  },
  "title" : "resolveCounterRange(_:)"
}
-->

# resolveCounterRange(_:)

Transforms samples of a GPU’s counter set from the driver’s internal format to a standard Metal data structure.

```
func resolveCounterRange(_ range: Range<Int>) throws -> Data?
```

## Parameters

`range`

A range that indicates which sample instances the method resolves in the counter sample buffer.

## Return Value

A <doc://com.apple.documentation/documentation/Foundation/Data> instance in Swift,
or an <doc://com.apple.documentation/documentation/Foundation/NSData> instance in Objective-C,
if the method successfully resolves the range of samples in the buffer; otherwise, `nil`.

## Discussion

You can only call this method on a counter sample buffer that you create with [`MTLStorageMode.shared`](/documentation/Metal/MTLStorageMode/shared) (see [`storageMode`](/documentation/Metal/MTLCounterSampleBufferDescriptor/storageMode)). For an example of how and when to use this method, see [Converting a GPU’s counter data into a readable format](/documentation/Metal/converting-a-gpus-counter-data-into-a-readable-format).

> Note:
> The GPU stores ``doc://com.apple.metal/documentation/Metal/MTLCounterErrorValue`` in `destinationBuffer` each time it encounters an error resolving a sample.

---

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)