title: Adreno 220 GLSL bug
body: <p>We experience issue with GLSL alpha testing on <em>Sony Xperia S</em> phone with <em>Adreno 220</em> GPU. Device is running Android 4.0.4.</p>
  
  <p>On <em>Adreno 200, Adreno 205, Adreno 225</em> as well as <em>Tegra2</em>, <em>Mali400</em> and <em>PowerVR</em> GPUs it works fine.</p>
  
  <p>Shader code:</p>
  
  <pre><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 &lt; 0.5){ discard; }
               else { gl_FragColor = base * uBlendColor; }
              }
  </code></pre>
  
  <p>Screenshot of bug:
  <img src="https://i.stack.imgur.com/yv4jA.png" alt="Buggy"></p>
  
  <p>Correct result on other devices:
  <img src="https://i.stack.imgur.com/hOZMG.jpg" alt="Without bug"></p>
  
  <p>Please advise what can cause such visual glitches, ways to find a cause and possible workarounds.</p>
  
  <p><strong>EDIT</strong>: The same bug confirmed for old stock ROMs of HTC Rezound. See my answer for more info.</p>