Using Fence Sync Objects in OpenGL

I am trying to find scenarios in which Sync objects can be used in OpenGL. I understand that a synchronization object once put into a GL command stream (using glFenceSync ()) will be signaled after all GL commands have been executed and implemented. If synchronization objects are synchronization primitives, why can't we ALWAYS signal them? Where exactly can this functionality help the GL programmer?

Is the following scenario correct?

Thread 1 : Load model Draw() glFenceSync() Thread 2 : glWaitSync(); ReadPixels Use data for subsequent operation. 

Does this mean that I cannot start thread 2 if glFenceSync () is not called in Thread 1?

+8
synchronization opengl opengl-3
source share
1 answer

Fences are not so much designed to synchronize threads, but also to know when asynchronous operations are completed. For example, if you are executing glReadPixels on a pixel buffer object (PBO), you might need to know that the read has been completed before you even try to read or map the PBO to the client address space.

If you execute glReadPixels when the PBO is the target, the call returns immediately, but data transfer may take some time. That the fences come in handy.

+8
source share

All Articles