---
title: "replace(bufferIndex:using:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/lowlevelmesh/replace(bufferindex:using:)"
---

# replace(bufferIndex:using:)

Retrieves a Metal vertex buffer you can use to replace the contents of the specified buffer on the GPU using Metal.

## Declaration

```swift
@MainActor func replace(bufferIndex index: Int, using commandBuffer: any MTLCommandBuffer) -> any MTLBuffer
```

## Parameters

- `index`: The index of the buffer to modify. Use a value that is less than doc://com.apple.RealityKit/documentation/RealityKit/LowLevelMesh/Descriptor-swift.struct/vertexBufferCount.
- `commandBuffer`: The doc://com.apple.documentation/documentation/Metal/MTLCommandBuffer you intend to use for buffer modifications. RealityKit waits for the command buffer to complete before utilizing the buffer for rendering.

## Discussion

Discussion The buffer’s contents are in an uninitialized state.

## See Also

### Accessing mesh data on the GPU with Metal

- [read(bufferIndex:using:)](realitykit/lowlevelmesh/read(bufferindex:using:).md)
- [readIndices(using:)](realitykit/lowlevelmesh/readindices(using:).md)
- [replaceIndices(using:)](realitykit/lowlevelmesh/replaceindices(using:).md)
