Deactivate vertex attribute arrays and the program. Seems to fix the crashes on PowerVR.
authorPatrick Walton <pwalton@mozilla.com>
Fri, 10 Feb 2012 23:50:13 -0800
changeset 89124 2a128563daedfa8bc1e2b1b9c312f958255292dc
parent 89123 000c3e42a0dbe7ef75955a55cefaa08ba957fd7d
child 89125 f290028f4842831ac03990fbcb2bd1bef8d0a994
push id22242
push userkgupta@mozilla.com
push dateWed, 14 Mar 2012 15:19:09 +0000
treeherdermozilla-central@936ef50fa498 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Deactivate vertex attribute arrays and the program. Seems to fix the crashes on PowerVR.
mobile/android/base/gfx/LayerRenderer.java
--- a/mobile/android/base/gfx/LayerRenderer.java
+++ b/mobile/android/base/gfx/LayerRenderer.java
@@ -207,38 +207,43 @@ public class LayerRenderer implements GL
         mTextureHandle = GLES20.glGetAttribLocation(mProgram, "aTexCoord");
         mSampleHandle = GLES20.glGetUniformLocation(mProgram, "sTexture");
         mTMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uTMatrix");
 
         int maxTextureSizeResult[] = new int[1];
         GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_SIZE, maxTextureSizeResult, 0);
         mMaxTextureSize = maxTextureSizeResult[0];
 
-        /*
+        // TODO: Move these calls into a separate activate() call that is called before the
+        // underlay and overlay are rendered.
 
         // Add the program to the OpenGL environment
         GLES20.glUseProgram(mProgram);
 
         // Set the transformation matrix
         GLES20.glUniformMatrix4fv(mTMatrixHandle, 1, false, TEXTURE_MATRIX, 0);
 
         // Enable the arrays from which we get the vertex and texture coordinates
         Log.e(LOGTAG, "### Position handle is " + mPositionHandle + ", texture handle is " +
               mTextureHandle + ", last error is " + GLES20.glGetError());
 
-        // FIXME: This crashes PowerVR drivers. Seems that we cannot actually use multiple GL
-        // programs reliably.
         GLES20.glEnableVertexAttribArray(mPositionHandle);
         GLES20.glEnableVertexAttribArray(mTextureHandle);
 
         GLES20.glUniform1i(mSampleHandle, 0);
 
         TextureGenerator.get().fill();
 
-        */
+        // NB: We must deactivate the program to avoid driver crashes on PowerVR.
+        // TODO: Move these calls into a separate deactivate() call that is called after the
+        // underlay and overlay are rendered.
+
+        GLES20.glDisableVertexAttribArray(mTextureHandle);
+        GLES20.glDisableVertexAttribArray(mPositionHandle);
+        GLES20.glUseProgram(0);
     }
 
     public int getMaxTextureSize() {
         return mMaxTextureSize;
     }
 
     public void addLayer(Layer layer) {
         LayerController controller = mView.getController();