We experience issue with GLSL alpha testing on Sony Xperia S phone with Adreno 220 GPU. Device is running Android 4.0.4.
On Adreno 200, Adreno 205, Adreno 225 as well as Tegra2, Mali400 and PowerVR GPUs it works fine.
Shader code:
// vertex
uniform highp mat4 uMVPMatrix;
attribute highp vec4 aPosition;
attribute highp vec2 aTextureCoord;
varying mediump vec2 vTextureCoord;
void main() {
gl_Position = uMVPMatrix * aPosition;
vTextureCoord = aTextureCoord;
}
// fragment
precision mediump float;
varying mediump vec2 vTextureCoord;
uniform sampler2D sTexture;
uniform sampler2D sAlpha;
uniform vec4 uBlendColor;
void main() {
vec4 base = texture2D(sTexture, vTextureCoord);
if(texture2D(sAlpha, vTextureCoord).r < 0.5){ discard; }
else { gl_FragColor = base * uBlendColor; }
}
Screenshot of bug:

Correct result on other devices:

Please advise what can cause such visual glitches, ways to find a cause and possible workarounds.
EDIT: The same bug confirmed for old stock ROMs of HTC Rezound. See my answer for more info.
I’ve asked to test app on different firmwares on xda-developers. On some devices it works just fine while on another these is present this visual glitch.
So I conclude that it is related to some bug in OpenGL drivers which is fixed in certain non-stock ROMs.
EDIT: Confirmed it as a bug in old Qualcomm’s Adreno 220 drivers. On HTC Rezound phone (also Adreno 220) with stock 4.0.3 ROM there was the same bug, and it was also present not only in my app but in some games too – missing certain lines or pixels on certain objects. After rooting and installing CM 4.1 bug disappeared.