---
title: "optimizeContentsForCPUAccess(texture:slice:level:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlblitcommandencoder/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.

## Declaration

```swift
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.

## Mentioned in

Optimizing texture data

## Discussion

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 property that’s MTLStorageMode.shared or 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.

## See Also

### Optimizing textures for CPU access

- [optimizeContentsForCPUAccess(texture:)](metal/mtlblitcommandencoder/optimizecontentsforcpuaccess(texture:).md)
