diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index a5aa7cc22268..415826221f76 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -1034,6 +1034,15 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) } } + mNeedsFakeNoStencil_UserFBs = false; +#ifdef MOZ_WIDGET_COCOA + if (!nsCocoaFeatures::IsAtLeastVersion(10, 12) && + gl->Vendor() == GLVendor::Intel) + { + mNeedsFakeNoStencil_UserFBs = true; + } +#endif + mResetLayer = true; mOptionsFrozen = true; @@ -2112,7 +2121,8 @@ ScopedDrawCallWrapper::ScopedDrawCallWrapper(WebGLContext& 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? @@ -2121,6 +2131,13 @@ ScopedDrawCallWrapper::ScopedDrawCallWrapper(WebGLContext& webgl) } driverDepthTest &= !mWebGL.mNeedsFakeNoDepth; driverStencilTest &= !mWebGL.mNeedsFakeNoStencil; + } else { + if (mWebGL.mNeedsFakeNoStencil_UserFBs && + fb->DepthAttachment().IsDefined() && + !fb->StencilAttachment().IsDefined()) + { + driverStencilTest = false; + } } const auto& gl = mWebGL.gl; diff --git a/dom/canvas/WebGLContext.h b/dom/canvas/WebGLContext.h index b2f6865cba28..7ec9887a8f4e 100644 --- a/dom/canvas/WebGLContext.h +++ b/dom/canvas/WebGLContext.h @@ -1980,6 +1980,7 @@ protected: bool mNeedsFakeNoAlpha; bool mNeedsFakeNoDepth; bool mNeedsFakeNoStencil; + bool mNeedsFakeNoStencil_UserFBs; mutable uint8_t mDriverColorMask; bool mDriverDepthTest; diff --git a/dom/canvas/WebGLContextUtils.cpp b/dom/canvas/WebGLContextUtils.cpp index 87f2e576bf92..99a03fc1330a 100644 --- a/dom/canvas/WebGLContextUtils.cpp +++ b/dom/canvas/WebGLContextUtils.cpp @@ -9,6 +9,7 @@ #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" @@ -805,10 +806,17 @@ WebGLContext::AssertCachedGlobalState() const 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); diff --git a/gfx/gl/MozFramebuffer.cpp b/gfx/gl/MozFramebuffer.cpp index 9dcbefbdf97e..7d3e4ba346d5 100644 --- a/gfx/gl/MozFramebuffer.cpp +++ b/gfx/gl/MozFramebuffer.cpp @@ -53,8 +53,6 @@ MozFramebuffer::Create(GLContext* const gl, const gfx::IntSize& size, 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);