Bind building of glx support on whether epoxy has a glx header

So far it was bound to whether we build for GLES. But this is
semantically wrong. It might be possible that even on desktop gl
epoxy is built without GLX support, thus we need to reflect this.

This change ensures that epoxy/glx.h is only included if available,
that relevant code is bound to it and that checks are in place to
enforce EGL if not build with glx support.

In addtion the glxbackend.cpp is now only included in the build set
if available.
This commit is contained in:
Martin Gräßlin 2015-10-30 11:50:31 +01:00
parent 9919627106
commit 03231942bb
12 changed files with 46 additions and 19 deletions

View file

@ -272,6 +272,7 @@ endif()
include_directories(${XKB_INCLUDE_DIR})
include_directories(${epoxy_INCLUDE_DIR})
set(HAVE_EPOXY_GLX ${epoxy_HAS_GLX})
# for things that are also used by kwin libraries
configure_file(libkwineffects/kwinconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/libkwineffects/kwinconfig.h )
@ -355,7 +356,6 @@ set(kwin_KDEINIT_SRCS
scene_xrender.cpp
scene_opengl.cpp
scene_qpainter.cpp
glxbackend.cpp
thumbnailitem.cpp
lanczosfilter.cpp
deleted.cpp
@ -392,6 +392,10 @@ set(kwin_KDEINIT_SRCS
wayland_cursor_theme.cpp
)
if(HAVE_EPOXY_GLX)
set(kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS} glxbackend.cpp)
endif()
if(KWIN_BUILD_TABBOX)
set(
kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS}

View file

@ -5,6 +5,7 @@
# epoxy_LIBRARY - The libepoxy library
# epoxy_INCLUDE_DIR - The libepoxy include dir
# epoxy_DEFINITIONS - Compiler switches required for using libepoxy
# epoxy_HAS_GLX - Whether GLX support is available
# Copyright (c) 2014 Fredrik Höglund <fredrik@kde.org>
#
@ -40,9 +41,16 @@ if (NOT WIN32)
find_path(epoxy_INCLUDE_DIR NAMES epoxy/gl.h HINTS ${PKG_epoxy_INCLUDEDIR} ${PKG_epoxy_INCLUDE_DIRS})
find_library(epoxy_LIBRARY NAMES epoxy HINTS ${PKG_epoxy_LIBDIR} ${PKG_epoxy_LIBRARY_DIRS})
find_file(epoxy_GLX_HEADER NAMES epoxy/glx.h HINTS ${epoxy_INCLUDE_DIR})
if (epoxy_GLX_HEADER STREQUAL "epoxy_GLX_HEADER-NOTFOUND")
set(epoxy_HAS_GLX FALSE CACHE BOOL "whether glx is available")
else ()
set(epoxy_HAS_GLX TRUE CACHE BOOL "whether glx is available")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(epoxy DEFAULT_MSG epoxy_LIBRARY epoxy_INCLUDE_DIR)
mark_as_advanced(epoxy_INCLUDE_DIR epoxy_LIBRARY)
mark_as_advanced(epoxy_INCLUDE_DIR epoxy_LIBRARY epoxy_HAS_GLX)
endif()

View file

@ -241,7 +241,10 @@ void CompositorDBusInterface::suspend()
QStringList CompositorDBusInterface::supportedOpenGLPlatformInterfaces() const
{
QStringList interfaces;
bool supportsGlx = (kwinApp()->operationMode() == Application::OperationModeX11);
bool supportsGlx = false;
#if HAVE_EPOXY_GLX
supportsGlx = (kwinApp()->operationMode() == Application::OperationModeX11);
#endif
#ifdef KWIN_HAVE_OPENGLES
supportsGlx = false;
#endif

View file

@ -22,8 +22,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
// TODO: cmake magic
#ifndef KWIN_HAVE_OPENGLES
// own
#include "glxbackend.h"
// kwin
@ -870,4 +868,3 @@ OpenGLBackend *GlxTexture::backend()
}
} // namespace
#endif

View file

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "x11eventfilter.h"
#include <xcb/glx.h>
#include <epoxy/glx.h>
#include <memory>
namespace KWin

View file

@ -19,5 +19,7 @@
/* KWIN_HAVE_XRENDER_COMPOSITING - whether XRender-based compositing support is available */
#cmakedefine KWIN_HAVE_XRENDER_COMPOSITING
#cmakedefine01 HAVE_EPOXY_GLX
#endif

View file

@ -45,6 +45,10 @@ 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) )
@ -77,7 +81,7 @@ int glTextureUnitsCount;
// Functions
void initGLX()
{
#ifndef KWIN_HAVE_OPENGLES
#if HAVE_EPOXY_GLX
// Get GLX version
int major, minor;
glXQueryVersion(display(), &major, &minor);

View file

@ -21,6 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "kwinglutils.h"
#include <dlfcn.h>
#if HAVE_EPOXY_GLX
#include <epoxy/glx.h>
#endif
// Resolves given function, using getProcAddress
@ -56,10 +59,12 @@ glGetnUniformfv_func glGetnUniformfv;
typedef void (*glXFuncPtr)();
#ifndef KWIN_HAVE_OPENGLES
static glXFuncPtr getProcAddress(const char* name)
{
glXFuncPtr ret = glXGetProcAddress((const GLubyte*) 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;
@ -72,7 +77,6 @@ void glxResolveFunctions()
else
glXSwapIntervalMESA = nullptr;
}
#endif
void eglResolveFunctions()
{

View file

@ -27,10 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <epoxy/egl.h>
#ifndef KWIN_HAVE_OPENGLES
#include <epoxy/glx.h>
#endif
#include <fixx11h.h>
#include <epoxy/gl.h>
@ -51,9 +47,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin
{
#ifndef KWIN_HAVE_OPENGLES
void KWINGLUTILS_EXPORT glxResolveFunctions();
#endif
void KWINGLUTILS_EXPORT eglResolveFunctions();

View file

@ -764,6 +764,10 @@ void Options::setGlPlatformInterface(OpenGLPlatformInterface interface)
qCDebug(KWIN_CORE) << "Forcing EGL native interface for Wayland mode";
interface = EglPlatformInterface;
}
#if !HAVE_EPOXY_GLX
qCDebug(KWIN_CORE) << "Forcing EGL native interface as compiled without GLX support";
interface = EglPlatformInterface;
#endif
#ifdef KWIN_HAVE_OPENGLES
qCDebug(KWIN_CORE) << "Forcing EGL native interface as compiled against OpenGL ES";
interface = EglPlatformInterface;

View file

@ -28,9 +28,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "scene_opengl.h"
#include "eglonxbackend.h"
#ifndef KWIN_HAVE_OPENGLES
#if HAVE_EPOXY_GLX
#include "glxbackend.h"
#endif // KWIN_HAVE_OPENGLES
#endif
#include "abstract_backend.h"
#include "wayland_server.h"
@ -541,7 +541,7 @@ SceneOpenGL *SceneOpenGL::createScene(QObject *parent)
switch (platformInterface) {
case GlxPlatformInterface:
#ifndef KWIN_HAVE_OPENGLES
#if HAVE_EPOXY_GLX
backend = new GlxBackend();
#endif
break;

View file

@ -1383,6 +1383,12 @@ QString Workspace::supportInformation() const
support.append(yes);
#else
support.append(no);
#endif
support.append(QStringLiteral("HAVE_EPOXY_GLX: "));
#if HAVE_EPOXY_GLX
support.append(yes);
#else
support.append(no);
#endif
support.append(QStringLiteral("\n"));