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 id21366
push userbjacob@mozilla.com
push dateMon, 24 Oct 2011 03:05:52 +0000
treeherderautoland@182a55b58e01 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs665578
milestone10.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
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);