Is FBO with EGLImage Working on SGX540 ?

This topic contains 6 replies, has 3 voices, and was last updated by  baudouis 5 years, 6 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #30783

    baudouis
    Member

    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,
                                  HAL_PIXEL_FORMAT_RGB_565,
                                  GraphicBuffer::USAGE_HW_TEXTURE |   
                                  GRALLOC_USAGE_SW_READ_OFTEN |
                                  GRALLOC_USAGE_SW_WRITE_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);

        glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, Renderbuf);

        // Create GL texture, bind to GL_TEXTURE_2D, etc.
        glGenTextures(1, textures);
        texture = textures[0];
               
        //color texture
        glBindTexture(GL_TEXTURE_2D, texture);
       
        glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
       
        glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                               
        _glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, pEGLImage);

        // attach the texture to FBO color attachment point
        glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES,
                            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.

    Seb

    #35567

    cuda.geek
    Member

    Did you try to use HAL_PIXEL_FORMAT_RGBA_8888 format of textures?

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

    #35568

    baudouis
    Member

    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 ?

    BR

    Seb

    #35569

    cuda.geek
    Member

    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 https://github.com/android/platform_frameworks_base/blob/dd1880ee5bea09e9d37c6db29ef20e49d619c094/libs/ui/GraphicBufferMapper.cpp said that U can create  
    4b:
           HAL_PIXEL_FORMAT_RGBA_8888
           HAL_PIXEL_FORMAT_RGBX_8888
           HAL_PIXEL_FORMAT_BGRA_8888
    3b:
           HAL_PIXEL_FORMAT_RGB_888
    2b:
           HAL_PIXEL_FORMAT_RGB_565
           HAL_PIXEL_FORMAT_RGBA_5551
           HAL_PIXEL_FORMAT_RGBA_4444

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

    #35570

    baudouis
    Member

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

    Thanks for the idea
    Seb

    #35571

    Joe Davis
    Member

    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.

    Thanks,
    Joe

    Joe2012-04-10 14:53:42

    #35572

    baudouis
    Member

    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,

    Sebastien

Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic.