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>
|
||||
|
||||
#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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
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()) {
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue