[Tutorial] - Activate OpenGL driver

WARNING : this tutorial is only for advanced users who want to play with the new opengl driver
THE DRIVER IS NOT STABLE AND FREEZE SOMETIMES !
YOU CAN LOOSE YOUR DATA SO MAKE SOME BACKUP BEFORE TESTING !
The new opengl driver was out yesterday for raspbian, this is a tutorial to activate it in unbuntu mate, lubuntu and xubuntu for raspberry pi 2.

Upgrade kernel version, open a terminal then :

sudo rpi-update

Edit file /boot/config.txt :

sudo pluma /boot/config.txt

Add the line :

dtoverlay=vc4-kms-v3d

Add the line or modify gpu_mem to 128:

gpu_mem=128

Save & quit.

Then we need to erase the xorg.conf, but it is better to rename it, if we want to go back :

sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.bak

Now we need to update mesa :

IMPORTANT : if you want to revert mesa in the futur you need to backup mesa libs

mkdir mesabackup
cd mesabackup
apt-get download libdrm-freedreno1 libgl1-mesa-dri libegl1-mesa libglapi-mesa libgl1-mesa-glx libgles1-mesa 1libgles2-mesa libglu1-mesa libwayland-egl1-mesa mesa-utils libgbm1
cd ..

END OF BACKUP
Then, install new mesa version

mkdir mesa
cd mesa
wget https://launchpad.net/ubuntu/+source/mesa/11.1.1-1ubuntu2/+build/8881184/+files/libegl1-mesa_11.1.1-1ubuntu2_armhf.deb https://launchpad.net/ubuntu/+source/mesa/11.1.1-1ubuntu2/+build/8881184/+files/libgl1-mesa-dri_11.1.1-1ubuntu2_armhf.deb https://launchpad.net/ubuntu/+source/mesa/11.1.1-1ubuntu2/+build/8881184/+files/libgl1-mesa-glx_11.1.1-1ubuntu2_armhf.deb https://launchpad.net/ubuntu/+source/mesa/11.1.1-1ubuntu2/+build/8881184/+files/libglapi-mesa_11.1.1-1ubuntu2_armhf.deb https://launchpad.net/ubuntu/+source/mesa/11.1.1-1ubuntu2/+build/8881184/+files/libgles1-mesa_11.1.1-1ubuntu2_armhf.deb https://launchpad.net/ubuntu/+source/mesa/11.1.1-1ubuntu2/+build/8881184/+files/libgles2-mesa_11.1.1-1ubuntu2_armhf.deb http://launchpadlibrarian.net/234263009/libdrm-freedreno1_2.4.66-2_armhf.deb http://launchpadlibrarian.net/222366701/libglu1-mesa_9.0.0-2.1_armhf.deb http://launchpadlibrarian.net/222366701/libglu1-mesa_9.0.0-2.1_armhf.deb http://launchpadlibrarian.net/234861434/libwayland-egl1-mesa_11.1.1-1ubuntu2_armhf.deb http://launchpadlibrarian.net/229716045/mesa-utils_8.3.0-1_armhf.deb http://launchpadlibrarian.net/234861425/libgbm1_11.1.1-1ubuntu2_armhf.deb

sudo dpkg -i libdrm-freedreno1_2.4.66-2_armhf.deb
sudo dpkg -i libgl1-mesa-dri_11.1.1-1ubuntu2_armhf.deb
sudo dpkg -i libegl1-mesa_11.1.1-1ubuntu2_armhf.deb
sudo dpkg -i libglapi-mesa_11.1.1-1ubuntu2_armhf.deb
sudo dpkg -i libgl1-mesa-glx_11.1.1-1ubuntu2_armhf.deb
sudo dpkg -i libgles1-mesa_11.1.1-1ubuntu2_armhf.deb
sudo dpkg -i libgles2-mesa_11.1.1-1ubuntu2_armhf.deb
sudo dpkg -i libglu1-mesa_9.0.0-2.1_armhf.deb
sudo dpkg -i libwayland-egl1-mesa_11.1.1-1ubuntu2_armhf.deb
sudo dpkg -i mesa-utils_8.3.0-1_armhf.deb
sudo dpkg -i libgbm1_11.1.1-1ubuntu2_armhf.deb

Reboot, it's done !

The hardware acceleration works but it is slower than raspbian.

Acceleration works in Chromium too and vlc works with glx video output too !

If I try glxgears ~240 fps and it is ~460 fps in raspbian.

So there is some things I forget maybe we need to update more mesa packages or Xorg ?
Anyone have some ideas about what is missing ?

How to disable the driver :

Edit file /boot/config.txt :

sudo pluma /boot/config.txt

Comment the line with a # at the begining :

#dtoverlay=vc4-kms-v3d

Reverse xorg.conf :

sudo mv /etc/X11/xorg.conf.bak /etc/X11/xorg.conf

Revert mesa librairies :
Go to your mesabackup directory

cd mesabackup
sudo apt-get clean
sudo dpkg -i libdrm-freedreno1_2.4.64-1_armhf.deb
sudo dpkg -i libgl1-mesa-dri_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i libegl1-mesa_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i libglapi-mesa_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i libgl1-mesa-glx_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i libgles1-mesa_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i libgles2-mesa_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i libglu1-mesa_9.0.0-2_armhf.deb
sudo dpkg -i libwayland-egl1-mesa_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i mesa-utils_8.2.0-1ubuntu1_armhf.deb
sudo dpkg -i libgbm1_11.0.2-1ubuntu4_armhf.deb
sudo apt-get update
sudo apt-get upgrade

Enjoy :slight_smile:

EDIT : Added more packages dependancies
EDIT2 : Remove some useless steps.
EDIT3 : Added clean mesa revert
EDIT4 : Added setting of gpu_mem

Aworan

4 Likes

Could the hardware acceleration be slower due to the presumably more complicated x server? and not because of non-updated libraries? (or both)

EDIT: This could be a reason. So I held the packages that you upgraded manually, and now when trying to upgrade the system these packages have unmet dependencies.
libgbm1 : Depends: libgl1-mesa-dri (= 11.0.2-1ubuntu4) but 11.1.1-1ubuntu2 is installed libwayland-egl1-mesa : Depends: libegl1-mesa (= 11.0.2-1ubuntu4)

Yes I install for a new fresh install I had the same problem but I fixed it.
I will update the tutorial :

you need extra packages :

wget http://launchpadlibrarian.net/222366701/libglu1-mesa_9.0.0-2.1_armhf.deb http://launchpadlibrarian.net/234861434/libwayland-egl1-mesa_11.1.1-1ubuntu2_armhf.deb http://launchpadlibrarian.net/229716045/mesa-utils_8.3.0-1_armhf.deb

Then :

sudo dpkg -i libglu1-mesa_9.0.0-2.1_armhf.deb
sudo dpkg -i libwayland-egl1-mesa_11.1.1-1ubuntu2_armhf.deb
sudo dpkg -i mesa-utils_8.3.0-1_armhf.deb

Thanks a lot!
Chromium is smoother now! If only we had video decoding as well.
I'll take a look at your vlc tutorial later.

I have one last issue, I still have an outdated libgbm1 and I can't find one compatible with mesa 11.1.1
I'm asking because my display isn't being rendered fully. I have this section of my screen black.
I'll post a picture soon.

Do you have this issue as well?

EDIT:
Found this one Debian -- Package Download Selection -- libgbm1_24.1.3-2_armhf.deb

EDIT2:
I still have the black display issues, any idea what's causing it?
Imgur
Left side of the screen.

Yes maybe there is a way recompling chromium-codecs-* packages.
I didn't have time to take a look ont it.
I think it can be easier with firefox, I explain in the lasts builds of firefox if ffmpeg (then libavcodec) is installed firefox use it by default.
So I write a tutorial how to compile ffmpeg/libavcodec with video hardware acceleration but it don't work because it is no possible to choose an hardware acceleration or a specific video codec.
My idea is changing source code of ffmpeg to switch h264 codec code by h264_mmal codec which have hardware video decoding.
I need some time to do it, if you wanna try and know C languages the files are in libavcodec directory h264.c and mmaldec.c.
I will try soon but it needs some time :stuck_out_tongue:
Maybe same trick is possible in chromium rebuilding the packages of chromium-codecs or/and chromium-codecs-extra because I know it is based on ffmpeg too.

Yes, I write some tutorials about it, if you want but hardware decoding only works on fullscreen for now. try the OpenMax-Il version it is stable, MMAL version is buggy (I think we must want a new version for mmal stuff, I think vlc team based his work on old version of firmware).
Could you try some hd video in OPENMAX-IL version with GLX output ?
GLX output works with the opengl driver (I tested it with no hd video) but I don't know if vlc uses openmax decoder in that video output.
Another solution for video decoding in windoded / fullscreen mode with hadware video decoding for playing hd video is mpv.
I will try to write some tutorial about it soon too ! And it work with great GUI like SMplayer or bomi !

I don't know, I try the new driver only on lubuntu (https://ubuntu-pi-flavour-maker.org/) because I have a old sdcard of 4GB for tests and mate need more space for playing with it.
I will try mate this weekend.
I have a bug too in raspbian or lubuntu, I have a old 4/3 screen (1280x1024) and there is space not used too but in the bottom !

I can't put my mouse pointer in it.
I will try with mate this weekend I will tell you, I will try with my hd tv too because I only have an old school monitor with DVI input :wink:

The input of your screen is HDMI ? or DVI ?

I think both but I am not sure, I think the best is to have an alpha version of next ubuntu (xenial) to make better tests because it have the good version of mesa out the box, so we don't need to make dirty updates of the mesa packages !
The build are made with https://ubuntu-pi-flavour-maker.org/ so maybe it's possible to build the alpha version of xenial or ask the team to provide it.

Thank you! If I get some time I will look at it.

Definitely! Once the driver has stabilized a bit I'm going to be trying all sorts of stuff with video decoding on the pi.

Very strange! I was able to put my mouse pointer, and certain things would be drawn, like the lower menu bar.
I have an HDMI screen! So I wonder if you will see the same issue with an HDMI screen.

Interestingly, I was able to play a couple opengl games and they ran beautifully! It froze once and I had to hard reset the Pi, but it was glorious.

One last thing, I disabled the driver by doing your instructions (the screen issue was gone) however, when I try to apt-get upgrade the libraries did not go back to their old versions. Did ubuntu mate update their repos?
I also don't have any of them held.

Cheers! Very exciting stuff for the pi. I'm personally using it as a chromebook style laptop (with the mototora atrix lapdock) and all I am missing is a slightly smoother browsing experience and a way to play videos without going full screen so that I can do work at the same time! Either youtube or vlc.
It's so close!

No, I am stupid sometimes, mesa libs are newer than in repo so there is no need to hold them, they will never get upgraded.
I correct the tutorial about that, but I don't know how to revert them.
I think the best is before doing the tutorial save mesa libs :

mkdir mesabackup
cd mesabackup
sudo apt-get download libdrm-freedreno1 libgl1-mesa-dri libegl1-mesa libglapi-mesa libgl1-mesa-glx libgles1-mesa 1libgles2-mesa libglu1-mesa libwayland-egl1-mesa mesa-utils libgbm1

then when you go to go back make some dpkg -i of the packages.

I will test I update tutorial if it works !

Ok you can revert mesa with :

mkdir mesarevert
cd mesarevert
sudo apt-get clean
sudo apt-get update
apt-get download libdrm-freedreno1=2.4.64-1 libgl1-mesa-dri=11.0.2-1ubuntu4 libegl1-mesa=11.0.2-1ubuntu4 libglapi-mesa=11.0.2-1ubuntu4 libgl1-mesa-glx=11.0.2-1ubuntu4 libgles1-mesa=11.0.2-1ubuntu4 libgles2-mesa=11.0.2-1ubuntu4 libglu1-mesa=9.0.0-2 libwayland-egl1-mesa=11.0.2-1ubuntu4 mesa-utils libgbm1=11.0.2-1ubuntu4
sudo dpkg -i libdrm-freedreno1_2.4.64-1_armhf.deb
sudo dpkg -i libgl1-mesa-dri_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i libegl1-mesa_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i libglapi-mesa_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i libgl1-mesa-glx_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i libgles1-mesa_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i libgles2-mesa_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i libglu1-mesa_9.0.0-2_armhf.deb
sudo dpkg -i libwayland-egl1-mesa_11.0.2-1ubuntu4_armhf.deb
sudo dpkg -i mesa-utils_8.2.0-1ubuntu1_armhf.deb
sudo dpkg -i libgbm1_11.0.2-1ubuntu4_armhf.deb

I update the totorial right now :wink:

How much is you gpu_mem in /boot/config.txt ?
If it is not set you only have 64Mo by default try adding /boot/config.txt :
gpu_mem=256
if it fix the problem you can try lowering value to 128

Awesome!! It is fixed! Strange though, if I give the GPU 256MB of memory the pi won't boot. I had to lower it to 128, and then it works and the black screen issue is resolved.
Though as you mentioned the driver does crash a bit, however I like being able to more graphic intensive games now!
By the way, are we sure the X server is using the driver? For some reason the menus are not as responsive and there's delays when drawing the screen even for simple programs like terminal.

Ok I know for now driver is only for raspberry pi 2 because it use a lot of memory so maybe if we give 256Go to GPU there is not enouth ram free for the driver working :slight_smile:

Maybe I don't really know but I'm sure it need something more to work great.
I will try to update Xserver but I think there is a lot of package dependancies ....

Let me start by saying that this is really great stuff. Great work OP and the rest of you guys for the tutorial on getting the driver to work on Mate. That said, I am having some serious problems with the OpenGL driver - which is obviously to be expected. For one, it pretty much breaks the desktop - everything (including windows, drop down menues, docky, etc) just runs much slower than with software rendering. Secondly, the driver crashed very frequently (again, this is to be expected I know). I also have encountered missing icons and appletes when using the driver. Now, what I really would like to know is - has anyone encountered (and perhaps sorted out?) the problems with desktop slowdowns using the driver, or am I the only one. Again, thanks for the great tutorial. cheers !

Hi,
Yes activating the driver is unstable. I don’t find a way to fix it. I think it will be works better with next release of Ubuntu mate (16.04) because we don’t have to update mesa libs anymore. So I think it would work like in raspbian !
So there is only one month to wait :wink:

Cheers,

Aworan

Hi,

Thanks for responding. So, you think that a functioning version of the driver can find its way into Ubuntu Mate 16.04? That would be great !

Take care!

What is the status of the OpenGL driver in Mate 16.04 for the pi3? Does its activation procedure differ than the procedure listed above?

Hi,
You don’t have to update mesa librairies because they are already in the good version with 16.04.
I didn’t try yet with pi 3, I read somewhere it don’t work with 4.1.x kernel.
I will try next week, I will post here if I found how to do it.

Aworan

Thank you. I’m looking forward to your results.

BobMarso

See my other posting where I describe trying to get OpenGL installed and working with 16.04 on a pi3

Hi,
I manage to activite the driver on Ubuntu 16.04 on rpi2 and rpi3 :slight_smile:
I works very great glxgears is faster than raspbian !
I will post a very easy tutorial soon :slight_smile:
See my teasing here : https://ubuntu-mate.community/t/teasing-aworans-next-tutorial-activate-opengl-driver-for-ubuntu-mate-16-04-for-rpi2-and-rpi3/7076

Stay tune !

Aworan

In 16.04 on a Pi 3 I have no xorg.conf in /etc/X11, just a xorg.conf.d in usr/share/X11.
Can I just skip the renaming step or should I do somrthing different?

Cheers :sunglasses:,
Caleb