Bug 697757 - WebGL context fix for alpha being improperly set on OSX. r=jgilbert
authorDoug Sherk <dsherk@mozilla.com>
Mon, 31 Oct 2011 17:49:55 -0700
changeset 79488 4f67677970f214cdcf3770d7096f054d4490404b
parent 79487 9a1f23ae9c36f26d511cc43a1699eec97cf83543
child 79489 773e9705c61bb9fed919e051d3cb99a41ecd100d
push id21408
push userkhuey@mozilla.com
push dateTue, 01 Nov 2011 14:32:20 +0000
treeherdermozilla-central@cd9add22f090 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs697757
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 697757 - WebGL context fix for alpha being improperly set on OSX. r=jgilbert If we request alpha and it isn't enabled, or we request it off and it gets enabled, we now fail the pbuffer creation and fall back to FBOs. This is bad for performance but allows us to pass the conformance test in this case.
content/canvas/test/webgl/failing_tests_mac.txt
gfx/thebes/GLContextProviderCGL.mm
--- a/content/canvas/test/webgl/failing_tests_mac.txt
+++ b/content/canvas/test/webgl/failing_tests_mac.txt
@@ -1,14 +1,12 @@
-conformance/context/context-attributes-alpha-depth-stencil-antialias.html
 conformance/context/premultiplyalpha-test.html
 conformance/glsl/misc/glsl-function-nodes.html
 conformance/glsl/misc/glsl-long-variable-names.html
 conformance/glsl/misc/shader-with-256-character-identifier.frag.html
 conformance/glsl/misc/shader-with-long-line.html
 conformance/programs/program-test.html
 conformance/state/gl-object-get-calls.html
-conformance/textures/tex-input-validation.html
 conformance/textures/texture-mips.html
 conformance/textures/texture-npot.html
 conformance/more/conformance/quickCheckAPI-S_V.html
 conformance/more/functions/uniformfBadArgs.html
 conformance/more/functions/uniformiBadArgs.html
--- a/gfx/thebes/GLContextProviderCGL.mm
+++ b/gfx/thebes/GLContextProviderCGL.mm
@@ -492,16 +492,30 @@ CreateOffscreenPBufferContext(const gfxI
     printf_stderr("colorbits: %d alpha: %d depth: %d stencil: %d\n", aFormat.colorBits(), aFormat.alpha, aFormat.depth, aFormat.stencil);
 
     NSOpenGLPixelFormat *pbFormat = [[NSOpenGLPixelFormat alloc]
                                      initWithAttributes:attribs.Elements()];
     if (!pbFormat) {
         return nsnull;
     }
 
+    // If we ask for any of these to be on/off and we get the opposite, we stop
+    // creating a pbuffer and instead create an FBO.
+    GLint alphaBits, depthBits, stencilBits;
+    [pbFormat getValues: &alphaBits forAttribute: NSOpenGLPFAAlphaSize forVirtualScreen: 0];
+    [pbFormat getValues: &depthBits forAttribute: NSOpenGLPFADepthSize forVirtualScreen: 0];
+    [pbFormat getValues: &stencilBits forAttribute: NSOpenGLPFAStencilSize forVirtualScreen: 0];
+    if ((alphaBits && !aFormat.alpha) || (!alphaBits && aFormat.alpha) ||
+        (depthBits && !aFormat.alpha) || (!depthBits && aFormat.depth) ||
+        (stencilBits && !aFormat.stencil) || (!stencilBits && aFormat.stencil)) 
+    {
+        [pbFormat release];
+        return nsnull;
+    }
+
     NSOpenGLPixelBuffer *pb = [[NSOpenGLPixelBuffer alloc]
                                initWithTextureTarget:LOCAL_GL_TEXTURE_2D
                                textureInternalFormat:(aFormat.alpha ? LOCAL_GL_RGBA : LOCAL_GL_RGB)
                                textureMaxMipMapLevel:0
                                pixelsWide:aSize.width
                                pixelsHigh:aSize.height];
     if (!pb) {
         [pbFormat release];