Commit 0f566fc7 by Jamie Madill Committed by Commit Bot

Introduce ConfigParameters test helper struct.

This allows us to more easily compare sets of parameters used in our tests. The config parameters are stuff like the red / gree / blue bits used in an EGL config. Or particular sets of extensions or other EGL options. This will more easily allow us to determine when we need to use a new EGL display instead of reusing a prior. Bug: angleproject:3261 Change-Id: Ia1f0ede988e0b4084fbb4d55097e94fd89ee4899 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1531535 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent a532570a
......@@ -70,16 +70,6 @@ SampleApplication::SampleApplication(std::string name,
EGLPlatformParameters(requestedRenderer));
mTimer.reset(CreateTimer());
mOSWindow = OSWindow::New();
mEGLWindow->setConfigRedBits(8);
mEGLWindow->setConfigGreenBits(8);
mEGLWindow->setConfigBlueBits(8);
mEGLWindow->setConfigAlphaBits(8);
mEGLWindow->setConfigDepthBits(24);
mEGLWindow->setConfigStencilBits(8);
// Disable vsync
mEGLWindow->setSwapInterval(0);
}
SampleApplication::~SampleApplication()
......@@ -138,7 +128,18 @@ int SampleApplication::run()
mOSWindow->setVisible(true);
if (!mEGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get()))
ConfigParameters configParams;
configParams.redBits = 8;
configParams.greenBits = 8;
configParams.blueBits = 8;
configParams.alphaBits = 8;
configParams.depthBits = 24;
configParams.stencilBits = 8;
// Disable vsync
configParams.swapInterval = 0;
if (!mEGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), configParams))
{
return -1;
}
......
......@@ -710,7 +710,8 @@ class ProgramBinariesAcrossPlatforms : public testing::TestWithParam<PlatformsWi
{
EGLWindow *eglWindow =
EGLWindow::New(param.majorVersion, param.minorVersion, param.eglParameters);
bool result = eglWindow->initializeGL(mOSWindow, mEntryPointsLib.get());
ConfigParameters configParams;
bool result = eglWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), configParams);
if (result == false)
{
EGLWindow::Delete(&eglWindow);
......
......@@ -416,7 +416,8 @@ void ANGLERenderTest::SetUp()
return;
}
mGLWindow->setSwapInterval(0);
// Disable vsync.
mConfigParams.swapInterval = 0;
mPlatformMethods.overrideWorkaroundsD3D = OverrideWorkaroundsD3D;
mPlatformMethods.logError = EmptyPlatformMethod;
......@@ -427,7 +428,8 @@ void ANGLERenderTest::SetUp()
mPlatformMethods.updateTraceEventDuration = UpdateTraceEventDuration;
mPlatformMethods.monotonicallyIncreasingTime = MonotonicallyIncreasingTime;
mPlatformMethods.context = this;
mGLWindow->setPlatformMethods(&mPlatformMethods);
mConfigParams.platformMethods = &mPlatformMethods;
if (!mOSWindow->initialize(mName, mTestParams.windowWidth, mTestParams.windowHeight))
{
......@@ -436,7 +438,7 @@ void ANGLERenderTest::SetUp()
// FAIL returns.
}
if (!mGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get()))
if (!mGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), mConfigParams))
{
mSkipTest = true;
FAIL() << "Failed initializing GL Window";
......@@ -588,12 +590,12 @@ bool ANGLERenderTest::areExtensionPrerequisitesFulfilled() const
void ANGLERenderTest::setWebGLCompatibilityEnabled(bool webglCompatibility)
{
mGLWindow->setWebGLCompatibilityEnabled(webglCompatibility);
mConfigParams.webGLCompatibility = webglCompatibility;
}
void ANGLERenderTest::setRobustResourceInit(bool enabled)
{
mGLWindow->setRobustResourceInit(enabled);
mConfigParams.robustResourceInit = enabled;
}
std::vector<TraceEvent> &ANGLERenderTest::getTraceEventBuffer()
......
......@@ -163,6 +163,7 @@ class ANGLERenderTest : public ANGLEPerfTest
OSWindow *mOSWindow;
std::vector<const char *> mExtensionPrerequisites;
angle::PlatformMethods mPlatformMethods;
ConfigParameters mConfigParams;
GLuint mTimestampQuery;
......
......@@ -319,7 +319,7 @@ ANGLETestBase::ANGLETestBase(const angle::PlatformParameters &params)
EGLWindow::New(params.majorVersion, params.minorVersion, params.eglParameters);
// Default debug layers to enabled in tests.
mEGLWindow->setDebugLayersEnabled(true);
mConfigParameters.debugLayersEnabled = true;
// 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.
......@@ -406,7 +406,8 @@ void ANGLETestBase::ANGLETestSetUp()
if (mWGLWindow)
{
#if defined(ANGLE_PLATFORM_WINDOWS) && defined(ANGLE_USE_UTIL_LOADER)
if (!mWGLWindow->initializeGL(mOSWindow, ANGLETestEnvironment::GetWGLLibrary()))
if (!mWGLWindow->initializeGL(mOSWindow, ANGLETestEnvironment::GetWGLLibrary(),
mConfigParameters))
{
std::cerr << "WGL init failed.. trying again with new OSWindow." << std::endl;
......@@ -419,7 +420,8 @@ void ANGLETestBase::ANGLETestSetUp()
FAIL() << "Failed to create ANGLE test window.";
}
if (!mWGLWindow->initializeGL(mOSWindow, ANGLETestEnvironment::GetWGLLibrary()))
if (!mWGLWindow->initializeGL(mOSWindow, ANGLETestEnvironment::GetWGLLibrary(),
mConfigParameters))
{
FAIL() << "WGL init failed.";
}
......@@ -436,12 +438,18 @@ void ANGLETestBase::ANGLETestSetUp()
mPlatformMethods.logWarning = angle::TestPlatform_logWarning;
mPlatformMethods.logInfo = angle::TestPlatform_logInfo;
mPlatformMethods.context = &mPlatformContext;
mEGLWindow->setPlatformMethods(&mPlatformMethods);
mConfigParameters.platformMethods = &mPlatformMethods;
if (!mEGLWindow->initializeDisplayAndSurface(mOSWindow,
ANGLETestEnvironment::GetEGLLibrary()))
if (!mEGLWindow->initializeDisplay(mOSWindow, ANGLETestEnvironment::GetEGLLibrary(),
mConfigParameters))
{
FAIL() << "egl display or surface init failed.";
FAIL() << "egl display init failed.";
}
if (!mEGLWindow->initializeSurface(mOSWindow, ANGLETestEnvironment::GetEGLLibrary(),
mConfigParameters))
{
FAIL() << "egl surface init failed.";
}
if (!mDeferContextInit && !mEGLWindow->initializeContext())
......@@ -471,7 +479,7 @@ void ANGLETestBase::ANGLETestTearDown()
{
if (mEGLWindow)
{
mEGLWindow->setPlatformMethods(nullptr);
mConfigParameters.platformMethods = nullptr;
checkD3D11SDKLayersMessages();
}
......@@ -991,102 +999,102 @@ GLWindowBase *ANGLETestBase::getGLWindow() const
void ANGLETestBase::setConfigRedBits(int bits)
{
getGLWindow()->setConfigRedBits(bits);
mConfigParameters.redBits = bits;
}
void ANGLETestBase::setConfigGreenBits(int bits)
{
getGLWindow()->setConfigGreenBits(bits);
mConfigParameters.greenBits = bits;
}
void ANGLETestBase::setConfigBlueBits(int bits)
{
getGLWindow()->setConfigBlueBits(bits);
mConfigParameters.blueBits = bits;
}
void ANGLETestBase::setConfigAlphaBits(int bits)
{
getGLWindow()->setConfigAlphaBits(bits);
mConfigParameters.alphaBits = bits;
}
void ANGLETestBase::setConfigDepthBits(int bits)
{
getGLWindow()->setConfigDepthBits(bits);
mConfigParameters.depthBits = bits;
}
void ANGLETestBase::setConfigStencilBits(int bits)
{
getGLWindow()->setConfigStencilBits(bits);
mConfigParameters.stencilBits = bits;
}
void ANGLETestBase::setConfigComponentType(EGLenum componentType)
{
mEGLWindow->setConfigComponentType(componentType);
mConfigParameters.componentType = componentType;
}
void ANGLETestBase::setMultisampleEnabled(bool enabled)
{
mEGLWindow->setMultisample(enabled);
mConfigParameters.multisample = enabled;
}
void ANGLETestBase::setSamples(EGLint samples)
{
mEGLWindow->setSamples(samples);
mConfigParameters.samples = samples;
}
void ANGLETestBase::setDebugEnabled(bool enabled)
{
mEGLWindow->setDebugEnabled(enabled);
mConfigParameters.debug = enabled;
}
void ANGLETestBase::setNoErrorEnabled(bool enabled)
{
mEGLWindow->setNoErrorEnabled(enabled);
mConfigParameters.noError = enabled;
}
void ANGLETestBase::setWebGLCompatibilityEnabled(bool webglCompatibility)
{
mEGLWindow->setWebGLCompatibilityEnabled(webglCompatibility);
mConfigParameters.webGLCompatibility = webglCompatibility;
}
void ANGLETestBase::setExtensionsEnabled(bool extensionsEnabled)
{
mEGLWindow->setExtensionsEnabled(extensionsEnabled);
mConfigParameters.extensionsEnabled = extensionsEnabled;
}
void ANGLETestBase::setRobustAccess(bool enabled)
{
mEGLWindow->setRobustAccess(enabled);
mConfigParameters.robustAccess = enabled;
}
void ANGLETestBase::setBindGeneratesResource(bool bindGeneratesResource)
{
mEGLWindow->setBindGeneratesResource(bindGeneratesResource);
mConfigParameters.bindGeneratesResource = bindGeneratesResource;
}
void ANGLETestBase::setDebugLayersEnabled(bool enabled)
{
mEGLWindow->setDebugLayersEnabled(enabled);
mConfigParameters.debugLayersEnabled = enabled;
}
void ANGLETestBase::setClientArraysEnabled(bool enabled)
{
mEGLWindow->setClientArraysEnabled(enabled);
mConfigParameters.clientArraysEnabled = enabled;
}
void ANGLETestBase::setRobustResourceInit(bool enabled)
{
mEGLWindow->setRobustResourceInit(enabled);
mConfigParameters.robustResourceInit = enabled;
}
void ANGLETestBase::setContextProgramCacheEnabled(bool enabled)
{
mEGLWindow->setContextProgramCacheEnabled(enabled);
mConfigParameters.contextProgramCacheEnabled = enabled;
}
void ANGLETestBase::setContextVirtualization(bool enabled)
{
mEGLWindow->setContextVirtualization(enabled);
mConfigParameters.contextVirtualization = enabled;
}
void ANGLETestBase::setDeferContextInit(bool enabled)
......
......@@ -18,6 +18,7 @@
#include "common/angleutils.h"
#include "common/vector_utils.h"
#include "platform/Platform.h"
#include "util/EGLWindow.h"
#include "util/shader_utils.h"
#include "util/system_utils.h"
#include "util/util_gl.h"
......@@ -411,6 +412,7 @@ class ANGLETestBase
EGLWindow *mEGLWindow;
WGLWindow *mWGLWindow;
ConfigParameters mConfigParameters;
int mWidth;
int mHeight;
......
......@@ -38,7 +38,8 @@ bool IsANGLEConfigSupported(const PlatformParameters &param, OSWindow *osWindow)
EGLWindow *eglWindow =
EGLWindow::New(param.majorVersion, param.minorVersion, param.eglParameters);
bool result = eglWindow->initializeGL(osWindow, eglLibrary.get());
ConfigParameters configParams;
bool result = eglWindow->initializeGL(osWindow, eglLibrary.get(), configParams);
eglWindow->destroyGL();
EGLWindow::Delete(&eglWindow);
return result;
......@@ -50,7 +51,8 @@ bool IsWGLConfigSupported(const PlatformParameters &param, OSWindow *osWindow)
std::unique_ptr<angle::Library> openglLibrary(angle::OpenSharedLibrary("opengl32"));
WGLWindow *wglWindow = WGLWindow::New(param.majorVersion, param.minorVersion);
bool result = wglWindow->initializeGL(osWindow, openglLibrary.get());
ConfigParameters configParams;
bool result = wglWindow->initializeGL(osWindow, openglLibrary.get(), configParams);
wglWindow->destroyGL();
WGLWindow::Delete(&wglWindow);
return result;
......
......@@ -26,46 +26,78 @@ class Library;
struct PlatformMethods;
} // namespace angle
struct ANGLE_UTIL_EXPORT ConfigParameters
{
ConfigParameters();
~ConfigParameters();
void reset();
// Display parameters.
Optional<bool> debugLayersEnabled;
Optional<bool> contextVirtualization;
angle::PlatformMethods *platformMethods;
// Surface and Context parameters.
int redBits;
int greenBits;
int blueBits;
int alphaBits;
int depthBits;
int stencilBits;
int swapInterval;
Optional<bool> webGLCompatibility;
Optional<bool> robustResourceInit;
// EGLWindow-specific.
EGLenum componentType;
bool multisample;
bool debug;
bool noError;
Optional<bool> extensionsEnabled;
bool bindGeneratesResource;
bool clientArraysEnabled;
bool robustAccess;
EGLint samples;
Optional<bool> contextProgramCacheEnabled;
};
class ANGLE_UTIL_EXPORT GLWindowBase : angle::NonCopyable
{
public:
static void Delete(GLWindowBase **window);
// It should also be possible to set multisample and floating point framebuffers.
void setConfigRedBits(int bits) { mRedBits = bits; }
void setConfigGreenBits(int bits) { mGreenBits = bits; }
void setConfigBlueBits(int bits) { mBlueBits = bits; }
void setConfigAlphaBits(int bits) { mAlphaBits = bits; }
void setConfigDepthBits(int bits) { mDepthBits = bits; }
void setConfigStencilBits(int bits) { mStencilBits = bits; }
void setSwapInterval(int swapInterval) { mSwapInterval = swapInterval; }
int getConfigRedBits() const { return mRedBits; }
int getConfigGreenBits() const { return mGreenBits; }
int getConfigBlueBits() const { return mBlueBits; }
int getConfigAlphaBits() const { return mAlphaBits; }
int getConfigDepthBits() const { return mDepthBits; }
int getConfigStencilBits() const { return mStencilBits; }
int getSwapInterval() const { return mSwapInterval; }
void setPlatformMethods(angle::PlatformMethods *platformMethods)
{
mPlatformMethods = platformMethods;
}
void setWebGLCompatibilityEnabled(bool webglCompatibility)
{
mWebGLCompatibility = webglCompatibility;
}
void setRobustResourceInit(bool enabled) { mRobustResourceInit = enabled; }
EGLint getClientMajorVersion() const { return mClientMajorVersion; }
EGLint getClientMinorVersion() const { return mClientMinorVersion; }
virtual bool initializeGL(OSWindow *osWindow, angle::Library *glWindowingLibrary) = 0;
virtual bool isGLInitialized() const = 0;
virtual void swap() = 0;
virtual void destroyGL() = 0;
virtual void makeCurrent() = 0;
virtual bool hasError() const = 0;
virtual bool initializeGL(OSWindow *osWindow,
angle::Library *glWindowingLibrary,
const ConfigParameters &config) = 0;
virtual bool isGLInitialized() const = 0;
virtual void swap() = 0;
virtual void destroyGL() = 0;
virtual void makeCurrent() = 0;
virtual bool hasError() const = 0;
int getConfigRedBits() const { return mConfigParams.redBits; }
int getConfigGreenBits() const { return mConfigParams.greenBits; }
int getConfigBlueBits() const { return mConfigParams.blueBits; }
int getConfigAlphaBits() const { return mConfigParams.alphaBits; }
int getConfigDepthBits() const { return mConfigParams.depthBits; }
int getConfigStencilBits() const { return mConfigParams.stencilBits; }
int getSwapInterval() const { return mConfigParams.swapInterval; }
bool isMultisample() const { return mConfigParams.multisample; }
bool isDebugEnabled() const { return mConfigParams.debug; }
const angle::PlatformMethods *getPlatformMethods() const
{
return mConfigParams.platformMethods;
}
const ConfigParameters &getConfigParams() const { return mConfigParams; }
protected:
GLWindowBase(EGLint glesMajorVersion, EGLint glesMinorVersion);
......@@ -73,17 +105,7 @@ class ANGLE_UTIL_EXPORT GLWindowBase : angle::NonCopyable
EGLint mClientMajorVersion;
EGLint mClientMinorVersion;
int mRedBits;
int mGreenBits;
int mBlueBits;
int mAlphaBits;
int mDepthBits;
int mStencilBits;
int mSwapInterval;
angle::PlatformMethods *mPlatformMethods;
Optional<bool> mWebGLCompatibility;
Optional<bool> mRobustResourceInit;
ConfigParameters mConfigParams;
};
class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase
......@@ -94,22 +116,6 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase
const EGLPlatformParameters &platform);
static void Delete(EGLWindow **window);
void setConfigComponentType(EGLenum componentType) { mComponentType = componentType; }
void setMultisample(bool multisample) { mMultisample = multisample; }
void setSamples(EGLint samples) { mSamples = samples; }
void setDebugEnabled(bool debug) { mDebug = debug; }
void setNoErrorEnabled(bool noError) { mNoError = noError; }
void setExtensionsEnabled(bool extensionsEnabled) { mExtensionsEnabled = extensionsEnabled; }
void setBindGeneratesResource(bool bindGeneratesResource)
{
mBindGeneratesResource = bindGeneratesResource;
}
void setDebugLayersEnabled(bool enabled) { mDebugLayersEnabled = enabled; }
void setClientArraysEnabled(bool enabled) { mClientArraysEnabled = enabled; }
void setRobustAccess(bool enabled) { mRobustAccess = enabled; }
void setContextProgramCacheEnabled(bool enabled) { mContextProgramCacheEnabled = enabled; }
void setContextVirtualization(bool enabled) { mContextVirtualization = enabled; }
static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
void swap() override;
......@@ -119,15 +125,21 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase
EGLDisplay getDisplay() const;
EGLSurface getSurface() const;
EGLContext getContext() const;
bool isMultisample() const { return mMultisample; }
bool isDebugEnabled() const { return mDebug; }
const angle::PlatformMethods *getPlatformMethods() const { return mPlatformMethods; }
// Internally initializes the Display, Surface and Context.
bool initializeGL(OSWindow *osWindow, angle::Library *glWindowingLibrary) override;
bool initializeGL(OSWindow *osWindow,
angle::Library *glWindowingLibrary,
const ConfigParameters &params) override;
// Only initializes the Display and Surface.
bool initializeDisplayAndSurface(OSWindow *osWindow, angle::Library *glWindowingLibrary);
// Only initializes the Display.
bool initializeDisplay(OSWindow *osWindow,
angle::Library *glWindowingLibrary,
const ConfigParameters &params);
// Only initializes the Surface.
bool initializeSurface(OSWindow *osWindow,
angle::Library *glWindowingLibrary,
const ConfigParameters &params);
// Create an EGL context with this window's configuration
EGLContext createContext(EGLContext share) const;
......@@ -136,10 +148,14 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase
bool initializeContext();
void destroyGL() override;
void destroySurface();
void destroyContext();
bool isGLInitialized() const override;
void makeCurrent() override;
bool hasError() const override;
bool isDisplayInitialized() const { return mDisplay != EGL_NO_DISPLAY; }
static bool ClientExtensionEnabled(const std::string &extName);
private:
......@@ -157,18 +173,6 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase
EGLint mEGLMajorVersion;
EGLint mEGLMinorVersion;
EGLPlatformParameters mPlatform;
EGLenum mComponentType;
bool mMultisample;
bool mDebug;
bool mNoError;
Optional<bool> mExtensionsEnabled;
bool mBindGeneratesResource;
bool mClientArraysEnabled;
bool mRobustAccess;
EGLint mSamples;
Optional<bool> mDebugLayersEnabled;
Optional<bool> mContextProgramCacheEnabled;
Optional<bool> mContextVirtualization;
};
ANGLE_UTIL_EXPORT bool CheckExtensionExists(const char *allExtensions, const std::string &extName);
......
......@@ -69,8 +69,11 @@ WGLWindow::WGLWindow(int glesMajorVersion, int glesMinorVersion)
WGLWindow::~WGLWindow() {}
// Internally initializes GL resources.
bool WGLWindow::initializeGL(OSWindow *osWindow, angle::Library *glWindowingLibrary)
bool WGLWindow::initializeGL(OSWindow *osWindow,
angle::Library *glWindowingLibrary,
const ConfigParameters &params)
{
mConfigParams = params;
glWindowingLibrary->getAs("wglGetProcAddress", &gCurrentWGLGetProcAddress);
if (!gCurrentWGLGetProcAddress)
......@@ -135,7 +138,7 @@ bool WGLWindow::initializeGL(OSWindow *osWindow, angle::Library *glWindowingLibr
return false;
}
if (mWebGLCompatibility.valid() || mRobustResourceInit.valid())
if (mConfigParams.webGLCompatibility.valid() || mConfigParams.robustResourceInit.valid())
{
std::cerr << "WGLWindow does not support the requested feature set." << std::endl;
return false;
......@@ -163,11 +166,11 @@ bool WGLWindow::initializeGL(OSWindow *osWindow, angle::Library *glWindowingLibr
makeCurrent();
if (mSwapInterval != -1)
if (mConfigParams.swapInterval != -1)
{
if (_wglSwapIntervalEXT)
{
if (_wglSwapIntervalEXT(mSwapInterval) == FALSE)
if (_wglSwapIntervalEXT(mConfigParams.swapInterval) == FALSE)
{
std::cerr << "Error setting swap interval." << std::endl;
}
......
......@@ -28,7 +28,9 @@ class ANGLE_UTIL_EXPORT WGLWindow : public GLWindowBase
static void Delete(WGLWindow **window);
// Internally initializes GL resources.
bool initializeGL(OSWindow *osWindow, angle::Library *glWindowingLibrary) override;
bool initializeGL(OSWindow *osWindow,
angle::Library *glWindowingLibrary,
const ConfigParameters &params) override;
void destroyGL() override;
bool isGLInitialized() const 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