Page 1 of 1

EGL and concurrent resource upload

Posted: Fri Nov 02, 2018 8:50 am
by blackshard83

I have a pure OpenVG application with two threads: the first thread is the graphics rendering loop, and the other thread does the resource upstreaming.

The first thread does its work and then issues a call to eglSwapBuffers() call. eglSwapBuffes waits for vsync, blits the things and then does a new cycle; just a common rendering loop with no fancies.

The second thread is mostly sitting except when there is the need to upload some resources concurrently (mostly large images or even vector paths).

The EGL setup seems correct to me: both threads are bound to OpenVG API, they use different contexts (altough the rendering thread creates its context sharing resources from the context of the upstream thread) and different surfaces (the rendering thread has a fullscreen native surface, the upstream thread has a dummy small pbuffer)

My problem arises when I increase the priority of the rendering thread to get a stable framerate: the upstream thread goes into starvation and can't upload resources as soon as possible.

CPU usage is low for both threads (less than 5% for both of them), so my only guess is the presence of a per-process lock which prevents two threads accessing the videocore internals at the same time, and eglSwapBuffers() is actively taking the lock while it is waiting for vsync, preventing the other thread to operate.

I would really like to increase the priority of the rendering thread and still maintain the asynchronous upstream thread, are there some best practices to follow or bad practices to avoid in such cases?

Re: EGL and concurrent resource upload

Posted: Mon Nov 05, 2018 9:30 am
by blackshard83
Just to add some other details, I'm noticing that calling eglSwapBuffers() starves all other threads of the same process which try to call eglMakeCurrent() and also other threads of the same process which try to invoke OMX functions to load videos.

Juggling with priorities (lowering rendering thread priority) or setting eglSwapInterval to 0 partially mitigates the situtation.