Contents

Synchronizing events within a single device

Use nonshareable events to synchronize your app’s work within a single device.

Overview

The following figure and code show a nonshareable event that synchronizes graphics rendering on one command queue with compute processing on another.

[Image]

During setup, the code creates a nonshareable event and two command queues. Then, to render a frame, the code encodes render commands onto the first queue and compute commands on the second queue. While the code shows these commands being encoded sequentially, in a real app, you should determine whether you can encode the commands for each command queue on a different thread.

The first render pass and first compute pass are assumed to not depend on each other’s results and modify the same data. By encoding them on different queues, the device object can schedule these commands concurrently.

When two sets of commands have dependencies on each other, the code expresses these dependencies by signaling or waiting on the event. When each queue reaches a command that waits for an event, that queue blocks further execution until the event is signaled.

See Also

Synchronizing with events