Bug 1427668 - Fixes and spew. - r=daoshengmu
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 22 Dec 2017 03:42:04 -0800
changeset 452363 86488a02187a697b1b49870c93a474e82e7e1404
parent 452362 1626b467a1275b77ceb51f27907091996f1274a4
child 452364 e8afea9b08757dc6a3415ebd38dbd572d1ec7a45
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaoshengmu
bugs1427668
milestone59.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 1427668 - Fixes and spew. - r=daoshengmu MozReview-Commit-ID: 9NPkWsh2rxE
dom/canvas/WebGLContext.cpp
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextUtils.cpp
gfx/gl/MozFramebuffer.cpp
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -1029,16 +1029,25 @@ WebGLContext::SetDimensions(int32_t sign
         if (!mOptions.depth) {
             mNeedsFakeNoDepth = true;
         }
         if (!mOptions.stencil) {
             mNeedsFakeNoStencil = true;
         }
     }
 
+    mNeedsFakeNoStencil_UserFBs = false;
+#ifdef MOZ_WIDGET_COCOA
+    if (!nsCocoaFeatures::IsAtLeastVersion(10, 12) &&
+        gl->Vendor() == GLVendor::Intel)
+    {
+        mNeedsFakeNoStencil_UserFBs = true;
+    }
+#endif
+
     mResetLayer = true;
     mOptionsFrozen = true;
 
     //////
     // Initial setup.
 
     gl->mImplicitMakeCurrent = true;
 
@@ -2107,25 +2116,33 @@ WebGLContext::DoColorMask(const uint8_t 
 ////////////////////////////////////////////////////////////////////////////////
 
 ScopedDrawCallWrapper::ScopedDrawCallWrapper(WebGLContext& webgl)
     : mWebGL(webgl)
 {
     uint8_t driverColorMask = mWebGL.mColorWriteMask;
     bool driverDepthTest    = mWebGL.mDepthTestEnabled;
     bool driverStencilTest  = mWebGL.mStencilTestEnabled;
-    if (!mWebGL.mBoundDrawFramebuffer) {
+    const auto& fb = mWebGL.mBoundDrawFramebuffer;
+    if (!fb) {
         if (mWebGL.mDefaultFB_DrawBuffer0 == LOCAL_GL_NONE) {
             driverColorMask = 0; // Is this well-optimized enough for depth-first
                                  // rendering?
         } else {
             driverColorMask &= ~(uint8_t(mWebGL.mNeedsFakeNoAlpha) << 3);
         }
         driverDepthTest   &= !mWebGL.mNeedsFakeNoDepth;
         driverStencilTest &= !mWebGL.mNeedsFakeNoStencil;
+    } else {
+        if (mWebGL.mNeedsFakeNoStencil_UserFBs &&
+            fb->DepthAttachment().IsDefined() &&
+            !fb->StencilAttachment().IsDefined())
+        {
+            driverStencilTest = false;
+        }
     }
 
     const auto& gl = mWebGL.gl;
     mWebGL.DoColorMask(driverColorMask);
     if (mWebGL.mDriverDepthTest != driverDepthTest) {
         // "When disabled, the depth comparison and subsequent possible updates to the
         //  depth buffer value are bypassed and the fragment is passed to the next
         //  operation." [GLES 3.0.5, p177]
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1975,16 +1975,17 @@ protected:
         return mNumPerfWarnings < mMaxPerfWarnings;
     }
 
     uint64_t mLastUseIndex;
 
     bool mNeedsFakeNoAlpha;
     bool mNeedsFakeNoDepth;
     bool mNeedsFakeNoStencil;
+    bool mNeedsFakeNoStencil_UserFBs;
 
     mutable uint8_t mDriverColorMask;
     bool mDriverDepthTest;
     bool mDriverStencilTest;
 
     bool mNeedsIndexValidation;
 
     const bool mAllowFBInvalidation;
--- a/dom/canvas/WebGLContextUtils.cpp
+++ b/dom/canvas/WebGLContextUtils.cpp
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WebGLContextUtils.h"
 #include "WebGLContext.h"
 
 #include "GLContext.h"
 #include "jsapi.h"
 #include "mozilla/dom/ScriptSettings.h"
+#include "mozilla/gfx/Logging.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Sprintf.h"
 #include "nsIDOMEvent.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIVariant.h"
 #include "nsPrintfCString.h"
 #include "nsServiceManagerUtils.h"
 #include <stdarg.h>
@@ -800,20 +801,27 @@ WebGLContext::AssertCachedGlobalState() 
     // Draw state
     MOZ_ASSERT(gl->fIsEnabled(LOCAL_GL_DITHER) == mDitherEnabled);
     MOZ_ASSERT_IF(IsWebGL2(),
                   gl->fIsEnabled(LOCAL_GL_RASTERIZER_DISCARD) == mRasterizerDiscardEnabled);
     MOZ_ASSERT(gl->fIsEnabled(LOCAL_GL_SCISSOR_TEST) == mScissorTestEnabled);
 
     GLfloat colorClearValue[4] = {0.0f, 0.0f, 0.0f, 0.0f};
     gl->fGetFloatv(LOCAL_GL_COLOR_CLEAR_VALUE, colorClearValue);
-    MOZ_ASSERT(IsCacheCorrect(mColorClearValue[0], colorClearValue[0]) &&
+    const bool ok = IsCacheCorrect(mColorClearValue[0], colorClearValue[0]) &&
                IsCacheCorrect(mColorClearValue[1], colorClearValue[1]) &&
                IsCacheCorrect(mColorClearValue[2], colorClearValue[2]) &&
-               IsCacheCorrect(mColorClearValue[3], colorClearValue[3]));
+               IsCacheCorrect(mColorClearValue[3], colorClearValue[3]);
+    if (!ok) {
+        gfxCriticalNote << mColorClearValue[0] << " - " << colorClearValue[0] << " = " << (mColorClearValue[0] - colorClearValue[0]) << "\n"
+                        << mColorClearValue[1] << " - " << colorClearValue[1] << " = " << (mColorClearValue[1] - colorClearValue[1]) << "\n"
+                        << mColorClearValue[2] << " - " << colorClearValue[2] << " = " << (mColorClearValue[2] - colorClearValue[2]) << "\n"
+                        << mColorClearValue[3] << " - " << colorClearValue[3] << " = " << (mColorClearValue[3] - colorClearValue[3]);
+    }
+    MOZ_ASSERT(ok);
 
     realGLboolean depthWriteMask = 0;
     gl->fGetBooleanv(LOCAL_GL_DEPTH_WRITEMASK, &depthWriteMask);
     MOZ_ASSERT(depthWriteMask == mDepthWriteMask);
 
     GLfloat depthClearValue = 0.0f;
     gl->fGetFloatv(LOCAL_GL_DEPTH_CLEAR_VALUE, &depthClearValue);
     MOZ_ASSERT(IsCacheCorrect(mDepthClearValue, depthClearValue));
--- a/gfx/gl/MozFramebuffer.cpp
+++ b/gfx/gl/MozFramebuffer.cpp
@@ -48,18 +48,16 @@ MozFramebuffer::Create(GLContext* const 
         const ScopedBindRenderbuffer bindRB(gl, colorName);
         gl->fRenderbufferStorageMultisample(colorTarget, samples, LOCAL_GL_RGBA8,
                                             size.width, size.height);
     } else {
         colorTarget = LOCAL_GL_TEXTURE_2D;
         colorName = gl->CreateTexture();
         const ScopedBindTexture bindTex(gl, colorName);
         gl->TexParams_SetClampNoMips();
-        const ScopedBindPBO bindPBO(gl, LOCAL_GL_PIXEL_UNPACK_BUFFER);
-        gl->fBindBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER, 0);
         gl->fTexImage2D(colorTarget, 0, LOCAL_GL_RGBA,
                         size.width, size.height, 0,
                         LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE, nullptr);
     }
 
     const auto err = errorScope.GetError();
     if (err) {
         if (err != LOCAL_GL_OUT_OF_MEMORY) {