Using EGL and openGL rendering to large ImageReader surface, unable to render out of GL_MAX_VIEWPORT_DIMS scrope

I’m trying to draw something with OpenGL ES on the surface of Imagereader. I create EGL context and surface for it. And everything work fine, when the imagereader size is smaller then GL_MAX_VIEWPORT_DIMS, which is 8192 on my device. I can get a good picture form it.

But when the size is large then 8192, like 8224, the output image still leaving some paddding can’t be draw. Here is the output image.

Even if I try to use glViewport(0, 32, width, 8192), the rendering result move offset up, but still can’t over the padding(8192~8224). But glclear command can make the background clear to the target color(In my case, it’s red).

It’s there any way to draw in the pading part of the surface?

Here is my code:


                mImageReader = ImageReader.newInstance(
                        size.getWidth(),
                        size.getHeight(),
                        PixelFormat.RGBA_8888,
//                        PixelFormat.RGB_888,
//                        ImageFormat.JPEG,
                        1);
//                mReaderSurface = new EglWindowSurface(core, mImageReader.getSurface(), null);
                mReaderSurface = core.createWindowSurface2(mImageReader.getSurface());


    public EGLSurface createWindowSurface2(Object surface) {
        if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture)) {
            throw new RuntimeException("invalid surface: " + surface);
        }

        // Create a window surface, and attach it to the Surface we received.
        int[] surfaceAttribs = {
                EGL14.EGL_NONE
        };

        int[] attribList = {
                EGL14.EGL_RED_SIZE, 8,
                EGL14.EGL_GREEN_SIZE, 8,
                EGL14.EGL_BLUE_SIZE, 8,
                EGL14.EGL_ALPHA_SIZE, 8,
                EGL14.EGL_DEPTH_SIZE, 16,
                EGL14.EGL_NONE
        };
        EGLConfig[] configs = new EGLConfig[1];
        int[] numConfigs = new int[1];
        if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
                numConfigs, 0)) {
            Log.e(TAG, "createWindowSurface2: ");
            return null;
        }

        EGLSurface eglSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], surface,
                surfaceAttribs, 0);
        checkEglError("eglCreateWindowSurface");
        if (eglSurface == null) {
            throw new RuntimeException("surface was null");
        }
        return eglSurface;
    }

I don’t know the details of the platform you’re running on or the ImageReader tool you’re using. But it’s worth considering whether the system supports rendering to render targets larger than 8192 pixels in a single dimension at all (at least via EGL + OpenGL ES).

Some values you might query and check:

  • GL_MAX_TEXTURE_SIZE
  • GL_MAX_RENDERBUFFER_SIZE
  • EGL_MAX_PBUFFER_WIDTH
  • EGL_MAX_PBUFFER_HEIGHT
  • EGL_MAX_PBUFFER_PIXELS

If these are all <= 8192, it seems pretty likely that 8k may be a hard limit on that platform.

Cross-ref:

Thanks for your reply.
the GL_MAX_RENDERBUFFER_SIZE is 8192.
So there no way to implement?

If GL_MAX_TEXTURE_SIZE is similarly set, then it’s not looking too promising on the pure OpenGL ES side.
It may be a limitation of your GPU hardware or driver.

Say, which GPU is this on?

I didn’t say that. If there is, you might need to look for platform-specific tricks.

For instance…:

  • if you can have an android.view.Surface which is larger than 8192x8192,
  • if you can only render to an 8192x8192 or smaller size region with OpenGL ES, and
  • if there is a platform-supported method to blit from OpenGL ES render targets to Surface regions outside 8192x8192

then you might be able to get there by rendering 8192x8192 sub-tiles (or even smaller sub-tiles like 2048x2048) in GL-ES, and then blitting them into the correct location on the Surface

…but I have no idea if any of the above “ifs” are true, much less all of them.

Related:

1 Like

Hi photon,
Things has changed, I found out the limit of same device been broken after upgrade to android S, which mean GL_MAX_RENDERBUFFER_SIZE is 16384.
Now I wonder where to config the size. I has the source code of this devices, and I can compile it. But have no idea who and how to config the size.