Bug 665578 - Use ANGLE's built-in-function-emulation feature on Mac - r=jrmuizel
authorBenoit Jacob <bjacob@mozilla.com>
Sun, 23 Oct 2011 22:46:40 -0400
changeset 79133 182a55b58e0171f0e14e5e750204f6e26299db23
parent 79132 a1b89b4913ca9d9e647eebc4858f695c74b2e2a8
child 79134 0cff4fe76772bcdde4a67f7a32f13a62008df3d3
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjrmuizel
bugs665578
milestone10.0a1
Bug 665578 - Use ANGLE's built-in-function-emulation feature on Mac - r=jrmuizel
content/canvas/src/WebGLContextGL.cpp
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -4037,16 +4037,22 @@ WebGLContext::Viewport(WebGLint x, WebGL
     if (width < 0 || height < 0)
         return ErrorInvalidValue("Viewport: negative size");
 
     MakeContextCurrent();
     gl->fViewport(x, y, width, height);
     return NS_OK;
 }
 
+#ifdef XP_MACOSX
+#define WEBGL_OS_IS_MAC 1
+#else
+#define WEBGL_OS_IS_MAC 0
+#endif
+
 NS_IMETHODIMP
 WebGLContext::CompileShader(nsIWebGLShader *sobj)
 {
     WebGLShader *shader;
     WebGLuint shadername;
     if (!GetConcreteObjectAndGLName("compileShader", sobj, &shader, &shadername))
         return NS_OK;
 
@@ -4088,18 +4094,24 @@ WebGLContext::CompileShader(nsIWebGLShad
         // 7-bit ASCII range, so we can skip the NS_IsAscii() check.
         const nsCString& sourceCString = NS_LossyConvertUTF16toASCII(flatSource);
     
         const PRUint32 maxSourceLength = (PRUint32(1)<<18) - 1;
         if (sourceCString.Length() > maxSourceLength)
             return ErrorInvalidValue("compileShader: source has more than %d characters", maxSourceLength);
 
         const char *s = sourceCString.get();
-
-        if (!ShCompile(compiler, &s, 1, SH_OBJECT_CODE)) {
+        
+        int compileOptions = SH_OBJECT_CODE;
+        
+        // work around bug 665578
+        if (WEBGL_OS_IS_MAC && gl->Vendor() == gl::GLContext::VendorATI)
+            compileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS;
+
+        if (!ShCompile(compiler, &s, 1, compileOptions)) {
             int len = 0;
             ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &len);
 
             if (len) {
                 nsCAutoString info;
                 info.SetLength(len);
                 ShGetInfoLog(compiler, info.BeginWriting());
                 shader->SetTranslationFailure(info);