Commit 6be602dc by He Yunchao Committed by Commit Bot

Some improvements for BlitFramebuffer.

This change can 1. Skip color blitting when draw buffers are disabled. 2. Skip depth/stencil blitting when depth/stencil buffer has no image. 3. Return early if possible. 4. Move the logic above from D3D backend to common part. BUG=angleproject:1677 Change-Id: I1662d214b72fb8caa4a95c86d9b8a67984b6071a Reviewed-on: https://chromium-review.googlesource.com/423135 Commit-Queue: Yunchao He <yunchao.he@intel.com> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent d68924e5
......@@ -840,7 +840,31 @@ Error Framebuffer::blit(rx::ContextImpl *context,
GLbitfield mask,
GLenum filter)
{
return mImpl->blit(context, sourceArea, destArea, mask, filter);
GLbitfield blitMask = mask;
// Note that blitting is called against draw framebuffer.
// See the code in gl::Context::blitFramebuffer.
if ((mask & GL_COLOR_BUFFER_BIT) && !hasEnabledDrawBuffer())
{
blitMask &= ~GL_COLOR_BUFFER_BIT;
}
if ((mask & GL_STENCIL_BUFFER_BIT) && mState.getStencilAttachment() == nullptr)
{
blitMask &= ~GL_STENCIL_BUFFER_BIT;
}
if ((mask & GL_DEPTH_BUFFER_BIT) && mState.getDepthAttachment() == nullptr)
{
blitMask &= ~GL_DEPTH_BUFFER_BIT;
}
if (!blitMask)
{
return NoError();
}
return mImpl->blit(context, sourceArea, destArea, blitMask, filter);
}
int Framebuffer::getSamples(const ContextState &state)
......
......@@ -263,38 +263,10 @@ gl::Error FramebufferD3D::blit(ContextImpl *context,
{
const auto &glState = context->getGLState();
const gl::Framebuffer *sourceFramebuffer = glState.getReadFramebuffer();
bool blitRenderTarget = false;
if ((mask & GL_COLOR_BUFFER_BIT) && sourceFramebuffer->getReadColorbuffer() != nullptr &&
mState.getFirstColorAttachment() != nullptr)
{
blitRenderTarget = true;
}
bool blitStencil = false;
if ((mask & GL_STENCIL_BUFFER_BIT) && sourceFramebuffer->getStencilbuffer() != nullptr &&
mState.getStencilAttachment() != nullptr)
{
blitStencil = true;
}
bool blitDepth = false;
if ((mask & GL_DEPTH_BUFFER_BIT) && sourceFramebuffer->getDepthbuffer() != nullptr &&
mState.getDepthAttachment() != nullptr)
{
blitDepth = true;
}
if (blitRenderTarget || blitDepth || blitStencil)
{
const gl::Rectangle *scissor =
glState.isScissorTestEnabled() ? &glState.getScissor() : nullptr;
gl::Error error = blitImpl(sourceArea, destArea, scissor, blitRenderTarget, blitDepth,
blitStencil, filter, sourceFramebuffer);
if (error.isError())
{
return error;
}
}
const gl::Rectangle *scissor = glState.isScissorTestEnabled() ? &glState.getScissor() : nullptr;
ANGLE_TRY(blitImpl(sourceArea, destArea, scissor, (mask & GL_COLOR_BUFFER_BIT) != 0,
(mask & GL_DEPTH_BUFFER_BIT) != 0, (mask & GL_STENCIL_BUFFER_BIT) != 0,
filter, sourceFramebuffer));
return gl::Error(GL_NO_ERROR);
}
......
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