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

glEGLImageTargetTexture2DOES does not set properly the state of an attached framebuffer

Hi,

I have recently encountered a problem with OpenGL/EGL on ARM Mali 450, Android 4.4.2. In my opinion this is a bug.

I have the following setup. A texture with no storage and a frame buffer attached to the texture. An EGLImageKHR is set as the texture's storage with glEGLImageTargetTexture2DOES. Then the frame buffer status is not complete, while it should be.

Here is an example code:

GLuint tex;
glGenTextures(1, &tex);
GLuint frmBuff;
glGenFramebuffers(1, &frmBuff);

glBindFramebuffer(GL_FRAMEBUFFER, frmBuff);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);

ANativeWindowBuffer* graphicBuffer = ...; // Init a graphic buffer in some manner
EGLClientBuffer cbuf = (EGLClientBuffer)graphicBuffer;

EGLint attrs[] = {
        EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
        EGL_NONE,
};

EGLImageKHR eglImg = eglCreateImageKHR(dpy, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, cbuf, attrs);

glBindTexture(GL_TEXTURE_2D, tex);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)eglImg);

GLenum framebufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); // Returns GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT

The frame buffer check should return GL_FRAMEBUFFER_COMPLETE, because a storage of the texture has been just given with glEGLImageTargetTexture2DOES. If we substitute glEGLImageTargetTexture2DOES

with the semantically equivalent

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);

we get nice behavior and the framebuffer is in complete state afterwards. This leads me to believe, if there has not been any texture storage beforehand, that glEGLImageTargetTexture2DOES does not properly set the state of the attached framebuffer.

  • Hi sogartar,

    The first thing we should do is validate that you have all the required extensions.

    For your explanation above, you need to check to make sure you have at least the following extensions supported on your platform:

    • EGL_KHR_image_base
    • EGL_ANDROID_image_native_buffer
    • GL_OES_EGL_image_external

    Once you validate that, then you should check for errors after every single EGL and GLES call to make sure that it isnt failing on a different API call than just glCheckFramebufferStatus.

    With a bit of googling I found this comment which could prove useful to you: Using GL_OES_EGL_image_external on Android · GitHub

    It suggests that you should change your glBindTexture and glEGLImageTargetTexture2DOES calls from using GL_TEXTURE_2D to using GL_TEXTURE_EXTERNAL_OES .

    I have not tested this myself so cannot confirm if this works.

    Please let us know how you get on.

    Kind Regards,

    Michael McGeagh