Commit aaa17b85 by Yuly Novikov Committed by Commit Bot

Restrict OpenGL/Vulkan test window re-creation workaround to NVIDIA

The workaround in https://chromium-review.googlesource.com/430887 was intended only for NVIDIA. Re-creating the test window causes new native display to be created every time. Normally, re-using the same native display with different implementation would release the old implementation. When new display is created instead of re-using the old one, old implementation is never released, leaking memory. Use SystemInfo to check if any of GPUs is NVIDIA and apply the workaround only then, reducing the leak on other platforms. Bug: angleproject:1810, angleproject:3153 Change-Id: I6198c01c82a01e2adc0bcd1fad303c47cd7328d8 Reviewed-on: https://chromium-review.googlesource.com/c/1490379 Commit-Queue: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@google.com>
parent 009696c5
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ANGLETest.h" #include "ANGLETest.h"
#include "common/platform.h" #include "common/platform.h"
#include "gpu_info_util/SystemInfo.h"
#include "util/EGLWindow.h" #include "util/EGLWindow.h"
#include "util/OSWindow.h" #include "util/OSWindow.h"
...@@ -317,9 +318,10 @@ ANGLETestBase::ANGLETestBase(const angle::PlatformParameters &params) ...@@ -317,9 +318,10 @@ ANGLETestBase::ANGLETestBase(const angle::PlatformParameters &params)
mEGLWindow->setDebugLayersEnabled(true); mEGLWindow->setDebugLayersEnabled(true);
// Workaround for NVIDIA not being able to share OpenGL and Vulkan contexts. // Workaround for NVIDIA not being able to share OpenGL and Vulkan contexts.
// Workaround if any of the GPUs is Nvidia, since we can't detect current GPU.
EGLint renderer = params.getRenderer(); EGLint renderer = params.getRenderer();
bool needsWindowSwap = bool needsWindowSwap =
mLastRendererType.valid() && hasNvidiaGPU() && mLastRendererType.valid() &&
((renderer != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE) != ((renderer != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE) !=
(mLastRendererType.value() != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE)); (mLastRendererType.value() != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE));
...@@ -922,6 +924,18 @@ void ANGLETestBase::checkD3D11SDKLayersMessages() ...@@ -922,6 +924,18 @@ void ANGLETestBase::checkD3D11SDKLayersMessages()
#endif // defined(ANGLE_PLATFORM_WINDOWS) #endif // defined(ANGLE_PLATFORM_WINDOWS)
} }
bool ANGLETestBase::hasNvidiaGPU()
{
for (const angle::GPUDeviceInfo &gpu : ANGLETestEnvironment::GetSystemInfo()->gpus)
{
if (angle::IsNvidia(gpu.vendorId))
{
return true;
}
}
return false;
}
bool ANGLETestBase::extensionEnabled(const std::string &extName) bool ANGLETestBase::extensionEnabled(const std::string &extName)
{ {
return CheckExtensionExists(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)), return CheckExtensionExists(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)),
...@@ -1281,6 +1295,7 @@ Optional<EGLint> ANGLETestBase::mLastRendererType; ...@@ -1281,6 +1295,7 @@ Optional<EGLint> ANGLETestBase::mLastRendererType;
std::unique_ptr<angle::Library> ANGLETestEnvironment::gEGLLibrary; std::unique_ptr<angle::Library> ANGLETestEnvironment::gEGLLibrary;
std::unique_ptr<angle::Library> ANGLETestEnvironment::gWGLLibrary; std::unique_ptr<angle::Library> ANGLETestEnvironment::gWGLLibrary;
std::unique_ptr<angle::SystemInfo> ANGLETestEnvironment::gSystemInfo;
void ANGLETestEnvironment::SetUp() void ANGLETestEnvironment::SetUp()
{ {
...@@ -1317,6 +1332,19 @@ angle::Library *ANGLETestEnvironment::GetWGLLibrary() ...@@ -1317,6 +1332,19 @@ angle::Library *ANGLETestEnvironment::GetWGLLibrary()
return gWGLLibrary.get(); return gWGLLibrary.get();
} }
angle::SystemInfo *ANGLETestEnvironment::GetSystemInfo()
{
if (!gSystemInfo)
{
gSystemInfo = std::make_unique<angle::SystemInfo>();
if (!angle::GetSystemInfo(gSystemInfo.get()))
{
std::cerr << "Failed to get system info." << std::endl;
}
}
return gSystemInfo.get();
}
void ANGLEProcessTestArgs(int *argc, char *argv[]) void ANGLEProcessTestArgs(int *argc, char *argv[])
{ {
testing::AddGlobalTestEnvironment(new ANGLETestEnvironment()); testing::AddGlobalTestEnvironment(new ANGLETestEnvironment());
......
...@@ -22,6 +22,11 @@ ...@@ -22,6 +22,11 @@
#include "util/system_utils.h" #include "util/system_utils.h"
#include "util/util_gl.h" #include "util/util_gl.h"
namespace angle
{
struct SystemInfo;
} // namespace angle
#define ASSERT_GL_TRUE(a) ASSERT_EQ(static_cast<GLboolean>(GL_TRUE), (a)) #define ASSERT_GL_TRUE(a) ASSERT_EQ(static_cast<GLboolean>(GL_TRUE), (a))
#define ASSERT_GL_FALSE(a) ASSERT_EQ(static_cast<GLboolean>(GL_FALSE), (a)) #define ASSERT_GL_FALSE(a) ASSERT_EQ(static_cast<GLboolean>(GL_FALSE), (a))
#define EXPECT_GL_TRUE(a) EXPECT_EQ(static_cast<GLboolean>(GL_TRUE), (a)) #define EXPECT_GL_TRUE(a) EXPECT_EQ(static_cast<GLboolean>(GL_TRUE), (a))
...@@ -394,6 +399,7 @@ class ANGLETestBase ...@@ -394,6 +399,7 @@ class ANGLETestBase
private: private:
void checkD3D11SDKLayersMessages(); void checkD3D11SDKLayersMessages();
bool hasNvidiaGPU();
void drawQuad(GLuint program, void drawQuad(GLuint program,
const std::string &positionAttribName, const std::string &positionAttribName,
...@@ -447,10 +453,14 @@ class ANGLETestEnvironment : public testing::Environment ...@@ -447,10 +453,14 @@ class ANGLETestEnvironment : public testing::Environment
static angle::Library *GetEGLLibrary(); static angle::Library *GetEGLLibrary();
static angle::Library *GetWGLLibrary(); static angle::Library *GetWGLLibrary();
static angle::SystemInfo *GetSystemInfo();
private: private:
// For loading entry points. // For loading entry points.
static std::unique_ptr<angle::Library> gEGLLibrary; static std::unique_ptr<angle::Library> gEGLLibrary;
static std::unique_ptr<angle::Library> gWGLLibrary; static std::unique_ptr<angle::Library> gWGLLibrary;
static std::unique_ptr<angle::SystemInfo> gSystemInfo;
}; };
// This base fixture loads the EGL entry points. // This base fixture loads the EGL entry points.
......
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