Commit 930b2641 by Jamie Madill Committed by Commit Bot

Allow tests to run on native EGL.

Adds support for Linux and Android native EGL testing. This can be useful for doing performance comparisons of ANGLE vs a native GL driver. Only enabled for the trace perf tests due to limitations in the test harness. Bug: angleproject:4596 Change-Id: Iba6d3ccd7c1275cf095893fab824a0ea33dc3a79 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2116254 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent a4b506f7
...@@ -155,7 +155,8 @@ int SampleApplication::run() ...@@ -155,7 +155,8 @@ int SampleApplication::run()
configParams.depthBits = 24; configParams.depthBits = 24;
configParams.stencilBits = 8; configParams.stencilBits = 8;
if (!mEGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), mPlatformParams, configParams)) if (!mEGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), angle::GLESDriverType::AngleEGL,
mPlatformParams, configParams))
{ {
return -1; return -1;
} }
......
...@@ -68,6 +68,7 @@ enum class SearchType ...@@ -68,6 +68,7 @@ enum class SearchType
}; };
Library *OpenSharedLibrary(const char *libraryName, SearchType searchType); Library *OpenSharedLibrary(const char *libraryName, SearchType searchType);
Library *OpenSharedLibraryWithExtension(const char *libraryName);
// Returns true if the process is currently being debugged. // Returns true if the process is currently being debugged.
bool IsDebuggerAttached(); bool IsDebuggerAttached();
......
...@@ -72,19 +72,11 @@ std::string GetHelperExecutableDir() ...@@ -72,19 +72,11 @@ std::string GetHelperExecutableDir()
class PosixLibrary : public Library class PosixLibrary : public Library
{ {
public: public:
PosixLibrary(const char *libraryName, SearchType searchType) PosixLibrary(const std::string &fullPath) : mModule(dlopen(fullPath.c_str(), RTLD_NOW))
{ {
std::string directory;
if (searchType == SearchType::ApplicationDir)
{
directory = GetHelperExecutableDir();
}
std::string fullPath = directory + libraryName + "." + GetSharedLibraryExtension();
mModule = dlopen(fullPath.c_str(), RTLD_NOW);
if (!mModule) if (!mModule)
{ {
std::cerr << "Failed to load " << libraryName << ": " << dlerror() << std::endl; std::cerr << "Failed to load " << fullPath << ": " << dlerror() << std::endl;
} }
} }
...@@ -114,7 +106,19 @@ class PosixLibrary : public Library ...@@ -114,7 +106,19 @@ class PosixLibrary : public Library
Library *OpenSharedLibrary(const char *libraryName, SearchType searchType) Library *OpenSharedLibrary(const char *libraryName, SearchType searchType)
{ {
return new PosixLibrary(libraryName, searchType); std::string directory;
if (searchType == SearchType::ApplicationDir)
{
directory = GetHelperExecutableDir();
}
std::string fullPath = directory + libraryName + "." + GetSharedLibraryExtension();
return new PosixLibrary(fullPath);
}
Library *OpenSharedLibraryWithExtension(const char *libraryName)
{
return new PosixLibrary(libraryName);
} }
bool IsDirectory(const char *filename) bool IsDirectory(const char *filename)
......
...@@ -42,19 +42,14 @@ class Win32Library : public Library ...@@ -42,19 +42,14 @@ class Win32Library : public Library
public: public:
Win32Library(const char *libraryName, SearchType searchType) Win32Library(const char *libraryName, SearchType searchType)
{ {
char buffer[MAX_PATH]; switch (searchType)
int ret = snprintf(buffer, MAX_PATH, "%s.%s", libraryName, GetSharedLibraryExtension());
if (ret > 0 && ret < MAX_PATH)
{ {
switch (searchType) case SearchType::ApplicationDir:
{ mModule = LoadLibraryA(libraryName);
case SearchType::ApplicationDir: break;
mModule = LoadLibraryA(buffer); case SearchType::SystemDir:
break; mModule = LoadLibraryExA(libraryName, nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
case SearchType::SystemDir: break;
mModule = LoadLibraryExA(buffer, nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
break;
}
} }
} }
...@@ -84,6 +79,21 @@ class Win32Library : public Library ...@@ -84,6 +79,21 @@ class Win32Library : public Library
Library *OpenSharedLibrary(const char *libraryName, SearchType searchType) Library *OpenSharedLibrary(const char *libraryName, SearchType searchType)
{ {
return new Win32Library(libraryName, searchType); char buffer[MAX_PATH];
int ret = snprintf(buffer, MAX_PATH, "%s.%s", libraryName, GetSharedLibraryExtension());
if (ret > 0 && ret < MAX_PATH)
{
return new Win32Library(buffer, searchType);
}
else
{
fprintf(stderr, "Error loading shared library: 0x%x", ret);
return nullptr;
}
}
Library *OpenSharedLibraryWithExtension(const char *libraryName)
{
return new Win32Library(libraryName, SearchType::SystemDir);
} }
} // namespace angle } // namespace angle
...@@ -35,23 +35,17 @@ class UwpLibrary : public Library ...@@ -35,23 +35,17 @@ class UwpLibrary : public Library
public: public:
UwpLibrary(const char *libraryName, SearchType searchType) UwpLibrary(const char *libraryName, SearchType searchType)
{ {
char buffer[MAX_PATH];
int ret = snprintf(buffer, MAX_PATH, "%s.%s", libraryName, GetSharedLibraryExtension());
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter; std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::wstring wideBuffer = converter.from_bytes(buffer); std::wstring wideBuffer = converter.from_bytes(libraryName);
if (ret > 0 && ret < MAX_PATH) switch (searchType)
{ {
switch (searchType) case SearchType::ApplicationDir:
{ mModule = LoadPackagedLibrary(wideBuffer.c_str(), 0);
case SearchType::ApplicationDir: break;
mModule = LoadPackagedLibrary(wideBuffer.c_str(), 0); case SearchType::SystemDir:
break; // Not supported in UWP
case SearchType::SystemDir: break;
// Not supported in UWP
break;
}
} }
} }
...@@ -81,6 +75,24 @@ class UwpLibrary : public Library ...@@ -81,6 +75,24 @@ class UwpLibrary : public Library
Library *OpenSharedLibrary(const char *libraryName, SearchType searchType) Library *OpenSharedLibrary(const char *libraryName, SearchType searchType)
{ {
return new UwpLibrary(libraryName, searchType); char buffer[MAX_PATH];
int ret = snprintf(buffer, MAX_PATH, "%s.%s", libraryName, GetSharedLibraryExtension());
if (ret > 0 && ret < MAX_PATH)
{
return new UwpLibrary(buffer, searchType);
}
else
{
fprintf(stderr, "Error loading shared library: 0x%x", ret);
return nullptr;
}
}
Library *OpenSharedLibraryWithExtension(const char *libraryName)
{
// SystemDir is not implemented in UWP.
fprintf(stderr, "Error loading shared library with extension.\n");
return nullptr;
} }
} // namespace angle } // namespace angle
...@@ -478,7 +478,7 @@ void RegisterContextCompatibilityTests() ...@@ -478,7 +478,7 @@ void RegisterContextCompatibilityTests()
EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE, EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE,
}}; }};
LoadEntryPointsWithUtilLoader(); LoadEntryPointsWithUtilLoader(angle::GLESDriverType::AngleEGL);
if (eglGetPlatformDisplayEXT == nullptr) if (eglGetPlatformDisplayEXT == nullptr)
{ {
......
...@@ -1108,8 +1108,8 @@ class ProgramBinariesAcrossPlatforms : public testing::TestWithParam<PlatformsWi ...@@ -1108,8 +1108,8 @@ class ProgramBinariesAcrossPlatforms : public testing::TestWithParam<PlatformsWi
{ {
EGLWindow *eglWindow = EGLWindow::New(param.majorVersion, param.minorVersion); EGLWindow *eglWindow = EGLWindow::New(param.majorVersion, param.minorVersion);
ConfigParameters configParams; ConfigParameters configParams;
bool result = eglWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), param.eglParameters, bool result = eglWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), param.driver,
configParams); param.eglParameters, configParams);
if (!result) if (!result)
{ {
EGLWindow::Delete(&eglWindow); EGLWindow::Delete(&eglWindow);
......
...@@ -422,8 +422,14 @@ ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams ...@@ -422,8 +422,14 @@ ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams
angle::SearchType::ApplicationDir)); angle::SearchType::ApplicationDir));
break; break;
case angle::GLESDriverType::SystemEGL: case angle::GLESDriverType::SystemEGL:
#if defined(ANGLE_USE_UTIL_LOADER) && !defined(ANGLE_PLATFORM_WINDOWS)
mGLWindow = EGLWindow::New(testParams.majorVersion, testParams.minorVersion);
mEntryPointsLib.reset(
angle::OpenSharedLibraryWithExtension(GetNativeEGLLibraryNameWithExtension()));
#else
std::cerr << "Not implemented." << std::endl; std::cerr << "Not implemented." << std::endl;
mSkipTest = true; mSkipTest = true;
#endif // defined(ANGLE_USE_UTIL_LOADER) && !defined(ANGLE_PLATFORM_WINDOWS)
break; break;
case angle::GLESDriverType::SystemWGL: case angle::GLESDriverType::SystemWGL:
#if defined(ANGLE_USE_UTIL_LOADER) && defined(ANGLE_PLATFORM_WINDOWS) #if defined(ANGLE_USE_UTIL_LOADER) && defined(ANGLE_PLATFORM_WINDOWS)
...@@ -494,7 +500,8 @@ void ANGLERenderTest::SetUp() ...@@ -494,7 +500,8 @@ void ANGLERenderTest::SetUp()
EGLPlatformParameters withMethods = mTestParams.eglParameters; EGLPlatformParameters withMethods = mTestParams.eglParameters;
withMethods.platformMethods = &mPlatformMethods; withMethods.platformMethods = &mPlatformMethods;
if (!mGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), withMethods, mConfigParams)) if (!mGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), mTestParams.driver, withMethods,
mConfigParams))
{ {
mSkipTest = true; mSkipTest = true;
FAIL() << "Failed initializing GL Window"; FAIL() << "Failed initializing GL Window";
......
...@@ -78,6 +78,13 @@ ParamsT WGL(const ParamsT &in) ...@@ -78,6 +78,13 @@ ParamsT WGL(const ParamsT &in)
return out; return out;
} }
template <typename ParamsT>
ParamsT EGL(const ParamsT &in)
{
ParamsT out = in;
out.driver = angle::GLESDriverType::SystemEGL;
return out;
}
} // namespace params } // namespace params
#endif // TESTS_PERF_TESTS_DRAW_CALL_PERF_PARAMS_H_ #endif // TESTS_PERF_TESTS_DRAW_CALL_PERF_PARAMS_H_
...@@ -314,7 +314,7 @@ using P = TracePerfParams; ...@@ -314,7 +314,7 @@ using P = TracePerfParams;
std::vector<P> gTestsWithID = std::vector<P> gTestsWithID =
CombineWithValues({P()}, AllEnums<RestrictedTraceID>(), CombineTestID); CombineWithValues({P()}, AllEnums<RestrictedTraceID>(), CombineTestID);
std::vector<P> gTestsWithRenderer = CombineWithFuncs(gTestsWithID, {Vulkan<P>}); std::vector<P> gTestsWithRenderer = CombineWithFuncs(gTestsWithID, {Vulkan<P>, EGL<P>});
ANGLE_INSTANTIATE_TEST_ARRAY(TracePerfTest, gTestsWithRenderer); ANGLE_INSTANTIATE_TEST_ARRAY(TracePerfTest, gTestsWithRenderer);
} // anonymous namespace } // anonymous namespace
...@@ -279,11 +279,11 @@ GLColor32F ReadColor32F(GLint x, GLint y) ...@@ -279,11 +279,11 @@ GLColor32F ReadColor32F(GLint x, GLint y)
return actual; return actual;
} }
void LoadEntryPointsWithUtilLoader() void LoadEntryPointsWithUtilLoader(angle::GLESDriverType driverType)
{ {
#if defined(ANGLE_USE_UTIL_LOADER) #if defined(ANGLE_USE_UTIL_LOADER)
PFNEGLGETPROCADDRESSPROC getProcAddress; PFNEGLGETPROCADDRESSPROC getProcAddress;
ANGLETestEnvironment::GetEGLLibrary()->getAs("eglGetProcAddress", &getProcAddress); ANGLETestEnvironment::GetDriverLibrary(driverType)->getAs("eglGetProcAddress", &getProcAddress);
ASSERT_NE(nullptr, getProcAddress); ASSERT_NE(nullptr, getProcAddress);
LoadEGL(getProcAddress); LoadEGL(getProcAddress);
...@@ -454,18 +454,13 @@ void ANGLETestBase::initOSWindow() ...@@ -454,18 +454,13 @@ void ANGLETestBase::initOSWindow()
switch (mCurrentParams->driver) switch (mCurrentParams->driver)
{ {
case GLESDriverType::AngleEGL: case GLESDriverType::AngleEGL:
case GLESDriverType::SystemEGL:
{ {
mFixture->eglWindow = mFixture->eglWindow =
EGLWindow::New(mCurrentParams->majorVersion, mCurrentParams->minorVersion); EGLWindow::New(mCurrentParams->majorVersion, mCurrentParams->minorVersion);
break; break;
} }
case GLESDriverType::SystemEGL:
{
std::cerr << "Unsupported driver." << std::endl;
break;
}
case GLESDriverType::SystemWGL: case GLESDriverType::SystemWGL:
{ {
// WGL tests are currently disabled. // WGL tests are currently disabled.
...@@ -536,10 +531,16 @@ void ANGLETestBase::ANGLETestSetUp() ...@@ -536,10 +531,16 @@ void ANGLETestBase::ANGLETestSetUp()
if (mCurrentParams->noFixture) if (mCurrentParams->noFixture)
{ {
LoadEntryPointsWithUtilLoader(); LoadEntryPointsWithUtilLoader(mCurrentParams->driver);
return; return;
} }
if (mLastLoadedDriver.valid() && mCurrentParams->driver != mLastLoadedDriver.value())
{
LoadEntryPointsWithUtilLoader(mCurrentParams->driver);
mLastLoadedDriver = mCurrentParams->driver;
}
// 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;
...@@ -559,11 +560,13 @@ void ANGLETestBase::ANGLETestSetUp() ...@@ -559,11 +560,13 @@ void ANGLETestBase::ANGLETestSetUp()
} }
else else
{ {
Library *driverLib = ANGLETestEnvironment::GetDriverLibrary(mCurrentParams->driver);
if (mForceNewDisplay || !mFixture->eglWindow->isDisplayInitialized()) if (mForceNewDisplay || !mFixture->eglWindow->isDisplayInitialized())
{ {
mFixture->eglWindow->destroyGL(); mFixture->eglWindow->destroyGL();
if (!mFixture->eglWindow->initializeDisplay(mFixture->osWindow, if (!mFixture->eglWindow->initializeDisplay(mFixture->osWindow, driverLib,
ANGLETestEnvironment::GetEGLLibrary(), mCurrentParams->driver,
mCurrentParams->eglParameters)) mCurrentParams->eglParameters))
{ {
FAIL() << "EGL Display init failed."; FAIL() << "EGL Display init failed.";
...@@ -574,8 +577,8 @@ void ANGLETestBase::ANGLETestSetUp() ...@@ -574,8 +577,8 @@ void ANGLETestBase::ANGLETestSetUp()
FAIL() << "Internal parameter conflict error."; FAIL() << "Internal parameter conflict error.";
} }
if (!mFixture->eglWindow->initializeSurface( if (!mFixture->eglWindow->initializeSurface(mFixture->osWindow, driverLib,
mFixture->osWindow, ANGLETestEnvironment::GetEGLLibrary(), mFixture->configParams)) mFixture->configParams))
{ {
FAIL() << "egl surface init failed."; FAIL() << "egl surface init failed.";
} }
...@@ -1286,9 +1289,11 @@ ANGLETestBase::ScopedIgnorePlatformMessages::~ScopedIgnorePlatformMessages() ...@@ -1286,9 +1289,11 @@ ANGLETestBase::ScopedIgnorePlatformMessages::~ScopedIgnorePlatformMessages()
OSWindow *ANGLETestBase::mOSWindowSingleton = nullptr; OSWindow *ANGLETestBase::mOSWindowSingleton = nullptr;
std::map<angle::PlatformParameters, ANGLETestBase::TestFixture> ANGLETestBase::gFixtures; std::map<angle::PlatformParameters, ANGLETestBase::TestFixture> ANGLETestBase::gFixtures;
Optional<EGLint> ANGLETestBase::mLastRendererType; Optional<EGLint> ANGLETestBase::mLastRendererType;
Optional<angle::GLESDriverType> ANGLETestBase::mLastLoadedDriver;
std::unique_ptr<Library> ANGLETestEnvironment::gEGLLibrary; std::unique_ptr<Library> ANGLETestEnvironment::gAngleEGLLibrary;
std::unique_ptr<Library> ANGLETestEnvironment::gWGLLibrary; std::unique_ptr<Library> ANGLETestEnvironment::gSystemEGLLibrary;
std::unique_ptr<Library> ANGLETestEnvironment::gSystemWGLLibrary;
void ANGLETestEnvironment::SetUp() {} void ANGLETestEnvironment::SetUp() {}
...@@ -1297,26 +1302,58 @@ void ANGLETestEnvironment::TearDown() ...@@ -1297,26 +1302,58 @@ void ANGLETestEnvironment::TearDown()
ANGLETestBase::ReleaseFixtures(); ANGLETestBase::ReleaseFixtures();
} }
Library *ANGLETestEnvironment::GetEGLLibrary() // static
Library *ANGLETestEnvironment::GetDriverLibrary(angle::GLESDriverType driver)
{
switch (driver)
{
case angle::GLESDriverType::AngleEGL:
return GetAngleEGLLibrary();
case angle::GLESDriverType::SystemEGL:
return GetSystemEGLLibrary();
case angle::GLESDriverType::SystemWGL:
return GetSystemWGLLibrary();
default:
return nullptr;
}
}
// static
Library *ANGLETestEnvironment::GetAngleEGLLibrary()
{ {
#if defined(ANGLE_USE_UTIL_LOADER) #if defined(ANGLE_USE_UTIL_LOADER)
if (!gEGLLibrary) if (!gAngleEGLLibrary)
{ {
gEGLLibrary.reset(OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, SearchType::ApplicationDir)); gAngleEGLLibrary.reset(
OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, SearchType::ApplicationDir));
} }
#endif // defined(ANGLE_USE_UTIL_LOADER) #endif // defined(ANGLE_USE_UTIL_LOADER)
return gEGLLibrary.get(); return gAngleEGLLibrary.get();
} }
Library *ANGLETestEnvironment::GetWGLLibrary() // static
Library *ANGLETestEnvironment::GetSystemEGLLibrary()
{
#if defined(ANGLE_USE_UTIL_LOADER)
if (!gSystemEGLLibrary)
{
gSystemEGLLibrary.reset(
OpenSharedLibraryWithExtension(GetNativeEGLLibraryNameWithExtension()));
}
#endif // defined(ANGLE_USE_UTIL_LOADER)
return gSystemEGLLibrary.get();
}
// static
Library *ANGLETestEnvironment::GetSystemWGLLibrary()
{ {
#if defined(ANGLE_USE_UTIL_LOADER) && defined(ANGLE_PLATFORM_WINDOWS) #if defined(ANGLE_USE_UTIL_LOADER) && defined(ANGLE_PLATFORM_WINDOWS)
if (!gWGLLibrary) if (!gSystemWGLLibrary)
{ {
gWGLLibrary.reset(OpenSharedLibrary("opengl32", SearchType::SystemDir)); gSystemWGLLibrary.reset(OpenSharedLibrary("opengl32", SearchType::SystemDir));
} }
#endif // defined(ANGLE_USE_UTIL_LOADER) && defined(ANGLE_PLATFORM_WINDOWS) #endif // defined(ANGLE_USE_UTIL_LOADER) && defined(ANGLE_PLATFORM_WINDOWS)
return gWGLLibrary.get(); return gSystemWGLLibrary.get();
} }
void ANGLEProcessTestArgs(int *argc, char *argv[]) void ANGLEProcessTestArgs(int *argc, char *argv[])
......
...@@ -186,7 +186,7 @@ constexpr std::array<GLenum, 6> kCubeFaces = { ...@@ -186,7 +186,7 @@ constexpr std::array<GLenum, 6> kCubeFaces = {
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z}}; GL_TEXTURE_CUBE_MAP_NEGATIVE_Z}};
void LoadEntryPointsWithUtilLoader(); void LoadEntryPointsWithUtilLoader(angle::GLESDriverType driver);
} // namespace angle } // namespace angle
...@@ -545,6 +545,7 @@ class ANGLETestBase ...@@ -545,6 +545,7 @@ class ANGLETestBase
// Workaround for NVIDIA not being able to share a window with OpenGL and Vulkan. // Workaround for NVIDIA not being able to share a window with OpenGL and Vulkan.
static Optional<EGLint> mLastRendererType; static Optional<EGLint> mLastRendererType;
static Optional<angle::GLESDriverType> mLastLoadedDriver;
}; };
template <typename Params = angle::PlatformParameters> template <typename Params = angle::PlatformParameters>
...@@ -596,13 +597,17 @@ class ANGLETestEnvironment : public testing::Environment ...@@ -596,13 +597,17 @@ class ANGLETestEnvironment : public testing::Environment
void SetUp() override; void SetUp() override;
void TearDown() override; void TearDown() override;
static angle::Library *GetEGLLibrary(); static angle::Library *GetDriverLibrary(angle::GLESDriverType driver);
static angle::Library *GetWGLLibrary();
private: private:
static angle::Library *GetAngleEGLLibrary();
static angle::Library *GetSystemEGLLibrary();
static angle::Library *GetSystemWGLLibrary();
// For loading entry points. // For loading entry points.
static std::unique_ptr<angle::Library> gEGLLibrary; static std::unique_ptr<angle::Library> gAngleEGLLibrary;
static std::unique_ptr<angle::Library> gWGLLibrary; static std::unique_ptr<angle::Library> gSystemEGLLibrary;
static std::unique_ptr<angle::Library> gSystemWGLLibrary;
}; };
extern angle::PlatformMethods gDefaultPlatformMethods; extern angle::PlatformMethods gDefaultPlatformMethods;
......
...@@ -112,7 +112,7 @@ std::ostream &operator<<(std::ostream &stream, const PlatformParameters &pp) ...@@ -112,7 +112,7 @@ std::ostream &operator<<(std::ostream &stream, const PlatformParameters &pp)
stream << "WGL"; stream << "WGL";
break; break;
case GLESDriverType::SystemEGL: case GLESDriverType::SystemEGL:
stream << "GLES"; stream << "EGL";
break; break;
default: default:
stream << "Error"; stream << "Error";
...@@ -769,4 +769,28 @@ PlatformParameters ES3_WGL() ...@@ -769,4 +769,28 @@ PlatformParameters ES3_WGL()
{ {
return PlatformParameters(3, 0, GLESDriverType::SystemWGL); return PlatformParameters(3, 0, GLESDriverType::SystemWGL);
} }
PlatformParameters ES2_EGL()
{
return PlatformParameters(2, 0, GLESDriverType::SystemEGL);
}
PlatformParameters ES3_EGL()
{
return PlatformParameters(3, 0, GLESDriverType::SystemEGL);
}
const char *GetNativeEGLLibraryNameWithExtension()
{
#if defined(ANGLE_PLATFORM_ANDROID)
return "libEGL.so";
#elif defined(ANGLE_PLATFORM_LINUX)
return "libEGL.so.1";
#elif defined(ANGLE_PLATFORM_WINDOWS)
return "libEGL.dll";
#else
return "unknown_libegl";
#endif
}
} // namespace angle } // namespace angle
...@@ -23,17 +23,6 @@ ...@@ -23,17 +23,6 @@
namespace angle namespace angle
{ {
// The GLES driver type determines what shared object we use to load the GLES entry points.
// AngleEGL loads from ANGLE's version of libEGL, libGLESv2, and libGLESv1_CM.
// SystemEGL uses the system copies of libEGL, libGLESv2, and libGLESv1_CM.
// SystemWGL loads Windows GL with the GLES compatiblity extensions. See util/WGLWindow.h.
enum class GLESDriverType
{
AngleEGL,
SystemEGL,
SystemWGL,
};
struct PlatformParameters struct PlatformParameters
{ {
PlatformParameters(); PlatformParameters();
...@@ -197,6 +186,11 @@ PlatformParameters ES3_METAL(); ...@@ -197,6 +186,11 @@ PlatformParameters ES3_METAL();
PlatformParameters ES2_WGL(); PlatformParameters ES2_WGL();
PlatformParameters ES3_WGL(); PlatformParameters ES3_WGL();
PlatformParameters ES2_EGL();
PlatformParameters ES3_EGL();
const char *GetNativeEGLLibraryNameWithExtension();
inline PlatformParameters WithNoVirtualContexts(const PlatformParameters &params) inline PlatformParameters WithNoVirtualContexts(const PlatformParameters &params)
{ {
PlatformParameters withNoVirtualContexts = params; PlatformParameters withNoVirtualContexts = params;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <map> #include <map>
#include "angle_gl.h" #include "angle_gl.h"
#include "common/debug.h"
#include "common/platform.h" #include "common/platform.h"
#include "common/system_utils.h" #include "common/system_utils.h"
#include "common/third_party/base/anglebase/no_destructor.h" #include "common/third_party/base/anglebase/no_destructor.h"
...@@ -36,7 +37,7 @@ namespace angle ...@@ -36,7 +37,7 @@ namespace angle
{ {
namespace namespace
{ {
bool IsANGLEConfigSupported(const PlatformParameters &param, OSWindow *osWindow) bool IsAngleEGLConfigSupported(const PlatformParameters &param, OSWindow *osWindow)
{ {
std::unique_ptr<angle::Library> eglLibrary; std::unique_ptr<angle::Library> eglLibrary;
...@@ -48,13 +49,14 @@ bool IsANGLEConfigSupported(const PlatformParameters &param, OSWindow *osWindow) ...@@ -48,13 +49,14 @@ bool IsANGLEConfigSupported(const PlatformParameters &param, OSWindow *osWindow)
EGLWindow *eglWindow = EGLWindow::New(param.majorVersion, param.minorVersion); EGLWindow *eglWindow = EGLWindow::New(param.majorVersion, param.minorVersion);
ConfigParameters configParams; ConfigParameters configParams;
bool result = bool result =
eglWindow->initializeGL(osWindow, eglLibrary.get(), param.eglParameters, configParams); eglWindow->initializeGL(osWindow, eglLibrary.get(), angle::GLESDriverType::AngleEGL,
param.eglParameters, configParams);
eglWindow->destroyGL(); eglWindow->destroyGL();
EGLWindow::Delete(&eglWindow); EGLWindow::Delete(&eglWindow);
return result; return result;
} }
bool IsWGLConfigSupported(const PlatformParameters &param, OSWindow *osWindow) bool IsSystemWGLConfigSupported(const PlatformParameters &param, OSWindow *osWindow)
{ {
#if defined(ANGLE_PLATFORM_WINDOWS) && defined(ANGLE_USE_UTIL_LOADER) #if defined(ANGLE_PLATFORM_WINDOWS) && defined(ANGLE_USE_UTIL_LOADER)
std::unique_ptr<angle::Library> openglLibrary( std::unique_ptr<angle::Library> openglLibrary(
...@@ -63,7 +65,8 @@ bool IsWGLConfigSupported(const PlatformParameters &param, OSWindow *osWindow) ...@@ -63,7 +65,8 @@ bool IsWGLConfigSupported(const PlatformParameters &param, OSWindow *osWindow)
WGLWindow *wglWindow = WGLWindow::New(param.majorVersion, param.minorVersion); WGLWindow *wglWindow = WGLWindow::New(param.majorVersion, param.minorVersion);
ConfigParameters configParams; ConfigParameters configParams;
bool result = bool result =
wglWindow->initializeGL(osWindow, openglLibrary.get(), param.eglParameters, configParams); wglWindow->initializeGL(osWindow, openglLibrary.get(), angle::GLESDriverType::SystemWGL,
param.eglParameters, configParams);
wglWindow->destroyGL(); wglWindow->destroyGL();
WGLWindow::Delete(&wglWindow); WGLWindow::Delete(&wglWindow);
return result; return result;
...@@ -72,10 +75,24 @@ bool IsWGLConfigSupported(const PlatformParameters &param, OSWindow *osWindow) ...@@ -72,10 +75,24 @@ bool IsWGLConfigSupported(const PlatformParameters &param, OSWindow *osWindow)
#endif // defined(ANGLE_PLATFORM_WINDOWS) && defined(ANGLE_USE_UTIL_LOADER) #endif // defined(ANGLE_PLATFORM_WINDOWS) && defined(ANGLE_USE_UTIL_LOADER)
} }
bool IsNativeConfigSupported(const PlatformParameters &param, OSWindow *osWindow) bool IsSystemEGLConfigSupported(const PlatformParameters &param, OSWindow *osWindow)
{ {
// Not yet implemented. #if defined(ANGLE_USE_UTIL_LOADER)
std::unique_ptr<angle::Library> eglLibrary;
eglLibrary.reset(OpenSharedLibraryWithExtension(GetNativeEGLLibraryNameWithExtension()));
EGLWindow *eglWindow = EGLWindow::New(param.majorVersion, param.minorVersion);
ConfigParameters configParams;
bool result =
eglWindow->initializeGL(osWindow, eglLibrary.get(), angle::GLESDriverType::SystemEGL,
param.eglParameters, configParams);
eglWindow->destroyGL();
EGLWindow::Delete(&eglWindow);
return result;
#else
return false; return false;
#endif
} }
bool IsAndroidDevice(const std::string &deviceName) bool IsAndroidDevice(const std::string &deviceName)
...@@ -412,13 +429,23 @@ bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters ...@@ -412,13 +429,23 @@ bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters
return (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE); return (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE);
} }
if (IsLinux()) if (IsLinux() || IsAndroid())
{ {
// We do not support non-ANGLE bindings on Linux. // We do not support WGL bindings on Linux/Android. We do support system EGL.
if (param.driver != GLESDriverType::AngleEGL) switch (param.driver)
{ {
return false; case GLESDriverType::SystemEGL:
return param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
case GLESDriverType::SystemWGL:
return false;
default:
break;
} }
}
if (IsLinux())
{
ASSERT(param.driver == GLESDriverType::AngleEGL);
// Currently we support the OpenGL and Vulkan back-ends on Linux. // Currently we support the OpenGL and Vulkan back-ends on Linux.
switch (param.getRenderer()) switch (param.getRenderer())
...@@ -434,11 +461,7 @@ bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters ...@@ -434,11 +461,7 @@ bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters
if (IsAndroid()) if (IsAndroid())
{ {
// We do not support non-ANGLE bindings on Android. ASSERT(param.driver == GLESDriverType::AngleEGL);
if (param.driver != GLESDriverType::AngleEGL)
{
return false;
}
// Nexus Android devices don't support backing 3.2 contexts // Nexus Android devices don't support backing 3.2 contexts
if (param.eglParameters.majorVersion == 3 && param.eglParameters.minorVersion == 2) if (param.eglParameters.majorVersion == 3 && param.eglParameters.minorVersion == 2)
...@@ -493,13 +516,13 @@ bool IsConfigSupported(const PlatformParameters &param) ...@@ -493,13 +516,13 @@ bool IsConfigSupported(const PlatformParameters &param)
switch (param.driver) switch (param.driver)
{ {
case GLESDriverType::AngleEGL: case GLESDriverType::AngleEGL:
result = IsANGLEConfigSupported(param, osWindow); result = IsAngleEGLConfigSupported(param, osWindow);
break; break;
case GLESDriverType::SystemEGL: case GLESDriverType::SystemEGL:
result = IsNativeConfigSupported(param, osWindow); result = IsSystemEGLConfigSupported(param, osWindow);
break; break;
case GLESDriverType::SystemWGL: case GLESDriverType::SystemWGL:
result = IsWGLConfigSupported(param, osWindow); result = IsSystemWGLConfigSupported(param, osWindow);
break; break;
} }
......
...@@ -15,6 +15,17 @@ ...@@ -15,6 +15,17 @@
namespace angle namespace angle
{ {
struct PlatformMethods; struct PlatformMethods;
// The GLES driver type determines what shared object we use to load the GLES entry points.
// AngleEGL loads from ANGLE's version of libEGL, libGLESv2, and libGLESv1_CM.
// SystemEGL uses the system copies of libEGL, libGLESv2, and libGLESv1_CM.
// SystemWGL loads Windows GL with the GLES compatiblity extensions. See util/WGLWindow.h.
enum class GLESDriverType
{
AngleEGL,
SystemEGL,
SystemWGL,
};
} // namespace angle } // namespace angle
struct EGLPlatformParameters struct EGLPlatformParameters
......
...@@ -69,6 +69,7 @@ class ANGLE_UTIL_EXPORT GLWindowBase : angle::NonCopyable ...@@ -69,6 +69,7 @@ class ANGLE_UTIL_EXPORT GLWindowBase : angle::NonCopyable
virtual bool initializeGL(OSWindow *osWindow, virtual bool initializeGL(OSWindow *osWindow,
angle::Library *glWindowingLibrary, angle::Library *glWindowingLibrary,
angle::GLESDriverType driverType,
const EGLPlatformParameters &platformParams, const EGLPlatformParameters &platformParams,
const ConfigParameters &configParams) = 0; const ConfigParameters &configParams) = 0;
virtual bool isGLInitialized() const = 0; virtual bool isGLInitialized() const = 0;
...@@ -112,6 +113,7 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase ...@@ -112,6 +113,7 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase
// Internally initializes the Display, Surface and Context. // Internally initializes the Display, Surface and Context.
bool initializeGL(OSWindow *osWindow, bool initializeGL(OSWindow *osWindow,
angle::Library *glWindowingLibrary, angle::Library *glWindowingLibrary,
angle::GLESDriverType driverType,
const EGLPlatformParameters &platformParams, const EGLPlatformParameters &platformParams,
const ConfigParameters &configParams) override; const ConfigParameters &configParams) override;
...@@ -125,6 +127,7 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase ...@@ -125,6 +127,7 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase
// Only initializes the Display. // Only initializes the Display.
bool initializeDisplay(OSWindow *osWindow, bool initializeDisplay(OSWindow *osWindow,
angle::Library *glWindowingLibrary, angle::Library *glWindowingLibrary,
angle::GLESDriverType driverType,
const EGLPlatformParameters &params); const EGLPlatformParameters &params);
// Only initializes the Surface. // Only initializes the Surface.
......
...@@ -71,9 +71,15 @@ WGLWindow::~WGLWindow() {} ...@@ -71,9 +71,15 @@ WGLWindow::~WGLWindow() {}
// Internally initializes GL resources. // Internally initializes GL resources.
bool WGLWindow::initializeGL(OSWindow *osWindow, bool WGLWindow::initializeGL(OSWindow *osWindow,
angle::Library *glWindowingLibrary, angle::Library *glWindowingLibrary,
angle::GLESDriverType driverType,
const EGLPlatformParameters &platformParams, const EGLPlatformParameters &platformParams,
const ConfigParameters &configParams) const ConfigParameters &configParams)
{ {
if (driverType != angle::GLESDriverType::SystemWGL)
{
return false;
}
glWindowingLibrary->getAs("wglGetProcAddress", &gCurrentWGLGetProcAddress); glWindowingLibrary->getAs("wglGetProcAddress", &gCurrentWGLGetProcAddress);
if (!gCurrentWGLGetProcAddress) if (!gCurrentWGLGetProcAddress)
......
...@@ -30,6 +30,7 @@ class ANGLE_UTIL_EXPORT WGLWindow : public GLWindowBase ...@@ -30,6 +30,7 @@ class ANGLE_UTIL_EXPORT WGLWindow : public GLWindowBase
// Internally initializes GL resources. // Internally initializes GL resources.
bool initializeGL(OSWindow *osWindow, bool initializeGL(OSWindow *osWindow,
angle::Library *glWindowingLibrary, angle::Library *glWindowingLibrary,
angle::GLESDriverType driverType,
const EGLPlatformParameters &platformParams, const EGLPlatformParameters &platformParams,
const ConfigParameters &configParams) override; const ConfigParameters &configParams) override;
void destroyGL() override; void destroyGL() 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