author | Kyle <kfung@mozilla.com> |
Wed, 29 Jul 2015 15:01:26 -0400 | |
changeset 256700 | af87603b35cd762855cb069c283b879ef5847a0f |
parent 256699 | 2e1b414266f1f89ac43aaa5f8ec3025b96d85985 |
child 256701 | 0993bd17c8237fc3b82b082cfc4b28d7798e087a |
push id | 29187 |
push user | cbook@mozilla.com |
push date | Fri, 07 Aug 2015 11:13:32 +0000 |
treeherder | mozilla-central@3e51753a099f [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jgilbert |
bugs | 1136428 |
milestone | 42.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
|
--- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -1363,16 +1363,17 @@ WebGLContext::ForceClearFramebufferWithD { MakeContextCurrent(); bool initializeColorBuffer = 0 != (mask & LOCAL_GL_COLOR_BUFFER_BIT); bool initializeDepthBuffer = 0 != (mask & LOCAL_GL_DEPTH_BUFFER_BIT); bool initializeStencilBuffer = 0 != (mask & LOCAL_GL_STENCIL_BUFFER_BIT); bool drawBuffersIsEnabled = IsExtensionEnabled(WebGLExtensionID::WEBGL_draw_buffers); bool shouldOverrideDrawBuffers = false; + bool usingDefaultFrameBuffer = !mBoundDrawFramebuffer; GLenum currentDrawBuffers[WebGLContext::kMaxColorAttachments]; // Fun GL fact: No need to worry about the viewport here, glViewport is just // setting up a coordinates transformation, it doesn't affect glClear at all. AssertCachedState(); // Can't check cached bindings, as we could // have a different FB bound temporarily. @@ -1380,27 +1381,37 @@ WebGLContext::ForceClearFramebufferWithD gl->fDisable(LOCAL_GL_SCISSOR_TEST); if (initializeColorBuffer) { if (drawBuffersIsEnabled) { GLenum drawBuffersCommand[WebGLContext::kMaxColorAttachments] = { LOCAL_GL_NONE }; - for(int32_t i = 0; i < mGLMaxDrawBuffers; i++) { + for (int32_t i = 0; i < mGLMaxDrawBuffers; i++) { GLint temp; gl->fGetIntegerv(LOCAL_GL_DRAW_BUFFER0 + i, &temp); currentDrawBuffers[i] = temp; if (colorAttachmentsMask[i]) { drawBuffersCommand[i] = LOCAL_GL_COLOR_ATTACHMENT0 + i; } if (currentDrawBuffers[i] != drawBuffersCommand[i]) shouldOverrideDrawBuffers = true; } + + // When clearing the default framebuffer, we must be clearing only + // GL_BACK, and nothing else, or else gl may return an error. We will + // only use the first element of currentDrawBuffers in this case. + if (usingDefaultFrameBuffer) { + gl->Screen()->SetDrawBuffer(LOCAL_GL_BACK); + if (currentDrawBuffers[0] == LOCAL_GL_COLOR_ATTACHMENT0) + currentDrawBuffers[0] = LOCAL_GL_BACK; + shouldOverrideDrawBuffers = false; + } // calling draw buffers can cause resolves on adreno drivers so // we try to avoid calling it if (shouldOverrideDrawBuffers) gl->fDrawBuffers(mGLMaxDrawBuffers, drawBuffersCommand); } gl->fColorMask(1, 1, 1, 1); @@ -1436,18 +1447,23 @@ WebGLContext::ForceClearFramebufferWithD gl->fEnable(LOCAL_GL_SCISSOR_TEST); if (mRasterizerDiscardEnabled) { gl->fEnable(LOCAL_GL_RASTERIZER_DISCARD); } // Restore GL state after clearing. if (initializeColorBuffer) { - if (shouldOverrideDrawBuffers) { - gl->fDrawBuffers(mGLMaxDrawBuffers, currentDrawBuffers); + + if (drawBuffersIsEnabled) { + if (usingDefaultFrameBuffer) { + gl->Screen()->SetDrawBuffer(currentDrawBuffers[0]); + } else if (shouldOverrideDrawBuffers) { + gl->fDrawBuffers(mGLMaxDrawBuffers, currentDrawBuffers); + } } gl->fColorMask(mColorWriteMask[0], mColorWriteMask[1], mColorWriteMask[2], mColorWriteMask[3]); gl->fClearColor(mColorClearValue[0], mColorClearValue[1],