Commit 2a72553d by Jonah Ryan-Davis Committed by Commit Bot

Add EGLSurfaceTest.ResizeWindowWithDraw

This test will ensure the backbuffer is also properly resized when the window is resized. Bug: angleproject:4167 Change-Id: I1d73f07379b4f05e453520e22ef1369f51182197 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1934311 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent ea1c2400
...@@ -92,6 +92,7 @@ class EGLSurfaceTest : public ANGLETest ...@@ -92,6 +92,7 @@ class EGLSurfaceTest : public ANGLETest
void initializeDisplay() void initializeDisplay()
{ {
GLenum platformType = GetParam().getRenderer(); GLenum platformType = GetParam().getRenderer();
GLenum deviceType = GetParam().getDeviceType();
std::vector<EGLint> displayAttributes; std::vector<EGLint> displayAttributes;
displayAttributes.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE); displayAttributes.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
...@@ -101,7 +102,7 @@ class EGLSurfaceTest : public ANGLETest ...@@ -101,7 +102,7 @@ class EGLSurfaceTest : public ANGLETest
displayAttributes.push_back(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE); displayAttributes.push_back(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE);
displayAttributes.push_back(EGL_DONT_CARE); displayAttributes.push_back(EGL_DONT_CARE);
displayAttributes.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE); displayAttributes.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE);
displayAttributes.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE); displayAttributes.push_back(deviceType);
displayAttributes.push_back(EGL_NONE); displayAttributes.push_back(EGL_NONE);
mDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, mDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
...@@ -300,7 +301,7 @@ TEST_P(EGLSurfaceTest, ResizeWindow) ...@@ -300,7 +301,7 @@ TEST_P(EGLSurfaceTest, ResizeWindow)
// TODO(syoussefi): http://anglebug.com/3123 // TODO(syoussefi): http://anglebug.com/3123
ANGLE_SKIP_TEST_IF(IsAndroid()); ANGLE_SKIP_TEST_IF(IsAndroid());
// Necessary for a window resizing test // Necessary for a window resizing test if there is no per-frame window size query
mOSWindow->setVisible(true); mOSWindow->setVisible(true);
GLenum platform = GetParam().getRenderer(); GLenum platform = GetParam().getRenderer();
...@@ -346,6 +347,91 @@ TEST_P(EGLSurfaceTest, ResizeWindow) ...@@ -346,6 +347,91 @@ TEST_P(EGLSurfaceTest, ResizeWindow)
ASSERT_EQ(64, height); ASSERT_EQ(64, height);
} }
// Test that the backbuffer is correctly resized after calling swapBuffers
TEST_P(EGLSurfaceTest, ResizeWindowWithDraw)
{
// Necessary for a window resizing test if there is no per-frame window size query
mOSWindow->setVisible(true);
initializeDisplay();
initializeSurfaceWithDefaultConfig();
initializeContext();
int size = 64;
EGLint height = 0;
EGLint width = 0;
eglMakeCurrent(mDisplay, mWindowSurface, mWindowSurface, mContext);
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_EGL_SUCCESS();
// Clear to red
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
eglQuerySurface(mDisplay, mWindowSurface, EGL_HEIGHT, &height);
eglQuerySurface(mDisplay, mWindowSurface, EGL_WIDTH, &width);
ASSERT_EGL_SUCCESS();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(size - 1, 0, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(size - 1, size - 1, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(0, size - 1, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(-1, -1, GLColor::transparentBlack);
EXPECT_PIXEL_COLOR_EQ(size, 0, GLColor::transparentBlack);
EXPECT_PIXEL_COLOR_EQ(0, size, GLColor::transparentBlack);
EXPECT_PIXEL_COLOR_EQ(size, size, GLColor::transparentBlack);
// set window's size small
size = 1;
mOSWindow->resize(size, size);
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_EGL_SUCCESS();
// Clear to green
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
eglQuerySurface(mDisplay, mWindowSurface, EGL_HEIGHT, &height);
eglQuerySurface(mDisplay, mWindowSurface, EGL_WIDTH, &width);
ASSERT_EGL_SUCCESS();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(size - 1, 0, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(size - 1, size - 1, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(0, size - 1, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(-1, -1, GLColor::transparentBlack);
EXPECT_PIXEL_COLOR_EQ(size, 0, GLColor::transparentBlack);
EXPECT_PIXEL_COLOR_EQ(0, size, GLColor::transparentBlack);
EXPECT_PIXEL_COLOR_EQ(size, size, GLColor::transparentBlack);
// set window's height large
size = 128;
mOSWindow->resize(size, size);
eglSwapBuffers(mDisplay, mWindowSurface);
ASSERT_EGL_SUCCESS();
// Clear to blue
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
eglQuerySurface(mDisplay, mWindowSurface, EGL_HEIGHT, &height);
eglQuerySurface(mDisplay, mWindowSurface, EGL_WIDTH, &width);
ASSERT_EGL_SUCCESS();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(size - 1, 0, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(size - 1, size - 1, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(0, size - 1, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(-1, -1, GLColor::transparentBlack);
EXPECT_PIXEL_COLOR_EQ(size, 0, GLColor::transparentBlack);
EXPECT_PIXEL_COLOR_EQ(0, size, GLColor::transparentBlack);
EXPECT_PIXEL_COLOR_EQ(size, size, GLColor::transparentBlack);
}
// Test that swap interval works. // Test that swap interval works.
TEST_P(EGLSurfaceTest, SwapInterval) TEST_P(EGLSurfaceTest, SwapInterval)
{ {
...@@ -358,6 +444,8 @@ TEST_P(EGLSurfaceTest, SwapInterval) ...@@ -358,6 +444,8 @@ TEST_P(EGLSurfaceTest, SwapInterval)
ANGLE_SKIP_TEST_IF(IsLinux() && IsNVIDIA() && isVulkanRenderer()); ANGLE_SKIP_TEST_IF(IsLinux() && IsNVIDIA() && isVulkanRenderer());
// Flaky on Linux NVIDIA OpenGL driver. http://anglebug.com/3807 // Flaky on Linux NVIDIA OpenGL driver. http://anglebug.com/3807
ANGLE_SKIP_TEST_IF(IsLinux() && IsNVIDIA() && isGLRenderer()); ANGLE_SKIP_TEST_IF(IsLinux() && IsNVIDIA() && isGLRenderer());
// Test fails on Swangle http://anglebug.com/4169
ANGLE_SKIP_TEST_IF(isVulkanSwiftshaderRenderer());
initializeDisplay(); initializeDisplay();
initializeSurfaceWithDefaultConfig(); initializeSurfaceWithDefaultConfig();
...@@ -811,7 +899,9 @@ ANGLE_INSTANTIATE_TEST(EGLSurfaceTest, ...@@ -811,7 +899,9 @@ ANGLE_INSTANTIATE_TEST(EGLSurfaceTest,
WithNoFixture(ES2_OPENGLES()), WithNoFixture(ES2_OPENGLES()),
WithNoFixture(ES3_OPENGLES()), WithNoFixture(ES3_OPENGLES()),
WithNoFixture(ES2_VULKAN()), WithNoFixture(ES2_VULKAN()),
WithNoFixture(ES3_VULKAN())); WithNoFixture(ES3_VULKAN()),
WithNoFixture(ES2_VULKAN_SWIFTSHADER()),
WithNoFixture(ES3_VULKAN_SWIFTSHADER()));
ANGLE_INSTANTIATE_TEST(EGLSurfaceTest3, WithNoFixture(ES3_VULKAN())); ANGLE_INSTANTIATE_TEST(EGLSurfaceTest3, WithNoFixture(ES3_VULKAN()));
#if defined(ANGLE_ENABLE_D3D11) #if defined(ANGLE_ENABLE_D3D11)
......
...@@ -470,6 +470,12 @@ class ANGLETestBase ...@@ -470,6 +470,12 @@ class ANGLETestBase
return mCurrentParams->getRenderer() == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE; return mCurrentParams->getRenderer() == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
} }
bool isVulkanSwiftshaderRenderer() const
{
return mCurrentParams->getRenderer() == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE &&
mCurrentParams->getDeviceType() == EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE;
}
private: private:
void checkD3D11SDKLayersMessages(); void checkD3D11SDKLayersMessages();
......
...@@ -39,6 +39,11 @@ EGLint PlatformParameters::getRenderer() const ...@@ -39,6 +39,11 @@ EGLint PlatformParameters::getRenderer() const
return eglParameters.renderer; return eglParameters.renderer;
} }
EGLint PlatformParameters::getDeviceType() const
{
return eglParameters.deviceType;
}
void PlatformParameters::initDefaultParameters() void PlatformParameters::initDefaultParameters()
{ {
#if defined(ANGLE_ENABLE_VULKAN_VALIDATION_LAYERS_BY_DEFAULT) #if defined(ANGLE_ENABLE_VULKAN_VALIDATION_LAYERS_BY_DEFAULT)
......
...@@ -43,6 +43,7 @@ struct PlatformParameters ...@@ -43,6 +43,7 @@ struct PlatformParameters
PlatformParameters(EGLint majorVersion, EGLint minorVersion, GLESDriverType driver); PlatformParameters(EGLint majorVersion, EGLint minorVersion, GLESDriverType driver);
EGLint getRenderer() const; EGLint getRenderer() const;
EGLint getDeviceType() const;
void initDefaultParameters(); void initDefaultParameters();
......
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