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
This commit is contained in:
parent
4783e45ab7
commit
feac312ee0
6 changed files with 27 additions and 38 deletions
|
@ -45,10 +45,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#if HAVE_EPOXY_GLX
|
|
||||||
#include <epoxy/glx.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEBUG_GLRENDERTARGET 0
|
#define DEBUG_GLRENDERTARGET 0
|
||||||
|
|
||||||
#define MAKE_GL_VERSION(major, minor, release) ( ((major) << 16) | ((minor) << 8) | (release) )
|
#define MAKE_GL_VERSION(major, minor, release) ( ((major) << 16) | ((minor) << 8) | (release) )
|
||||||
|
@ -68,22 +64,12 @@ namespace KWin
|
||||||
static int eglVersion;
|
static int eglVersion;
|
||||||
// List of all supported GL, EGL and GLX extensions
|
// List of all supported GL, EGL and GLX extensions
|
||||||
static QList<QByteArray> glExtensions;
|
static QList<QByteArray> glExtensions;
|
||||||
static QList<QByteArray> s_glxExtensions;
|
|
||||||
static QList<QByteArray> s_eglExtensions;
|
static QList<QByteArray> s_eglExtensions;
|
||||||
|
|
||||||
int glTextureUnitsCount;
|
int glTextureUnitsCount;
|
||||||
|
|
||||||
|
|
||||||
// Functions
|
// 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()
|
void initEGL()
|
||||||
{
|
{
|
||||||
|
@ -129,7 +115,6 @@ void cleanupGL()
|
||||||
GLPlatform::cleanup();
|
GLPlatform::cleanup();
|
||||||
|
|
||||||
glExtensions.clear();
|
glExtensions.clear();
|
||||||
s_glxExtensions.clear();
|
|
||||||
s_eglExtensions.clear();
|
s_eglExtensions.clear();
|
||||||
|
|
||||||
eglVersion = 0;
|
eglVersion = 0;
|
||||||
|
@ -148,7 +133,7 @@ bool hasEGLVersion(int major, int minor, int release)
|
||||||
|
|
||||||
bool hasGLExtension(const QByteArray &extension)
|
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()
|
QList<QByteArray> eglExtensions()
|
||||||
|
|
|
@ -48,9 +48,6 @@ namespace KWin
|
||||||
class GLVertexBuffer;
|
class GLVertexBuffer;
|
||||||
class GLVertexBufferPrivate;
|
class GLVertexBufferPrivate;
|
||||||
|
|
||||||
|
|
||||||
// Initializes GLX function pointers
|
|
||||||
void KWINGLUTILS_EXPORT initGLX();
|
|
||||||
// Initializes OpenGL stuff. This includes resolving function pointers as
|
// Initializes OpenGL stuff. This includes resolving function pointers as
|
||||||
// well as checking for GL version and extensions
|
// well as checking for GL version and extensions
|
||||||
// Note that GL context has to be created by the time this function is called
|
// Note that GL context has to be created by the time this function is called
|
||||||
|
|
|
@ -50,9 +50,6 @@ static void ReadnPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
|
||||||
GLenum type, GLsizei bufSize, GLvoid *data);
|
GLenum type, GLsizei bufSize, GLvoid *data);
|
||||||
static void GetnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
|
static void GetnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
|
||||||
|
|
||||||
// GL_MESA_swap_control
|
|
||||||
glXSwapIntervalMESA_func glXSwapIntervalMESA;
|
|
||||||
|
|
||||||
// GL_ARB_robustness / GL_EXT_robustness
|
// GL_ARB_robustness / GL_EXT_robustness
|
||||||
glGetGraphicsResetStatus_func glGetGraphicsResetStatus;
|
glGetGraphicsResetStatus_func glGetGraphicsResetStatus;
|
||||||
glReadnPixels_func glReadnPixels;
|
glReadnPixels_func glReadnPixels;
|
||||||
|
@ -71,14 +68,6 @@ static glXFuncPtr getProcAddress(const char* name)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxResolveFunctions()
|
|
||||||
{
|
|
||||||
if (hasGLExtension(QByteArrayLiteral("GLX_MESA_swap_control")))
|
|
||||||
glXSwapIntervalMESA = (glXSwapIntervalMESA_func) getProcAddress("glXSwapIntervalMESA");
|
|
||||||
else
|
|
||||||
glXSwapIntervalMESA = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void eglResolveFunctions()
|
void eglResolveFunctions()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,16 +47,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
void KWINGLUTILS_EXPORT glxResolveFunctions();
|
|
||||||
|
|
||||||
void KWINGLUTILS_EXPORT eglResolveFunctions();
|
void KWINGLUTILS_EXPORT eglResolveFunctions();
|
||||||
|
|
||||||
void KWINGLUTILS_EXPORT glResolveFunctions(OpenGLPlatformInterface platformInterface);
|
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
|
// GL_ARB_robustness / GL_EXT_robustness
|
||||||
using glGetGraphicsResetStatus_func = GLenum (*)();
|
using glGetGraphicsResetStatus_func = GLenum (*)();
|
||||||
using glReadnPixels_func = void (*)(GLint x, GLint y, GLsizei width, GLsizei height,
|
using glReadnPixels_func = void (*)(GLint x, GLint y, GLsizei width, GLsizei height,
|
||||||
|
|
|
@ -42,6 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
#ifndef XCB_GLX_BUFFER_SWAP_COMPLETE
|
#ifndef XCB_GLX_BUFFER_SWAP_COMPLETE
|
||||||
#define XCB_GLX_BUFFER_SWAP_COMPLETE 1
|
#define XCB_GLX_BUFFER_SWAP_COMPLETE 1
|
||||||
|
@ -148,10 +149,22 @@ GlxBackend::~GlxBackend()
|
||||||
delete m_overlayWindow;
|
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()
|
void GlxBackend::init()
|
||||||
{
|
{
|
||||||
initGLX();
|
|
||||||
|
|
||||||
// Require at least GLX 1.3
|
// Require at least GLX 1.3
|
||||||
if (!checkVersion()) {
|
if (!checkVersion()) {
|
||||||
setFailed(QStringLiteral("Requires at least GLX 1.3"));
|
setFailed(QStringLiteral("Requires at least GLX 1.3"));
|
||||||
|
@ -160,6 +173,13 @@ void GlxBackend::init()
|
||||||
|
|
||||||
initExtensions();
|
initExtensions();
|
||||||
|
|
||||||
|
// resolve glXSwapIntervalMESA if available
|
||||||
|
if (hasExtension(QByteArrayLiteral("GLX_MESA_swap_control"))) {
|
||||||
|
glXSwapIntervalMESA = (glXSwapIntervalMESA_func) getProcAddress("glXSwapIntervalMESA");
|
||||||
|
} else {
|
||||||
|
glXSwapIntervalMESA = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
initVisualDepthHashTable();
|
initVisualDepthHashTable();
|
||||||
|
|
||||||
if (!initBuffer()) {
|
if (!initBuffer()) {
|
||||||
|
|
|
@ -29,6 +29,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// GLX_MESA_swap_interval
|
||||||
|
using glXSwapIntervalMESA_func = int (*)(unsigned int interval);
|
||||||
|
extern glXSwapIntervalMESA_func glXSwapIntervalMESA;
|
||||||
|
|
||||||
class FBConfigInfo
|
class FBConfigInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue