Hi.
Usually, I use render-to-texture technique to process the image.
However, recently, I need to read the contents to the system memory.
So, I tried to use glReadPixels as follows:
GLubyte pixels[256] = { 0, 0, 0, 0 };
GL_CHECK( glReadPixels(100, 100, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, pixels) );
LOGI("%d %d %d %d\n", pixels[0], pixels[1], pixels[2], pixels[3]);
This code works well on my desktop PC with NVIDIA card.
But, it fails with ARM Mali-T628.
Debug: test0clear.cpp:36: glGetError() = OUT_OF_MEMORY at test0clear.cpp:36
Here is the details of my system:
EGL vendor = ARM
EGL version = 1.4 Midgard-"r4p0-02rel0"
EGL client apis = OpenGL_ES
GL ES vendor = ARM
GL ES version = OpenGL ES 3.0
GL ES renderer = Mali-T628
GL ES SL version = OpenGL ES GLSL ES 3.00
Do you have any idea to overcome this abnormal situation?
Thanks in advance.
--
oceancru
oceancru,
All your drawing commands may be collected up and rendered at glFinish or glReadPixels and that may be when memory is allocated and a failure occurs. I don't know why you wouldn't get the error at glFinish, but there are both draw and read contexts, so there may be a problem with the read context.
I haven't heard any other reports of glReadPixels issues on the version of the driver you reported at the start (r4p0), so I don't think this is a general problem with glReadPixels. I don't think we can say until we see more of the context of how your application is calling the code.
Thank you for the draw function code snippet. Can you send us a larger sample program source or even an APK which shows the problem including how you created your rendering surface and context and set them current? How you created the surface and made it current may impact the behavior of glReadPixels.
Thank you. -Brad