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
ANGLETest::SetUp();
// This test seems to fail on an nVidia machine when the window is hidden
setWindowVisible(true);
SetWindowVisible(true);
glGenFramebuffers(1, &mFBO);
glBindFramebuffer(GL_FRAMEBUFFER, mFBO);
......
......@@ -238,7 +238,21 @@ ANGLETestBase::ANGLETestBase(const angle::PlatformParameters &params)
// Default debug layers to enabled in tests.
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()
......@@ -263,14 +277,12 @@ void ANGLETestBase::ANGLETestSetUp()
mPlatformContext.ignoreMessages = false;
mPlatformContext.currentTest = this;
OSWindow *osWindow = getOSWindow();
// Resize the window before creating the context so that the first make current
// sets the viewport and scissor box to the right size.
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.";
}
......@@ -284,7 +296,7 @@ void ANGLETestBase::ANGLETestSetUp()
mPlatformMethods.context = &mPlatformContext;
mEGLWindow->setPlatformMethods(&mPlatformMethods);
if (!mEGLWindow->initializeDisplayAndSurface(osWindow))
if (!mEGLWindow->initializeDisplayAndSurface(mOSWindow))
{
FAIL() << "egl display or surface init failed.";
}
......@@ -328,8 +340,7 @@ void ANGLETestBase::ANGLETestTearDown()
FAIL() << "egl error during swap.";
}
OSWindow *osWindow = getOSWindow();
osWindow->messageLoop();
mOSWindow->messageLoop();
if (!destroyEGLContext())
{
......@@ -338,7 +349,7 @@ void ANGLETestBase::ANGLETestTearDown()
// Check for quit message
Event myEvent;
while (osWindow->popEvent(&myEvent))
while (mOSWindow->popEvent(&myEvent))
{
if (myEvent.Type == Event::EVENT_CLOSED)
{
......@@ -781,11 +792,6 @@ bool ANGLETestBase::eglDeviceExtensionEnabled(EGLDeviceEXT device, const std::st
return CheckExtensionExists(eglQueryDeviceStringEXT(device, EGL_EXTENSIONS), extName);
}
void ANGLETestBase::setWindowVisible(bool isVisible)
{
getOSWindow()->setVisible(isVisible);
}
void ANGLETestBase::setWindowWidth(int width)
{
mWidth = width;
......@@ -932,47 +938,36 @@ bool ANGLETestBase::destroyEGLContext()
return true;
}
OSWindow *ANGLETestBase::getOSWindow()
// static
bool ANGLETestBase::InitTestWindow()
{
// We only need to separate the Vulkan renderer from others
int rendererIndex = 0;
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())
mOSWindow = CreateOSWindow();
if (!mOSWindow->initialize("ANGLE_TEST", 128, 128))
{
return it->second;
return false;
}
// Create a new window for this renderer, tagged with the renderer name
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);
mOSWindow->setVisible(true);
mOSWindows[rendererIndex] = osWindow;
return osWindow;
return true;
}
// static
void ANGLETestBase::DestroyTestWindows()
bool ANGLETestBase::DestroyTestWindow()
{
for (auto it : mOSWindows)
if (mOSWindow)
{
OSWindow *osWindow = it.second;
std::cerr << "Unexpected nullptr OSWindow" << std::endl;
osWindow->destroy();
delete osWindow;
mOSWindow->destroy();
delete mOSWindow;
mOSWindow = nullptr;
}
mOSWindows.clear();
return true;
}
void ANGLETestBase::SetWindowVisible(bool isVisible)
{
mOSWindow->setVisible(isVisible);
}
ANGLETest::ANGLETest() : ANGLETestBase(GetParam())
......@@ -1148,9 +1143,18 @@ ANGLETestBase::ScopedIgnorePlatformMessages::~ScopedIgnorePlatformMessages()
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()
{
ANGLETestBase::DestroyTestWindows();
ANGLETestBase::DestroyTestWindow();
}
......@@ -247,7 +247,9 @@ class ANGLETestBase
virtual ~ANGLETestBase();
public:
static void DestroyTestWindows();
static bool InitTestWindow();
static bool DestroyTestWindow();
static void SetWindowVisible(bool isVisible);
static bool eglDisplayExtensionEnabled(EGLDisplay display, const std::string &extName);
virtual void overrideWorkaroundsD3D(angle::WorkaroundsD3D *workaroundsD3D) {}
......@@ -311,7 +313,6 @@ class ANGLETestBase
static bool eglClientExtensionEnabled(const std::string &extName);
static bool eglDeviceExtensionEnabled(EGLDeviceEXT device, const std::string &extName);
void setWindowVisible(bool isVisible);
void setWindowWidth(int width);
void setWindowHeight(int height);
void setConfigRedBits(int bits);
......@@ -349,7 +350,7 @@ class ANGLETestBase
void ignoreD3D11SDKLayersWarnings();
OSWindow *getOSWindow();
static OSWindow *GetOSWindow() { return mOSWindow; }
GLuint get2DTexturedQuadProgram();
......@@ -395,10 +396,10 @@ class ANGLETestBase
bool mDeferContextInit;
// Using the same window for both Vulkan and OpenGL crashes on the NVIDIA driver so we use one
// OS window lazily-created per group of renderer.
EGLint mCurrentRenderer;
static std::map<int, OSWindow *> mOSWindows;
static OSWindow *mOSWindow;
// Workaround for NVIDIA not being able to share a window with OpenGL and Vulkan.
static Optional<EGLint> mLastRendererType;
};
class ANGLETest : public ANGLETestBase, public ::testing::TestWithParam<angle::PlatformParameters>
......@@ -414,6 +415,7 @@ class ANGLETest : public ANGLETestBase, public ::testing::TestWithParam<angle::P
class ANGLETestEnvironment : public testing::Environment
{
public:
void SetUp() 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