Move glxbackend to x11 standalone plugin

Summary:
It's only needed by the standalone x11 variant. This allows us to
simplify the creation of the OpenGLBackend: it's created by the
platform plugin - we don't need custom complex logic.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1392
This commit is contained in:
Martin Gräßlin 2016-04-12 15:03:07 +02:00
parent a3cd28a87e
commit 248991223b
9 changed files with 46 additions and 45 deletions

View file

@ -414,10 +414,6 @@ 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

@ -25,8 +25,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// xcb
#include <xcb/xcb.h>
#include <kwin_export.h>
namespace KWin {
class OverlayWindow {
class KWIN_EXPORT OverlayWindow {
public:
OverlayWindow();
~OverlayWindow();

View file

@ -4,6 +4,10 @@ set(X11PLATFORM_SOURCES
screens_xrandr.cpp
)
if(HAVE_EPOXY_GLX)
set(X11PLATFORM_SOURCES ${X11PLATFORM_SOURCES} glxbackend.cpp)
endif()
add_library(KWinX11Platform MODULE ${X11PLATFORM_SOURCES})
target_link_libraries(KWinX11Platform kwin Qt5::X11Extras)

View file

@ -24,9 +24,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// own
#include "glxbackend.h"
#include "logging.h"
// kwin
#include "options.h"
#include "utils.h"
#include "overlaywindow.h"
#include "composite.h"
#include "screens.h"
@ -229,9 +229,9 @@ void GlxBackend::init()
setBlocksForRetrace(true);
haveWaitSync = true;
} else
qCWarning(KWIN_CORE) << "NO VSYNC! glXSwapInterval is not supported, glXWaitVideoSync is supported but broken";
qCWarning(KWIN_X11STANDALONE) << "NO VSYNC! glXSwapInterval is not supported, glXWaitVideoSync is supported but broken";
} else
qCWarning(KWIN_CORE) << "NO VSYNC! neither glSwapInterval nor glXWaitVideoSync are supported";
qCWarning(KWIN_X11STANDALONE) << "NO VSYNC! neither glSwapInterval nor glXWaitVideoSync are supported";
} else {
// disable v-sync (if possible)
setSwapInterval(0);
@ -245,7 +245,7 @@ void GlxBackend::init()
setIsDirectRendering(bool(glXIsDirect(display(), ctx)));
qCDebug(KWIN_CORE) << "Direct rendering:" << isDirectRendering();
qCDebug(KWIN_X11STANDALONE) << "Direct rendering:" << isDirectRendering();
}
bool GlxBackend::initRenderingContext()
@ -302,12 +302,12 @@ bool GlxBackend::initRenderingContext()
ctx = glXCreateNewContext(display(), fbconfig, GLX_RGBA_TYPE, NULL, direct);
if (!ctx) {
qCDebug(KWIN_CORE) << "Failed to create an OpenGL context.";
qCDebug(KWIN_X11STANDALONE) << "Failed to create an OpenGL context.";
return false;
}
if (!glXMakeCurrent(display(), glxWindow, ctx)) {
qCDebug(KWIN_CORE) << "Failed to make the OpenGL context current.";
qCDebug(KWIN_X11STANDALONE) << "Failed to make the OpenGL context current.";
glXDestroyContext(display(), ctx);
ctx = 0;
return false;
@ -329,7 +329,7 @@ bool GlxBackend::initBuffer()
glXGetFBConfigAttrib(display(), fbconfig, GLX_VISUAL_ID, (int *) &visual);
if (!visual) {
qCCritical(KWIN_CORE) << "The GLXFBConfig does not have an associated X visual";
qCCritical(KWIN_X11STANDALONE) << "The GLXFBConfig does not have an associated X visual";
return false;
}
@ -346,7 +346,7 @@ bool GlxBackend::initBuffer()
glxWindow = glXCreateWindow(display(), fbconfig, window, NULL);
overlayWindow()->setup(window);
} else {
qCCritical(KWIN_CORE) << "Failed to create overlay window";
qCCritical(KWIN_X11STANDALONE) << "Failed to create overlay window";
return false;
}
@ -415,12 +415,12 @@ bool GlxBackend::initFbConfig()
glXGetFBConfigAttrib(display(), fbconfig, GLX_DEPTH_SIZE, &depth);
glXGetFBConfigAttrib(display(), fbconfig, GLX_STENCIL_SIZE, &stencil);
qCDebug(KWIN_CORE, "Choosing GLXFBConfig %#x X visual %#x depth %d RGBA %d:%d:%d:%d ZS %d:%d",
qCDebug(KWIN_X11STANDALONE, "Choosing GLXFBConfig %#x X visual %#x depth %d RGBA %d:%d:%d:%d ZS %d:%d",
fbconfig_id, visual_id, visualDepth(visual_id), red, green, blue, alpha, depth, stencil);
}
if (fbconfig == nullptr) {
qCCritical(KWIN_CORE) << "Failed to find a usable framebuffer configuration";
qCCritical(KWIN_X11STANDALONE) << "Failed to find a usable framebuffer configuration";
return false;
}
@ -466,7 +466,7 @@ FBConfigInfo *GlxBackend::infoForVisual(xcb_visualid_t visual)
const xcb_render_directformat_t *direct = XRenderUtils::findPictFormatInfo(format);
if (!direct) {
qCCritical(KWIN_CORE).nospace() << "Could not find a picture format for visual 0x" << hex << visual;
qCCritical(KWIN_X11STANDALONE).nospace() << "Could not find a picture format for visual 0x" << hex << visual;
return info;
}
@ -499,7 +499,7 @@ FBConfigInfo *GlxBackend::infoForVisual(xcb_visualid_t visual)
GLXFBConfig *configs = glXChooseFBConfig(display(), DefaultScreen(display()), attribs, &count);
if (count < 1) {
qCCritical(KWIN_CORE).nospace() << "Could not find a framebuffer configuration for visual 0x" << hex << visual;
qCCritical(KWIN_X11STANDALONE).nospace() << "Could not find a framebuffer configuration for visual 0x" << hex << visual;
return info;
}
@ -581,7 +581,7 @@ FBConfigInfo *GlxBackend::infoForVisual(xcb_visualid_t visual)
glXGetFBConfigAttrib(display(), info->fbconfig, GLX_FBCONFIG_ID, &fbc_id);
glXGetFBConfigAttrib(display(), info->fbconfig, GLX_VISUAL_ID, &visual_id);
qCDebug(KWIN_CORE).nospace() << "Using FBConfig 0x" << hex << fbc_id << " for visual 0x" << hex << visual_id;
qCDebug(KWIN_X11STANDALONE).nospace() << "Using FBConfig 0x" << hex << fbc_id << " for visual 0x" << hex << visual_id;
}
return info;
@ -643,7 +643,7 @@ void GlxBackend::present()
options->setGlPreferBufferSwap(0);
setSwapInterval(0);
result = 0; // hint proper behavior
qCWarning(KWIN_CORE) << "\nIt seems you are using the nvidia driver without triple buffering\n"
qCWarning(KWIN_X11STANDALONE) << "\nIt seems you are using the nvidia driver without triple buffering\n"
"You must export __GL_YIELD=\"USLEEP\" to prevent large CPU overhead on synced swaps\n"
"Preferably, enable the TripleBuffer Option in the xorg.conf Device\n"
"For this reason, the tearing prevention has been disabled.\n"

View file

@ -18,7 +18,13 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "x11_platform.h"
#include <kwinconfig.h>
#if HAVE_EPOXY_GLX
#include "glxbackend.h"
#endif
#include "eglonxbackend.h"
#include "screens_xrandr.h"
#include "options.h"
#include <QX11Info>
@ -47,4 +53,19 @@ Screens *X11StandalonePlatform::createScreens(QObject *parent)
return new XRandRScreens(parent);
}
OpenGLBackend *X11StandalonePlatform::createOpenGLBackend()
{
switch (options->glPlatformInterface()) {
#if HAVE_EPOXY_GLX
case GlxPlatformInterface:
return new GlxBackend();
#endif
case EglPlatformInterface:
return new EglOnXBackend();
default:
// no backend available
return nullptr;
}
}
}

View file

@ -39,6 +39,7 @@ public:
void init() override;
Screens *createScreens(QObject *parent = nullptr) override;
OpenGLBackend *createOpenGLBackend() override;
};

View file

@ -27,10 +27,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/>.
*********************************************************************/
#include "scene_opengl.h"
#include "eglonxbackend.h"
#if HAVE_EPOXY_GLX
#include "glxbackend.h"
#endif
#include "platform.h"
#include "wayland_server.h"
@ -561,26 +557,7 @@ void SceneOpenGL::initDebugOutput()
SceneOpenGL *SceneOpenGL::createScene(QObject *parent)
{
OpenGLBackend *backend = NULL;
OpenGLPlatformInterface platformInterface = options->glPlatformInterface();
switch (platformInterface) {
case GlxPlatformInterface:
#if HAVE_EPOXY_GLX
backend = new GlxBackend();
#endif
break;
case EglPlatformInterface:
if (kwinApp()->shouldUseWaylandForCompositing()) {
backend = kwinApp()->platform()->createOpenGLBackend();
} else {
backend = new EglOnXBackend();
}
break;
default:
// no backend available
return NULL;
}
OpenGLBackend *backend = kwinApp()->platform()->createOpenGLBackend();
if (!backend) {
return nullptr;
}

View file

@ -38,7 +38,7 @@ class OpenGLBackend;
class SyncManager;
class SyncObject;
class SceneOpenGL
class KWIN_EXPORT SceneOpenGL
: public Scene
{
Q_OBJECT
@ -347,7 +347,7 @@ private:
* @short Profiler to detect whether we have triple buffering
* The strategy is to start setBlocksForRetrace(false) but assume blocking and have the system prove that assumption wrong
**/
class SwapProfiler
class KWIN_EXPORT SwapProfiler
{
public:
SwapProfiler();