---
title: "optimizeContents(forCPUAccess:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtl4computecommandencoder/optimizecontents(forcpuaccess:)"
---

# optimizeContents(forCPUAccess:)

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

## Declaration

```swift
func optimizeContents(forCPUAccess texture: any MTLTexture)
```

## Parameters

- `texture`: A doc://com.apple.metal/documentation/Metal/MTLTexture instance the command optimizes for CPU access.

## Discussion

Discussion Optimizing a texture for CPU access may affect the performance of GPU accesses, however, the data the GPU retrieves from the texture remains consistent. You typically use this command for: Textures the CPU accesses for an extended period of time. Textures with a storageMode property that’s MTLStorageMode.shared or MTLStorageMode.managed.

## See Also

### Encoding optimization commands

- [optimizeCommands(buffer:range:)](metal/mtl4computecommandencoder/optimizecommands(buffer:range:).md)
- [optimizeContents(forCPUAccess:slice:level:)](metal/mtl4computecommandencoder/optimizecontents(forcpuaccess:slice:level:).md)
- [optimizeContents(forGPUAccess:)](metal/mtl4computecommandencoder/optimizecontents(forgpuaccess:).md)
- [optimizeContents(forGPUAccess:slice:level:)](metal/mtl4computecommandencoder/optimizecontents(forgpuaccess:slice:level:).md)
