Commit 11e26fa0 by Jamie Madill Committed by Commit Bot

Allow running Samples against native GL.

Useful for perf testing/comparison. Bug: angleproject:4729 Change-Id: Ic46424570dcef0a30d506962f546910ba7440595 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2241620Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 31bbe1ba
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "SampleApplication.h" #include "SampleApplication.h"
#include "common/debug.h"
#include "util/EGLWindow.h" #include "util/EGLWindow.h"
#include "util/gles_loader_autogen.h" #include "util/gles_loader_autogen.h"
#include "util/random_utils.h" #include "util/random_utils.h"
...@@ -15,9 +16,14 @@ ...@@ -15,9 +16,14 @@
#include <iostream> #include <iostream>
#include <utility> #include <utility>
#if defined(ANGLE_PLATFORM_WINDOWS)
# include "util/windows/WGLWindow.h"
#endif // defined(ANGLE_PLATFORM_WINDOWS)
namespace namespace
{ {
const char *kUseAngleArg = "--use-angle="; const char *kUseAngleArg = "--use-angle=";
const char *kUseGlArg = "--use-gl=native";
using DisplayTypeInfo = std::pair<const char *, EGLint>; using DisplayTypeInfo = std::pair<const char *, EGLint>;
...@@ -71,29 +77,56 @@ SampleApplication::SampleApplication(std::string name, ...@@ -71,29 +77,56 @@ SampleApplication::SampleApplication(std::string name,
mWidth(width), mWidth(width),
mHeight(height), mHeight(height),
mRunning(false), mRunning(false),
mGLWindow(nullptr),
mEGLWindow(nullptr), mEGLWindow(nullptr),
mOSWindow(nullptr) mOSWindow(nullptr),
mDriverType(angle::GLESDriverType::AngleEGL)
{ {
mPlatformParams.renderer = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE; mPlatformParams.renderer = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
bool useNativeGL = false;
if (argc > 1 && strncmp(argv[1], kUseAngleArg, strlen(kUseAngleArg)) == 0) for (int argIndex = 1; argIndex < argc; argIndex++)
{ {
const char *arg = argv[1] + strlen(kUseAngleArg); if (strncmp(argv[argIndex], kUseAngleArg, strlen(kUseAngleArg)) == 0)
mPlatformParams.renderer = GetDisplayTypeFromArg(arg); {
mPlatformParams.deviceType = GetDeviceTypeFromArg(arg); const char *arg = argv[argIndex] + strlen(kUseAngleArg);
mPlatformParams.renderer = GetDisplayTypeFromArg(arg);
mPlatformParams.deviceType = GetDeviceTypeFromArg(arg);
}
if (strncmp(argv[argIndex], kUseGlArg, strlen(kUseGlArg)) == 0)
{
useNativeGL = true;
}
} }
// Load EGL library so we can initialize the display. mOSWindow = OSWindow::New();
mEntryPointsLib.reset(
angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, angle::SearchType::ApplicationDir));
mEGLWindow = EGLWindow::New(glesMajorVersion, glesMinorVersion); // Load EGL library so we can initialize the display.
mOSWindow = OSWindow::New(); if (useNativeGL)
{
#if defined(ANGLE_PLATFORM_WINDOWS)
mGLWindow = WGLWindow::New(glesMajorVersion, glesMinorVersion);
mEntryPointsLib.reset(angle::OpenSharedLibrary("opengl32", angle::SearchType::SystemDir));
mDriverType = angle::GLESDriverType::SystemWGL;
#else
mGLWindow = EGLWindow::New(glesMajorVersion, glesMinorVersion);
mEntryPointsLib.reset(
angle::OpenSharedLibraryWithExtension(angle::GetNativeEGLLibraryNameWithExtension()));
mDriverType = angle::GLESDriverType::SystemEGL;
#endif // defined(ANGLE_PLATFORM_WINDOWS)
}
else
{
mGLWindow = mEGLWindow = EGLWindow::New(glesMajorVersion, glesMinorVersion);
mEntryPointsLib.reset(
angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, angle::SearchType::ApplicationDir));
}
} }
SampleApplication::~SampleApplication() SampleApplication::~SampleApplication()
{ {
EGLWindow::Delete(&mEGLWindow); GLWindowBase::Delete(&mGLWindow);
OSWindow::Delete(&mOSWindow); OSWindow::Delete(&mOSWindow);
} }
...@@ -110,7 +143,7 @@ void SampleApplication::draw() {} ...@@ -110,7 +143,7 @@ void SampleApplication::draw() {}
void SampleApplication::swap() void SampleApplication::swap()
{ {
mEGLWindow->swap(); mGLWindow->swap();
} }
OSWindow *SampleApplication::getWindow() const OSWindow *SampleApplication::getWindow() const
...@@ -120,21 +153,25 @@ OSWindow *SampleApplication::getWindow() const ...@@ -120,21 +153,25 @@ OSWindow *SampleApplication::getWindow() const
EGLConfig SampleApplication::getConfig() const EGLConfig SampleApplication::getConfig() const
{ {
ASSERT(mEGLWindow);
return mEGLWindow->getConfig(); return mEGLWindow->getConfig();
} }
EGLDisplay SampleApplication::getDisplay() const EGLDisplay SampleApplication::getDisplay() const
{ {
ASSERT(mEGLWindow);
return mEGLWindow->getDisplay(); return mEGLWindow->getDisplay();
} }
EGLSurface SampleApplication::getSurface() const EGLSurface SampleApplication::getSurface() const
{ {
ASSERT(mEGLWindow);
return mEGLWindow->getSurface(); return mEGLWindow->getSurface();
} }
EGLContext SampleApplication::getContext() const EGLContext SampleApplication::getContext() const
{ {
ASSERT(mEGLWindow);
return mEGLWindow->getContext(); return mEGLWindow->getContext();
} }
...@@ -155,20 +192,18 @@ int SampleApplication::run() ...@@ -155,20 +192,18 @@ int SampleApplication::run()
configParams.depthBits = 24; configParams.depthBits = 24;
configParams.stencilBits = 8; configParams.stencilBits = 8;
if (!mEGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), angle::GLESDriverType::AngleEGL, if (!mGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), mDriverType, mPlatformParams,
mPlatformParams, configParams)) configParams))
{ {
return -1; return -1;
} }
// Disable vsync // Disable vsync
if (!mEGLWindow->setSwapInterval(0)) if (!mGLWindow->setSwapInterval(0))
{ {
return -1; return -1;
} }
angle::LoadGLES(eglGetProcAddress);
mRunning = true; mRunning = true;
int result = 0; int result = 0;
...@@ -223,7 +258,7 @@ int SampleApplication::run() ...@@ -223,7 +258,7 @@ int SampleApplication::run()
} }
destroy(); destroy();
mEGLWindow->destroyGL(); mGLWindow->destroyGL();
mOSWindow->destroy(); mOSWindow->destroy();
return result; return result;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "util/egl_loader_autogen.h" #include "util/egl_loader_autogen.h"
class EGLWindow; class EGLWindow;
class GLWindowBase;
namespace angle namespace angle
{ {
...@@ -66,8 +67,10 @@ class SampleApplication ...@@ -66,8 +67,10 @@ class SampleApplication
bool mRunning; bool mRunning;
Timer mTimer; Timer mTimer;
GLWindowBase *mGLWindow;
EGLWindow *mEGLWindow; EGLWindow *mEGLWindow;
OSWindow *mOSWindow; OSWindow *mOSWindow;
angle::GLESDriverType mDriverType;
EGLPlatformParameters mPlatformParams; EGLPlatformParameters mPlatformParams;
......
...@@ -784,18 +784,4 @@ PlatformParameters ES3_EGL() ...@@ -784,18 +784,4 @@ PlatformParameters ES3_EGL()
{ {
return PlatformParameters(3, 0, GLESDriverType::SystemEGL); 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
...@@ -433,4 +433,15 @@ int NumberOfProcessors() ...@@ -433,4 +433,15 @@ int NumberOfProcessors()
return static_cast<int>(res); return static_cast<int>(res);
} }
const char *GetNativeEGLLibraryNameWithExtension()
{
#if defined(ANGLE_PLATFORM_ANDROID)
return "libEGL.so";
#elif defined(ANGLE_PLATFORM_LINUX)
return "libEGL.so.1";
#else
return "unknown_libegl";
#endif
}
} // namespace angle } // namespace angle
...@@ -120,6 +120,7 @@ Process *LaunchProcess(const std::vector<const char *> &args, ...@@ -120,6 +120,7 @@ Process *LaunchProcess(const std::vector<const char *> &args,
int NumberOfProcessors(); int NumberOfProcessors();
const char *GetNativeEGLLibraryNameWithExtension();
} // namespace angle } // namespace angle
#endif // UTIL_TEST_UTILS_H_ #endif // UTIL_TEST_UTILS_H_
...@@ -444,4 +444,9 @@ bool DeleteFile(const char *path) ...@@ -444,4 +444,9 @@ bool DeleteFile(const char *path)
return !!::DeleteFileA(path) ? true : ReturnSuccessOnNotFound(); return !!::DeleteFileA(path) ? true : ReturnSuccessOnNotFound();
} }
const char *GetNativeEGLLibraryNameWithExtension()
{
return "libEGL.dll";
}
} // namespace angle } // namespace angle
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