Bug 357755

Summary: Please automatically use QT_XCB_FORCE_SOFTWARE_OPENGL=1, if hardware don't support OpenGL2
Product: [Plasma] plasmashell Reporter: opensuse.lietuviu.kalba
Component: generalAssignee: David Edmundson <kde>
Status: RESOLVED INTENTIONAL    
Severity: normal CC: bhush94, christian_burger, kevin.kofler, plasma-bugs
Priority: NOR    
Version: master   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description opensuse.lietuviu.kalba 2016-01-09 18:22:31 UTC
Plasma wants OpenGL 2 at hardware level.

Now we will see message like
"Plasma is unable to start as it could not correctly use OpenGL 2.
Please check that your graphic drivers are set up correctly."

But please use QT_XCB_FORCE_SOFTWARE_OPENGL=1 , if hardware don't support OpenGL2: maybe automatically or provide warning dialog and ask for software rendering.
For example, in Linux, you can just create
/etc/xdg/plasma-workspace/env/plasma-check-Qt5-OpenGL2.sh file with content (and make this file executable): 
#!/bin/sh 
OPENGL_VERSION=`LANG=C glxinfo | grep '^OpenGL version string: ' | head -n 1 | 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

Reproducible: Always
Comment 1 David Edmundson 2016-01-10 01:30:01 UTC
Fedora carries that patch in their init scripts.

For what it's worth, safe mode now enables this flag constantly too.

Note that it doesn't do what you described. It does *not* change whether Qt uses software rendering, it simply internally sets the environment variable LIBGL_ALWAYS_SOFTWARE. This is a Mesa specific variable and it changes how mesa behaves. If you use propreitory NVidia/ATI or even a different open source driver that isn't Mesa this does nothing.

What I don't really understand is:

if it's the correct thing to do and it's so easy to check, why doesn't Qt just do it automatically?

Laszlo Agocs merged this env variable in Qt instead of a simple check, so this was a very explicit deliberate decision (by people who frankly know a lot more than either of us) to not enable it all the time based on opengl version - and that makes me hesitant about merging this.
Comment 2 opensuse.lietuviu.kalba 2016-01-10 06:22:17 UTC
I wish some specialists would fine more proper solution
Comment 3 Kevin Kofler 2016-01-16 06:17:23 UTC
I explained why I implemented this the way I did in my Qt review request:
https://codereview.qt-project.org/#/c/76992/

> Q: Why do you need the special QT_XCB_FORCE_SOFTWARE_OPENGL environment
>    variable and the xinitrc.d snippet? Can't you just detect this
>    automatically inside Qt?
> A: The problem is that to check what version of OpenGL is supported by the
>    driver, I have to initialize it, and after initializing it, it is too late
>    to switch to software rendering. So I would have to spawn an external
>    helper executable to check that. Doing so all the time is expensive.
>    Therefore, I decided to do the check once at session startup and cache the
>    result (which is not likely to change) in an environment variable. (And I
>    also cache the result of the environment variable lookup inside Qt, to
>    minimize the performance hit of the workaround.)
Comment 4 Kevin Kofler 2016-01-16 06:18:58 UTC
In short, the thing is, Mesa can only tell me what version of OpenGL the hardware supports after I initialize it, but at that point I can no longer switch to software rendering. So the check has to be done in another process.
Comment 5 Kevin Kofler 2016-01-16 06:28:21 UTC
Oh, and:
* Doing this check in /etc/xdg/plasma-workspace/env/ is not that great a solution, because QML can also be used in other desktop environments. For the same reason, I also think Plasma is not the right place to ship this script. Fedora installs the script to /etc/X11/xinit/xinitrc.d/10-qt5-check-opengl2.sh in its Qt packaging.
* As for drivers that do not support LIBGL_ALWAYS_SOFTWARE, well, if those do not support OpenGL 2 in hardware, there's not much I can do for you. QML 2 renders using OpenGL, so to get software rendering, you need an OpenGL implementation that does software rendering. You would actually need some hack like Bumblebee to run Qt with a different libGL in such a situation. That said, haven't the proprietary AMD/ATI and NVidia drivers dropped support for ancient OpenGL-1-only cards long ago? I think the Mesa ones are the only ones that support such old hardware to begin with, and the Mesa libGL honors LIBGL_ALWAYS_SOFTWARE.
Comment 6 Christian 2017-01-28 19:13:05 UTC
This has nothing to do with the hardware not being capable, it's a BUG.
My system runs in LxQT / Gnome or any other DE you can imagine with no problems, using opengl, runs 3D games etc.
Plasma 5 won't work if you're using NVidia's proprietary drivers / libraries.
The issue is with whatever check you're doing which throws this message:
"Plasma is unable to start as it could not correctly use OpenGL 2."
Comment 7 Kevin Kofler 2017-01-28 23:58:39 UTC
Please do not hijack bug reports! Your issue has nothing to do with this issue. The NVidia proprietary driver does OpenGL 2, and even if your distro sets QT_XCB_FORCE_SOFTWARE_OPENGL on it for some reason, it should have no effect whatsoever on the NVidia driver. (All it does is make Qt set LIBGL_ALWAYS_SOFTWARE before initializing libGL. That's a Mesa environmet variable that, as far as I know, the NVidia libGL does not do anything at all with.)
Comment 8 David Edmundson 2021-03-10 23:51:04 UTC
We haven't had any reports of this being a real world problem in years.

We also have the software renderer fallback in place that wasn't there when this requestwas made.

If the change wasn't deemed worthwhile in the last 4 years, it won't be now.