---
title: "optimizeContents(forGPUAccess:slice:level:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtl4computecommandencoder/optimizecontents(forgpuaccess:slice:level:)"
---

# optimizeContents(forGPUAccess:slice:level:)

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

## Declaration

```swift
func optimizeContents(forGPUAccess texture: any MTLTexture, slice: Int, level: Int)
```

## Parameters

- `texture`: A doc://com.apple.metal/documentation/Metal/MTLTexture the command optimizes for GPU access.
- `slice`: A slice within texture.
- `level`: A mipmap level within texture.

## Discussion

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

## See Also

### Encoding optimization commands

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