Commit f4863b70 by Corentin Wallez

Implement swapInterval for EGL on GLX

BUG=angleproject:892 Change-Id: I80d8d67270662c7f2be893f4a8318fbc0926f1fc Reviewed-on: https://chromium-review.googlesource.com/272677Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 7c2acaf3
...@@ -236,6 +236,7 @@ egl::ConfigSet DisplayGLX::generateConfigs() const ...@@ -236,6 +236,7 @@ egl::ConfigSet DisplayGLX::generateConfigs() const
// GLX_EXT_texture_from_pixmap is required for the "bind to rgb(a)" attributes // GLX_EXT_texture_from_pixmap is required for the "bind to rgb(a)" attributes
bool hasTextureFromPixmap = mGLX.hasExtension("GLX_EXT_texture_from_pixmap"); bool hasTextureFromPixmap = mGLX.hasExtension("GLX_EXT_texture_from_pixmap");
bool hasSwapControl = mGLX.hasExtension("GLX_EXT_swap_control");
int attribList[] = int attribList[] =
{ {
...@@ -332,9 +333,17 @@ egl::ConfigSet DisplayGLX::generateConfigs() const ...@@ -332,9 +333,17 @@ egl::ConfigSet DisplayGLX::generateConfigs() const
(glxDrawable & GLX_PBUFFER_BIT ? EGL_PBUFFER_BIT : 0) | (glxDrawable & GLX_PBUFFER_BIT ? EGL_PBUFFER_BIT : 0) |
(glxDrawable & GLX_PIXMAP_BIT ? EGL_PIXMAP_BIT : 0); (glxDrawable & GLX_PIXMAP_BIT ? EGL_PIXMAP_BIT : 0);
// In GLX_EXT_swap_control querying these is done on a GLXWindow so we just set a default value. if (hasSwapControl)
config.maxSwapInterval = 1; {
config.minSwapInterval = 1; // In GLX_EXT_swap_control querying these is done on a GLXWindow so we just set a default value.
config.minSwapInterval = 0;
config.maxSwapInterval = 4;
}
else
{
config.minSwapInterval = 1;
config.maxSwapInterval = 1;
}
// TODO(cwallez) wildly guessing these formats, another TODO says they should be removed anyway // TODO(cwallez) wildly guessing these formats, another TODO says they should be removed anyway
config.renderTargetFormat = GL_RGBA8; config.renderTargetFormat = GL_RGBA8;
config.depthStencilFormat = GL_DEPTH24_STENCIL8; config.depthStencilFormat = GL_DEPTH24_STENCIL8;
......
...@@ -50,7 +50,8 @@ struct FunctionsGLX::GLXFunctionTable ...@@ -50,7 +50,8 @@ struct FunctionsGLX::GLXFunctionTable
createPbufferPtr(nullptr), createPbufferPtr(nullptr),
destroyPbufferPtr(nullptr), destroyPbufferPtr(nullptr),
queryDrawablePtr(nullptr), queryDrawablePtr(nullptr),
createContextAttribsARBPtr(nullptr) createContextAttribsARBPtr(nullptr),
swapIntervalEXTPtr(nullptr)
{ {
} }
...@@ -79,6 +80,9 @@ struct FunctionsGLX::GLXFunctionTable ...@@ -79,6 +80,9 @@ struct FunctionsGLX::GLXFunctionTable
// GLX_ARB_create_context // GLX_ARB_create_context
PFNGLXCREATECONTEXTATTRIBSARBPROC createContextAttribsARBPtr; PFNGLXCREATECONTEXTATTRIBSARBPROC createContextAttribsARBPtr;
// GLX_EXT_swap_control
PFNGLXSWAPINTERVALEXTPROC swapIntervalEXTPtr;
}; };
FunctionsGLX::FunctionsGLX() FunctionsGLX::FunctionsGLX()
...@@ -191,6 +195,14 @@ bool FunctionsGLX::initialize(Display *xDisplay, int screen, std::string *errorS ...@@ -191,6 +195,14 @@ bool FunctionsGLX::initialize(Display *xDisplay, int screen, std::string *errorS
{ {
mFnPtrs->createContextAttribsARBPtr = nullptr; mFnPtrs->createContextAttribsARBPtr = nullptr;
} }
if (hasExtension("GLX_EXT_swap_control"))
{
GET_PROC_OR_ERROR(&mFnPtrs->swapIntervalEXTPtr, "glXSwapIntervalEXT");
}
else
{
mFnPtrs->swapIntervalEXTPtr = nullptr;
}
#undef GET_PROC_OR_ERROR #undef GET_PROC_OR_ERROR
...@@ -315,4 +327,9 @@ glx::Context FunctionsGLX::createContextAttribsARB(glx::FBConfig config, glx::Co ...@@ -315,4 +327,9 @@ glx::Context FunctionsGLX::createContextAttribsARB(glx::FBConfig config, glx::Co
return reinterpret_cast<glx::Context>(ctx); return reinterpret_cast<glx::Context>(ctx);
} }
void FunctionsGLX::swapIntervalEXT(glx::Drawable drawable, int intervals) const
{
mFnPtrs->swapIntervalEXTPtr(mXDisplay, drawable, intervals);
}
} }
...@@ -62,6 +62,9 @@ class FunctionsGLX ...@@ -62,6 +62,9 @@ class FunctionsGLX
// GLX_ARB_create_context // GLX_ARB_create_context
glx::Context createContextAttribsARB(glx::FBConfig config, glx::Context shareContext, Bool direct, const int *attribList) const; glx::Context createContextAttribsARB(glx::FBConfig config, glx::Context shareContext, Bool direct, const int *attribList) const;
// GLX_EXT_swap_control
void swapIntervalEXT(glx::Drawable drawable, int interval) const;
private: private:
// So as to isolate GLX from angle we do not include angleutils.h and cannot // So as to isolate GLX from angle we do not include angleutils.h and cannot
// use angle::NonCopyable so we replicated it here instead. // use angle::NonCopyable so we replicated it here instead.
......
...@@ -26,7 +26,8 @@ WindowSurfaceGLX::WindowSurfaceGLX(const FunctionsGLX &glx, const DisplayGLX &gl ...@@ -26,7 +26,8 @@ WindowSurfaceGLX::WindowSurfaceGLX(const FunctionsGLX &glx, const DisplayGLX &gl
mGLXDisplay(glxDisplay), mGLXDisplay(glxDisplay),
mContext(context), mContext(context),
mFBConfig(fbConfig), mFBConfig(fbConfig),
mGLXWindow(0) mGLXWindow(0),
mMaxSwapInterval(1)
{ {
} }
...@@ -87,6 +88,11 @@ egl::Error WindowSurfaceGLX::initialize() ...@@ -87,6 +88,11 @@ egl::Error WindowSurfaceGLX::initialize()
0, visualInfo->depth, InputOutput, visual, attributeMask, &attributes); 0, visualInfo->depth, InputOutput, visual, attributeMask, &attributes);
mGLXWindow = mGLX.createWindow(mFBConfig, mWindow, nullptr); mGLXWindow = mGLX.createWindow(mFBConfig, mWindow, nullptr);
if (mGLX.hasExtension("GLX_EXT_swap_control"))
{
mGLX.queryDrawable(mGLXWindow, GLX_MAX_SWAP_INTERVAL_EXT, &mMaxSwapInterval);
}
XMapWindow(mDisplay, mWindow); XMapWindow(mDisplay, mWindow);
XFlush(mDisplay); XFlush(mDisplay);
...@@ -141,7 +147,12 @@ egl::Error WindowSurfaceGLX::releaseTexImage(EGLint buffer) ...@@ -141,7 +147,12 @@ egl::Error WindowSurfaceGLX::releaseTexImage(EGLint buffer)
void WindowSurfaceGLX::setSwapInterval(EGLint interval) void WindowSurfaceGLX::setSwapInterval(EGLint interval)
{ {
// TODO(cwallez) WGL has this, implement it if (mGLX.hasExtension("GLX_EXT_swap_control"))
{
// TODO(cwallez) error checking?
const int realInterval = std::min(interval, static_cast<int>(mMaxSwapInterval));
mGLX.swapIntervalEXT(mGLXWindow, realInterval);
}
} }
EGLint WindowSurfaceGLX::getWidth() const EGLint WindowSurfaceGLX::getWidth() const
......
...@@ -50,6 +50,7 @@ class WindowSurfaceGLX : public SurfaceGL ...@@ -50,6 +50,7 @@ class WindowSurfaceGLX : public SurfaceGL
glx::Context mContext; glx::Context mContext;
glx::FBConfig mFBConfig; glx::FBConfig mFBConfig;
glx::Window mGLXWindow; glx::Window mGLXWindow;
unsigned int mMaxSwapInterval;
}; };
} }
......
...@@ -145,6 +145,10 @@ ...@@ -145,6 +145,10 @@
#define GLX_AUX7_EXT 0x20E9 #define GLX_AUX7_EXT 0x20E9
#define GLX_AUX8_EXT 0x20EA #define GLX_AUX8_EXT 0x20EA
#define GLX_AUX9_EXT 0x20EB #define GLX_AUX9_EXT 0x20EB
// GLX_EXT_swap_control
#define GLX_SWAP_INTERVAL_EXT 0x20F1
#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2
#endif // !defined(ANGLE_SKIP_GLX_DEFINES) #endif // !defined(ANGLE_SKIP_GLX_DEFINES)
// GLX typedefs depend on the X headers // GLX typedefs depend on the X headers
......
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