PBuffer flickering


i’m using a Raspberry PI and OpenGLES 2.

I’m using a PBuffer in a thread, rendering some content in parallel. This is what i’m doing:

  1. Create context and surface for window
  2. Create in other thread context and pbuffer

Main process main loop: Activate context of window, drawing my content to the window from step 1, when using the PBuffer as texture bind it with eglBindTexImage and unbind after usage. Deactivate context of window
In thread loop: Activate Context from step 2, draw stuff, call glFLush and glFinish and deactivate context.

The content of the PBuffer is flickering, it’s like i can watch step by step how the content of the Pbuffer is draw. The main loop stuff is rendering at 55FPS, the content of the PBuffer at 10-15FPS.

I’m doing something wrong?

Thank you in advance.
Regards Mario

You’re likely rendering to the texture while it’s being sampled. There’s lots of potential solutions, the simplest would be moving everything to a single thread or adding a mutex between the threads, to something more complicated and efficient like keeping the threads, using an EGL shared context with multiple EGL Images and EGL fences to synchronize content.