Search code examples
androidopengl-es-2.0depth-buffer

OpenGL ES 2 on Vivante GPU (Android): depth buffer doesn't work


I have a Samsung Galaxy Tab 3 (Android 4.2.2) and the depth buffer doesn't seem to work. Any other devices are ok. I create the context as follows:

setEGLContextClientVersion(2);
setEGLConfigChooser(new MultisampleConfigChooser(...));

// ...

@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
    mValue = new int[1];

    // Try to find a normal multisample configuration first.
    int[] configSpec = {
            EGL10.EGL_RED_SIZE, 5,
            EGL10.EGL_GREEN_SIZE, 6,
            EGL10.EGL_BLUE_SIZE, 5,
            EGL10.EGL_DEPTH_SIZE, 16,
            // Requires that setEGLContextClientVersion(2) is called on the view.
            EGL10.EGL_RENDERABLE_TYPE, 4 /* EGL_OPENGL_ES2_BIT */,
            EGL10.EGL_SAMPLE_BUFFERS, (!mDisableMultisampling ? 1 : 0)/* true */,
            EGL10.EGL_SAMPLES, (!mDisableMultisampling ? 2 : 0),
            EGL10.EGL_STENCIL_SIZE, 8,
            EGL10.EGL_NONE
    };

    if (!egl.eglChooseConfig(display, configSpec, null, 0, mValue)) {
        // ...
    }

    ...
}

I tried the following things:

  • disable multisampling (no effect)
  • use 24 bit depth (no effect)
  • glGet(GL_DEPTH_BITS) = 16
  • glIsEnabled(GL_DEPTH_TEST) = true
  • glGet(GL_DEPTH_FUNC) = GL_LESS
  • glGet(GL_DEPTH_WRITEMASK) = 1
  • glGetString(GL_RENDERER) = gc1000 core

Projection matrix is OK (the program works on any other Android device, as well as on iOS).

What might cause the problem?


Solution

  • "User error." Apparently glDepthMask accepts values greater than 1 on every GPU except Vivante. Finding this out and forcing it to 0 or 1 solved the problem.