---
title: "replace(deviceResource:using:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/lowleveltexture/replace(deviceresource:using:)"
---

# replace(deviceResource:using:)

Replaces this object’s underlying texture with an existing LowLevelDeviceResource created and managed by the application.

## Declaration

```swift
@MainActor func replace(deviceResource: LowLevelDeviceResource, using commandBuffer: (any MTLCommandBuffer)? = nil)
```

## Parameters

- `deviceResource`: The underlying texture this object should refer to.
- `commandBuffer`: The doc://com.apple.documentation/documentation/Metal/MTLCommandBuffer you intend to use for texture modifications. RealityKit waits for the command buffer to complete before utilizing the texture for rendering.

## Discussion

Discussion While it’s valid to replace a LowLevelTexture with an externally-managed texture having different dimensions, the LowLevelTexture will remember its initial size and calling replace(using:) to obtain a new MTLTexture will respect the initial size.
