Commit 6898b358 by Corentin Wallez Committed by Commit Bot

FramebufferGL: Fix blit workaround corner case

The SRGB blit workaround had to wrong assumptions: - SRGB blits can have a multisample source. - The woarkound is needed even when the filter is GL_LINEAR in the case where we are doing a RGB -> SRGB or RGB -> SRGB blit. BUG=angleproject:1492 BUG=chromium:658898 Change-Id: I1d89572565a4e23c1c97bdf985bb21a445e898b7 Reviewed-on: https://chromium-review.googlesource.com/409540Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent f58585cb
...@@ -283,12 +283,13 @@ Error FramebufferGL::blit(ContextImpl *context, ...@@ -283,12 +283,13 @@ Error FramebufferGL::blit(ContextImpl *context,
const Framebuffer *sourceFramebuffer = context->getGLState().getReadFramebuffer(); const Framebuffer *sourceFramebuffer = context->getGLState().getReadFramebuffer();
const Framebuffer *destFramebuffer = context->getGLState().getDrawFramebuffer(); const Framebuffer *destFramebuffer = context->getGLState().getDrawFramebuffer();
const FramebufferAttachment *colorReadAttachment = sourceFramebuffer->getReadColorbuffer();
GLsizei readAttachmentSamples = colorReadAttachment->getSamples();
bool needManualColorBlit = false; bool needManualColorBlit = false;
// The manual SRGB blit is only needed to perform correct linear interpolation. We don't // TODO(cwallez) when the filter is LINEAR and both source and destination are SRGB, we
// need to make sure there is SRGB conversion for NEAREST as the values will be copied. // could avoid doing a manual blit.
if (filter != GL_NEAREST)
{
// Prior to OpenGL 4.4 BlitFramebuffer (section 18.3.1 of GL 4.3 core profile) reads: // Prior to OpenGL 4.4 BlitFramebuffer (section 18.3.1 of GL 4.3 core profile) reads:
// When values are taken from the read buffer, no linearization is performed, even // When values are taken from the read buffer, no linearization is performed, even
...@@ -299,9 +300,8 @@ Error FramebufferGL::blit(ContextImpl *context, ...@@ -299,9 +300,8 @@ Error FramebufferGL::blit(ContextImpl *context,
// corresponding to the read buffer is SRGB, the red, green, and blue components are // corresponding to the read buffer is SRGB, the red, green, and blue components are
// converted from the non-linear sRGB color space according [...]. // converted from the non-linear sRGB color space according [...].
{ {
const FramebufferAttachment *readAttachment = sourceFramebuffer->getReadColorbuffer(); bool sourceSRGB = colorReadAttachment != nullptr &&
bool sourceSRGB = colorReadAttachment->getColorEncoding() == GL_SRGB;
readAttachment != nullptr && readAttachment->getColorEncoding() == GL_SRGB;
needManualColorBlit = needManualColorBlit =
needManualColorBlit || (sourceSRGB && mFunctions->isAtMostGL(gl::Version(4, 3))); needManualColorBlit || (sourceSRGB && mFunctions->isAtMostGL(gl::Version(4, 3)));
} }
...@@ -329,13 +329,12 @@ Error FramebufferGL::blit(ContextImpl *context, ...@@ -329,13 +329,12 @@ Error FramebufferGL::blit(ContextImpl *context,
needManualColorBlit = needManualColorBlit =
needManualColorBlit || (destSRGB && mFunctions->isAtMostGL(gl::Version(4, 1))); needManualColorBlit || (destSRGB && mFunctions->isAtMostGL(gl::Version(4, 1)));
} }
}
// Enable FRAMEBUFFER_SRGB if needed // Enable FRAMEBUFFER_SRGB if needed
mStateManager->setFramebufferSRGBEnabledForFramebuffer(true, this); mStateManager->setFramebufferSRGBEnabledForFramebuffer(true, this);
GLenum blitMask = mask; GLenum blitMask = mask;
if (needManualColorBlit && (mask & GL_COLOR_BUFFER_BIT)) if (needManualColorBlit && (mask & GL_COLOR_BUFFER_BIT) && readAttachmentSamples <= 1)
{ {
ANGLE_TRY(mBlitter->blitColorBufferWithShader(sourceFramebuffer, destFramebuffer, ANGLE_TRY(mBlitter->blitColorBufferWithShader(sourceFramebuffer, destFramebuffer,
sourceArea, destArea, filter)); sourceArea, destArea, filter));
......
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