Commit 0b83323d by Geoff Lang

Perform validation of glClear parameters at the API level.

TRAC #23475 Author: Geoff Lang Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods
parent da507fea
......@@ -2459,15 +2459,7 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
void Context::clear(GLbitfield mask)
{
Framebuffer *framebufferObject = getDrawFramebuffer();
if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE)
{
return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION);
}
ClearParameters clearParams = { 0 };
for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++)
{
clearParams.clearColor[i] = false;
......@@ -2486,10 +2478,9 @@ void Context::clear(GLbitfield mask)
clearParams.scissorEnabled = mState.scissorTest;
clearParams.scissor = mState.scissor;
Framebuffer *framebufferObject = getDrawFramebuffer();
if (mask & GL_COLOR_BUFFER_BIT)
{
mask &= ~GL_COLOR_BUFFER_BIT;
if (framebufferObject->hasEnabledColorAttachment())
{
for (unsigned int i = 0; i < ArraySize(clearParams.clearColor); i++)
......@@ -2501,7 +2492,6 @@ void Context::clear(GLbitfield mask)
if (mask & GL_DEPTH_BUFFER_BIT)
{
mask &= ~GL_DEPTH_BUFFER_BIT;
if (mState.depthStencil.depthMask && framebufferObject->getDepthbufferType() != GL_NONE)
{
clearParams.clearDepth = true;
......@@ -2510,7 +2500,6 @@ void Context::clear(GLbitfield mask)
if (mask & GL_STENCIL_BUFFER_BIT)
{
mask &= ~GL_STENCIL_BUFFER_BIT;
if (framebufferObject->getStencilbufferType() != GL_NONE)
{
rx::RenderTarget *depthStencil = framebufferObject->getStencilbuffer()->getDepthStencil();
......@@ -2527,10 +2516,6 @@ void Context::clear(GLbitfield mask)
}
}
if (mask != 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (!applyRenderTarget(GL_TRIANGLES, true)) // Clips the clear to the scissor rectangle but not the viewport
{
......
......@@ -825,6 +825,18 @@ void __stdcall glClear(GLbitfield mask)
if (context)
{
gl::Framebuffer *framebufferObject = context->getDrawFramebuffer();
if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE)
{
return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION);
}
if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
{
return gl::error(GL_INVALID_VALUE);
}
context->clear(mask);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment