I want to use eglimage as texture my linux platform using Mali400.
But the result image is not correct.
-------------------------------------------------------------my source-------------------------------------------------------------------------
glGenTextures(1, texID);
glActiveTexture(GL_TEXTURE0);glBindTexture(GL_TEXTURE_2D, texID[0]);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
#if 0 //===> It's OK ----------------glTexImage2d case OK---------------------
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB, img_width, img_height,0,GL_RGB,GL_UNSIGNED_BYTE,imgBuf)
#else //===> it's not OK ----------------eglimage case Fail---------------------
//set teximage
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB, img_width, img_height,0,GL_RGB,GL_UNSIGNED_BYTE,NULL);
//create
eglimage = eglCreateImageKHR( pStatics->sEGLInfo.sEGLDisplay, pStatics->sEGLInfo.sEGLContext,
EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer) texID[0], NULL);
//update eglimage data from texture data
EGLint attribs_rgb[] = { MALI_EGL_IMAGE_PLANE, MALI_EGL_IMAGE_PLANE_RGB, MALI_EGL_IMAGE_MIPLEVEL, 0, MALI_EGL_IMAGE_ACCESS_MODE, MALI_EGL_IMAGE_ACCESS_READ_WRITE, EGL_NONE };
mali_egl_image *img = mali_egl_image_lock_ptr( eglimage );void *rgb = mali_egl_image_map_buffer( img, attribs_rgb );MEMCPY( rgb, pdata, width*height*3);mali_egl_image_unmap_buffer( img, attribs_rgb );
//connect eglimage to texture
glEGLImageTargetTexture2DOES( GL_TEXTURE_2D, (GLeglImageOES)eglImage);
//destroy
eglDestroyImageKHR(pStatics->sEGLInfo.sEGLDisplay, eglImage);
#endif
----------------------------------------------------------------------------------------------------------------------------------------
I checked there are no egl_error, gl_error, egl_image_error through eglGetError(), glGetError(), mali_egl_image_get_error().
I don't know how to update eglImage exactly.
Can I get some information to solve this problem?
Hi jenner,
I notice in the TexImage2D case you pass "imgbuf" as the data, but in the second case you pass "pdata", is there any significance to this? Are they the same data?
Thanks,
Chris
Hi Chris,
"padta" and "imgBuf" are the same data.
Thnaks,
jenner
Hi Jenner,
Nothing obvious is coming to mind... Does the target support OES_EGL_image as well as OES_EGL_image_external?
Anyway, Thanks for your reply. I think I'll have to search for another solution.
No problem. I have had a word with the driver guys about this though. Using the mali_egl_image interface gives you full access to the internal texture data, but this means you have to consider that the driver does not necessarily store textures in a way you would expect. It might use diferent pitch, layout, or change the format of the texture for a faster runtime experience. In this case it's block interleaved for cache friendliness, and might even store as RGBx8888. Even if there is no explicit error, its likely you have not correctly matched the internal format of the texture. The driver guys have this to say:
"To ensure the texture is stored in an expected layout, I suggest basing the EGL Image on a EGL Pixmap instead of a GLES texture. That way, the layout of the texture is locked to what the windowing system expects it is. If you work on linux fbdev, the mali DDK supports a really simple pixmap structure that will be stored in a straightforward linear manner. If you work on an android platform, the Android DDK defines how android native buffers are laid out. So even if there is no error involved, you may not be writing data in the way that the DDK expects it to behave. Basing yourself on an EGL Pixmap should resolve this."
Also: "That call to glEGLImageTargetTexture2DOES is strange given your use case. You created a new GLES texture object, then you created an EGL Image based on this GLES texture object. At that point, the GLES texture object is an EGL Image sibling. Any change happening to the EGL Image will be reflected in the GLES texture object. By calling glEGLImageTargetTexture2DOES you explicitly state that the GLES texture object should be reset, delete every data inside it, and instead have it be a sibling of the input EGL Image. That's a bit puzzling, because it already is an EGL sibling. Unless you did some glBindTexture inbetween.
Hope this helps,
Thanks for your detailed information. EGLPixmap + EGLImage + shared memory solution is working well.
This solution is a just right what I wanted. Thank you very much.
Can you please show some sample code on how you implemented the EGLPixmap + EGLImage + shared memory solution? I'm trying to do the same thing where I create the image in one process and render it in another process and i need some help.
Thanks
Ony