Display and GPU Synchronization
The client application is expected to manage the synchronization of the GPU and the display controller and must specify the correct synchronisation fence in the configure request. Usually a synchronization update fence from the last submission of rendering GPU work to the display buffer is supplied, merged in with any other dependencies. When this fence is met, the display buffer is ready to be shown.
The above diagram shows how synchronisation is embedded in the configuration flow. The
blue Sync comments above show when fences may be given, checked or signalled. The
general flow has three major stages:
- When the client application is requesting a configuration change to display a buffer, it usually specifies an acquire fence that will be signalled as soon as the buffer is ready to be displayed. That means usually the client application or the GPU has finished writing to it.
- There are three events which trigger a check of the synchronization fence of the
next command in the configuration queue. These events could possibly have
unblocked the next configuration command:
- A GPU task has finished and signalled a update fence.
- Insertion of a new command in the configure queue.
- A configuration has been retired, i.e. a buffer is again ready to be used.
- If the synchronization fence with the next command in the queue is signalled and the command is ready to be submitted Services will call into the display driver via a registered configuration callback to display the buffer. As soon as the buffer is not on display anymore the display driver must retire the configuration with a call into services. Services then will signal the synchronisation release fence associated with that configuration, and this may unblock another item in the configuration queue or a GPU task.
- The drawn VSync event is special in that it will not change any synchronisation fences but will signal a waiting client application to wake up. The client application itself can choose if it wants to be notified on a VSync event by calling PVRSRVDCSetVSyncReporting from the Services client library. This will ask the display driver to call the exported server function PVRSRVCheckStatus every time a VSync event occurred. PVRSRVCheckStatus again will signal a Services server event object that the client application can wait for by calling PVRSRVEventObjectWait.