Commit 83c7e1ae by Amy Liu Committed by Commit Bot

Fix the regression of color blit.

Move the offset aligning code to stencilBlitResolveNoShaderExport to avoid affecting color blit. Test: dEQP-GLES3.functional.fbo.blit.default_framebuffer.*_linear_* Bug: angleproject:5044 Change-Id: Ic2ebef94091853146424d567b0035161611ba32d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2416008 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent 3b8c957e
...@@ -239,8 +239,6 @@ void AdjustBlitResolveParametersForPreRotation(SurfaceRotation framebufferAngle, ...@@ -239,8 +239,6 @@ void AdjustBlitResolveParametersForPreRotation(SurfaceRotation framebufferAngle,
ASSERT(!params->flipX && params->flipY); ASSERT(!params->flipX && params->flipY);
params->flipX = true; params->flipX = true;
params->flipY = false; params->flipY = false;
// Align the offset.
--params->srcOffset[0];
break; break;
case SurfaceRotation::Rotated270Degrees: case SurfaceRotation::Rotated270Degrees:
std::swap(params->stretch[0], params->stretch[1]); std::swap(params->stretch[0], params->stretch[1]);
...@@ -253,10 +251,6 @@ void AdjustBlitResolveParametersForPreRotation(SurfaceRotation framebufferAngle, ...@@ -253,10 +251,6 @@ void AdjustBlitResolveParametersForPreRotation(SurfaceRotation framebufferAngle,
ASSERT(!params->flipX && !params->flipY); ASSERT(!params->flipX && !params->flipY);
params->flipX = true; params->flipX = true;
params->flipY = true; params->flipY = true;
// Align the offset, or the sample position near the edge will be wrong.
--params->srcOffset[0];
--params->srcOffset[1];
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
......
...@@ -1560,25 +1560,27 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk, ...@@ -1560,25 +1560,27 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk,
case SurfaceRotation::Rotated180Degrees: case SurfaceRotation::Rotated180Degrees:
if (isResolve) if (isResolve)
{ {
shaderParams.offset.resolve[0] += params.rotatedOffsetFactor[0]; // Align the offset with minus 1, or the sample position near the edge will be
// wrong.
shaderParams.offset.resolve[0] += params.rotatedOffsetFactor[0] - 1;
shaderParams.offset.resolve[1] += params.rotatedOffsetFactor[1]; shaderParams.offset.resolve[1] += params.rotatedOffsetFactor[1];
} }
else else
{ {
shaderParams.offset.blit[0] += params.rotatedOffsetFactor[0]; shaderParams.offset.blit[0] += params.rotatedOffsetFactor[0] - 1;
shaderParams.offset.blit[1] += params.rotatedOffsetFactor[1]; shaderParams.offset.blit[1] += params.rotatedOffsetFactor[1];
} }
break; break;
case SurfaceRotation::Rotated270Degrees: case SurfaceRotation::Rotated270Degrees:
if (isResolve) if (isResolve)
{ {
shaderParams.offset.resolve[0] += params.rotatedOffsetFactor[0]; shaderParams.offset.resolve[0] += params.rotatedOffsetFactor[0] - 1;
shaderParams.offset.resolve[1] += params.rotatedOffsetFactor[1]; shaderParams.offset.resolve[1] += params.rotatedOffsetFactor[1] - 1;
} }
else else
{ {
shaderParams.offset.blit[0] += params.rotatedOffsetFactor[0]; shaderParams.offset.blit[0] += params.rotatedOffsetFactor[0] - 1;
shaderParams.offset.blit[1] += params.rotatedOffsetFactor[1]; shaderParams.offset.blit[1] += params.rotatedOffsetFactor[1] - 1;
} }
shaderParams.rotateXY = 1; shaderParams.rotateXY = 1;
break; break;
......
...@@ -1248,6 +1248,63 @@ TEST_P(EGLPreRotationBlitFramebufferTest, BlitColorWithFlip) ...@@ -1248,6 +1248,63 @@ TEST_P(EGLPreRotationBlitFramebufferTest, BlitColorWithFlip)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
} }
// Blit color buffer to default framebuffer with linear filter.
TEST_P(EGLPreRotationBlitFramebufferTest, BlitColorWithLinearFilter)
{
// http://anglebug.com/4453
ANGLE_SKIP_TEST_IF(isVulkanRenderer() && IsLinux() && IsIntel());
// Flaky on Linux SwANGLE http://anglebug.com/4453
ANGLE_SKIP_TEST_IF(IsLinux() && isSwiftshader());
setWindowVisible(mOSWindow, true);
initializeDisplay();
initializeSurfaceWithRGBA8888Config();
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
ASSERT_EGL_SUCCESS();
mOSWindow->setOrientation(300, 400);
angle::Sleep(1000);
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_EGL_SUCCESS();
constexpr int kSize = 128;
glViewport(0, 0, kSize, kSize);
GLRenderbuffer colorbuf;
glBindRenderbuffer(GL_RENDERBUFFER, colorbuf.get());
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 0, GL_RGBA8, kSize, kSize);
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuf);
glCheckFramebufferStatus(GL_FRAMEBUFFER);
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
ANGLE_GL_PROGRAM(gradientProgram, essl31_shaders::vs::Passthrough(),
essl31_shaders::fs::RedGreenGradient());
drawQuad(gradientProgram, essl31_shaders::PositionAttrib(), 0.5f, 1.0f, true);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBlitFramebuffer(0, 0, kSize, kSize, 0, 0, kSize, kSize, GL_COLOR_BUFFER_BIT, GL_LINEAR);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
// Check the result, especially the boundaries.
EXPECT_PIXEL_NEAR(0, 0, 0, 0, 0, 255, 1.0); // Black
EXPECT_PIXEL_NEAR(kSize - 1, 0, 253, 0, 0, 255, 1.0); // Red
EXPECT_PIXEL_NEAR(0, kSize - 1, 0, 253, 0, 255, 1.0); // Green
EXPECT_PIXEL_NEAR(kSize - 1, kSize - 1, 253, 253, 0, 255, 1.0); // Yellow
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_GL_NO_ERROR();
}
// Draw a predictable pattern (for testing pre-rotation) into an FBO, and then use glBlitFramebuffer // Draw a predictable pattern (for testing pre-rotation) into an FBO, and then use glBlitFramebuffer
// to blit the left and right halves of that pattern into various places within the 400x300 window // to blit the left and right halves of that pattern into various places within the 400x300 window
TEST_P(EGLPreRotationBlitFramebufferTest, LeftAndRightBlitFramebuffer) TEST_P(EGLPreRotationBlitFramebufferTest, LeftAndRightBlitFramebuffer)
......
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