Commit 44b422c1 by Dongseong Hwang Committed by Geoff Lang

Unify duplicated code for both depth and stencil buffer in ValidateBlitFramebufferParameters()

Tested with angle_*_tests and WebGL CTS in Chrome Canary on Windows. Passed with no regressions. Change-Id: Ied0a32ea75565ef19b8e87bed8bdd555b74edee3 Reviewed-on: https://chromium-review.googlesource.com/234110Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarDongseong Hwang <dongseong.hwang@intel.com> Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org>
parent 4ed1c450
...@@ -620,58 +620,24 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint ...@@ -620,58 +620,24 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
} }
} }
if (mask & GL_DEPTH_BUFFER_BIT) GLenum masks[] = {GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT};
GLenum attachments[] = {GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT};
for (size_t i = 0; i < 2; i++)
{ {
gl::FramebufferAttachment *readDepthBuffer = readFramebuffer->getDepthbuffer(); if (mask & masks[i])
gl::FramebufferAttachment *drawDepthBuffer = drawFramebuffer->getDepthbuffer();
if (readDepthBuffer && drawDepthBuffer)
{
if (readDepthBuffer->getActualFormat() != drawDepthBuffer->getActualFormat())
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
}
if (readDepthBuffer->getSamples() > 0 && !sameBounds)
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
}
if (fromAngleExtension)
{
if (IsPartialBlit(context, readDepthBuffer, drawDepthBuffer,
srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1))
{ {
ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); gl::FramebufferAttachment *readBuffer = readFramebuffer->getAttachment(attachments[i]);
context->recordError(Error(GL_INVALID_OPERATION)); // only whole-buffer copies are permitted gl::FramebufferAttachment *drawBuffer = drawFramebuffer->getAttachment(attachments[i]);
return false;
}
if (readDepthBuffer->getSamples() != 0 || drawDepthBuffer->getSamples() != 0) if (readBuffer && drawBuffer)
{ {
context->recordError(Error(GL_INVALID_OPERATION)); if (readBuffer->getActualFormat() != drawBuffer->getActualFormat())
return false;
}
}
}
}
if (mask & GL_STENCIL_BUFFER_BIT)
{
gl::FramebufferAttachment *readStencilBuffer = readFramebuffer->getStencilbuffer();
gl::FramebufferAttachment *drawStencilBuffer = drawFramebuffer->getStencilbuffer();
if (readStencilBuffer && drawStencilBuffer)
{
if (readStencilBuffer->getActualFormat() != drawStencilBuffer->getActualFormat())
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; return false;
} }
if (readStencilBuffer->getSamples() > 0 && !sameBounds) if (readBuffer->getSamples() > 0 && !sameBounds)
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; return false;
...@@ -679,7 +645,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint ...@@ -679,7 +645,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
if (fromAngleExtension) if (fromAngleExtension)
{ {
if (IsPartialBlit(context, readStencilBuffer, drawStencilBuffer, if (IsPartialBlit(context, readBuffer, drawBuffer,
srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1)) srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1))
{ {
ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); ERR("Only whole-buffer depth and stencil blits are supported by this implementation.");
...@@ -687,7 +653,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint ...@@ -687,7 +653,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
return false; return false;
} }
if (readStencilBuffer->getSamples() != 0 || drawStencilBuffer->getSamples() != 0) if (readBuffer->getSamples() != 0 || drawBuffer->getSamples() != 0)
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; return false;
...@@ -695,6 +661,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint ...@@ -695,6 +661,7 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
} }
} }
} }
}
return true; return true;
} }
......
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