aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gräßlin <[email protected]>2016-11-10 16:51:39 +0100
committerMartin Gräßlin <[email protected]>2016-11-16 09:06:47 +0100
commitfeac312ee02039de2fa5f372d595612a3d17600d (patch)
tree1843998065d3243c33d9b1c98bc2cf76d2ea5904
parent4783e45ab76a0a60866fe675adcd6fbabee95abe (diff)
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
-rw-r--r--libkwineffects/kwinglutils.cpp17
-rw-r--r--libkwineffects/kwinglutils.h3
-rw-r--r--libkwineffects/kwinglutils_funcs.cpp11
-rw-r--r--libkwineffects/kwinglutils_funcs.h6
-rw-r--r--plugins/platforms/x11/standalone/glxbackend.cpp24
-rw-r--r--plugins/platforms/x11/standalone/glxbackend.h4
6 files changed, 27 insertions, 38 deletions
diff --git a/libkwineffects/kwinglutils.cpp b/libkwineffects/kwinglutils.cpp
index eead483..2ddbd2b 100644
--- a/libkwineffects/kwinglutils.cpp
+++ b/libkwineffects/kwinglutils.cpp
@@ -45,10 +45,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <math.h>
-#if HAVE_EPOXY_GLX
-#include <epoxy/glx.h>
-#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<QByteArray> glExtensions;
-static QList<QByteArray> s_glxExtensions;
static QList<QByteArray> 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<QByteArray> eglExtensions()
diff --git a/libkwineffects/kwinglutils.h b/libkwineffects/kwinglutils.h
index 9f5290c..9e17620 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 23a2936..c8783fa 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 4b60a46..b9787d3 100644
--- a/libkwineffects/kwinglutils_funcs.h
+++ b/libkwineffects/kwinglutils_funcs.h
@@ -47,16 +47,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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 58fd4a9..43bdedc 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 <http://www.gnu.org/licenses/>.
#include <deque>
#include <algorithm>
+#include <dlfcn.h>
#ifndef XCB_GLX_BUFFER_SWAP_COMPLETE
#define XCB_GLX_BUFFER_SWAP_COMPLETE 1
@@ -148,10 +149,22 @@ GlxBackend::~GlxBackend()
delete m_overlayWindow;
}
-void GlxBackend::init()
+typedef void (*glXFuncPtr)();
+
+static glXFuncPtr getProcAddress(const char* name)
{
- initGLX();
+ 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()
+{
// 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 5c6c351..1f801df 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 <http://www.gnu.org/licenses/>.
namespace KWin
{
+// GLX_MESA_swap_interval
+using glXSwapIntervalMESA_func = int (*)(unsigned int interval);
+extern glXSwapIntervalMESA_func glXSwapIntervalMESA;
+
class FBConfigInfo
{
public: