<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLBlitCommandEncoder/optimizeContentsForCPUAccess(texture:slice:level:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLBlitCommandEncoder(im)optimizeContentsForCPUAccess:slice:level:"
  },
  "title" : "optimizeContentsForCPUAccess(texture:slice:level:)"
}
-->

# optimizeContentsForCPUAccess(texture:slice:level:)

Encodes a command that improves the performance of CPU memory operations with a specific portion of a texture.

```
func optimizeContentsForCPUAccess(texture: any MTLTexture, slice: Int, level: Int)
```

## Parameters

`texture`

A texture the command optimizes.

`slice`

A slice within `texture`.

`level`

A mipmap level within `texture`.

## Discussion

This command can reduce the time it takes the CPU to access a texture. Apps typically run the command for:

- Textures the CPU accesses for an extended period of time
- Textures with a [`storageMode`](/documentation/Metal/MTLResource/storageMode) property that’s [`MTLStorageMode.shared`](/documentation/Metal/MTLStorageMode/shared) or [`MTLStorageMode.managed`](/documentation/Metal/MTLStorageMode/managed)

When a blit pass runs this command, the GPU only applies lossless changes to the texture’s underlying data.

> Note:
> Optimizing a texture for the CPU may affect the performance of GPU memory operations,
> but the data the GPU retrieves from the texture remains consistent.

---

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)