<!--
{
  "availability" : [
    "iOS: 13.0.0 - 26.4.0",
    "iPadOS: 13.0.0 - 26.4.0",
    "macCatalyst: 14.0.0 - 26.4.0",
    "macOS: 11.0.0 - 26.4.0",
    "tvOS: 16.0.0 - 26.4.0",
    "visionOS: 1.0.0 - 26.4.0"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLBlitCommandEncoder/getTextureAccessCounters(_:region:mipLevel:slice:resetCounters:countersBuffer:countersBufferOffset:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLBlitCommandEncoder(im)getTextureAccessCounters:region:mipLevel:slice:resetCounters:countersBuffer:countersBufferOffset:"
  },
  "title" : "getTextureAccessCounters(_:region:mipLevel:slice:resetCounters:countersBuffer:countersBufferOffset:)"
}
-->

# getTextureAccessCounters(_:region:mipLevel:slice:resetCounters:countersBuffer:countersBufferOffset:)

Encodes a command that retrieves a sparse texture’s access data for a specific region, mipmap level, and slice.

```
func getTextureAccessCounters(_ texture: any MTLTexture, region: MTLRegion, mipLevel: Int, slice: Int, resetCounters: Bool, countersBuffer: any MTLBuffer, countersBufferOffset: Int)
```

## Parameters

`texture`

A sparse texture instance.

`region`

A region within the sparse texture’s `mipLevel`, in sparse tile coordinates.

`mipLevel`

A mipmap level within the sparse texture.

`slice`

A slice within the sparse texture.

`resetCounters`

A Boolean value that indicates whether the command resets the counters after it completes.

`countersBuffer`

A destination buffer where the command stores the sparse texture’s access counter data.

`countersBufferOffset`

A starting offset, in bytes, within `countersBuffer` where the command writes the first byte of the sparse texture’s access counter data.

## Discussion

The GPU returns a counter for each sparse tile in the region you specify.
Each counter is a <doc://com.apple.documentation/documentation/kernel/uint32_t> in row-major order. Provide space in the buffer for each counter you request.

When the GPU samples a texture and fails to find data in its internal caches, the GPU increments the access counter for the sparse tile. The GPU then attempts to fetch a new cache line from device memory that contains those pixels.

The counter doesn’t track memory operations to data that’s already in the GPU’s caches.
You can ignore differences in cache line sizes or pixel formats because the GPU driver normalizes the access counts.
Each count represents the number of pixels the GPU fetches into memory.

---

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)