Commit 22aba328 by Geoff Lang Committed by Commit Bot

Don't write alpha when blitting to a framebuffer with emulated alpha.

Emulated alpha framebuffers should never modify the alpha channel. Our blitting code didn't take this property into account. TEST=conformance2/rendering/blitframebuffer-resolve-to-back-buffer.html BUG=angleproject:4645 Change-Id: I1797934df7e7aa520bacfba8a379f6545e38753e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2210023Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarJames Darpinian <jdarpinian@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 585e3555
......@@ -398,7 +398,8 @@ angle::Result BlitGL::blitColorBufferWithShader(const gl::Context *context,
const gl::Framebuffer *dest,
const gl::Rectangle &sourceAreaIn,
const gl::Rectangle &destAreaIn,
GLenum filter)
GLenum filter,
bool writeAlpha)
{
ANGLE_TRY(initializeResources(context));
......@@ -488,6 +489,9 @@ angle::Result BlitGL::blitColorBufferWithShader(const gl::Context *context,
ANGLE_TRY(scopedState.enter(context, destArea, ScopedGLState::KEEP_SCISSOR));
scopedState.willUseTextureUnit(context, 0);
// Set the write color mask to potentially not write alpha
mStateManager->setColorMask(true, true, true, writeAlpha);
// Set uniforms
mStateManager->activeTexture(0);
mStateManager->bindTexture(gl::TextureType::_2D, textureId);
......
......@@ -69,7 +69,8 @@ class BlitGL : angle::NonCopyable
const gl::Framebuffer *dest,
const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
GLenum filter);
GLenum filter,
bool writeAlpha);
angle::Result copySubTexture(const gl::Context *context,
TextureGL *source,
......
......@@ -767,6 +767,13 @@ angle::Result FramebufferGL::blit(const gl::Context *context,
needManualColorBlit || (destSRGB && functions->isAtMostGL(gl::Version(4, 1)));
}
// If the destination has an emulated alpha channel, we need to blit with a shader with alpha
// writes disabled.
if (mHasEmulatedAlphaAttachment)
{
needManualColorBlit = true;
}
// Enable FRAMEBUFFER_SRGB if needed
stateManager->setFramebufferSRGBEnabledForFramebuffer(context, true, this);
......@@ -775,7 +782,8 @@ angle::Result FramebufferGL::blit(const gl::Context *context,
{
BlitGL *blitter = GetBlitGL(context);
ANGLE_TRY(blitter->blitColorBufferWithShader(context, sourceFramebuffer, destFramebuffer,
sourceArea, destArea, filter));
sourceArea, destArea, filter,
!mHasEmulatedAlphaAttachment));
blitMask &= ~GL_COLOR_BUFFER_BIT;
}
......
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