---
title: "replace(commandBuffer:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/lowleveltextureresource/replace(commandbuffer:)"
---

# replace(commandBuffer:)

Retrieves a Metal texture that shaders can write to on the GPU. The texture’s contents are in an uninitialized state. The renderer waits for the command buffer to complete before using the texture for rendering.

## Declaration

```swift
final func replace(commandBuffer: (any MTLCommandBuffer)?) -> any MTLTexture
```

## Parameters

- `commandBuffer`: The command buffer writing to this texture, or nil to skip synchronization.

## Return Value

Return Value A MTLTexture ready for GPU write operations.

## See Also

### Reading and writing texture data

- [read(commandBuffer:)](realitykit/lowleveltextureresource/read(commandbuffer:).md)
