<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/LowLevelBufferResource/replace(commandBuffer:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:19RealityCoreRenderer22LowLevelBufferResourceC7replace07commandF0So9MTLBuffer_pSo010MTLCommandF0_pSg_tF"
  },
  "title" : "replace(commandBuffer:)"
}
-->

# replace(commandBuffer:)

Returns a Metal buffer you populate on the GPU with the new contents of the buffer resource.

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

## Parameters

`commandBuffer`

The command buffer that writes to this buffer, or `nil` to skip synchronization.

## Return Value

A `MTLBuffer` ready for GPU write operations.

## Discussion

Upon return the buffer’s contents are undefined; the caller is responsible for
populating it with valid data. The renderer waits for the provided command buffer
to complete before using the buffer for rendering.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)