Check the busy status of the OpenVG core


Is there a way to check the (gpu/state machine?) status on openVG?

Currently the only way I have to synchronize is vgFinish which will stall the CPU and it cannot by used by my application. I need a mechanism to poll the state without blocking, such:

rslt = vgIsFinish();

Or getting a callback when finished… if it is done I can swap buffers and render the next frame other wise I can check later.

Thanks in advance.

You don’t need to worry about when rendering is complete, the swap handles presentation and synchronization.

You can explicitly flush a context with vgFlush() if you’d like, but a swap has an explicit flush. The swap will block until it’s safe to start issuing rendering commands again. This could before the previous frame has completed rendering. But it will ensure your not rendering to a buffer which is currently being displayed.

There normally lots of mechanism under the cover to do this kind of synchronization, but it’s not necessary for applications by any means since the implementation can always handle all the synchronization that’s required.

Keep in mind however, some implementation might be more optimal then others, allowing greater overlap of resources.

Well, the thing is I am working in part of the implementation, I cannot afford to wait any blocking function since I would be wasting precious CPU time on doing nothing. Since I am the one swapping the buffers directly, I was wondering if there was a standard mechanism of checking the status using the API or I had to drill down to the system to get an IRQ or something else to get that status flag. I guess I just can do the latest.

If you doing the implementation, you shouldn’t be calling eglSwapBuffers(), only applications should be doing this. The implementation of eglSwapBuffers() should tie into platform/OS specific code which handles synchronization and the actual buffer swap. In the implementation of this, you should make use of the OpenVG driver’s internals to handle synchronization. How this is handled, depends on the windowing system, driver etc.

If your aiming for something optimal, you want to ensure eglSwapBuffers() will only block the application as long as it needs too. This allows it to start queue rendering commands while the GPU is busy. But you also need to ensure it doesn’t return before it’s safe to do so. Driver’s absolutely need a mechanism to know when rendering is complete, popular mechanisms are callbacks, or blocking function calls. If it’s a blocking function call, you can have a thread block waiting for rendering to complete prior to doing the actual swap, so you can return early on the eglSwapBuffers().