Yes there is. Assuming you have access to OpenGL 3.2+ or the ARB_sync extension.
If you want to know when a particular command has completed, you can insert a synchronization object into the "fence" command stream immediately after issuing this command. This is done using the glFenceSync function.
You must keep the pointer returned by this function. With this pointer in hand, you can ask if the fence is complete by checking if the fence is enabled using the glGetSync function. Like this:
GLint isSignaled = 0; glGetSync(syncObj, GL_SYNC_STATUS, 1, NULL, &isSignaled); if(isSignaled == GL_SIGNALED) { //Prior commands have completed. } else { //Not done yet. }
If you lack other things to work, you do not need to wait for the synchronization object to complete; you can just do whatever OpenGL process you want to do. This will call the processor unit for you.
Once you are done with the synchronization object, you should delete it. Use the glDeleteSync function to do this.
Nicol bolas
source share