Synchronizing events across multiple devices or processes
Use shareable events to synchronize your app’s work across multiple devices or processes.
Overview
The following figure and code show a shareable event that synchronizes graphics rendering on one device with compute processing on another.
[Image]
During setup, the code creates a shareable event (MTLSharedEvent) and command queues on two different devices. Like the example shown in Synchronizing events within a single device, it encodes render commands onto the first queue and compute commands on the second queue.
You call the same methods when signaling and waiting on shared events as you do when working with events on a single device. The only difference is that the queues are associated with different devices and the event being used to synchronize access is a shared event.
The code shown above assumes you’ve created each resource on both device objects, and each pair of resources share a single allocation of memory. This strategy means that change made by one device object are visible to the other device object. For an example of how to do this, see Selecting device objects for compute processing.