Portal:OpenGL Concepts/Sync: Difference between revisions

From OpenGL Wiki
Jump to navigation Jump to search
Portal sync page.
 
Shorter text.
Line 3: Line 3:
OpenGL implementations attempt to do as much work asynchronously as possible. When a rendering function returns, odds are good that the actual rendering operation has not even ''started'' yet, let alone has finished. However, as long as you don't query any state that would be changed by that rendering command (such as the content of the destination images), you would not be able to tell the difference.
OpenGL implementations attempt to do as much work asynchronously as possible. When a rendering function returns, odds are good that the actual rendering operation has not even ''started'' yet, let alone has finished. However, as long as you don't query any state that would be changed by that rendering command (such as the content of the destination images), you would not be able to tell the difference.


Therefore, the key phrase to remember from the above definition is "as if". The implementation must make it look synchronous, while being as asynchronous as possible. That is why it is important to avoid querying state that may be affected by rendering operations for best performance. This also means avoiding modifying objects that were used in recently-issued rendering commands. Attempts to do so will stall the OpenGL renderer until those rendering commands have completed, so as to behave "as if" everything happened synchronously.
The key phrase to remember from the above definition is "as if". The implementation must make it look synchronous, while being as asynchronous as possible. So, for best performance, you must avoid looking at things that have been affected by rendering commands, as well as avoiding changing the contents of objects that will be used by rendering commands that may not have executed yet.
 
OpenGL operates on a delayed synchronous policy.

Revision as of 06:33, 16 February 2013

The OpenGL specification, usually, defines the behavior of commands such that they will execute in the order given, and that every subsequent command must behave as if all prior commands have completed and their contents are visible. However, it is important to keep in mind that this is how OpenGL is specified, not how it is implemented.

OpenGL implementations attempt to do as much work asynchronously as possible. When a rendering function returns, odds are good that the actual rendering operation has not even started yet, let alone has finished. However, as long as you don't query any state that would be changed by that rendering command (such as the content of the destination images), you would not be able to tell the difference.

The key phrase to remember from the above definition is "as if". The implementation must make it look synchronous, while being as asynchronous as possible. So, for best performance, you must avoid looking at things that have been affected by rendering commands, as well as avoiding changing the contents of objects that will be used by rendering commands that may not have executed yet.