Bug 1258036 - Separate global state checks from fb-specific checks. - r=jrmuizel

This commit is contained in:
Jeff Gilbert 2016-05-31 14:44:46 -07:00
Родитель 140a910bc3
Коммит b2883162ea
3 изменённых файлов: 28 добавлений и 26 удалений

Просмотреть файл

@ -984,6 +984,9 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
mOptions.antialias = gl->Caps().antialias;
//////
// Initial setup.
MakeContextCurrent();
gl->fViewport(0, 0, mWidth, mHeight);
@ -991,20 +994,13 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
mViewportHeight = mHeight;
gl->fScissor(0, 0, mWidth, mHeight);
// Make sure that we clear this out, otherwise
// we'll end up displaying random memory
gl->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
//////
// Check everything
AssertCachedBindings();
AssertCachedState();
// Clear immediately, because we need to present the cleared initial
// buffer.
mBackbufferNeedsClear = true;
ClearBackbufferIfNeeded();
mShouldPresent = true;
AssertCachedGlobalState();
MOZ_ASSERT(gl->Caps().color);
@ -1020,8 +1016,14 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
MOZ_ASSERT(gl->Caps().antialias == mOptions.antialias);
MOZ_ASSERT(gl->Caps().preserve == mOptions.preserveDrawingBuffer);
AssertCachedBindings();
AssertCachedState();
//////
// Clear immediately, because we need to present the cleared initial buffer
mBackbufferNeedsClear = true;
ClearBackbufferIfNeeded();
mShouldPresent = true;
//////
reporter.SetSuccessful();
@ -1416,8 +1418,7 @@ WebGLContext::ForceClearFramebufferWithDefaultValues(GLbitfield clearBits,
// 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.
AssertCachedGlobalState();
// Prepare GL state for clearing.
gl->fDisable(LOCAL_GL_SCISSOR_TEST);

Просмотреть файл

@ -376,7 +376,7 @@ public:
bool TryToRestoreContext();
void AssertCachedBindings();
void AssertCachedState();
void AssertCachedGlobalState();
dom::HTMLCanvasElement* GetCanvas() const { return mCanvasElement; }

Просмотреть файл

@ -684,7 +684,7 @@ WebGLContext::AssertCachedBindings()
AssertUintParamCorrect(gl, LOCAL_GL_VERTEX_ARRAY_BINDING, bound);
}
// Bound object state
// Framebuffers
if (IsWebGL2()) {
GLuint bound = mBoundDrawFramebuffer ? mBoundDrawFramebuffer->mGLName
: 0;
@ -699,6 +699,15 @@ WebGLContext::AssertCachedBindings()
AssertUintParamCorrect(gl, LOCAL_GL_FRAMEBUFFER_BINDING, bound);
}
GLint stencilBits = 0;
if (GetStencilBits(&stencilBits)) { // Depends on current draw framebuffer.
const GLuint stencilRefMask = (1 << stencilBits) - 1;
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_REF, stencilRefMask, mStencilRefFront);
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_BACK_REF, stencilRefMask, mStencilRefBack);
}
// Program
GLuint bound = mCurrentProgram ? mCurrentProgram->mGLName : 0;
AssertUintParamCorrect(gl, LOCAL_GL_CURRENT_PROGRAM, bound);
@ -730,7 +739,7 @@ WebGLContext::AssertCachedBindings()
}
void
WebGLContext::AssertCachedState()
WebGLContext::AssertCachedGlobalState()
{
#ifdef DEBUG
MakeContextCurrent();
@ -771,14 +780,6 @@ WebGLContext::AssertCachedState()
AssertUintParamCorrect(gl, LOCAL_GL_STENCIL_CLEAR_VALUE, mStencilClearValue);
GLint stencilBits = 0;
if (GetStencilBits(&stencilBits)) {
const GLuint stencilRefMask = (1 << stencilBits) - 1;
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_REF, stencilRefMask, mStencilRefFront);
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_BACK_REF, stencilRefMask, mStencilRefBack);
}
// GLES 3.0.4, $4.1.4, p177:
// [...] the front and back stencil mask are both set to the value `2^s - 1`, where
// `s` is greater than or equal to the number of bits in the deepest stencil buffer