diff options
author | Kevin Kofler <kevin.kofler@chello.at> | 2014-01-30 16:28:18 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-07 15:55:24 +0100 |
commit | c716cb2600dfe80d6e723ecb3b4c45cbc693becf (patch) | |
tree | 42d9ed066281e81aacd5663240c9ff360c8dcd3a | |
parent | 4e319ca4c47a99295c1a07aa759e09d86f1b7c87 (diff) |
glxconvenience: Add a QT_XCB_FORCE_SOFTWARE_OPENGL environment variable.
The QT_XCB_FORCE_SOFTWARE_OPENGL environment variable is equivalent to
LIBGL_ALWAYS_SOFTWARE for Qt 5 applications only. This is most useful
with drivers that only support OpenGL 1. We need OpenGL 2, but the user
probably doesn't want LIBGL_ALWAYS_SOFTWARE in OpenGL 1 apps.
Together with
http://pkgs.fedoraproject.org/cgit/qt5-qtbase.git/tree/10-qt5-check-opengl2.sh
which goes into /etc/X11/xinit/xinitrc.d, it makes QML 2 just work on
old hardware that supports only OpenGL 1.x in hardware. The scriptlet
checks the glxinfo output for the OpenGL version and sets
QT_XCB_FORCE_SOFTWARE_OPENGL if the major version is < 2. (The scriptlet
requires xorg-x11-xinit and glx-utils.)
Tested on a Radeon 9200 SE (RV280) that supports only OpenGL 1.3 in
hardware.
Change-Id: Ief80d283820d6336052b8f390a0030ba9b687492
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
-rw-r--r-- | src/platformsupport/glxconvenience/qglxconvenience.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp index 11d9377db7..4630b12a57 100644 --- a/src/platformsupport/glxconvenience/qglxconvenience.cpp +++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp @@ -39,6 +39,10 @@ ** ****************************************************************************/ +// We have to include this before the X11 headers dragged in by +// qglxconvenience_p.h. +#include <QtCore/QByteArray> + #include "qglxconvenience_p.h" #include <QtCore/QVector> @@ -116,6 +120,27 @@ QVector<int> qglx_buildSpec(const QSurfaceFormat &format, int drawableBit) GLXFBConfig qglx_findConfig(Display *display, int screen , const QSurfaceFormat &format, int drawableBit) { + // Allow forcing LIBGL_ALWAYS_SOFTWARE for Qt 5 applications only. + // This is most useful with drivers that only support OpenGL 1. + // We need OpenGL 2, but the user probably doesn't want + // LIBGL_ALWAYS_SOFTWARE in OpenGL 1 apps. + static bool checkedForceSoftwareOpenGL = false; + static bool forceSoftwareOpenGL = false; + if (!checkedForceSoftwareOpenGL) { + // If LIBGL_ALWAYS_SOFTWARE is already set, don't mess with it. + // We want to unset LIBGL_ALWAYS_SOFTWARE at the end so it does not + // get inherited by other processes, of course only if it wasn't + // already set before. + if (!qEnvironmentVariableIsEmpty("QT_XCB_FORCE_SOFTWARE_OPENGL") + && !qEnvironmentVariableIsSet("LIBGL_ALWAYS_SOFTWARE")) + forceSoftwareOpenGL = true; + + checkedForceSoftwareOpenGL = true; + } + + if (forceSoftwareOpenGL) + qputenv("LIBGL_ALWAYS_SOFTWARE", QByteArrayLiteral("1")); + bool reduced = true; GLXFBConfig chosenConfig = 0; QSurfaceFormat reducedFormat = format; @@ -159,6 +184,10 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QSurfaceFormat reducedFormat = qglx_reduceSurfaceFormat(reducedFormat,&reduced); } + // unset LIBGL_ALWAYS_SOFTWARE now so other processes don't inherit it + if (forceSoftwareOpenGL) + qunsetenv("LIBGL_ALWAYS_SOFTWARE"); + return chosenConfig; } |