зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1258036 - Separate global state checks from fb-specific checks. - r=jrmuizel
This commit is contained in:
Родитель
140a910bc3
Коммит
b2883162ea
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче