copyAsync(to:completionHandler:)
Asynchronously copies texture data to another texture.
Declaration
@MainActor @preconcurrency func copyAsync(to texture: any MTLTexture, completionHandler: @escaping @MainActor ((any Error)?) -> Void)Parameters
- texture:
The target texture for copying the data. It needs to have the same width and height as Textureresource, and Shaderwrite usage.
- completionHandler:
The system calls this closure after it finishes copying the data, with a
nilerror if it succeeds.
Discussion
This function is asynchronous. It returns immediately and runs in the background, calling completionHandler when it finishes or errors. This method copies all available mipmap sizes to texture.
It’s recommended that you provide a value for semantic when creating this resource. Specifying a semantic enables RealityKit to select an appropriate pixel format for the target texture.