Bug 736123 - short-term fix: blacklist adreno using the global GLContext to get renderer info - r=bgirard, a=lsblakk
authorBenoit Jacob <bjacob@mozilla.com>
Tue, 08 May 2012 15:55:52 -0400
changeset 95730 2a085bd1c43a31b0b863409b77e0fdd2a37eff5a
parent 95729 104b56122486b7161e7520898cffb2c9d067f7f1
child 95731 ed1123c5969aaba55d0671956ee43b1ed7ee6572
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgirard, lsblakk
bugs736123
milestone14.0a2
Bug 736123 - short-term fix: blacklist adreno using the global GLContext to get renderer info - r=bgirard, a=lsblakk It really works, but it's not future-proof as it relies on the global GL context that's going away soon. But it probably won't go away in Aurora 14, so this should at least allow us to ship Fennec 14. Longer term, we need to do some message passing so we can get the LayerManager's OpenGL context's renderer id, from the OMTC thread.
content/canvas/src/WebGLContext.cpp
content/canvas/src/WebGLContextValidate.cpp
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -496,16 +496,51 @@ WebGLContext::SetDimensions(PRInt32 widt
     // allow forcing GL and not EGL/ANGLE
     if (PR_GetEnv("MOZ_WEBGL_FORCE_OPENGL")) {
         preferEGL = false;
         useANGLE = false;
         useOpenGL = true;
     }
 #endif
 
+
+#ifdef ANDROID
+    // bug 736123, blacklist WebGL on Adreno
+    //
+    // The Adreno driver in WebGL context creation, specifically in the first MakeCurrent
+    // call on the newly created OpenGL context.
+    //
+    // Notice that we can't rely on GfxInfo for this blacklisting,
+    // as GfxInfo on Android currently doesn't know the GL strings, which are,
+    // AFAIK, the only way to identify Adreno GPUs.
+    //
+    // Somehow, the Layers' OpenGL context creation doesn't crash, and neither does
+    // the global GL context creation. So we currently use the Renderer() id from the
+    // global context. This is not future-proof, as the plan is to get rid of the global
+    // context soon with OMTC. We need to replace this by getting the renderer id from
+    // the Layers' GL context, but as with OMTC the LayerManager lives on a different
+    // thread, this will have to involve some message-passing.
+    if (!forceEnabled) {
+        GLContext *globalContext = GLContextProvider::GetGlobalContext();
+        if (!globalContext) {
+            // make sure that we don't forget to update this code once the globalContext
+            // is removed
+            NS_RUNTIMEABORT("No global context anymore? Then you need to update "
+                            "this code, or force-enable WebGL.");
+        }
+        int renderer = globalContext->Renderer();
+        if (renderer == gl::GLContext::RendererAdreno200 ||
+            renderer == gl::GLContext::RendererAdreno205)
+        {
+            LogMessage("WebGL blocked on this Adreno driver!");
+            return NS_ERROR_FAILURE;
+        }
+    }
+#endif
+
     // if we're forcing osmesa, do it first
     if (forceOSMesa) {
         gl = gl::GLContextProviderOSMesa::CreateOffscreen(gfxIntSize(width, height), format);
         if (!gl || !InitAndValidateGL()) {
             LogMessage("OSMesa forced, but creating context failed -- aborting!");
             return NS_ERROR_FAILURE;
         }
         LogMessage("Using software rendering via OSMesa (THIS WILL BE SLOW)");
--- a/content/canvas/src/WebGLContextValidate.cpp
+++ b/content/canvas/src/WebGLContextValidate.cpp
@@ -513,30 +513,16 @@ WebGLContext::InitAndValidateGL()
     if (!gl) return false;
 
     GLenum error = gl->fGetError();
     if (error != LOCAL_GL_NO_ERROR) {
         LogMessage("GL error 0x%x occurred during OpenGL context initialization, before WebGL initialization!", error);
         return false;
     }
 
-#ifdef ANDROID
-    // bug 736123, blacklist WebGL on Adreno because they do not implement
-    // glTexSubImage2D in a way that is safe to expose to WebGL </euphemism>
-    // We don't rely on GfxInfo for this blacklisting, because GfxInfo on Android doesn't know
-    // about GL strings and GL strings are the only way I know to detect Adreno (EGL Vendor only
-    // says 'Android'), and it is not convenient to have to create a GL context before GfxInfo::Init()
-    // is first called.
-    if (gl->Renderer() == gl::GLContext::RendererAdreno200 ||
-        gl->Renderer() == gl::GLContext::RendererAdreno205)
-    {
-        return false;
-    }
-#endif
-
     mMinCapability = Preferences::GetBool("webgl.min_capability_mode", false);
     mDisableExtensions = Preferences::GetBool("webgl.disable-extensions", false);
 
     mActiveTexture = 0;
     mWebGLError = LOCAL_GL_NO_ERROR;
 
     mAttribBuffers.Clear();