Commit b3c7d39a by Amy Liu Committed by Commit Bot

Align the sample position in blitResolveStencil compute shader

The input coordinates of blitResolveStencil compute shader start from 0,we need to align the sample position to start from 0 if x/y is flipped. Test: dEQP-GLES3.functional.fbo.invalidate.*.unbind_blit_msaa_* Bug: b/159995959 Change-Id: If0c9f5b7cacddbe1a2d7062469a757a63bcc1378 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2392162 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarIan Elliott <ianelliott@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 437a811b
...@@ -239,6 +239,8 @@ void AdjustBlitResolveParametersForPreRotation(SurfaceRotation framebufferAngle, ...@@ -239,6 +239,8 @@ 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]);
...@@ -251,6 +253,10 @@ void AdjustBlitResolveParametersForPreRotation(SurfaceRotation framebufferAngle, ...@@ -251,6 +253,10 @@ 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();
......
...@@ -1678,12 +1678,6 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk, ...@@ -1678,12 +1678,6 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk,
region.imageExtent.width = params.blitArea.width; region.imageExtent.width = params.blitArea.width;
region.imageExtent.height = params.blitArea.height; region.imageExtent.height = params.blitArea.height;
region.imageExtent.depth = 1; region.imageExtent.depth = 1;
if ((params.rotation == SurfaceRotation::Rotated270Degrees) && (params.blitArea.width > 32))
{
// TODO(ianelliott): Figure out why this adjustment is needed
// https://issuetracker.google.com/issues/159995959
region.imageOffset.x += 2;
}
commandBuffer.copyBufferToImage(blitBuffer.get().getBuffer().getHandle(), commandBuffer.copyBufferToImage(blitBuffer.get().getBuffer().getHandle(),
depthStencilImage->getImage(), depthStencilImage->getImage(),
......
...@@ -1225,6 +1225,74 @@ TEST_P(BlitFramebufferTest, MultisampleDepth) ...@@ -1225,6 +1225,74 @@ TEST_P(BlitFramebufferTest, MultisampleDepth)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
} }
// Blit multisample stencil buffer to default framebuffer without prerotaion.
TEST_P(BlitFramebufferTest, BlitMultisampleStencilToDefault)
{
// http://anglebug.com/3496
ANGLE_SKIP_TEST_IF(IsOpenGL() && IsIntel() && IsOSX());
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
GLRenderbuffer colorbuf;
glBindRenderbuffer(GL_RENDERBUFFER, colorbuf.get());
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 128, 128);
GLRenderbuffer depthstencilbuf;
glBindRenderbuffer(GL_RENDERBUFFER, depthstencilbuf.get());
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH24_STENCIL8, 128, 128);
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuf);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
depthstencilbuf);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
depthstencilbuf);
glCheckFramebufferStatus(GL_FRAMEBUFFER);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glFlush();
// Replace stencil to 1.
ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red());
glEnable(GL_STENCIL_TEST);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
glStencilFunc(GL_ALWAYS, 1, 255);
drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.8f);
// Blit multisample stencil buffer to default frambuffer.
GLenum attachments1[] = {GL_COLOR_ATTACHMENT0};
glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, attachments1);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBlitFramebuffer(0, 0, 128, 128, 0, 0, 128, 128, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
// Disable stencil and draw full_screen green color.
ANGLE_GL_PROGRAM(drawGreen, essl3_shaders::vs::Simple(), essl3_shaders::fs::Green());
glDisable(GL_STENCIL_TEST);
drawQuad(drawGreen.get(), essl3_shaders::PositionAttrib(), 0.5f);
// Draw blue color if the stencil is equal to 1.
// If the blit finished successfully, the stencil test should all pass.
ANGLE_GL_PROGRAM(drawBlue, essl3_shaders::vs::Simple(), essl3_shaders::fs::Blue());
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_EQUAL, 1, 255);
drawQuad(drawBlue.get(), essl3_shaders::PositionAttrib(), 0.2f);
// Check the result, especially the boundaries.
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(127, 0, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(50, 0, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(127, 1, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(0, 127, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(127, 127, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(64, 64, GLColor::blue);
ASSERT_GL_NO_ERROR();
}
// Tests clearing a multisampled depth buffer. // Tests clearing a multisampled depth buffer.
TEST_P(BlitFramebufferTest, MultisampleDepthClear) TEST_P(BlitFramebufferTest, MultisampleDepthClear)
{ {
......
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