Git commit 29795f49e87d1ef2d293a076e5c1a123427bc6a4 by Fredrik H=C3=B6glund. Committed on 18/09/2014 at 15:09. Pushed by fredrik into branch 'master'. Add support for GLX in Xcb::Extensions M +2 -0 CMakeLists.txt M +1 -12 compositingprefs.cpp M +72 -1 xcbutils.cpp M +10 -0 xcbutils.h http://commits.kde.org/kwin/29795f49e87d1ef2d293a076e5c1a123427bc6a4 diff --git a/CMakeLists.txt b/CMakeLists.txt index b05e106..d87291e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,6 +195,7 @@ find_package(XCB IMAGE SHM XTEST + GLX OPTIONAL_COMPONENTS ICCCM ) @@ -513,6 +514,7 @@ set(kwin_XCB_LIBS XCB::KEYSYMS XCB::SHM XCB::XTEST + XCB::GLX ) = set(kwin_WAYLAND_LIBS diff --git a/compositingprefs.cpp b/compositingprefs.cpp index b675872..ee92851 100644 --- a/compositingprefs.cpp +++ b/compositingprefs.cpp @@ -116,20 +116,9 @@ QString CompositingPrefs::compositingNotPossibleReason= () return QString(); } = -static bool s_glxDetected =3D false; -static bool s_hasGlx =3D false; - bool CompositingPrefs::hasGlx() { - if (s_glxDetected) { - return s_hasGlx; - } -#ifndef KWIN_HAVE_OPENGLES - int event_base, error_base; - s_hasGlx =3D glXQueryExtension(display(), &event_base, &error_base); -#endif - s_glxDetected =3D true; - return s_hasGlx; + return Xcb::Extensions::self()->hasGlx(); } = } // namespace diff --git a/xcbutils.cpp b/xcbutils.cpp index 1ac3b09..a536f67 100644 --- a/xcbutils.cpp +++ b/xcbutils.cpp @@ -30,6 +30,7 @@ along with this program. If not, see . #include #include #include +#include // system #include #include @@ -266,6 +267,70 @@ QVector syncOpCodes() QByteArrayLiteral("AwaitFence")}); } = +static QVector glxOpCodes() +{ + return QVector{ + QByteArrayLiteral(""), + QByteArrayLiteral("Render"), + QByteArrayLiteral("RenderLarge"), + QByteArrayLiteral("CreateContext"), + QByteArrayLiteral("DestroyContext"), + QByteArrayLiteral("MakeCurrent"), + QByteArrayLiteral("IsDirect"), + QByteArrayLiteral("QueryVersion"), + QByteArrayLiteral("WaitGL"), + QByteArrayLiteral("WaitX"), + QByteArrayLiteral("CopyContext"), + QByteArrayLiteral("SwapBuffers"), + QByteArrayLiteral("UseXFont"), + QByteArrayLiteral("CreateGLXPixmap"), + QByteArrayLiteral("GetVisualConfigs"), + QByteArrayLiteral("DestroyGLXPixmap"), + QByteArrayLiteral("VendorPrivate"), + QByteArrayLiteral("VendorPrivateWithReply"), + QByteArrayLiteral("QueryExtensionsString"), + QByteArrayLiteral("QueryServerString"), + QByteArrayLiteral("ClientInfo"), + QByteArrayLiteral("GetFBConfigs"), + QByteArrayLiteral("CreatePixmap"), + QByteArrayLiteral("DestroyPixmap"), + QByteArrayLiteral("CreateNewContext"), + QByteArrayLiteral("QueryContext"), + QByteArrayLiteral("MakeContextCurrent"), + QByteArrayLiteral("CreatePbuffer"), + QByteArrayLiteral("DestroyPbuffer"), + QByteArrayLiteral("GetDrawableAttributes"), + QByteArrayLiteral("ChangeDrawableAttributes"), + QByteArrayLiteral("CreateWindow"), + QByteArrayLiteral("DeleteWindow"), + QByteArrayLiteral("SetClientInfoARB"), + QByteArrayLiteral("CreateContextAttribsARB"), + QByteArrayLiteral("SetClientInfo2ARB") + // Opcodes 36-100 are unused + // The GL single commands begin at opcode 101 + }; +} + +static QVector glxErrorCodes() +{ + return QVector{ + QByteArrayLiteral("BadContext"), + QByteArrayLiteral("BadContextState"), + QByteArrayLiteral("BadDrawable"), + QByteArrayLiteral("BadPixmap"), + QByteArrayLiteral("BadContextTag"), + QByteArrayLiteral("BadCurrentWindow"), + QByteArrayLiteral("BadRenderRequest"), + QByteArrayLiteral("BadLargeRequest"), + QByteArrayLiteral("UnsupportedPrivateRequest"), + QByteArrayLiteral("BadFBConfig"), + QByteArrayLiteral("BadPbuffer"), + QByteArrayLiteral("BadCurrentDrawable"), + QByteArrayLiteral("BadWindow"), + QByteArrayLiteral("GLXBadProfileARB") + }; +} + ExtensionData::ExtensionData() : version(0) , eventBase(0) @@ -317,6 +382,7 @@ void Extensions::init() xcb_prefetch_extension_data(c, &xcb_xfixes_id); xcb_prefetch_extension_data(c, &xcb_render_id); xcb_prefetch_extension_data(c, &xcb_sync_id); + xcb_prefetch_extension_data(c, &xcb_glx_id); = m_shape.name =3D QByteArray("SHAPE"); m_randr.name =3D QByteArray("RANDR"); @@ -325,6 +391,7 @@ void Extensions::init() m_fixes.name =3D QByteArray("XFIXES"); m_render.name =3D QByteArray("RENDER"); m_sync.name =3D QByteArray("SYNC"); + m_glx.name =3D QByteArray("GLX"); = m_shape.opCodes =3D shapeOpCodes(); m_randr.opCodes =3D randrOpCodes(); @@ -333,10 +400,12 @@ void Extensions::init() m_fixes.opCodes =3D fixesOpCodes(); m_render.opCodes =3D renderOpCodes(); m_sync.opCodes =3D syncOpCodes(); + m_glx.opCodes =3D glxOpCodes(); = m_randr.errorCodes =3D randrErrorCodes(); m_damage.errorCodes =3D damageErrorCodes(); m_fixes.errorCodes =3D fixesErrorCodes(); + m_glx.errorCodes =3D glxErrorCodes(); = extensionQueryReply(xcb_get_extension_data(c, &xcb_shape_id), &m_shape= ); extensionQueryReply(xcb_get_extension_data(c, &xcb_randr_id), &m_randr= ); @@ -345,6 +414,7 @@ void Extensions::init() extensionQueryReply(xcb_get_extension_data(c, &xcb_xfixes_id), &m_fixe= s); extensionQueryReply(xcb_get_extension_data(c, &xcb_render_id), &m_rend= er); extensionQueryReply(xcb_get_extension_data(c, &xcb_sync_id), &m_sync); + extensionQueryReply(xcb_get_extension_data(c, &xcb_glx_id), &m_glx); = // extension specific queries xcb_shape_query_version_cookie_t shapeVersion; @@ -480,7 +550,8 @@ QVector Extensions::extensions() const << m_composite << m_render << m_fixes - << m_sync; + << m_sync + << m_glx; return extensions; } = diff --git a/xcbutils.h b/xcbutils.h index 2640e52..39ca05b 100644 --- a/xcbutils.h +++ b/xcbutils.h @@ -909,6 +909,15 @@ public: } int syncAlarmNotifyEvent() const; QVector extensions() const; + bool hasGlx() const { + return m_glx.present; + } + int glxEventBase() const { + return m_glx.eventBase; + } + int glxMajorOpcode() const { + return m_glx.majorOpcode; + } = static Extensions *self(); static void destroy(); @@ -927,6 +936,7 @@ private: ExtensionData m_render; ExtensionData m_fixes; ExtensionData m_sync; + ExtensionData m_glx; = static Extensions *s_self; };