Search code examples
opengl-espowervr-sgx

OpenGL ES rendering to user-space memory


I need to implement off-screen rendering to texture on an ARM device with PowerVR SGX hardware.

Everything is done (pixelbuffers and OpenGL ES 2.0 API were used). The only problem unsolved is very slow glReadPixels function.

I'm not an expert in OpenGL ES, so I'm asking community: is it possible to render textures directly into user-space memory? Or may be there is some way to get hardware address of texture's memory region? Some other technique (EGL extensions)?

I don't need an universal solution, just working one for PowerVR hardware.

Update: A little more information on 'slow function glReadPixels'. Copy 512x512 RGB texture data to CPU's memory:

  • glReadPixels(0, 0, WIDTH, HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, &arr) takes 210 ms,
  • glReadPixels(0, 0, WIDTH, HEIGHT, GL_BGRA, GL_UNSIGNED_BYTE, &arr) takes 24 ms (GL_BGRA is not standard for glReadPixels, it's PoverVR extension),
  • memcpy(&arr, &arr2, WIDTH * HEIGHT * 4) takes 5 ms

In case of bigger textures, differences are bigger too.


Solution

  • Solved.

    The way how to force OpenVR hardware render into user-allocated memory: http://processors.wiki.ti.com/index.php/Render_to_Texture_with_OpenGL_ES#Pixmaps

    An example, how to use it: https://gforge.ti.com/gf/project/gleslayer/

    After all of this I can get rendered image as faster as 5 ms.