Move querying glx extensions into the platform plugin

Summary:
Glx extensions are only interesting to the glxbackend. Given that
querying can be moved there.

In order to simplify the extensions can be stored in the OpenGLBackend
which also provides the convenience check as before.

The egl platforms should also be adjusted to query in that way and
remove it from the kwinglutils.

There is still a usage of the glxextensions inside kwinglutils to
resolve one function. That should also be moved into the platform.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3332
This commit is contained in:
Martin Gräßlin 2016-11-10 15:56:36 +01:00
parent 5d39da8427
commit 730fd05f58
6 changed files with 48 additions and 16 deletions

View file

@ -18,9 +18,11 @@ 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 "debug_console.h"
#include "composite.h"
#include "client.h"
#include "input_event.h"
#include "main.h"
#include "scene_opengl.h"
#include "shell_client.h"
#include "unmanaged.h"
#include "wayland_server.h"
@ -548,7 +550,7 @@ void DebugConsole::initGLTab()
m_ui->eglExtensionsBox->setVisible(false);
m_ui->glxExtensionsBox->setVisible(true);
m_ui->glxExtensionsLabel->setText(extensionsString(glxExtensions()));
m_ui->glxExtensionsLabel->setText(extensionsString(static_cast<SceneOpenGL*>(Compositor::self()->scene())->backend()->extensions()));
}
m_ui->openGLExtensionsLabel->setText(extensionsString(openGLExtensions()));

View file

@ -156,11 +156,6 @@ QList<QByteArray> eglExtensions()
return s_eglExtensions;
}
QList<QByteArray> glxExtensions()
{
return s_glxExtensions;
}
QList<QByteArray> openGLExtensions()
{
return glExtensions;

View file

@ -84,7 +84,6 @@ inline bool KWINGLUTILS_EXPORT isPowerOfTwo(int x)
int KWINGLUTILS_EXPORT nearestPowerOfTwo(int x);
QList<QByteArray> KWINGLUTILS_EXPORT eglExtensions();
QList<QByteArray> KWINGLUTILS_EXPORT glxExtensions();
QList<QByteArray> KWINGLUTILS_EXPORT openGLExtensions();
class KWINGLUTILS_EXPORT GLShader

View file

@ -158,6 +158,8 @@ void GlxBackend::init()
return;
}
initExtensions();
initVisualDepthHashTable();
if (!initBuffer()) {
@ -180,12 +182,12 @@ void GlxBackend::init()
initGL(GlxPlatformInterface);
// Check whether certain features are supported
m_haveMESACopySubBuffer = hasGLExtension(QByteArrayLiteral("GLX_MESA_copy_sub_buffer"));
m_haveMESASwapControl = hasGLExtension(QByteArrayLiteral("GLX_MESA_swap_control"));
m_haveEXTSwapControl = hasGLExtension(QByteArrayLiteral("GLX_EXT_swap_control"));
m_haveSGISwapControl = hasGLExtension(QByteArrayLiteral("GLX_SGI_swap_control"));
m_haveMESACopySubBuffer = hasExtension(QByteArrayLiteral("GLX_MESA_copy_sub_buffer"));
m_haveMESASwapControl = hasExtension(QByteArrayLiteral("GLX_MESA_swap_control"));
m_haveEXTSwapControl = hasExtension(QByteArrayLiteral("GLX_EXT_swap_control"));
m_haveSGISwapControl = hasExtension(QByteArrayLiteral("GLX_SGI_swap_control"));
// only enable Intel swap event if env variable is set, see BUG 342582
m_haveINTELSwapEvent = hasGLExtension(QByteArrayLiteral("GLX_INTEL_swap_event"))
m_haveINTELSwapEvent = hasExtension(QByteArrayLiteral("GLX_INTEL_swap_event"))
&& qgetenv("KWIN_USE_INTEL_SWAP_EVENT") == QByteArrayLiteral("1");
if (m_haveINTELSwapEvent) {
@ -197,7 +199,7 @@ void GlxBackend::init()
setSupportsBufferAge(false);
if (hasGLExtension(QByteArrayLiteral("GLX_EXT_buffer_age"))) {
if (hasExtension(QByteArrayLiteral("GLX_EXT_buffer_age"))) {
const QByteArray useBufferAge = qgetenv("KWIN_USE_BUFFER_AGE");
if (useBufferAge != "0")
@ -220,7 +222,7 @@ void GlxBackend::init()
gs_tripleBufferUndetected = false;
}
gs_tripleBufferNeedsDetection = gs_tripleBufferUndetected;
} else if (hasGLExtension(QByteArrayLiteral("GLX_SGI_video_sync"))) {
} else if (hasExtension(QByteArrayLiteral("GLX_SGI_video_sync"))) {
unsigned int sync;
if (glXGetVideoSyncSGI(&sync) == 0 && glXWaitVideoSyncSGI(1, 0, &sync) == 0) {
setSyncsToVBlank(true);
@ -253,12 +255,18 @@ bool GlxBackend::checkVersion()
return kVersionNumber(major, minor) >= kVersionNumber(1, 3);
}
void GlxBackend::initExtensions()
{
const QByteArray string = (const char *) glXQueryExtensionsString(display(), QX11Info::appScreen());
setExtensions(string.split(' '));
}
bool GlxBackend::initRenderingContext()
{
const bool direct = true;
// Use glXCreateContextAttribsARB() when it's available
if (hasGLExtension(QByteArrayLiteral("GLX_ARB_create_context"))) {
if (hasExtension(QByteArrayLiteral("GLX_ARB_create_context"))) {
const int attribs_31_core_robustness[] = {
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 1,
@ -285,7 +293,7 @@ bool GlxBackend::initRenderingContext()
0
};
const bool have_robustness = hasGLExtension(QByteArrayLiteral("GLX_ARB_create_context_robustness"));
const bool have_robustness = hasExtension(QByteArrayLiteral("GLX_ARB_create_context_robustness"));
// Try to create a 3.1 context first
if (options->glCoreProfile()) {

View file

@ -79,6 +79,7 @@ protected:
private:
bool initBuffer();
bool checkVersion();
void initExtensions();
void waitSync();
bool initRenderingContext();
bool initFbConfig();

View file

@ -507,6 +507,22 @@ public:
*/
void addToDamageHistory(const QRegion &region);
/**
* The backend specific extensions (e.g. EGL/GLX extensions).
*
* Not the OpenGL (ES) extension!
**/
QList<QByteArray> extensions() const {
return m_extensions;
}
/**
* @returns whether the backend specific extensions contains @p extension.
**/
bool hasExtension(const QByteArray &extension) const {
return m_extensions.contains(extension);
}
protected:
/**
* @brief Backend specific flushing of frame to screen.
@ -583,6 +599,15 @@ protected:
m_surfaceLessContext = set;
}
/**
* Sets the platform-specific @p extensions.
*
* These are the EGL/GLX extensions, not the OpenGL extensions
**/
void setExtensions(const QList<QByteArray> &extensions) {
m_extensions = extensions;
}
SwapProfiler m_swapProfiler;
private:
@ -619,6 +644,8 @@ private:
**/
QElapsedTimer m_renderTimer;
bool m_surfaceLessContext = false;
QList<QByteArray> m_extensions;
};
class SceneOpenGLDecorationRenderer : public Decoration::Renderer