Imagination PowerVR SDK Blog

Is FBO with EGLImage Working on SGX540 ?


Hi all,
i try to perform off screen rendering using FBO and using as target texture a Android native Buffer.
To do so, i created a Android GraphicBuffer (with width and height = 1024)
  GraphicBuffer*  buffer = new GraphicBuffer(texWidth, texHeight,
                              GraphicBuffer::USAGE_HW_TEXTURE |   
                              GRALLOC_USAGE_SW_READ_OFTEN |

Then from that GraphicBuffer i get a native buffer handle that i use to create an EGLImage (ImageKHR)
  EGLImageKHR pEGLImage = _eglCreateImageKHR(eglGetCurrentDisplay(),
                                EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, (EGLClientBuffer)anb, attrs);

Then i initialize the FBO in order to render into that ImageKHR
    // create a framebuffer object
    glGenFramebuffersOES(1, framebuffers);
    framebuffer = framebuffers[0];       
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, framebuffer);   

    //Create Depth buffer
    glGenRenderbuffersOES(1, depthRb);
    Renderbuf = depthRb[0];
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, Renderbuf);

    glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, width, height);


    // Create GL texture, bind to GL_TEXTURE_2D, etc.
    glGenTextures(1, textures);
    texture = textures[0];
    //color texture
    glBindTexture(GL_TEXTURE_2D, texture);
    _glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, pEGLImage);

    // attach the texture to FBO color attachment point
                        GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D,
                        texture, NULL);
  // check FBO status
    int status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
   //Then Bind the FBO
   glBindFramebufferOES(GL_FRAMEBUFFER_OES, framebuffer);

After that i’m doing my rendering that i expect to be at teh end in my GraphicBuffer

The problem i have is that i’m checking error after each gl call and there is no error; the FBO status is COMPLETE so NO error is raised. But when i look at the FBO nothing is rendered.

I tried that code on other GPUs and it is working fine so i’m suspecting that i’m missing something for SGX. But after long days of investigation still same result: Nothing is rendered.

It seems that Size is not the problem (Power of 2) may be RGB565 but is tried with RGB888 and still nothing.

COuld you help me giving idea for investigation or link on document or even better providing solution ?

Thanks in advance.



Did you try to use HAL_PIXEL_FORMAT_RGBA_8888 format of textures?

cuda.geek2012-03-21 14:47:19


Yes i tried also but it is the same it is as if the FBO is not doing anything (even reporting the error)

If 565 was not supported i would expect an error no ?




I noticed that libui has very silent errorsSmile

What hardware has your device? I mean processor and gpu unit. Realization of libui is platform dependent. Open code from said that U can create  

Maybe U can more… But this must work. I can’t say about any optimization…


I tried with  HAL_PIXEL_FORMAT_RGB_888 and teh result is the same.
I will try with

Thanks for the idea


Hi Seb,

Can you explain your use case? There are caveats when using EGLImage in this way, for example setting up a suitable synchronization framework to avoid tearing (if tearing is a concern). You should keep this in mind when deciding if using EGLImage is the best option for you.

I've discussed this issue with our driver team. The driver is designed in such a way that drawing commands issued for FBOs will not be executed until that FBO is referenced by the main framebuffer's rendering. The idea behind this is to optimize out FBO rendering that doesn't affect the final image to avoid redundant rendering.

I would suggest drawing an off-screen primitive that references the FBO (e.g. a triangle) into the main framebuffer to force the FBO to render, if you are not doing so already.

Let me know if this does not resolve your problem.


Joe2012-04-10 14:53:42


Hi Joe,

As you advised, i added some code to use the FBO to draw a rectangle into a pBuffer Surface.
But doing that didn’t change anything.

Sometime i can see part of my texture rendered into the FBO but that part of texture is not rendered at the right place. Even if it is not working the part of texture that is rendered seems OK which make me think that RGB565 is working fine.

As for texture that i bind to FBO i’m using a native_buffer given thanks to EGLImage, is Imagination expecting some specific parameter when creating the native buffer ?

Again the same code is working fine on LG2 Revolution  using  Adreno 200 or GalaxySII using MALI400-MP.

Do you have any new idea to try ? i would expect that FBO is working fine.

Thanks and Best Regards,