Commit 0659c991 by Jamie Madill Committed by Commit Bot

Set swap interval explicitly.

The swap interval can be changed independent of the Surface config. Thus it makes more sense to set it explicitly in test setup. This simplifies the test config. Also updates some of the API for GLWindowBase. Return an explicit error from makeCurrent. Bug: angleproject:3393 Change-Id: Ic62b33018e872bc0e38f2848e2427ed898b60749 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1574672Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 8f39cd83
...@@ -136,14 +136,17 @@ int SampleApplication::run() ...@@ -136,14 +136,17 @@ int SampleApplication::run()
configParams.depthBits = 24; configParams.depthBits = 24;
configParams.stencilBits = 8; configParams.stencilBits = 8;
// Disable vsync
configParams.swapInterval = 0;
if (!mEGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), configParams)) if (!mEGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(), configParams))
{ {
return -1; return -1;
} }
// Disable vsync
if (!mEGLWindow->setSwapInterval(0))
{
return -1;
}
angle::LoadGLES(eglGetProcAddress); angle::LoadGLES(eglGetProcAddress);
mRunning = true; mRunning = true;
......
...@@ -416,9 +416,6 @@ void ANGLERenderTest::SetUp() ...@@ -416,9 +416,6 @@ void ANGLERenderTest::SetUp()
return; return;
} }
// Disable vsync.
mConfigParams.swapInterval = 0;
mPlatformMethods.overrideWorkaroundsD3D = OverrideWorkaroundsD3D; mPlatformMethods.overrideWorkaroundsD3D = OverrideWorkaroundsD3D;
mPlatformMethods.logError = EmptyPlatformMethod; mPlatformMethods.logError = EmptyPlatformMethod;
mPlatformMethods.logWarning = EmptyPlatformMethod; mPlatformMethods.logWarning = EmptyPlatformMethod;
...@@ -445,6 +442,14 @@ void ANGLERenderTest::SetUp() ...@@ -445,6 +442,14 @@ void ANGLERenderTest::SetUp()
// FAIL returns. // FAIL returns.
} }
// Disable vsync.
if (!mGLWindow->setSwapInterval(0))
{
mSkipTest = true;
FAIL() << "Failed setting swap interval";
// FAIL returns.
}
if (!areExtensionPrerequisitesFulfilled()) if (!areExtensionPrerequisitesFulfilled())
{ {
mSkipTest = true; mSkipTest = true;
......
...@@ -96,7 +96,6 @@ ConfigParameters::ConfigParameters() ...@@ -96,7 +96,6 @@ ConfigParameters::ConfigParameters()
alphaBits(-1), alphaBits(-1),
depthBits(-1), depthBits(-1),
stencilBits(-1), stencilBits(-1),
swapInterval(-1),
componentType(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT), componentType(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT),
multisample(false), multisample(false),
debug(false), debug(false),
...@@ -182,7 +181,9 @@ bool EGLWindow::initializeGL(OSWindow *osWindow, ...@@ -182,7 +181,9 @@ bool EGLWindow::initializeGL(OSWindow *osWindow,
return false; return false;
if (!initializeSurface(osWindow, glWindowingLibrary, params)) if (!initializeSurface(osWindow, glWindowingLibrary, params))
return false; return false;
return initializeContext(); if (!initializeContext())
return false;
return true;
} }
bool EGLWindow::initializeDisplay(OSWindow *osWindow, bool EGLWindow::initializeDisplay(OSWindow *osWindow,
...@@ -527,19 +528,12 @@ bool EGLWindow::initializeContext() ...@@ -527,19 +528,12 @@ bool EGLWindow::initializeContext()
return false; return false;
} }
eglMakeCurrent(mDisplay, mSurface, mSurface, mContext); if (!makeCurrent())
if (eglGetError() != EGL_SUCCESS)
{ {
std::cerr << "Error during eglMakeCurrent.\n";
destroyGL(); destroyGL();
return false; return false;
} }
if (mConfigParams.swapInterval != -1)
{
eglSwapInterval(mDisplay, mConfigParams.swapInterval);
}
return true; return true;
} }
...@@ -621,9 +615,27 @@ EGLBoolean EGLWindow::FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, E ...@@ -621,9 +615,27 @@ EGLBoolean EGLWindow::FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, E
return EGL_FALSE; return EGL_FALSE;
} }
void EGLWindow::makeCurrent() bool EGLWindow::makeCurrent()
{ {
eglMakeCurrent(mDisplay, mSurface, mSurface, mContext); if (eglMakeCurrent(mDisplay, mSurface, mSurface, mContext) == EGL_FALSE ||
eglGetError() != EGL_SUCCESS)
{
std::cerr << "Error during eglMakeCurrent.\n";
return false;
}
return true;
}
bool EGLWindow::setSwapInterval(EGLint swapInterval)
{
if (eglSwapInterval(mDisplay, swapInterval) == EGL_FALSE || eglGetError() != EGL_SUCCESS)
{
std::cerr << "Error during eglSwapInterval.\n";
return false;
}
return true;
} }
bool EGLWindow::hasError() const bool EGLWindow::hasError() const
......
...@@ -47,7 +47,6 @@ struct ANGLE_UTIL_EXPORT ConfigParameters ...@@ -47,7 +47,6 @@ struct ANGLE_UTIL_EXPORT ConfigParameters
int alphaBits; int alphaBits;
int depthBits; int depthBits;
int stencilBits; int stencilBits;
int swapInterval;
Optional<bool> webGLCompatibility; Optional<bool> webGLCompatibility;
Optional<bool> robustResourceInit; Optional<bool> robustResourceInit;
...@@ -81,16 +80,9 @@ class ANGLE_UTIL_EXPORT GLWindowBase : angle::NonCopyable ...@@ -81,16 +80,9 @@ class ANGLE_UTIL_EXPORT GLWindowBase : angle::NonCopyable
virtual bool isGLInitialized() const = 0; virtual bool isGLInitialized() const = 0;
virtual void swap() = 0; virtual void swap() = 0;
virtual void destroyGL() = 0; virtual void destroyGL() = 0;
virtual void makeCurrent() = 0; virtual bool makeCurrent() = 0;
virtual bool hasError() const = 0; virtual bool hasError() const = 0;
virtual bool setSwapInterval(EGLint swapInterval) = 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 isMultisample() const { return mConfigParams.multisample; }
bool isDebugEnabled() const { return mConfigParams.debug; } bool isDebugEnabled() const { return mConfigParams.debug; }
...@@ -121,8 +113,6 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase ...@@ -121,8 +113,6 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase
static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config); static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
void swap() override;
const EGLPlatformParameters &getPlatform() const { return mPlatform; } const EGLPlatformParameters &getPlatform() const { return mPlatform; }
EGLConfig getConfig() const; EGLConfig getConfig() const;
EGLDisplay getDisplay() const; EGLDisplay getDisplay() const;
...@@ -134,6 +124,13 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase ...@@ -134,6 +124,13 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase
angle::Library *glWindowingLibrary, angle::Library *glWindowingLibrary,
const ConfigParameters &params) override; const ConfigParameters &params) override;
bool isGLInitialized() const override;
void swap() override;
void destroyGL() override;
bool makeCurrent() override;
bool hasError() const override;
bool setSwapInterval(EGLint swapInterval) override;
// Only initializes the Display. // Only initializes the Display.
bool initializeDisplay(OSWindow *osWindow, bool initializeDisplay(OSWindow *osWindow,
angle::Library *glWindowingLibrary, angle::Library *glWindowingLibrary,
...@@ -150,12 +147,8 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase ...@@ -150,12 +147,8 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase
// Only initializes the Context. // Only initializes the Context.
bool initializeContext(); bool initializeContext();
void destroyGL() override;
void destroySurface(); void destroySurface();
void destroyContext(); void destroyContext();
bool isGLInitialized() const override;
void makeCurrent() override;
bool hasError() const override;
bool isDisplayInitialized() const { return mDisplay != EGL_NO_DISPLAY; } bool isDisplayInitialized() const { return mDisplay != EGL_NO_DISPLAY; }
......
...@@ -116,7 +116,10 @@ bool WGLWindow::initializeGL(OSWindow *osWindow, ...@@ -116,7 +116,10 @@ bool WGLWindow::initializeGL(OSWindow *osWindow,
return false; return false;
} }
makeCurrent(); if (!makeCurrent())
{
return false;
}
// Reload entry points to capture extensions. // Reload entry points to capture extensions.
angle::LoadWGL(GetProcAddressWithFallback); angle::LoadWGL(GetProcAddressWithFallback);
...@@ -164,21 +167,9 @@ bool WGLWindow::initializeGL(OSWindow *osWindow, ...@@ -164,21 +167,9 @@ bool WGLWindow::initializeGL(OSWindow *osWindow,
return false; return false;
} }
makeCurrent(); if (!makeCurrent())
if (mConfigParams.swapInterval != -1)
{ {
if (_wglSwapIntervalEXT) return false;
{
if (_wglSwapIntervalEXT(mConfigParams.swapInterval) == FALSE)
{
std::cerr << "Error setting swap interval." << std::endl;
}
}
else
{
std::cerr << "Error setting swap interval." << std::endl;
}
} }
angle::LoadGLES(GetProcAddressWithFallback); angle::LoadGLES(GetProcAddressWithFallback);
...@@ -205,19 +196,32 @@ bool WGLWindow::isGLInitialized() const ...@@ -205,19 +196,32 @@ bool WGLWindow::isGLInitialized() const
return mWGLContext != nullptr; return mWGLContext != nullptr;
} }
void WGLWindow::makeCurrent() bool WGLWindow::makeCurrent()
{ {
if (_wglMakeCurrent(mDeviceContext, mWGLContext) == FALSE) if (_wglMakeCurrent(mDeviceContext, mWGLContext) == FALSE)
{ {
std::cerr << "Error during wglMakeCurrent." << std::endl; std::cerr << "Error during wglMakeCurrent.\n";
return false;
} }
return true;
}
bool WGLWindow::setSwapInterval(EGLint swapInterval)
{
if (!_wglSwapIntervalEXT || _wglSwapIntervalEXT(swapInterval) == FALSE)
{
std::cerr << "Error during wglSwapIntervalEXT.\n";
return false;
}
return true;
} }
void WGLWindow::swap() void WGLWindow::swap()
{ {
if (SwapBuffers(mDeviceContext) == FALSE) if (SwapBuffers(mDeviceContext) == FALSE)
{ {
std::cerr << "Error during SwapBuffers." << std::endl; std::cerr << "Error during SwapBuffers.\n";
} }
} }
......
...@@ -34,9 +34,10 @@ class ANGLE_UTIL_EXPORT WGLWindow : public GLWindowBase ...@@ -34,9 +34,10 @@ class ANGLE_UTIL_EXPORT WGLWindow : public GLWindowBase
void destroyGL() override; void destroyGL() override;
bool isGLInitialized() const override; bool isGLInitialized() const override;
void makeCurrent() override; bool makeCurrent() override;
void swap() override; void swap() override;
bool hasError() const override; bool hasError() const override;
bool setSwapInterval(EGLint swapInterval) override;
private: private:
WGLWindow(int glesMajorVersion, int glesMinorVersion); WGLWindow(int glesMajorVersion, int glesMinorVersion);
......
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