Commit c0a403e2 by Frank Henigman Committed by Commit Bot

Revert "ANGLETest: Reuse test windows per-renderer"

This reverts commit fad918f8. Reason for revert: attempt to fix anglebug.com/2537 Original change's description: > ANGLETest: Reuse test windows per-renderer > > When running angle_end2end_tests unfiltered with the OpenGL and Vulkan > backends enabled, the test window was recreated all the time and grabbed > focus every-time it was created. This made it impossible to do anything > with the machine running the tests. > > Fix this by having one OSWindow per renderer group that's lazily created: > this solves most of the issue since only a couple windows end up being > created, and at the beginning of the test suite. > > BUG= > > Change-Id: I7a51300f0d59d8b6bb79e54d20b3acbf01068002 > Reviewed-on: https://chromium-review.googlesource.com/1038433 > Commit-Queue: Corentin Wallez <cwallez@chromium.org> > Reviewed-by: Jamie Madill <jmadill@chromium.org> TBR=geofflang@chromium.org,jmadill@chromium.org,cwallez@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: I93bdfa38757cbe2a6ce939c0c3e3da806307e7dd Reviewed-on: https://chromium-review.googlesource.com/1050326Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Frank Henigman <fjhenigman@chromium.org>
parent de1c1db0
...@@ -29,7 +29,7 @@ class DrawBuffersTest : public ANGLETest ...@@ -29,7 +29,7 @@ class DrawBuffersTest : public ANGLETest
ANGLETest::SetUp(); ANGLETest::SetUp();
// This test seems to fail on an nVidia machine when the window is hidden // This test seems to fail on an nVidia machine when the window is hidden
setWindowVisible(true); SetWindowVisible(true);
glGenFramebuffers(1, &mFBO); glGenFramebuffers(1, &mFBO);
glBindFramebuffer(GL_FRAMEBUFFER, mFBO); glBindFramebuffer(GL_FRAMEBUFFER, mFBO);
......
...@@ -238,7 +238,21 @@ ANGLETestBase::ANGLETestBase(const angle::PlatformParameters &params) ...@@ -238,7 +238,21 @@ ANGLETestBase::ANGLETestBase(const angle::PlatformParameters &params)
// Default debug layers to enabled in tests. // Default debug layers to enabled in tests.
mEGLWindow->setDebugLayersEnabled(true); mEGLWindow->setDebugLayersEnabled(true);
mCurrentRenderer = params.getRenderer(); // Workaround for NVIDIA not being able to share OpenGL and Vulkan contexts.
EGLint renderer = params.getRenderer();
bool needsWindowSwap = mLastRendererType.valid() &&
((renderer != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE) !=
(mLastRendererType.value() != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE));
if (needsWindowSwap)
{
DestroyTestWindow();
if (!InitTestWindow())
{
std::cerr << "Failed to create ANGLE test window.";
}
}
mLastRendererType = renderer;
} }
ANGLETestBase::~ANGLETestBase() ANGLETestBase::~ANGLETestBase()
...@@ -263,14 +277,12 @@ void ANGLETestBase::ANGLETestSetUp() ...@@ -263,14 +277,12 @@ void ANGLETestBase::ANGLETestSetUp()
mPlatformContext.ignoreMessages = false; mPlatformContext.ignoreMessages = false;
mPlatformContext.currentTest = this; mPlatformContext.currentTest = this;
OSWindow *osWindow = getOSWindow();
// Resize the window before creating the context so that the first make current // Resize the window before creating the context so that the first make current
// sets the viewport and scissor box to the right size. // sets the viewport and scissor box to the right size.
bool needSwap = false; bool needSwap = false;
if (osWindow->getWidth() != mWidth || osWindow->getHeight() != mHeight) if (mOSWindow->getWidth() != mWidth || mOSWindow->getHeight() != mHeight)
{ {
if (!osWindow->resize(mWidth, mHeight)) if (!mOSWindow->resize(mWidth, mHeight))
{ {
FAIL() << "Failed to resize ANGLE test window."; FAIL() << "Failed to resize ANGLE test window.";
} }
...@@ -284,7 +296,7 @@ void ANGLETestBase::ANGLETestSetUp() ...@@ -284,7 +296,7 @@ void ANGLETestBase::ANGLETestSetUp()
mPlatformMethods.context = &mPlatformContext; mPlatformMethods.context = &mPlatformContext;
mEGLWindow->setPlatformMethods(&mPlatformMethods); mEGLWindow->setPlatformMethods(&mPlatformMethods);
if (!mEGLWindow->initializeDisplayAndSurface(osWindow)) if (!mEGLWindow->initializeDisplayAndSurface(mOSWindow))
{ {
FAIL() << "egl display or surface init failed."; FAIL() << "egl display or surface init failed.";
} }
...@@ -328,8 +340,7 @@ void ANGLETestBase::ANGLETestTearDown() ...@@ -328,8 +340,7 @@ void ANGLETestBase::ANGLETestTearDown()
FAIL() << "egl error during swap."; FAIL() << "egl error during swap.";
} }
OSWindow *osWindow = getOSWindow(); mOSWindow->messageLoop();
osWindow->messageLoop();
if (!destroyEGLContext()) if (!destroyEGLContext())
{ {
...@@ -338,7 +349,7 @@ void ANGLETestBase::ANGLETestTearDown() ...@@ -338,7 +349,7 @@ void ANGLETestBase::ANGLETestTearDown()
// Check for quit message // Check for quit message
Event myEvent; Event myEvent;
while (osWindow->popEvent(&myEvent)) while (mOSWindow->popEvent(&myEvent))
{ {
if (myEvent.Type == Event::EVENT_CLOSED) if (myEvent.Type == Event::EVENT_CLOSED)
{ {
...@@ -781,11 +792,6 @@ bool ANGLETestBase::eglDeviceExtensionEnabled(EGLDeviceEXT device, const std::st ...@@ -781,11 +792,6 @@ bool ANGLETestBase::eglDeviceExtensionEnabled(EGLDeviceEXT device, const std::st
return CheckExtensionExists(eglQueryDeviceStringEXT(device, EGL_EXTENSIONS), extName); return CheckExtensionExists(eglQueryDeviceStringEXT(device, EGL_EXTENSIONS), extName);
} }
void ANGLETestBase::setWindowVisible(bool isVisible)
{
getOSWindow()->setVisible(isVisible);
}
void ANGLETestBase::setWindowWidth(int width) void ANGLETestBase::setWindowWidth(int width)
{ {
mWidth = width; mWidth = width;
...@@ -932,47 +938,36 @@ bool ANGLETestBase::destroyEGLContext() ...@@ -932,47 +938,36 @@ bool ANGLETestBase::destroyEGLContext()
return true; return true;
} }
OSWindow *ANGLETestBase::getOSWindow() // static
bool ANGLETestBase::InitTestWindow()
{ {
// We only need to separate the Vulkan renderer from others mOSWindow = CreateOSWindow();
int rendererIndex = 0; if (!mOSWindow->initialize("ANGLE_TEST", 128, 128))
if (mCurrentRenderer == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE) {
rendererIndex = 1;
}
// The same renderer can always reuse a window.
auto it = mOSWindows.find(rendererIndex);
if (it != mOSWindows.end())
{ {
return it->second; return false;
} }
// Create a new window for this renderer, tagged with the renderer name mOSWindow->setVisible(true);
OSWindow *osWindow = CreateOSWindow();
std::string name = "ANGLE_TEST";
if (!osWindow->initialize(name, 128, 128))
{
std::cerr << "Failed to initialize test window" << std::endl;
return nullptr;
}
osWindow->setVisible(true);
mOSWindows[rendererIndex] = osWindow; return true;
return osWindow;
} }
// static // static
void ANGLETestBase::DestroyTestWindows() bool ANGLETestBase::DestroyTestWindow()
{ {
for (auto it : mOSWindows) if (mOSWindow)
{ {
OSWindow *osWindow = it.second; mOSWindow->destroy();
std::cerr << "Unexpected nullptr OSWindow" << std::endl; delete mOSWindow;
osWindow->destroy(); mOSWindow = nullptr;
delete osWindow;
} }
mOSWindows.clear(); return true;
}
void ANGLETestBase::SetWindowVisible(bool isVisible)
{
mOSWindow->setVisible(isVisible);
} }
ANGLETest::ANGLETest() : ANGLETestBase(GetParam()) ANGLETest::ANGLETest() : ANGLETestBase(GetParam())
...@@ -1148,9 +1143,18 @@ ANGLETestBase::ScopedIgnorePlatformMessages::~ScopedIgnorePlatformMessages() ...@@ -1148,9 +1143,18 @@ ANGLETestBase::ScopedIgnorePlatformMessages::~ScopedIgnorePlatformMessages()
mTest->mPlatformContext.ignoreMessages = false; mTest->mPlatformContext.ignoreMessages = false;
} }
std::map<EGLint, OSWindow *> ANGLETestBase::mOSWindows; OSWindow *ANGLETestBase::mOSWindow = nullptr;
Optional<EGLint> ANGLETestBase::mLastRendererType;
void ANGLETestEnvironment::SetUp()
{
if (!ANGLETestBase::InitTestWindow())
{
FAIL() << "Failed to create ANGLE test window.";
}
}
void ANGLETestEnvironment::TearDown() void ANGLETestEnvironment::TearDown()
{ {
ANGLETestBase::DestroyTestWindows(); ANGLETestBase::DestroyTestWindow();
} }
...@@ -247,7 +247,9 @@ class ANGLETestBase ...@@ -247,7 +247,9 @@ class ANGLETestBase
virtual ~ANGLETestBase(); virtual ~ANGLETestBase();
public: public:
static void DestroyTestWindows(); static bool InitTestWindow();
static bool DestroyTestWindow();
static void SetWindowVisible(bool isVisible);
static bool eglDisplayExtensionEnabled(EGLDisplay display, const std::string &extName); static bool eglDisplayExtensionEnabled(EGLDisplay display, const std::string &extName);
virtual void overrideWorkaroundsD3D(angle::WorkaroundsD3D *workaroundsD3D) {} virtual void overrideWorkaroundsD3D(angle::WorkaroundsD3D *workaroundsD3D) {}
...@@ -311,7 +313,6 @@ class ANGLETestBase ...@@ -311,7 +313,6 @@ class ANGLETestBase
static bool eglClientExtensionEnabled(const std::string &extName); static bool eglClientExtensionEnabled(const std::string &extName);
static bool eglDeviceExtensionEnabled(EGLDeviceEXT device, const std::string &extName); static bool eglDeviceExtensionEnabled(EGLDeviceEXT device, const std::string &extName);
void setWindowVisible(bool isVisible);
void setWindowWidth(int width); void setWindowWidth(int width);
void setWindowHeight(int height); void setWindowHeight(int height);
void setConfigRedBits(int bits); void setConfigRedBits(int bits);
...@@ -349,7 +350,7 @@ class ANGLETestBase ...@@ -349,7 +350,7 @@ class ANGLETestBase
void ignoreD3D11SDKLayersWarnings(); void ignoreD3D11SDKLayersWarnings();
OSWindow *getOSWindow(); static OSWindow *GetOSWindow() { return mOSWindow; }
GLuint get2DTexturedQuadProgram(); GLuint get2DTexturedQuadProgram();
...@@ -395,10 +396,10 @@ class ANGLETestBase ...@@ -395,10 +396,10 @@ class ANGLETestBase
bool mDeferContextInit; bool mDeferContextInit;
// Using the same window for both Vulkan and OpenGL crashes on the NVIDIA driver so we use one static OSWindow *mOSWindow;
// OS window lazily-created per group of renderer.
EGLint mCurrentRenderer; // Workaround for NVIDIA not being able to share a window with OpenGL and Vulkan.
static std::map<int, OSWindow *> mOSWindows; static Optional<EGLint> mLastRendererType;
}; };
class ANGLETest : public ANGLETestBase, public ::testing::TestWithParam<angle::PlatformParameters> class ANGLETest : public ANGLETestBase, public ::testing::TestWithParam<angle::PlatformParameters>
...@@ -414,6 +415,7 @@ class ANGLETest : public ANGLETestBase, public ::testing::TestWithParam<angle::P ...@@ -414,6 +415,7 @@ class ANGLETest : public ANGLETestBase, public ::testing::TestWithParam<angle::P
class ANGLETestEnvironment : public testing::Environment class ANGLETestEnvironment : public testing::Environment
{ {
public: public:
void SetUp() override;
void TearDown() override; void TearDown() override;
}; };
......
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