From feac312ee02039de2fa5f372d595612a3d17600d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 10 Nov 2016 16:51:39 +0100 Subject: [PATCH] Move resolving glxSwapIntervalMesa into platform plugin Summary: No need to resolve glx methods through the shared lib. At the moment this duplicates some code, but will be cleaned up with a follow up change. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D3335 --- libkwineffects/kwinglutils.cpp | 17 +------------ libkwineffects/kwinglutils.h | 3 --- libkwineffects/kwinglutils_funcs.cpp | 11 --------- libkwineffects/kwinglutils_funcs.h | 6 ----- .../platforms/x11/standalone/glxbackend.cpp | 24 +++++++++++++++++-- plugins/platforms/x11/standalone/glxbackend.h | 4 ++++ 6 files changed, 27 insertions(+), 38 deletions(-) diff --git a/libkwineffects/kwinglutils.cpp b/libkwineffects/kwinglutils.cpp index eead483e96..2ddbd2bdc2 100644 --- a/libkwineffects/kwinglutils.cpp +++ b/libkwineffects/kwinglutils.cpp @@ -45,10 +45,6 @@ along with this program. If not, see . #include -#if HAVE_EPOXY_GLX -#include -#endif - #define DEBUG_GLRENDERTARGET 0 #define MAKE_GL_VERSION(major, minor, release) ( ((major) << 16) | ((minor) << 8) | (release) ) @@ -68,22 +64,12 @@ namespace KWin static int eglVersion; // List of all supported GL, EGL and GLX extensions static QList glExtensions; -static QList s_glxExtensions; static QList s_eglExtensions; int glTextureUnitsCount; // Functions -void initGLX() -{ -#if HAVE_EPOXY_GLX - // Get list of supported GLX extensions - const QByteArray string = (const char *) glXQueryExtensionsString(display(), QX11Info::appScreen()); - s_glxExtensions = string.split(' '); - glxResolveFunctions(); -#endif -} void initEGL() { @@ -129,7 +115,6 @@ void cleanupGL() GLPlatform::cleanup(); glExtensions.clear(); - s_glxExtensions.clear(); s_eglExtensions.clear(); eglVersion = 0; @@ -148,7 +133,7 @@ bool hasEGLVersion(int major, int minor, int release) bool hasGLExtension(const QByteArray &extension) { - return glExtensions.contains(extension) || s_glxExtensions.contains(extension) || s_eglExtensions.contains(extension); + return glExtensions.contains(extension) || s_eglExtensions.contains(extension); } QList eglExtensions() diff --git a/libkwineffects/kwinglutils.h b/libkwineffects/kwinglutils.h index 9f5290c64c..9e17620335 100644 --- a/libkwineffects/kwinglutils.h +++ b/libkwineffects/kwinglutils.h @@ -48,9 +48,6 @@ namespace KWin class GLVertexBuffer; class GLVertexBufferPrivate; - -// Initializes GLX function pointers -void KWINGLUTILS_EXPORT initGLX(); // Initializes OpenGL stuff. This includes resolving function pointers as // well as checking for GL version and extensions // Note that GL context has to be created by the time this function is called diff --git a/libkwineffects/kwinglutils_funcs.cpp b/libkwineffects/kwinglutils_funcs.cpp index 23a29367b3..c8783fa0fd 100644 --- a/libkwineffects/kwinglutils_funcs.cpp +++ b/libkwineffects/kwinglutils_funcs.cpp @@ -50,9 +50,6 @@ static void ReadnPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum GLenum type, GLsizei bufSize, GLvoid *data); static void GetnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -// GL_MESA_swap_control -glXSwapIntervalMESA_func glXSwapIntervalMESA; - // GL_ARB_robustness / GL_EXT_robustness glGetGraphicsResetStatus_func glGetGraphicsResetStatus; glReadnPixels_func glReadnPixels; @@ -71,14 +68,6 @@ static glXFuncPtr getProcAddress(const char* name) return ret; } -void glxResolveFunctions() -{ - if (hasGLExtension(QByteArrayLiteral("GLX_MESA_swap_control"))) - glXSwapIntervalMESA = (glXSwapIntervalMESA_func) getProcAddress("glXSwapIntervalMESA"); - else - glXSwapIntervalMESA = nullptr; -} - void eglResolveFunctions() { } diff --git a/libkwineffects/kwinglutils_funcs.h b/libkwineffects/kwinglutils_funcs.h index 4b60a46abf..b9787d3d43 100644 --- a/libkwineffects/kwinglutils_funcs.h +++ b/libkwineffects/kwinglutils_funcs.h @@ -47,16 +47,10 @@ along with this program. If not, see . namespace KWin { -void KWINGLUTILS_EXPORT glxResolveFunctions(); - void KWINGLUTILS_EXPORT eglResolveFunctions(); void KWINGLUTILS_EXPORT glResolveFunctions(OpenGLPlatformInterface platformInterface); -// GLX_MESA_swap_interval -using glXSwapIntervalMESA_func = int (*)(unsigned int interval); -extern KWINGLUTILS_EXPORT glXSwapIntervalMESA_func glXSwapIntervalMESA; - // GL_ARB_robustness / GL_EXT_robustness using glGetGraphicsResetStatus_func = GLenum (*)(); using glReadnPixels_func = void (*)(GLint x, GLint y, GLsizei width, GLsizei height, diff --git a/plugins/platforms/x11/standalone/glxbackend.cpp b/plugins/platforms/x11/standalone/glxbackend.cpp index 58fd4a9ddc..43bdedcdc8 100644 --- a/plugins/platforms/x11/standalone/glxbackend.cpp +++ b/plugins/platforms/x11/standalone/glxbackend.cpp @@ -42,6 +42,7 @@ along with this program. If not, see . #include #include +#include #ifndef XCB_GLX_BUFFER_SWAP_COMPLETE #define XCB_GLX_BUFFER_SWAP_COMPLETE 1 @@ -148,10 +149,22 @@ GlxBackend::~GlxBackend() delete m_overlayWindow; } +typedef void (*glXFuncPtr)(); + +static glXFuncPtr getProcAddress(const char* name) +{ + glXFuncPtr ret = nullptr; +#if HAVE_EPOXY_GLX + ret = glXGetProcAddress((const GLubyte*) name); +#endif + if (ret == nullptr) + ret = (glXFuncPtr) dlsym(RTLD_DEFAULT, name); + return ret; +} +glXSwapIntervalMESA_func glXSwapIntervalMESA; + void GlxBackend::init() { - initGLX(); - // Require at least GLX 1.3 if (!checkVersion()) { setFailed(QStringLiteral("Requires at least GLX 1.3")); @@ -160,6 +173,13 @@ void GlxBackend::init() initExtensions(); + // resolve glXSwapIntervalMESA if available + if (hasExtension(QByteArrayLiteral("GLX_MESA_swap_control"))) { + glXSwapIntervalMESA = (glXSwapIntervalMESA_func) getProcAddress("glXSwapIntervalMESA"); + } else { + glXSwapIntervalMESA = nullptr; + } + initVisualDepthHashTable(); if (!initBuffer()) { diff --git a/plugins/platforms/x11/standalone/glxbackend.h b/plugins/platforms/x11/standalone/glxbackend.h index 5c6c351d31..1f801df7b9 100644 --- a/plugins/platforms/x11/standalone/glxbackend.h +++ b/plugins/platforms/x11/standalone/glxbackend.h @@ -29,6 +29,10 @@ along with this program. If not, see . namespace KWin { +// GLX_MESA_swap_interval +using glXSwapIntervalMESA_func = int (*)(unsigned int interval); +extern glXSwapIntervalMESA_func glXSwapIntervalMESA; + class FBConfigInfo { public: