mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

X11 EGL on the Raspberry Pi

Mon Apr 14, 2014 5:40 pm

I've added a half-completed X11 EGL implementation for RPi at:

https://github.com/kika123/x11eglrpi

Precompiled :

https://github.com/kika123/pi3d-binpackages.git

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: X11 EGL on the Raspberry Pi

Sat Jul 19, 2014 1:58 pm

Wow, only just noticed this and I am thinking this could be something I was looking for.

Have you any further details about using this library?

I notice there is also something called GLshim that should allow some acceleration of standard openGL 1.4 code using the VC4 gpu.

There is no example code for using this library (running pi3d in an X11 window accelerated) and no source code for the GLshim lib???


Has there been any progress in the last few months?

Looks like this could be great work for improving the pi running 3D apps.

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: X11 EGL on the Raspberry Pi

Sun Jul 20, 2014 6:41 pm

Very cunning code :lol:

I have spent a couple of hours looking at it this weekend and my guess is that the dlfn.h library wrapping handlers are not implemented correctly on the raspberry pi gnu c libs.

I know nothing about library wrapping so I have no real idea and it looks like at least 2 weekends work to get to the bottom of it(my guess knowing nothing about the subject).

The code takes quite a few hacks to get it to compile and then running hello_triangle segfaults at the call to real_eglGetDisplay.

I had to actually define RTLD_NEXT as even including <dlfn.h> and defining _USE_GNU did not define it so I guess there are parts of the GNU libs that are not working for the rpi?.

I could look at other ways to wrap the EGL lib but I really have no idea and I think I will not go any further unless someone has some suggestions. It looks like too much time when I have other things I should be doing.

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: X11 EGL on the Raspberry Pi

Sun Jul 20, 2014 10:43 pm

I had dinner and then though maybe I would have one last quick look at the code and sort of worked out the problems with the library wrapping.

Now I see the X11 stuff is not setup correctly, but that should be relatively simple to create an X window.

If the gles code is okay then maybe I could fix it next weekend, but if the gles code does not work then there could be problems as I have no real idea about gles.

Has anyone else looked at this code and has any advice?

aegis
Posts: 9
Joined: Sat Jul 27, 2013 4:21 am

Re: X11 EGL on the Raspberry Pi

Mon Jul 21, 2014 5:26 am

mung wrote:Wow, only just noticed this and I am thinking this could be something I was looking for.

Have you any further details about using this library?

I notice there is also something called GLshim that should allow some acceleration of standard openGL 1.4 code using the VC4 gpu.

There is no example code for using this library (running pi3d in an X11 window accelerated) and no source code for the GLshim lib???


Has there been any progress in the last few months?

Looks like this could be great work for improving the pi running 3D apps.
glshim is my project (primarily developed for the OpenPandora handheld): https://github.com/lunixbochs/glshim
There's not much documentation, because you just use OpenGL as you would on a desktop. It's very actively developed.

To note: setting the LIBGL_FB=1 environment variable allows you to draw directly to the framebuffer, which helps for drivers with no X11 support.

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: X11 EGL on the Raspberry Pi

Mon Jul 21, 2014 12:38 pm

Thanks for the reply aegis, I will hopefully get time and inclination to try out the glshim code next weekend.

I am sort of ashamed and glad that I ruined my sleep last night staying up till past 2am checking the x11egl code and trying to fix bugs.

I feel terrible today, but can now say that the code works almost perfectly in X on the pi (what code there is works though lots of stuff is needed to have decent X integration).

I only tried one test which was the hello_triangle demo from the /opt/vc/src examples, it all displays reasonably well and dragging the window looks reasonably smooth, though things like scaling need to be looked at.

I think mitShm should probably be used instead of XPutimage, but don't know if I will bother.

I know nothing about EGL really so if anyone knows how to handle setting display surface scaling and colordepth and pixel formats that would be very helpful advice.

It currently only works in 32bpp mode on X.

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: X11 EGL on the Raspberry Pi

Mon Jul 21, 2014 6:44 pm

I thought I would just post some relevant links in case I lose them or anyone else is interested.

Seems there are an number of other similar pieces of code floating around.

https://github.com/ssvb/xf86-video-fbturbo/issues/24
http://www.raspberrypi.org/forums/viewt ... =63&t=6488
https://www.youtube.com/watch?v=jqNQ7-6Nk7Q
https://github.com/PaulHaeberli/pi-eglonx
https://www.youtube.com/watch?v=8Fy63w6WxOw
http://wiki.maemo.org/SimpleGL_example


I will tidy up the code I have and release it next weekend if I have time.

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: X11 EGL on the Raspberry Pi

Mon Jul 21, 2014 8:15 pm

Good. Before I stopped development because nobody was reading the post.

User avatar
AndyD
Posts: 2334
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: X11 EGL on the Raspberry Pi

Mon Jul 21, 2014 10:06 pm

I didn't know that Paul Haeberli has been tinkering with the Raspberry Pi. I really love his ideas. GRAFICA Obscura was inspirational.

ssvb
Posts: 112
Joined: Sat May 19, 2012 6:15 pm

Re: X11 EGL on the Raspberry Pi

Tue Jul 22, 2014 11:53 pm

mung wrote:I think mitShm should probably be used instead of XPutimage, but don't know if I will bother.
Neither of these options is good enough (the performance is going to be very poor). A much better solution would be to implement zero copy with the use of DRI2.

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 1:24 am

ssvb wrote:
mung wrote:I think mitShm should probably be used instead of XPutimage, but don't know if I will bother.
Neither of these options is good enough (the performance is going to be very poor). A much better solution would be to implement zero copy with the use of DRI2.
Not that poor. 20fps in a 1024*768 window with XPutImage.

ssvb
Posts: 112
Joined: Sat May 19, 2012 6:15 pm

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 1:32 am

Not that poor. 20fps in a 1024*768 window with XPutImage.
You normally expect 200fps or more for the simple OpenGL ES stuff. Zero copy buffer swaps make a big difference - http://ssvb.github.io/images/2013-02-01 ... ration.png
In addition, some people may prefer perfect 60Hz vsync without tearing, which is also not really possible with XPutImage.

User avatar
PeterO
Posts: 6068
Joined: Sun Jul 22, 2012 4:14 pm

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 7:11 am

I did wonder about the performance......

It is ironic that some of the videos showing this sort of thing working run their demos in "fullscreen" mode, which makes the whole thing pointless as it might as well be run with the native EGL support ! TBH I can't really see that running in an X window is going to be that useful unless it incurs zero performance hit.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 11:02 am

PeterO wrote: TBH I can't really see that running in an X window is going to be that useful unless it incurs zero performance hit.
PeterO
I think that running gles accelerated in an X window is quite important as it in theory allows integration with X widget sets. Most apps are going to require some UI widgets and the only options for gles as far as I am aware are pi3d gui and kivy. These options are not so good at present, but if accelerated gles in a window is available then gui widget options are greatly expanded. Also if this ties in with glshim then running a lot of standard off the shelf openGL apps will be greatly improved?

Obviously running with the minimum performance hit is important, and maybe using the bcm dma system could allow zero hit on the ARM, unfortunatley all things take effort and time and need people with the right expertise. I don't know if there is enough availability to get it done or if there are other more important things that need doing first?

Of course maybe wayland will offer some other options?

User avatar
PeterO
Posts: 6068
Joined: Sun Jul 22, 2012 4:14 pm

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 11:15 am

Probably chicken and egg though.

There is very low interest in actually using openGL ES on the PI, probably as a side effect of the lack of interest in C as it is seen as "too hard".

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 1:48 pm

PeterO wrote:Probably chicken and egg though.

There is very low interest in actually using openGL ES on the PI, probably as a side effect of the lack of interest in C as it is seen as "too hard".

PeterO
No, I currently run Gnome 3 on the Pi. It is useful if you want a neat desktop.

User avatar
PeterO
Posts: 6068
Joined: Sun Jul 22, 2012 4:14 pm

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 2:22 pm

mimi123 wrote:
PeterO wrote:Probably chicken and egg though.

There is very low interest in actually using openGL ES on the PI, probably as a side effect of the lack of interest in C as it is seen as "too hard".

PeterO
No, I currently run Gnome 3 on the Pi. It is useful if you want a neat desktop.
No ? Where are all the openGL ES programmes that have been developed for the PI ?

I don't see why your choice of desktop has got anything to do with the lack of interest in using openGL ES for application development ?

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 2:44 pm

PeterO wrote:
mimi123 wrote:
PeterO wrote:Probably chicken and egg though.

There is very low interest in actually using openGL ES on the PI, probably as a side effect of the lack of interest in C as it is seen as "too hard".

PeterO
No, I currently run Gnome 3 on the Pi. It is useful if you want a neat desktop.
No ? Where are all the openGL ES programmes that have been developed for the PI ?

I don't see why your choice of desktop has got anything to do with the lack of interest in using openGL ES for application development ?

PeterO
ALL modern GUI toolkits supports OpenGL|ES including GTK3 , QT4 and QT5.

User avatar
PeterO
Posts: 6068
Joined: Sun Jul 22, 2012 4:14 pm

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 3:20 pm

But as I keep saying where are all the openGL ES applications for the PI. The fact that your desktop is using openGL ES is irrelevant.
This thread is (was) about providing a way to run openGL ES applications in an X11 window. That is something for application developers to take advantage of, not something to directly help desktop GUI users.
And to be honest the first thing I did with Gnome3 was turn all the pointelss 3D eye candy off as it's just a distraction.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 7:46 pm

PeterO wrote:But as I keep saying where are all the openGL ES applications for the PI.
PeterO
I think gles is quite new, it always takes a few years for the apps to come after the toolkits are released. Most of the stuff is for mobile phones as thats what it was designed for?

But if the gles works in a window and glshim works then lots of standard opengl apps will work far faster under X.

I am not really sure why no one has got gles in an X window working yet, it seems to me that someone that knows gles well could do it in only a few hours.

The library wrapping method used in this code is quite cunning and not something I have seen before as it uses objectdump to split up the original library rename the stubs and then add a wrapper library avoiding the need to use dlfn wrapping.

Using this starting point it 'should' be reasonably simple to have seamless windowing of any standard gles app, it works okay for all the /opt/vc/src examples and pi3d apps that I have tried.

The main things that have me stumped are finding any documentation for brcm gles implementation.

I think if I knew how the pixel formats are defined (typedef structs) and where the pointer to the pixel buffer is defined then I could maybe implement xshm zero copy next weekend (wishful thinking, but possible).

There are quite a few bits of information out there but there are a lot of gaps that make actually getting things working rather experimental.

I also think if there was more example code available people maybe would start hacking more, but everyone has their own interests gles is not really something I am interested in, its just something needed for my other hacking projects.

Also I am thinking the standard X bpp should be supported by gles looking at this https://github.com/shirro/compositing-e ... _surface.c there is an option #define EGL_PIXEL_FORMAT_RGB_565_BRCM 3

Anyone any idea where the pixmap buffer pointer is and what format it is stored in when calling eglCreatePixmapSurface

https://www.khronos.org/registry/egl/ap ... platform.h seems to suggest EGLNativePixmapType is platform dependent and in X should be a normal XPixmap, but is brcm format xpixmap?

Once all the pixel formats, buffers and shm are setup in the init then there is just a xputimage required.

If that is known there is no need for glreadpixels and xputimage, in swapbuffers, the only call would be to Xshmputimage.

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 7:56 pm

mung wrote:
PeterO wrote:But as I keep saying where are all the openGL ES applications for the PI.
PeterO
I think gles is quite new, it always takes a few years for the apps to come after the toolkits are released. Most of the stuff is for mobile phones as thats what it was designed for?

But if the gles works in a window and glshim works then lots of standard opengl apps will work far faster under X.

I am not really sure why no one has got gles in an X window working yet, it seems to me that someone that knows gles well could do it in only a few hours.

The library wrapping method used in this code is quite cunning and not something I have seen before as it uses objectdump to split up the original library rename the stubs and then add a wrapper library avoiding the need to use dlfn wrapping.

Using this starting point it 'should' be reasonably simple to have seamless windowing of any standard gles app, it works okay for all the /opt/vc/src examples and pi3d apps that I have tried.

The main things that have me stumped are finding any documentation for brcm gles implementation.

I think if I knew how the pixel formats are defined (typedef structs) and where the pointer to the pixel buffer is defined then I could maybe implement xshm zero copy next weekend (wishful thinking, but possible).

There are quite a few bits of information out there but there are a lot of gaps that make actually getting things working rather experimental.

I also think if there was more example code available people maybe would start hacking more, but everyone has their own interests gles is not really something I am interested in, its just something needed for my other hacking projects.

Also I am thinking the standard X bpp should be supported by gles looking at this https://github.com/shirro/compositing-e ... _surface.c there is an option #define EGL_PIXEL_FORMAT_RGB_565_BRCM 3

Anyone any idea where the pixmap buffer pointer is and what format it is stored in when calling eglCreatePixmapSurface

https://www.khronos.org/registry/egl/ap ... platform.h seems to suggest EGLNativePixmapType is platform dependent and in X should be a normal XPixmap, but is brcm format xpixmap?

Once all the pixel formats, buffers and shm are setup in the init then there is just a xputimage required.

If that is known there is no need for glreadpixels and xputimage, in swapbuffers, the only call would be to Xshmputimage.
Can you publish or send me the code? (PM is fine)

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 8:00 pm

ssvb wrote:
Not that poor. 20fps in a 1024*768 window with XPutImage.
You normally expect 200fps or more for the simple OpenGL ES stuff. Zero copy buffer swaps make a big difference - http://ssvb.github.io/images/2013-02-01 ... ration.png
In addition, some people may prefer perfect 60Hz vsync without tearing, which is also not really possible with XPutImage.
Is the a beaglebone or has someone created a mali expansion board? all the things I have read suggest that the vc4 gpu is far better than the mali 400, why such high frame rates and the pi still has no support?

Why has the foundation not done anything about improving X support?

mung
Posts: 506
Joined: Fri Nov 18, 2011 10:49 am

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 8:05 pm

mimi123 wrote: Can you publish or send me the code? (PM is fine)
I will post something on this thread, but I have to get to the pi and transfer things off the SD card and also tidy up the code.

Maybe do it tommorrow evening but I was hoping to have further hack at the weekend then possible I could get the xshm implemented?

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 8:24 pm

mung wrote:
ssvb wrote:
Not that poor. 20fps in a 1024*768 window with XPutImage.
You normally expect 200fps or more for the simple OpenGL ES stuff. Zero copy buffer swaps make a big difference - http://ssvb.github.io/images/2013-02-01 ... ration.png
In addition, some people may prefer perfect 60Hz vsync without tearing, which is also not really possible with XPutImage.
Is the a beaglebone or has someone created a mali expansion board? all the things I have read suggest that the vc4 gpu is far better than the mali 400, why such high frame rates and the pi still has no support?

Why has the foundation not done anything about improving X support?
It is better but not X11 support.
See that for 300fps framerates on Pi: https://github.com/nfz/RPIGears

User avatar
AndyD
Posts: 2334
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: X11 EGL on the Raspberry Pi

Wed Jul 23, 2014 10:26 pm

mung wrote:Why has the foundation not done anything about improving X support?
I think because they are concentrating on Weston/Wayland.

Return to “General discussion”