idegani
Posts: 3
Joined: Mon Jun 24, 2019 2:27 pm

Synchronization of EGLImage in hello_videocube sample

Mon Jul 15, 2019 5:07 am

Hi,

I'm a bit confused by how the hello_videocube sample handles synchronization between the main OpenGL render thread and the OMAX video update thread. I've found several articles on EGLImage and it appears that it requires explicit synchronization and maintenance of a front/back buffer:

https://docs.google.com/file/d/0B_oQNe1 ... FuVlE/edit
https://link.springer.com/chapter/10.10 ... -2472-4_15

However in videocube's triangle.c, I see a pthread created with an EGLImage (from an OpenGL texture). After this, the two threads never communicate again. Is the back/front buffering handled automatically by OMAX? What prevents tearing since the OpenGL thread is probably running faster than the video decoder thread?

In my case, I'd like to derive EGLImageKHR from an OpenVG image object:

Code: Select all

 
 vg_img = vgCreateImage(VG_sL_8, 1280,760, VG_IMAGE_QUALITY_NONANTIALIASED);
 eglImage = eglCreateImageKHR(
                state->display,
                state->context,
                EGL_VG_PARENT_IMAGE_KHR,
                (EGLClientBuffer)vg_img,
                0);
If I fill this eglImage buffer using the OMAX "egl_render" component, can I expect the openVG loop below to reliably update vg_img without any explicit synchronization?

Code: Select all

while (1) {
vgSetPixels(x, y, vg_img, 0, 0, width, height);

// draw other UI overlays...

eglSwapBuffers(egl_state.display, egl_state.surface);
}

And finally, having OMAX fill/empty the egl buffer is far more tedious that just calling vgImageSubData on the vg_image directly. If synchronization is handled automatically, is there any reason I can't just launch a thread which calls this function instead?

Code: Select all

 vgImageSubData(vg_img, new_data, width, VG_sL_8, 0, 0, width, height);
(In my case I don't need a decoder in my pipeline because I'm getting raw images from a camera sensor)

Thanks for the help!

Ismail

Return to “OpenMAX”