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,
ASSERT(!params->flipX && params->flipY);
params->flipX = true;
params->flipY = false;
// Align the offset.
--params->srcOffset[0];
break;
case SurfaceRotation::Rotated270Degrees:
std::swap(params->stretch[0], params->stretch[1]);
......@@ -251,6 +253,10 @@ void AdjustBlitResolveParametersForPreRotation(SurfaceRotation framebufferAngle,
ASSERT(!params->flipX && !params->flipY);
params->flipX = true;
params->flipY = true;
// Align the offset, or the sample position near the edge will be wrong.
--params->srcOffset[0];
--params->srcOffset[1];
break;
default:
UNREACHABLE();
......
......@@ -1678,12 +1678,6 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk,
region.imageExtent.width = params.blitArea.width;
region.imageExtent.height = params.blitArea.height;
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(),
depthStencilImage->getImage(),
......
......@@ -184,6 +184,36 @@ class EGLPreRotationSurfaceTest : public ANGLETestWithParam<EGLPreRotationSurfac
initializeContext();
}
void initializeSurfaceWithRGBA8888d24s8Config()
{
const EGLint configAttributes[] = {
EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8,
EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8, EGL_SAMPLE_BUFFERS, 0, EGL_NONE};
EGLint configCount;
EGLConfig config;
ASSERT_TRUE(eglChooseConfig(mDisplay, configAttributes, &config, 1, &configCount) ||
(configCount != 1) == EGL_TRUE);
mConfig = config;
EGLint surfaceType = EGL_NONE;
eglGetConfigAttrib(mDisplay, mConfig, EGL_SURFACE_TYPE, &surfaceType);
std::vector<EGLint> windowAttributes;
windowAttributes.push_back(EGL_NONE);
if (surfaceType & EGL_WINDOW_BIT)
{
// Create first window surface
mWindowSurface = eglCreateWindowSurface(mDisplay, mConfig, mOSWindow->getNativeWindow(),
windowAttributes.data());
ASSERT_EGL_SUCCESS();
}
initializeContext();
}
void testDrawingAndReadPixels()
{
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);
......@@ -892,6 +922,332 @@ TEST_P(EGLPreRotationBlitFramebufferTest, BasicBlitFramebuffer)
ASSERT_EGL_SUCCESS();
}
// Blit the ms0 stencil buffer to the default framebuffer with rotation on android.
TEST_P(EGLPreRotationBlitFramebufferTest, BlitStencilWithRotation)
{
// 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();
initializeSurfaceWithRGBA8888d24s8Config();
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
ASSERT_EGL_SUCCESS();
mOSWindow->setOrientation(300, 400);
angle::Sleep(1000);
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_EGL_SUCCESS();
GLRenderbuffer colorbuf;
glBindRenderbuffer(GL_RENDERBUFFER, colorbuf.get());
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 0, GL_RGBA8, 64, 128);
GLRenderbuffer depthstencilbuf;
glBindRenderbuffer(GL_RENDERBUFFER, depthstencilbuf.get());
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 0, GL_DEPTH24_STENCIL8, 64, 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);
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// 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 stencil buffer to default frambuffer.
GLenum attachments1[] = {GL_COLOR_ATTACHMENT0};
glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, attachments1);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBlitFramebuffer(0, 0, 64, 128, 0, 0, 64, 128, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
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.3f);
// Check the result, especially the boundaries.
EXPECT_PIXEL_COLOR_EQ(0, 127, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(32, 127, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(32, 0, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(63, 0, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(63, 1, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(63, 64, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(32, 64, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(63, 127, GLColor::blue);
// Some pixels around x=0 still fail on android.There are other issues to fix.
// From the image in the window, the failures near one of the image's edge look like "aliasing".
// We need to fix blit with pre-rotation. http://anglebug.com/5044
// EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue);
// EXPECT_PIXEL_COLOR_EQ(0, 64, GLColor::blue);
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_GL_NO_ERROR();
}
// Blit the multisample stencil buffer to the default framebuffer with rotation on android.
TEST_P(EGLPreRotationBlitFramebufferTest, BlitMultisampleStencilWithRotation)
{
// 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();
initializeSurfaceWithRGBA8888d24s8Config();
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
ASSERT_EGL_SUCCESS();
mOSWindow->setOrientation(300, 400);
angle::Sleep(1000);
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_EGL_SUCCESS();
GLRenderbuffer colorbuf;
glBindRenderbuffer(GL_RENDERBUFFER, colorbuf.get());
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 128, 64);
GLRenderbuffer depthstencilbuf;
glBindRenderbuffer(GL_RENDERBUFFER, depthstencilbuf.get());
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH24_STENCIL8, 128, 64);
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);
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// 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, 64, 0, 0, 128, 64, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
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.3f);
// Check the result, especially the boundaries.
EXPECT_PIXEL_COLOR_EQ(64, 0, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(127, 0, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(127, 1, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(127, 32, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(64, 32, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(0, 63, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(64, 63, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(127, 63, GLColor::blue);
// Some pixels around x=0 still fail on android.There are other issues to fix.
// We need to fix blit with pre-rotation. http://anglebug.com/5044
// EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue);
// EXPECT_PIXEL_COLOR_EQ(0, 32, GLColor::blue);
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_GL_NO_ERROR();
}
// Blit stencil to default framebuffer with flip and prerotation.
TEST_P(EGLPreRotationBlitFramebufferTest, BlitStencilWithFlip)
{
// 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());
// We need to fix blit with pre-rotation. http://anglebug.com/5044
ANGLE_SKIP_TEST_IF(IsAndroid());
// To aid in debugging, we want this window visible
setWindowVisible(mOSWindow, true);
initializeDisplay();
initializeSurfaceWithRGBA8888d24s8Config();
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);
GLRenderbuffer depthstencilbuf;
glBindRenderbuffer(GL_RENDERBUFFER, depthstencilbuf.get());
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 0, GL_DEPTH24_STENCIL8, kSize, kSize);
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);
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// 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 stencil buffer to default frambuffer with X-flip.
GLenum attachments1[] = {GL_COLOR_ATTACHMENT0};
glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, attachments1);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBlitFramebuffer(0, 0, kSize, kSize, kSize, 0, 0, kSize,
GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
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.
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_EQUAL, 1, 255);
ANGLE_GL_PROGRAM(gradientProgram, essl31_shaders::vs::Passthrough(),
essl31_shaders::fs::RedGreenGradient());
drawQuad(gradientProgram, essl31_shaders::PositionAttrib(), 0.5f, 1.0f, true);
// 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();
}
// Blit color buffer to default framebuffer with flip and prerotation.
TEST_P(EGLPreRotationBlitFramebufferTest, BlitColorWithFlip)
{
// 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());
// We need to fix blit with pre-rotation. http://anglebug.com/5044
ANGLE_SKIP_TEST_IF(IsAndroid());
// To aid in debugging, we want this window visible
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);
// Blit color buffer to default frambuffer with Y-flip.
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBlitFramebuffer(0, 0, kSize, kSize, 0, kSize, kSize, 0, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
// Check the result, especially the boundaries.
EXPECT_PIXEL_NEAR(0, 0, 0, 253, 0, 255, 1.0); // Green
EXPECT_PIXEL_NEAR(kSize - 1, 0, 253, 253, 0, 255, 1.0); // Yellow
EXPECT_PIXEL_NEAR(0, kSize - 1, 0, 0, 0, 255, 1.0); // Balck
EXPECT_PIXEL_NEAR(kSize - 1, kSize - 1, 253, 0, 0, 255, 1.0); // Red
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_GL_NO_ERROR();
}
// 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
TEST_P(EGLPreRotationBlitFramebufferTest, LeftAndRightBlitFramebuffer)
......
......@@ -1225,6 +1225,74 @@ TEST_P(BlitFramebufferTest, MultisampleDepth)
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.
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