eglCreateImageKHR on Raspberry Pi

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

eglCreateImageKHR on Raspberry Pi

strator
I'm currently working to implement some off-screen image processing using shaders with the help of JogAmp and
framebufffer objects.
This works great the the performance and the memory consumption of Java on the RPi is impressive.
Since I need the processed data back in the CPU I used glReadPixels for the transfer.
However, it turned out that glReadPixes is really slow (no surprise) and so I looked for other approaches
for the transfer. I figured out that eglCreateImageKHR could be a solution for my problem (correct me, if I'm wrong).
I tried now for several days to get eglCreateImageKHR to work but wasn't successfull. All I get is EGL_BAD_PARAMETER
no matter what configuration I use.

Here is a stripped down version of my code:


        ByteBuffer bb = ByteBuffer.allocateDirect(640*480*3);
        IntBuffer ib = Buffers.newDirectIntBuffer(1);

        gl.glGenTextures(1, ib);
        gl.glBindTexture(GL_TEXTURE_2D, ib.get(0));
        System.out.println("texture id: " + ib.get(0));

        gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 640, 480, 0, GL_RGB, GL_UNSIGNED_BYTE, null);

        gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

        gl.glGenerateMipmap(GL_TEXTURE_2D);
        gl.glBindTexture(GL_TEXTURE_2D, 0);
       
        IntBuffer attribList = Buffers.newDirectIntBuffer(new int[] {
            EGLExt.EGL_MATCH_FORMAT_KHR, EGLExt.EGL_FORMAT_RGBA_8888_KHR,
            EGLExt.EGL_GL_TEXTURE_LEVEL_KHR, 0,
            EGLExt.EGL_IMAGE_PRESERVED_KHR, EGL.EGL_TRUE,
            EGL.EGL_TEXTURE_FORMAT, EGL.EGL_TEXTURE_RGB,
            EGL.EGL_TEXTURE_TARGET, EGL.EGL_TEXTURE_2D,
            EGL.EGL_NONE
        });
       
        long eglImage = eglExt.eglCreateImageKHR(display, context.getHandle(), EGLExt.EGL_GL_TEXTURE_2D_KHR, ib.get(0), attribList);
        System.out.println("got EGLimage: " + (eglImage));
        gl.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImage);


Everythink works fine until I try to create the EGLImage. I have tried all possible configuration and attributes but
could not figure out the problem.

Any help would be greatly appreciated!
Torsten
Reply | Threaded
Open this post in threaded view
|

Re: eglCreateImageKHR on Raspberry Pi

gouessej
Administrator
EGLExt.EGL_GL_TEXTURE_2D_KHR or an attribute seems to be considered as a bad parameter in your case, I've just checked in the documentation:
http://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_image_base.txt
http://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_gl_image.txt
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: eglCreateImageKHR on Raspberry Pi

strator
Many thanks for the quick response!

The Raspberry Pi supports both of these EGL extensions (http://elinux.org/RPi_VideoCore_APIs#EGL).

And regarding the attributes: I've tried many different combinations. The error happens also
if I use only EGL_NONE in the attribute list or even no attribute list at all.

From what I've seen in many forum posts, using C/C++ eglCreateImageKHR seems to work.

Reply | Threaded
Open this post in threaded view
|

Re: eglCreateImageKHR on Raspberry Pi

gouessej
Administrator
strator wrote
From what I've seen in many forum posts, using C/C++ eglCreateImageKHR seems to work.
Yes but it doesn't mean that the problem comes from JOGL and even in C/C++, depending on which version of the Pi and the driver, it can be tricky to make some features work.
Julien Gouesse | Personal blog | Website