bug 908232 - step 2 - [WebGL 2.0] Add RASTERIZER_DISCARD tracking - r=jgilbert

This commit is contained in:
Guillaume Abadie 2013-08-22 20:11:40 -04:00
parent e2f8566e17
commit 26127c2eb2
4 changed files with 14 additions and 0 deletions

View File

@ -155,6 +155,7 @@ WebGLContext::WebGLContext()
mScissorTestEnabled = 0;
mDitherEnabled = 1;
mRasterizerDiscardEnabled = 0; // OpenGL ES 3.0 spec p244
// initialize some GL values: we're going to get them from the GL and use them as the sizes of arrays,
// so in case glGetIntegerv leaves them uninitialized because of a GL bug, we would have very weird crashes.
@ -1327,6 +1328,10 @@ WebGLContext::ForceClearFramebufferWithDefaultValues(GLbitfield mask, const bool
gl->fClearStencil(0);
}
if (mRasterizerDiscardEnabled) {
gl->fDisable(LOCAL_GL_RASTERIZER_DISCARD);
}
// Do the clear!
gl->fClear(mask);
@ -1334,6 +1339,10 @@ WebGLContext::ForceClearFramebufferWithDefaultValues(GLbitfield mask, const bool
if (mScissorTestEnabled)
gl->fEnable(LOCAL_GL_SCISSOR_TEST);
if (mRasterizerDiscardEnabled) {
gl->fEnable(LOCAL_GL_RASTERIZER_DISCARD);
}
// Restore GL state after clearing.
if (initializeColorBuffer) {
if (drawBuffersIsEnabled) {

View File

@ -782,6 +782,7 @@ public:
private:
// State tracking slots
realGLboolean mDitherEnabled;
realGLboolean mRasterizerDiscardEnabled;
realGLboolean mScissorTestEnabled;
bool ValidateCapabilityEnum(WebGLenum cap, const char* info);

View File

@ -24,6 +24,8 @@ WebGLContext::Clear(WebGLbitfield mask)
if (mask == 0) {
GenerateWarning("Calling gl.clear(0) has no effect.");
} else if (mRasterizerDiscardEnabled) {
GenerateWarning("Calling gl.clear() with RASTERIZER_DISCARD enabled has no effects.");
}
if (mBoundFramebuffer) {

View File

@ -552,6 +552,8 @@ WebGLContext::GetStateTrackingSlot(WebGLenum cap)
return &mScissorTestEnabled;
case LOCAL_GL_DITHER:
return &mDitherEnabled;
case LOCAL_GL_RASTERIZER_DISCARD:
return &mRasterizerDiscardEnabled;
}
return nullptr;