<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTL4ComputeCommandEncoder/optimizeContents(forGPUAccess:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTL4ComputeCommandEncoder(im)optimizeContentsForGPUAccess:"
  },
  "title" : "optimizeContents(forGPUAccess:)"
}
-->

# optimizeContents(forGPUAccess:)

Encodes a command that modifies the contents of a texture to improve the performance of GPU accesses
to its contents.

```
func optimizeContents(forGPUAccess texture: any MTLTexture)
```

## Parameters

`texture`

A [`MTLTexture`](/documentation/Metal/MTLTexture) instance the command optimizes for GPU access.

## Discussion

Optimizing a texture for GPU access may affect the performance of CPU accesses, however, the data the CPU
retrieves from the texture remains consistent.

You typically run this command for:

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

---

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)