b=582469; use high precision depth buffer if available (esp with FBOs); r=bjacob
authorVladimir Vukicevic <vladimir@pobox.com>
Wed, 28 Jul 2010 14:24:09 -0700
changeset 48311 5f857be14db9c4db133063774df2baa8c1fc5d24
parent 48310 9b83403b328b50ce7be1bfb4422a2386aac6d423
child 48312 6bd0e6c7fc94e9c07fbeae29fc2643a72d99d71d
push id14680
push uservladimir@mozilla.com
push dateWed, 28 Jul 2010 21:24:35 +0000
treeherdermozilla-central@5f857be14db9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob
bugs582469
milestone2.0b3pre
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
b=582469; use high precision depth buffer if available (esp with FBOs); r=bjacob
gfx/thebes/GLContext.cpp
gfx/thebes/GLDefs.h
--- a/gfx/thebes/GLContext.cpp
+++ b/gfx/thebes/GLContext.cpp
@@ -466,22 +466,16 @@ PRBool
 GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize)
 {
     MakeCurrent();
 
     bool alpha = mCreationFormat.alpha > 0;
     int depth = mCreationFormat.depth;
     int stencil = mCreationFormat.stencil;
 
-#ifdef USE_GLES2
-    const bool isMobile = true;
-#else
-    const bool isMobile = false;
-#endif
-
     bool firstTime = (mOffscreenFBO == 0);
 
     GLuint curBoundTexture = 0;
     GLuint curBoundRenderbuffer = 0;
     GLuint curBoundFramebuffer = 0;
 
     GLint viewport[4];
 
@@ -497,22 +491,26 @@ GLContext::ResizeOffscreenFBO(const gfxI
         fGenTextures(1, &mOffscreenTexture);
         fBindTexture(LOCAL_GL_TEXTURE_2D, mOffscreenTexture);
         fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
         fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
 
         fGenFramebuffers(1, &mOffscreenFBO);
         fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mOffscreenFBO);
 
-        if (depth) {
+        if (depth && stencil && !mIsGLES2) {
             fGenRenderbuffers(1, &mOffscreenDepthRB);
-        }
+        } else {
+            if (depth) {
+                fGenRenderbuffers(1, &mOffscreenDepthRB);
+            }
 
-        if (stencil) {
-            fGenRenderbuffers(1, &mOffscreenStencilRB);
+            if (stencil) {
+                fGenRenderbuffers(1, &mOffscreenStencilRB);
+            }
         }
     } else {
         fBindTexture(LOCAL_GL_TEXTURE_2D, mOffscreenTexture);
         fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mOffscreenFBO);
     }
 
     // resize the FBO components
     if (alpha) {
@@ -526,56 +524,75 @@ GLContext::ResizeOffscreenFBO(const gfxI
                     NULL);
     } else {
         fTexImage2D(LOCAL_GL_TEXTURE_2D,
                     0,
                     LOCAL_GL_RGB,
                     aSize.width, aSize.height,
                     0,
                     LOCAL_GL_RGB,
-                    isMobile ? LOCAL_GL_UNSIGNED_SHORT_5_6_5
+                    mIsGLES2 ? LOCAL_GL_UNSIGNED_SHORT_5_6_5
                              : LOCAL_GL_UNSIGNED_BYTE,
                     NULL);
     }
 
-
-    if (depth) {
+    if (depth && stencil && !mIsGLES2) {
         fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, mOffscreenDepthRB);
         fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
-                             LOCAL_GL_DEPTH_COMPONENT16,
+                             LOCAL_GL_DEPTH24_STENCIL8,
                              aSize.width, aSize.height);
-    }
+    } else {
+        if (depth) {
+            fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, mOffscreenDepthRB);
+            fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
+                                 mIsGLES2 ? LOCAL_GL_DEPTH_COMPONENT16
+                                          : LOCAL_GL_DEPTH_COMPONENT24,
+                                 aSize.width, aSize.height);
+        }
 
-    if (stencil) {
-        fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, mOffscreenStencilRB);
-        fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
-                             LOCAL_GL_STENCIL_INDEX8,
-                             aSize.width, aSize.height);
+        if (stencil) {
+            fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, mOffscreenStencilRB);
+            fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
+                                 LOCAL_GL_STENCIL_INDEX8,
+                                 aSize.width, aSize.height);
+        }
     }
 
     // Now assemble the FBO, if we're creating one
     // for the first time.
     if (firstTime) {
         fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
                               LOCAL_GL_COLOR_ATTACHMENT0,
                               LOCAL_GL_TEXTURE_2D,
                               mOffscreenTexture,
                               0);
-        if (depth) {
+
+        if (depth && stencil && !mIsGLES2) {
             fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
                                      LOCAL_GL_DEPTH_ATTACHMENT,
                                      LOCAL_GL_RENDERBUFFER,
                                      mOffscreenDepthRB);
-        }
-
-        if (stencil) {
             fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
                                      LOCAL_GL_STENCIL_ATTACHMENT,
                                      LOCAL_GL_RENDERBUFFER,
-                                     mOffscreenStencilRB);
+                                     mOffscreenDepthRB);
+        } else {
+            if (depth) {
+                fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
+                                         LOCAL_GL_DEPTH_ATTACHMENT,
+                                         LOCAL_GL_RENDERBUFFER,
+                                         mOffscreenDepthRB);
+            }
+
+            if (stencil) {
+                fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
+                                         LOCAL_GL_STENCIL_ATTACHMENT,
+                                         LOCAL_GL_RENDERBUFFER,
+                                         mOffscreenStencilRB);
+            }
         }
     }
 
     // We should be all resized.  Check for framebuffer completeness.
     GLenum status = fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
     if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
         NS_WARNING("Error resizing offscreen framebuffer -- framebuffer not complete");
         return PR_FALSE;
--- a/gfx/thebes/GLDefs.h
+++ b/gfx/thebes/GLDefs.h
@@ -1872,16 +1872,17 @@ typedef ptrdiff_t GLintptr;
 #define LOCAL_GL_SAMPLE_MASK_VALUE_EXT 0x80AA
 #define LOCAL_GL_SAMPLE_MASK_INVERT_EXT 0x80AB
 #define LOCAL_GL_SAMPLE_PATTERN_EXT 0x80AC
 #define LOCAL_GL_MULTISAMPLE_BIT_EXT 0x20000000
 #define LOCAL_GL_EXT_packed_depth_stencil 1
 #define LOCAL_GL_DEPTH_STENCIL_EXT 0x84F9
 #define LOCAL_GL_UNSIGNED_INT_24_8_EXT 0x84FA
 #define LOCAL_GL_DEPTH24_STENCIL8_EXT 0x88F0
+#define LOCAL_GL_DEPTH24_STENCIL8 0x88F0
 #define LOCAL_GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
 #define LOCAL_GL_EXT_packed_pixels 1
 #define LOCAL_GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032
 #define LOCAL_GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033
 #define LOCAL_GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034
 #define LOCAL_GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035
 #define LOCAL_GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036
 #define LOCAL_GL_EXT_paletted_texture 1