Bug Hunting on Android …

While fixing JOGL for Android,
Rami and I are testing the code against the consumer devices:

  1. Asus Transformer, Android 3.2, NV Tegra2
  2. Samsung Galaxy Tab 10.1, Android 3.1, NV Tegra2
  3. Samsung Galaxy S2, Android 2.3, ARM Mali 400 MP
  4. Samsung Galaxy S1, Android 2.3, Omap 34xx

We have expected glitches in the OpenGL drivers and/or Android environment
and even found bugs which does not exist on a similar device, ie device 1 and 2.

Device 3 works absolutely flawless, kudos to the ARM developer
of the MALI silicon and it’s drivers! No workaround is necessary and our demos worked
straight out of the box, even w/ multisampling enabled.

Device 4 shows flickering on all demos, where the FPS value
is always just around 18-23, hence below V-Sync.
We actually have no clue why, since device 3 works perfect. Since both devices are mostly equal
but it’s GPU .. we must assume it’s about the Omap3 driver.

The Tegra2 devices gave us quite a headache 🙁

Device 1 and 2 (hence Tegra2) exposes the following bugs:

  • discard in fragment shader freezes the GLSL compiler
  • mixing sampler2D w/ a non texture code path let’s GLSL compiler result in error
    P1202 Texture's gl states do not match with shader's

Device 2 also exposes an interesting bug not available on the other Tegra2 device,
which rendered all our demos invisible, ie. resulting in a blank screen, where only the clear color was shown.
Hunting down this one took also quite a while, but after stumbling over NV’s PerfHud ES and some hints about how to enable it on consumer devices the culprit was found.
The GLState Viewer exposed that our uniform mat4 mgl_PMVMatrix[2]; wasn’t set via glUniformMatrix4fv(..), probably a bug within the OpenGL ES 2.0 driver code.
Actually device 1 and 2’s libGLESv2_tegra.so differ where the other EGL/GL driver files are the same. However, replacing it did not do the trick.

Replacing the mat4 array with a simple uniform mat4 mgl_PMVMatrix; did the trick, ofc we need a better workaround for this case.

Update: The mat4 array bug turns out to be Android 3.0 Dalvik Issue 16434. A simple workaround for our PMVMatrix is submitted.

Further more Tegra2 doesn’t support the old fashioned MSAA, but their own new extension
EGL_NV_coverage_sample, to which we will have to revert to in our multisample GLCapabilties.