Question

Machine is Freescale iMX53, my program creates many images with a call like this:

EGLint attr[] = {
    EGL_WIDTH,            720,
    EGL_HEIGHT,           576,
    EGL_IMAGE_FORMAT_FSL, EGL_FORMAT_YUV_YV12_FSL,
    EGL_NONE
};

img = eglCreateImageKHR(egl_display, EGL_NO_CONTEXT, EGL_NEW_IMAGE_FSL, NULL, attr);

Later a call like this gets the details (physical/virtual addresses, stride) of the allocated image:

eglQueryImageFSL(egl_display, img, EGL_CLIENTBUFFER_TYPE_FSL, (EGLint *)&info);

iMX53 runs EGL 1.4 and OpenGL ES 2.0. It appears to me (by investigating the stride value) that eglCreateImageKHR(...) is capable of allocating image width with a multiple of 32 only, which is absolutely bad in my case. Unfortunately I can't use glTexImage2D and friends due to the performance penalty they cause.

Can I make somehow eglCreateImageKHR(...) avoid using 32-byte multiples, or even force it to use 4/8/16 byte align? 16-byte align would also be sufficient for me. I'm not using Android, just a 2.6.35.4 kernel and OpenGL ES / EGL libraries with a custom linux distro.

Was it helpful?

Solution

I looked at my implementation on the Freescale iMX53 and you are right - eglCreateImageKHR() requires the texture dimensions to be multiples of at least 32 pixels (not bytes). In fact, my code rounds the width up to a multiple of 64.

I believe this is a requirement of the AMD Z430, which is the GPU. My solution was to just allocate the worst case size of 1920 x 1088 once and use those textures for all video formats, since their EGL does not allow resizing anyway. Use the texture coordinates to compensate for smaller formats, like this:

static GLfloat gafTexCoords[] =
{
    0.0f, 1.0f,
    1.0f, 1.0f,
    1.0f, 0.0f,
    0.0f, 0.0f
};

iTextureWidth = (iOriginalTextureWidth + 63) & ~63;
iTextureHeight = (iOriginalTextureHeight + 31) & ~31;

gafTexCoords[2] = gafTexCoords[4] = (GLfloat)iOriginalTextureWidth / (GLfloat)iTextureWidth;
gafTexCoords[1] = gafTexCoords[3] = (GLfloat)iOriginalTextureHeight / (GLfloat)iTextureHeight;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top