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

eglCreatePixmapSurface  error 0x300a

Note: This was originally posted on 12th September 2012 at http://forums.arm.com

When I try the SAMSUNG S3 run the above code, I failed.


void GLImageRenderBlux::initEGL(int width, int height, SkBitmap bitmap)
{
const EGLint attribList[] = { EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE };

EGLConfig config;
EGLint maj;
EGLint min;

m_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
checkEGLError("eglGetDisplay");
if(m_display == EGL_NO_DISPLAY) {
  LOGE("getDisplay fail!");
  return ;
}

if(eglInitialize(m_display, &maj, &min) == EGL_FALSE) {
  LOGE("Initialize fail");
  return ;
}

config = chooseConfig(m_display);
EGLint contextAttrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };

m_context = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextAttrs);
checkEGLError("eglCreateContext");
if(m_context == EGL_NO_CONTEXT) {
  LOGE("Create Context failure");
  return ;
}


//
SkPixelRef* ref = bitmap.pixelRef();
SkSafeRef(ref);
ref->lockPixels();

egl_native_pixmap_t pixmap;
pixmap.version = sizeof(pixmap);
pixmap.width  = width;
pixmap.height = height;
pixmap.stride = bitmap.rowBytes() / bitmap.bytesPerPixel();
pixmap.format = SkBitmap::kARGB_8888_Config;
pixmap.data   = (uint8_t*)ref->pixels();

ref->unlockPixels();

m_surface = eglCreatePixmapSurface(m_display, config, &pixmap, attribList);
checkEGLError("eglCreatePixmapSurface");
if(m_surface == EGL_NO_SURFACE) {
  LOGE("Create Surface failure");
  return ;
}

if (!eglMakeCurrent(m_display, m_surface, m_surface, m_context)) {
  LOGE("Make Current failure");
  return ;
}
}

EGLConfig GLImageRenderBlux::chooseConfig(EGLDisplay display)
{
EGLConfig config;
EGLint numConfigs;

static const EGLint configAttribs[] = {
   EGL_SURFACE_TYPE,
   EGL_PIXMAP_BIT,
   EGL_RENDERABLE_TYPE,
   EGL_OPENGL_ES2_BIT,
   EGL_NONE
};

eglChooseConfig(display, configAttribs, &config, 1, &numConfigs);
checkEGLError("eglPbufferConfig");
if (numConfigs != 1) {
  LOGE("eglPbufferConfig failed (%d)\n", numConfigs);
}

return config;
}

Error information is as follows:
'eglCreatePixmapSurface error: EGL_BAD_NATIVE_PIXMAP (0x300a)'
'[color=#FF0000]Create Surface failure'[/color]

Does any know how to fix the problem?
  • Note: This was originally posted on 13th September 2012 at http://forums.arm.com

    Hi Likai,

        There is no support for Pixmap Surfaces in Android. Could you let us know what is your application and why you would want to use Pixmap surfaces? If you need the GPU to write to CPU allocated memory that you need to access, you can so do using Android Native buffers and EGL Image extensions.

    Please look at the following post for more information to see if it can help you.
    http://forums.arm.com/index.php?/topic/15782-glreadpixels/

    Cheers
    Karthik
  • Note: This was originally posted on 17th September 2012 at http://forums.arm.com

    Hi Karthik,thanks a lot for answering me.
    I have read that page, and try, but I failed.

    Here are some of my code:



    void initEGL(int width, int height, SkBitmap bitmap)
    {
    //step 1.
    const char* const driver_absolute_path = "/system/lib/egl/libEGL_mali.so";
    void* dso = dlopen(driver_absolute_path, RTLD_LAZY);
    if (dso != 0) {
      LOGI("dlopen: SUCCEEDED");
      _eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)dlsym(dso, "eglCreateImageKHR");
      _eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) dlsym(dso, "eglDestroyImageKHR");
    }
    else {
      LOGI("dlopen: FAILED! Loading functions in common way!");
      _eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress("eglCreateImageKHR");  _eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) eglGetProcAddress("eglDestroyImageKHR");
    }

    if(_eglCreateImageKHR == NULL) {
      LOGE("Error: Failed to find eglCreateImageKHR at %s:%i\n", __FILE__, __LINE__);
      exit(1);
    }
    if(_eglDestroyImageKHR == NULL) {
      LOGE("Error: Failed to find eglDestroyImageKHR at %s:%i\n", __FILE__, __LINE__);
      exit(1);
    }
    _glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) eglGetProcAddress("glEGLImageTargetTexture2DOES");

    if(_glEGLImageTargetTexture2DOES == NULL) {
      LOGE("Error: Failed to find glEGLImageTargetTexture2DOES at %s:%i\n", __FILE__, __LINE__);
      exit(1);
    }

    //step 2. Create the Android Graphic Buffer
       GraphicBuffer* buffer = new GraphicBuffer(width, height, HAL_PIXEL_FORMAT_RGBA_8888, GraphicBuffer::USAGE_HW_TEXTURE | GraphicBuffer::USAGE_HW_2D | GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
        // Init the buffer
    status_t err = buffer->initCheck();
    if (err != NO_ERROR){
    [indent]LOGE("Error: %s\n", strerror(-err));
    return ;
    [/indent]
    }

    // Retrieve andorid native buffer
    android_native_buffer_t* anb = buffer->getNativeBuffer();

    //step 3. Create the EGLImage
    const EGLint attrs[] = {
    [indent]EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
    EGL_NONE, EGL_NONE
    [/indent]
    };

    EGLImageKHR pEGLImage = _eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, (EGLClientBuffer)anb, attrs);

    if (pEGLImage == EGL_NO_IMAGE_KHR) {
    [indent]EGLint error = eglGetError();
    LOGE("Error (%#x): Creating EGLImageKHR at %s:%i\n", error, __FILE__, __LINE__);
    [/indent]
    }
    //setp 4. Set up the FBO with the EGLImage as target
    GLuint iFBOTex;
    GLuint iFBO;
    glViewport(0, 0, width, height);
    checkGlError("glViewport");

    glGenFramebuffers(1, &iFBO);
    checkGlError("glGenFramebuffers");

    /* Initialize FBO texture. */
    glGenTextures(1, &iFBOTex);
    checkGlError("glGenTextures");
    glBindTexture(GL_TEXTURE_2D, iFBOTex);

    /* Bind our framebuffer for rendering. */
    glBindFramebuffer(GL_FRAMEBUFFER, iFBO);
    checkGlError("glBindFramebuffer");

    /* Attach texture to the framebuffer. */
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, iFBOTex, 0);
    checkGlError("glFramebufferTexture2D");

    /* Check FBO is OK. */
    GLenum iResult = glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if(iResult != GL_FRAMEBUFFER_COMPLETE) {
    [indent]LOGE("Error (%#x): Framebuffer incomplete at %s:%i\n", iResult, __FILE__, __LINE__);
    [/indent]
    }
    _glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, pEGLImage);
    checkEGLError("glEGLImageTargetTexture2DOES");

    /* Render to framebuffer object. */
    /* Unbind framebuffer. */
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    checkGlError("glBindFramebuffer");

    //step 5. When rendering every frame, bind to the FBO and issue all glCommands, followed by unbind.
    glBindFramebuffer(GL_FRAMEBUFFER, iFBO);

    /* Set the viewport according to the FBO's texture. */
    glViewport(0, 0, width , height);

    /* Clear screen on FBO. */
    glClearColor(0.5f, 0.5f, 0.5f, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    /*********************************************
    *******************************************/
    glDrawArrays(GL_TRIANGLES, 0, 3);
    /* And unbind the FrameBuffer Object so subsequent drawing calls are to the EGL window surface. */
    glBindFramebuffer(GL_FRAMEBUFFER,0);

    //setp 6. Finally use the following code for reading the buffer out from user space. Something like the following
    // Just in case the buffer was not created yet
    if (buffer == NULL)
    [indent]return;
    [/indent]
    void* vaddr;
    // Lock the buffer and retrieve a pointer where we are going to write the data
    buffer->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, &vaddr);
    if (vaddr == NULL){
    [indent]buffer->unlock();
    return;
    [/indent]
    }

    unsigned char* ucVaddr = (unsigned char*)vaddr;
    }


    occur error when execute the follow code fragement.
    /* Attach texture to the framebuffer. */
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, iFBOTex, 0);
    checkGlError("glFramebufferTexture2D");
    /* Check FBO is OK. */
    GLenum iResult = glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if(iResult != GL_FRAMEBUFFER_COMPLETE) {
    LOGE("Error (%#x): Framebuffer incomplete at %s:%i\n", iResult, __FILE__, __LINE__);
    }

    When the code is executed to glCheckFramebufferStatus will prompt an error, the error is: "Error (0x3008): Creating EGLImageKHR at..." and "Error (0): Framebuffer incomplete at ...."

    Not to create a context, how to use the texture?Give me a complete sample,Appreciate it.

    Thanks for your help.
  • Note: This was originally posted on 19th September 2012 at http://forums.arm.com

    No one can answer my question?
  • Note: This was originally posted on 20th September 2012 at http://forums.arm.com

    Hi Likai,

       I have been able to reproduce the problem with your code snippet. If you look carefully at the code sample provided in the link you have missed out a GLES Call to set the width and height of the texture using glTexImage2D. Without this call, the framebuffer status will be reported as incomplete as the dimensions have not been defined.

    Please add the following line to remove your error,

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, g_texWidth, g_texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);


    You might also want to consider using SurfaceTexture available from Android version 3.0 onwards. Please look at the following documentation also,
    http://developer.and...aceTexture.html

    There is an example in the Android NDK (native-media) that shows how to use this.

    Please let me know if you need any more information.

    Cheers, Karthik
  • Note: This was originally posted on 21st September 2012 at http://forums.arm.com

    I will try.Thank you, thank you very much!
  • Note: This was originally posted on 21st September 2012 at http://forums.arm.com

    We're sorry!I tried the following code, but it is still wrong. I think I'm really stupid, but this is a very important task, I must finish it.


    new code:


    void test2(int width, int height, SkBitmap bitmap)
    {
    LOGV("Enter test2 (%d x %d)", width, height);

    LOGI("*************** 3. During egl initialization, get the addresses for the extensions (function pointers) ***************");
    const char* const driver_absolute_path = "/system/lib/egl/libEGL_mali.so";
    void* dso = dlopen(driver_absolute_path, RTLD_LAZY);
    if (dso != 0)
    {
      LOGI("dlopen: SUCCEEDED");
      _eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)dlsym(dso, "eglCreateImageKHR");
      _eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) dlsym(dso, "eglDestroyImageKHR");
    }
    else
    {
      MLOGI("dlopen: FAILED! Loading functions in common way!");
      _eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress("eglCreateImageKHR");
      _eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) eglGetProcAddress("eglDestroyImageKHR");
    }

    if(_eglCreateImageKHR == NULL)
    {
      LOGE("Error: Failed to find eglCreateImageKHR at %s:%i\n", __FILE__, __LINE__);
      exit(1);
    }
    if(_eglDestroyImageKHR == NULL)
    {
      LOGE("Error: Failed to find eglDestroyImageKHR at %s:%i\n", __FILE__, __LINE__);
      exit(1);
    }
    _glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) eglGetProcAddress("glEGLImageTargetTexture2DOES");
    if(_glEGLImageTargetTexture2DOES == NULL)
    {
      LOGE("Error: Failed to find glEGLImageTargetTexture2DOES at %s:%i\n", __FILE__, __LINE__);
      exit(1);
    }

    LOGI("*************** 4. Create the Android Graphic Buffer ***************");
    GraphicBuffer* buffer = new GraphicBuffer(width, height,
       PIXEL_FORMAT_RGBA_8888,
       GraphicBuffer::USAGE_HW_TEXTURE |
       GraphicBuffer::USAGE_HW_2D |
       GRALLOC_USAGE_SW_READ_OFTEN |
       GRALLOC_USAGE_SW_WRITE_OFTEN);
    // Init the buffer
    status_t err = buffer->initCheck();
    if (err != NO_ERROR)
    {
      LOGE("Error: %s\n", strerror(-err));
      return ;
    }

    // Retrieve andorid native buffer
    android_native_buffer_t* anb = buffer->getNativeBuffer();

    MLOGI("*************** 5. Create the EGLImage ***************");
    const EGLint attrs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE, EGL_NONE };
    //EGLImageKHR pEGLImage = _eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, (EGLClientBuffer)anb, attrs);
    EGLImageKHR pEGLImage = _eglCreateImageKHR(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, (EGLClientBuffer)anb, attrs);

    if (pEGLImage == EGL_NO_IMAGE_KHR) {
      EGLint error = eglGetError();
      LOGE("Error (%#x): Creating EGLImageKHR at %s:%i\n", error, __FILE__, __LINE__);
    }

    LOGI("*************** 6. Set up the FBO with the EGLImage as target ***************");
    GLuint iFBOTex, iFBO;

    glViewport(0, 0, width, height);
    checkGlError("glViewport");
    /* Initialize FBO texture. */
    glGenTextures(1, &iFBOTex);
    glBindTexture(GL_TEXTURE_2D, iFBOTex);
    /* Set filtering. */
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

    /* Initialize FBOs. */
    glGenFramebuffers(1, &iFBO);
    checkGlError("glGenFramebuffers");

    /* Render to framebuffer object. */
    /* Bind our framebuffer for rendering. */
    glBindFramebuffer(GL_FRAMEBUFFER, iFBO);
    checkGlError("glBindFramebuffer");

    /* Attach texture to the framebuffer. */
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, iFBOTex, NULL);
    checkFrameBufferStatus("glFramebufferTexture2D"); //checkGlError("glFramebufferTexture2D");

    _glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, pEGLImage);
    /* Check FBO is OK. */
    GLenum iResult = glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if(iResult != GL_FRAMEBUFFER_COMPLETE)
    {
      LOGE("Error : Framebuffer incomplete at %s:%i\n", __FILE__, __LINE__);
    }

    /* Unbind framebuffer. */
    glBindFramebuffer(GL_FRAMEBUFFER, 0);


    LOGI("*************** 7. When rendering every frame, bind to the FBO and issue all glCommands, followed by unbind. ***************");
    glBindFramebuffer(GL_FRAMEBUFFER, iFBO);

    /* Set the viewport according to the FBO's texture. */
    glViewport(0, 0, width , height);

    /* Clear screen on FBO. */
    glClearColor(0.5f, 0.5f, 0.5f, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    /*********************************************
      *******************************************/
    glDrawArrays(GL_TRIANGLES, 0, 3);
    checkGlError("glDrawArrays");
    /* And unbind the FrameBuffer Object so subsequent drawing calls are to the EGL window surface. */
    glBindFramebuffer(GL_FRAMEBUFFER,0);


    LOGI("*************** 9. Finally use the following code for reading the buffer out from user space. Something like the following ***************");
    // Just in case the buffer was not created yet
    if (buffer == NULL){
      LOGE("The Buffer is NULL!");
      return;
    }


    void* vaddr;
    // Lock the buffer and retrieve a pointer where we are going to write the data

    buffer->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, &vaddr);
    if (vaddr == NULL)
    {
      buffer->unlock();
      return;
    }

    unsigned char* ucVaddr = (unsigned char*)vaddr;

    bitmap.setPixels(ucVaddr);

    LOGV("Exit test2");
    }

    Output log:

    09-21 10:22:40.415: V/ BitmapRender(16378): Enter test2 (3264 x 2176)
    09-21 10:22:40.415: I/BitmapRender (16378): *************** 3. During egl initialization, get the addresses for the extensions (function pointers) ***************
    09-21 10:22:40.415: I/BitmapRender (16378): onPictureTake call back
    09-21 10:22:40.415: I/BitmapRender (16378): dlopen: SUCCEEDED
    09-21 10:22:40.415: I/BitmapRender (16378): *************** 4. Create the Android Graphic Buffer ***************
    09-21 10:22:40.505: I/BitmapRender (16378): *************** 5. Create the EGLImage ***************
    09-21 10:22:40.530: I/BitmapRender (16378): *************** 6. Set up the FBO with the EGLImage as target ***************
    09-21 10:22:40.530: E/BitmapRender (16378): after glFramebufferTexture2D FLIPBOOM : failed to make complete FrameBuffer object 0
    09-21 10:22:40.530: I/[color=#2E8B57]BitmapRender[/color] (16378): *************** 7. When rendering every frame, bind to the FBO and issue all glCommands, followed by unbind. ***************
    09-21 10:22:40.530: I/[color=#2E8B57]BitmapRender[/color] (16378): *************** 9. Finally use the following code for reading the buffer out from user space. Something like the following ***************
    09-21 10:22:40.530: V/BitmapRender (16378): Exit test2
  • Note: This was originally posted on 21st September 2012 at http://forums.arm.com

    Hi Likai,

      I have tried your above code snippet also on a Galaxy S2 (Android 4.0.4) and have not faced any  issue.  In the above code snippet, you also seem to be checking if the framebuffer is complete. If incomplete, you should get the following in Logcat, but I can't see it in your console log.

    [color=#FF0000][font=Arial, sans-serif][size=2]Framebuffer incomplete at XXX[/size][/font][/color]

    Cheers
    Karthik
  • Note: This was originally posted on 22nd September 2012 at http://forums.arm.com

    Hi KarthikH,

       Sorry!The log output from 'checkFrameBufferStatus' function, but error happened in where.
    I use samsung sIII (I9300 Android 4.0.4) will bring this problem?
    I9300 configuration parameters are as follows:
    [
      GL Version = OpenGL ES 2.0
      GL Vendor = ARM
      GL Renderer = Mali-400 MP
      GL Extensions =
          GL_OES_texture_npot    GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives  GL_OES_EGL_image GL_OES_depth24 GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth_texture    GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 GL_EXT_blend_minmax    GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_rgb8_rgba8    GL_EXT_multisampled_render_to_texture GL_EXT_discard_framebuffer
    ]

    'glGenTexutres' and 'glGenFramebuffers' function need to call after 'eglCreaeteContext', and 'eglMakeCurrent' function to run?

    On my I9300 'eglCreatePbufferSurface' and use 'glReadPixels' to get the pixel data is entirely feasible, so I think it must in after the initialization EGLDisplay, EGLSurface and EGLContext before use of texture and Framebuffer, is this it?

    my 'checkFrameBufferStatus' function code:


    static void checkFrameBufferStatus(const char* op)
    {
    GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
    switch (status)
    {
    case GL_FRAMEBUFFER_COMPLETE:
      LOGI("after %s FLIPBOOM : FBO complete GL_FRAMEBUFFER_COMPLETE %x", op, status);
      break;
    case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
      LOGI("after %s FLIPBOOM : FBO GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT  %x", op, status);
      break;
    case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
      LOGI("after %s FLIPBOOM : FBO FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT %x", op, status);
      break;
    case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
      LOGI("after %s FLIPBOOM : FBO FRAMEBUFFER_INCOMPLETE_DIMENSIONS  %x", op, status);
      break;
    case GL_FRAMEBUFFER_UNSUPPORTED:
      LOGI("after %s FLIPBOOM : FBO GL_FRAMEBUFFER_UNSUPPORTED  %x", op, status);
      break;
    default :
      LOGE("after %s FLIPBOOM : failed to make complete FrameBuffer object %x", op, status);
      break;
    }
    }