[qt5-qtbase] use software OpenGL (llvmpipe) if the hardware driver doesn't support OpenGL 2
Kevin Kofler
kkofler at fedoraproject.org
Wed Jan 29 02:27:47 UTC 2014
commit b22f3a788e8ff4f7bf54e959d0adbd889a228030
Author: Kevin Kofler <Kevin at tigcc.ticalc.org>
Date: Wed Jan 29 03:26:07 2014 +0100
use software OpenGL (llvmpipe) if the hardware driver doesn't support OpenGL 2
* Wed Jan 29 2014 Kevin Kofler <Kevin at tigcc.ticalc.org> - 5.2.0-9
- use software OpenGL (llvmpipe) if the hardware driver doesn't support OpenGL 2
10-qt5-check-opengl2.sh | 6 ++
qt5-qtbase.spec | 24 +++++++-
...ensource-src-5.2.0-allow-forcing-llvmpipe.patch | 70 ++++++++++++++++++++
3 files changed, 99 insertions(+), 1 deletions(-)
---
diff --git a/10-qt5-check-opengl2.sh b/10-qt5-check-opengl2.sh
new file mode 100755
index 0000000..31cb501
--- /dev/null
+++ b/10-qt5-check-opengl2.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+OPENGL_VERSION=`LANG=C glxinfo | grep '^OpenGL version string: ' | sed -e 's/^OpenGL version string: \([0-9]\).*$/\1/g'`
+if [ "$OPENGL_VERSION" -lt 2 ]; then
+ QT_XCB_FORCE_SOFTWARE_OPENGL=1
+ export QT_XCB_FORCE_SOFTWARE_OPENGL
+fi
diff --git a/qt5-qtbase.spec b/qt5-qtbase.spec
index d7f14f9..b70c43c 100644
--- a/qt5-qtbase.spec
+++ b/qt5-qtbase.spec
@@ -26,7 +26,7 @@
Summary: Qt5 - QtBase components
Name: qt5-qtbase
Version: 5.2.0
-Release: 8%{?dist}
+Release: 9%{?dist}
# See LGPL_EXCEPTIONS.txt, LICENSE.GPL3, respectively, for exception details
License: LGPLv2 with exceptions or GPLv3 with exceptions
@@ -45,6 +45,10 @@ Source0: http://download.qt-project.org/official_releases/qt/5.2/%{version}/subm
# https://bugzilla.redhat.com/show_bug.cgi?id=1036956
Source5: qconfig-multilib.h
+# xinitrc script to check for OpenGL 1 only drivers and automatically set
+# QT_XCB_FORCE_SOFTWARE_OPENGL for them
+Source6: 10-qt5-check-opengl2.sh
+
# help build on some lowmem archs, e.g. drop hard-coded -O3 optimization on some files
Patch1: qtbase-opensource-src-5.0.2-lowmem.patch
@@ -60,6 +64,10 @@ Patch4: qt-everywhere-opensource-src-4.8.5-QTBUG-35459.patch
# fix QTBUG-35460 (error message for CVE-2013-4549 is misspelled)
Patch5: qt-everywhere-opensource-src-4.8.5-QTBUG-35460.patch
+# add a QT_XCB_FORCE_SOFTWARE_OPENGL environment variable to allow forcing
+# LIBGL_ALWAYS_SOFTWARE (llvmpipe) for Qt 5 apps only
+Patch6: qtbase-opensource-src-5.2.0-allow-forcing-llvmpipe.patch
+
# unconditionally enable freetype lcdfilter support
Patch12: qtbase-opensource-src-5.2.0-enable_ft_lcdfilter.patch
@@ -237,6 +245,13 @@ Summary: Qt5 GUI-related libraries
Requires: %{name}%{?_isa} = %{version}-%{release}
Obsoletes: qt5-qtbase-x11 < 5.2.0
Provides: qt5-qtbase-x11 = %{version}-%{release}
+
+# for Source6: 10-qt5-check-opengl2.sh:
+# directory ownership
+Requires: xorg-x11-xinit
+# glxinfo
+Requires: glx-utils
+
%description gui
Qt5 libraries used for drawing widgets and OpenGL items.
@@ -251,6 +266,7 @@ rm -fv mkspecs/linux-g++*/qmake.conf.multilib-optflags
%patch3 -p1 -b .qatomic-ppc
%patch4 -p1 -b .QTBUG-35459
%patch5 -p1 -b .QTBUG-35460
+%patch6 -p1 -b .allow-forcing-llvmpipe
%patch12 -p1 -b .enable_ft_lcdfilter
#patch50 -p1 -b .poll
@@ -450,6 +466,8 @@ for prl_file in libQt5*.prl ; do
done
popd
+install -p -m755 -D %{SOURCE6} %{_sysconfdir}/X11/xinit/xinitrc.d/10-qt5-check-opengl2.sh
+
## work-in-progress, doesn't work yet -- rex
%check
@@ -646,6 +664,7 @@ popd
%postun gui -p /sbin/ldconfig
%files gui
+%{_sysconfdir}/X11/xinit/xinitrc.d/10-qt5-check-opengl2.sh
%{_qt5_libdir}/libQt5Gui.so.5*
%{_qt5_libdir}/libQt5OpenGL.so.5*
%{_qt5_libdir}/libQt5PrintSupport.so.5*
@@ -669,6 +688,9 @@ popd
%changelog
+* Wed Jan 29 2014 Kevin Kofler <Kevin at tigcc.ticalc.org> - 5.2.0-9
+- use software OpenGL (llvmpipe) if the hardware driver doesn't support OpenGL 2
+
* Tue Jan 28 2014 Rex Dieter <rdieter at fedoraproject.org> 5.2.0-8
- (re)enable -docs
diff --git a/qtbase-opensource-src-5.2.0-allow-forcing-llvmpipe.patch b/qtbase-opensource-src-5.2.0-allow-forcing-llvmpipe.patch
new file mode 100644
index 0000000..7ad97e8
--- /dev/null
+++ b/qtbase-opensource-src-5.2.0-allow-forcing-llvmpipe.patch
@@ -0,0 +1,70 @@
+diff -ur qtbase-opensource-src-5.2.0/src/plugins/platforms/xcb/qglxintegration.cpp qtbase-opensource-src-5.2.0-allow-forcing-llvmpipe/src/plugins/platforms/xcb/qglxintegration.cpp
+--- qtbase-opensource-src-5.2.0/src/plugins/platforms/xcb/qglxintegration.cpp 2013-12-08 18:09:53.000000000 +0100
++++ qtbase-opensource-src-5.2.0-allow-forcing-llvmpipe/src/plugins/platforms/xcb/qglxintegration.cpp 2014-01-29 02:58:13.000000000 +0100
+@@ -173,6 +173,27 @@
+ if (m_format.renderableType() != QSurfaceFormat::OpenGL && m_format.renderableType() != QSurfaceFormat::OpenGLES)
+ return;
+
++ // 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")
++ && qEnvironmentVariableIsEmpty("LIBGL_ALWAYS_SOFTWARE"))
++ forceSoftwareOpenGL = true;
++
++ checkedForceSoftwareOpenGL = true;
++ }
++
++ if (forceSoftwareOpenGL)
++ qputenv("LIBGL_ALWAYS_SOFTWARE", "1");
++
+ if (share)
+ m_shareContext = static_cast<const QGLXContext*>(share)->glxContext();
+
+@@ -267,8 +288,12 @@
+ // Could not create a context using glXCreateContextAttribsARB, falling back to glXCreateNewContext.
+ if (!m_context) {
+ // requesting an OpenGL ES context requires glXCreateContextAttribsARB, so bail out
+- if (m_format.renderableType() == QSurfaceFormat::OpenGLES)
++ if (m_format.renderableType() == QSurfaceFormat::OpenGLES) {
++ // unset LIBGL_ALWAYS_SOFTWARE now so other processes don't inherit it
++ if (forceSoftwareOpenGL)
++ qunsetenv("LIBGL_ALWAYS_SOFTWARE");
+ return;
++ }
+
+ m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, m_shareContext, true);
+ if (!m_context && m_shareContext) {
+@@ -287,8 +312,12 @@
+ window = createDummyWindow(screen, config);
+ } else {
+ // requesting an OpenGL ES context requires glXCreateContextAttribsARB, so bail out
+- if (m_format.renderableType() == QSurfaceFormat::OpenGLES)
++ if (m_format.renderableType() == QSurfaceFormat::OpenGLES) {
++ // unset LIBGL_ALWAYS_SOFTWARE now so other processes don't inherit it
++ if (forceSoftwareOpenGL)
++ qunsetenv("LIBGL_ALWAYS_SOFTWARE");
+ return;
++ }
+
+ // Note that m_format gets updated with the used surface format
+ visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(screen), screen->screenNumber(), &m_format);
+@@ -317,6 +346,10 @@
+
+ // Destroy our temporary window
+ XDestroyWindow(DISPLAY_FROM_XCB(screen), window);
++
++ // unset LIBGL_ALWAYS_SOFTWARE now so other processes don't inherit it
++ if (forceSoftwareOpenGL)
++ qunsetenv("LIBGL_ALWAYS_SOFTWARE");
+ }
+
+ QGLXContext::~QGLXContext()
More information about the scm-commits
mailing list