This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

glReadPixels generates OUT_OF_MEMORY error

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

  • What device are you running on?

    To help us give you a quick answer, can you also share a complete test case (source or Android APK is fine), so we're not trying to reproduce what you have done from the tiny snippet above?

    A couple of starting points:

    • Just to check the obvious, can you double check that the OpenGL ES error state is not set immediately before the call to glReadPixels() - the error state is sticky and may have been set by an earlier function.
    • I think that version of the driver supports the KHR_debug extension, so you may get some more information about the error out via that channel, although with OUT_OF_MEMORY I'm not convinced that will necessarily be the case.

    Cheers,
    Pete

  • Hi, Mr. Harris.

    My system is:  Odroid-XU3, running Ubuntu 14.04 LTS.

    It is equipped with ARM armv7l and Mali-T628.

    With its original OpenGL ES SDK, the "libmali.so" file works well for most applications.

    But, it generates 0x505 OUT_OF_MEMORY error for any glReadPixels function call.

    Sigh.

    I made the very simple drawing function as follows:

    void mydraw(void) {

    static GLubyte buf[1024*1024] = { 0, 0, 0, 0 };

    GL_CHECK( glClearColor(0.5f, 0.5f, 0.5f, 1.0f) );

    GL_CHECK( glClear(GL_COLOR_BUFFER_BIT) );

    GL_CHECK( glFinish() );

    GL_CHECK( glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)(&buf[0])) );

    GL_CHECK( glFinish() );

    }

    It also generates OUT_OF_MEMORY.

    I cannot understand why ReadPixels function call requires memory...

    Sigh.

    Thanks in advance.

    --

    Nakhoon Baek

  • Hi Oceancru,

    Thank you for the code snippet you provided. Before I investigate the issue I was wondering if you could tell me more about the Ubuntu distribution you are currently running. As the Odroid XU3 only started shipping 2 days ago, I am guessing that you have access to pre release hardware? If this is the case where did you get the binary from? If it is directly from hard kernel, can you tell me which version you are using?

    Cheers,

    Stephen

  • 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