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,77 +620,44 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint ...@@ -620,77 +620,44 @@ 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()) gl::FramebufferAttachment *readBuffer = readFramebuffer->getAttachment(attachments[i]);
{ gl::FramebufferAttachment *drawBuffer = drawFramebuffer->getAttachment(attachments[i]);
context->recordError(Error(GL_INVALID_OPERATION));
return false;
}
if (readDepthBuffer->getSamples() > 0 && !sameBounds) if (readBuffer && drawBuffer)
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
}
if (fromAngleExtension)
{ {
if (IsPartialBlit(context, readDepthBuffer, drawDepthBuffer, if (readBuffer->getActualFormat() != drawBuffer->getActualFormat())
srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1))
{ {
ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); context->recordError(Error(GL_INVALID_OPERATION));
context->recordError(Error(GL_INVALID_OPERATION)); // only whole-buffer copies are permitted
return false; return false;
} }
if (readDepthBuffer->getSamples() != 0 || drawDepthBuffer->getSamples() != 0) if (readBuffer->getSamples() > 0 && !sameBounds)
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; 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));
return false;
}
if (readStencilBuffer->getSamples() > 0 && !sameBounds) if (fromAngleExtension)
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
}
if (fromAngleExtension)
{
if (IsPartialBlit(context, readStencilBuffer, drawStencilBuffer,
srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1))
{ {
ERR("Only whole-buffer depth and stencil blits are supported by this implementation."); if (IsPartialBlit(context, readBuffer, drawBuffer,
context->recordError(Error(GL_INVALID_OPERATION)); // only whole-buffer copies are permitted srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1))
return false; {
} ERR("Only whole-buffer depth and stencil blits are supported by this implementation.");
context->recordError(Error(GL_INVALID_OPERATION)); // only whole-buffer copies are permitted
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;
}
} }
} }
} }
......
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