How can I synchronize the contents of a managed resource from the GPU to the CPU on iOS ? On MacOS I just need to call the synchronize method.
https://developer.apple.com/documentation/metal/mtlblitcommandencoder/1400775-synchronize
But this is not available on iOS, do you know how can I do it ?
There are no managed resources in Metal on iOS. All resource storage is in memory that is shared by the CPU and GPU. Therefore, to synchronize data written by the GPU to the CPU, you only need to ensure that any command buffers that have written to the resource have completed before accessing them from the CPU. You can use the addCompletedHandler
method on the MTLCommandBuffer
protocol to register a block that will be called when the command buffer completes.