User avatar
teh_orph
Posts: 346
Joined: Mon Jan 30, 2012 2:09 pm
Location: London
Contact: Website

Re: Simon's accelerated X development thread

Mon Sep 10, 2012 8:53 am

Yet another update on this project.
I was blocked from working on this for a few more weeks as my trusty Hyundai Q17S monitor decided to die after eight years of service. For a long time, the most expensive thing I've ever bought! As this was my Pi monitor I couldn't get much work done without it. However popping down to my IT dept got me two 12 year-old 18" TFTs for £5! They do have weird pink splotches on them though...

Work still does continue on my driver: I've put a lot of hours in over the last week and especially this weekend and the final pieces are starting to drop into place.
After spending quite some time analysing the workload that comes towards X from client programs I can now better tailor the code to the sort of inputs we're expecting to see. My apologies to all the people I sent huge Dot graphs to :)
This has culminated in a fancy piece of template meta-programming to generate ~270 specialised versions of the same code (permuted based on pixel format, wrapping, clamping, operator etc). We often had doubt about the fit-for-rpi-ness of some of the pixman ARM optimisations so here I'm taking it back to basics. I can test the performance of these functions in bulk and then assemblerify the most used functions where necessary.

https://github.com/simonjhall/fbdev_exa ... te_ops.inl
https://github.com/simonjhall/fbdev_exa ... iation.cpp

Although it's really annoying to compile this file...it takes ~5 seconds for a 1.6 GHz Atom to compile it with -O3 (targetting x86-64) but > 5 minutes on the Rpi! Seriously.

User avatar
xranby
Posts: 539
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: Simon's accelerated X development thread

Mon Sep 10, 2012 9:43 am

Jasper St. Pierre posted an updated introduction "The Linux Graphics Stack"
http://blog.mecheye.net/2012/06/the-lin ... ics-stack/

Its a good introduction to all the acronyms used by today’s accelerated X11 Linux graphics stacks.
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

User avatar
teh_orph
Posts: 346
Joined: Mon Jan 30, 2012 2:09 pm
Location: London
Contact: Website

Re: Simon's accelerated X development thread

Mon Sep 10, 2012 10:11 am

xranby wrote:Jasper St. Pierre posted an updated introduction "The Linux Graphics Stack"
http://blog.mecheye.net/2012/06/the-linux-graphics-stack/

Its a good introduction to all the acronyms used by today’s accelerated X11 Linux graphics stacks.
Wowza. I wished I'd been able to read that six months ago!
If you're interested in the bit I've been doing I've been doing the "2D rendering with Cairo" acceleration bit.

pasnox
Posts: 9
Joined: Sat Aug 25, 2012 1:18 pm

Re: Simon's accelerated X development thread

Mon Sep 10, 2012 10:36 pm

Hi,

I just discussed with a guy from the DirectFB project.
OpenGL ES 2 accelerated driver is nearly ready for the pi and something should be available very shortly.
You may ask what's the link with this thread ? and I will answer XDirectFB!
According to their homepage, XDirectFB is a rootless X Server rendered by DirectFB itself.
Meaning you got an X accelerated by the OpenGL ES 2 driver for free!
Of course, not all operations are yet accelerated, but it's a thing quite easy to do compared to the work needed for a true x11 / xorg graphics driver.
Gnome has been ran successfuly on that X as well as quake 3 giving the idea that the project is good and powerfull enought to ask a question:

Could XDirectFB be the hardware accelerated X Server for the Pi ??

Of course a native x11 driver will be nice to have, but i'm not sure having something working quickly is to be expected.
This thing could be a really good alternative in the wait of that driver.

Please gimme your feedback about this idea.
Sorry for my english, but i'm not a native english speaker.

CharlieSpalton
Posts: 1
Joined: Mon Sep 10, 2012 10:28 pm

Re: Simon's accelerated X development thread

Mon Sep 10, 2012 10:36 pm

Hi. At the risk of posting out of date or useless info, I thought I'd introduce this hint I found: I don't have access to the paper itself, but the abstract looks interesting, even if it dates from 2009. It refers to writing a GPU based X-server on EGL and OpenVG, both of which are supported by the Pi. If nothing else it suggests that any problems can be overcome:
http://ieeexplore.ieee.org/xpl/login.js ... er=5012187

Apologies if I'm reposting info that's already been brought up.

Regards,
Charlie

factoid
Posts: 45
Joined: Tue Jul 17, 2012 5:35 am

Re: Simon's accelerated X development thread

Tue Sep 11, 2012 1:58 am

X is X, so if it's compliant, then anyone who wants to substitute it out can, and creating a debian package will make it easy to do so on raspbian. What they've accomplished is what I'm trying to do in an xf86 server, but I'm definitely out of my depth (won't stop me from trying). But I'll definitely want to look at the project to see if it can help me better understand what's involved in my stuff, or see if I can use it to accelerate the xfree driver process.

Could really use some input from people with the time and/or knowledge to contribute, between my professional and family lives, I'm still only slowing meandering towards "make X not crash".

Thanks for the heads up on that, I'd heard of DirectFB, but it didn't sound like it would be really related to my work, but an actual X implementation is something else.
pasnox wrote:Hi,

I just discussed with a guy from the DirectFB project.
OpenGL ES 2 accelerated driver is nearly ready for the pi and something should be available very shortly.
You may ask what's the link with this thread ? and I will answer XDirectFB!
According to their homepage, XDirectFB is a rootless X Server rendered by DirectFB itself.
Meaning you got an X accelerated by the OpenGL ES 2 driver for free!
Of course, not all operations are yet accelerated, but it's a thing quite easy to do compared to the work needed for a true x11 / xorg graphics driver.
Gnome has been ran successfuly on that X as well as quake 3 giving the idea that the project is good and powerfull enought to ask a question:

Could XDirectFB be the hardware accelerated X Server for the Pi ??

Of course a native x11 driver will be nice to have, but i'm not sure having something working quickly is to be expected.
This thing could be a really good alternative in the wait of that driver.

Please gimme your feedback about this idea.
Sorry for my english, but i'm not a native english speaker.

User avatar
teh_orph
Posts: 346
Joined: Mon Jan 30, 2012 2:09 pm
Location: London
Contact: Website

Re: Simon's accelerated X development thread

Tue Sep 11, 2012 9:06 am

Yeah I have a feeling that DirectFB and XDirectFB are something a little bit different from X. It's unclear what they're doing regarding X integration but from the stuff on their page each window gets it's own DirectFB window - this should allow smooth dragging and so on.

However there's no mention of what actually does the rendering within these windows. This is typically done by the X server. Since all they mention is translucent windows I have a feeling the actual X rendering is not handled by their project and will therefore not be accelerated. So scrolling etc will still be slow.

Also I'm having trouble actually finding the XDirectFB code...is it still maintained?

pasnox
Posts: 9
Joined: Sat Aug 25, 2012 1:18 pm

Re: Simon's accelerated X development thread

Tue Sep 11, 2012 9:14 am

Hi,

I found http://directfb.org/index.php?path=Deve ... GIT+Access and http://git.directfb.org/.

According to the developer, last update for XDirectFB was january 2011. There was a small blank on it, but the dev is still active/continue.

I think the better way will be to comes on #directfb channel on freenode (IRC), this way you could directly ask questions to the developer itself.

Regards,

User avatar
teh_orph
Posts: 346
Joined: Mon Jan 30, 2012 2:09 pm
Location: London
Contact: Website

Re: Simon's accelerated X development thread

Tue Sep 11, 2012 11:16 am

Cheers.
Having looked at the code now I can see they're accelerating the blitting of windows and composition (ie blending) of large things but it seems the rest of the system uses the generic libfb to do drawing and composition.

Either way useful to see the code...I now know how to overload a few more functions!

factoid
Posts: 45
Joined: Tue Jul 17, 2012 5:35 am

Re: Simon's accelerated X development thread

Tue Sep 11, 2012 6:06 pm

I've been trying to build the code, hit a few snags on the actual X side of it, but I believe it was because I clobbered something in the autoconf. Looks like they have a drop-in solution that adds to the /hw/ folder, and their patch file is just some modifications to the autotools files so that it builds properly. I'm going to see if I can get their stuff to run against 1.12.3 that's currently used by Raspbian. Failing that I'll see if I can get their most recent patch file to work against 1.11.3

Anyone else who's wanting to attempt the same thing, you'll need libjpeg-dev from apt-get, and you'll have to clone the following repos from them.

git://git.directfb.org/git/directfb/core/DirectFB.git
git://git.directfb.org/git/directfb/programs/XDirectFB.git
git://git.directfb.org/git/directfb/core/flux

iirc you build flux first, then DirectFB, then use the contents of the XDirectFB to patch the xserver from freedesktop.

pasnox
Posts: 9
Joined: Sat Aug 25, 2012 1:18 pm

Re: Simon's accelerated X development thread

Tue Sep 11, 2012 6:11 pm

Thanks for the informations.
For my part i will try that once the opengl es2 driver for direct fb will be out, which is question of days now.

ncorrare
Posts: 3
Joined: Thu Nov 17, 2011 1:51 pm

Re: Simon's accelerated X development thread

Wed Sep 12, 2012 9:41 am

I thought opengl es 2 was already available on the pi...

pasnox
Posts: 9
Joined: Sat Aug 25, 2012 1:18 pm

Re: Simon's accelerated X development thread

Wed Sep 12, 2012 10:02 am

It is.
But it's support in DirectFB library is not yet working.

factoid
Posts: 45
Joined: Tue Jul 17, 2012 5:35 am

Re: Simon's accelerated X development thread

Wed Sep 12, 2012 5:59 pm

I've been able to build a XDirectFB server but I haven't moved my pi out of headless mode so I can't actually evaluate the end result just yet. Here are a few of the gotchas/tips from my own experience.

There are a number of XDirectFB dependencies:
You'll need flux, DirectFB, and XDirectFB from the directfb.org git repo.
Flux I believe requires libjpeg.
make sure you're running 'sudo make install' as you finish the libraries

The XDirectFB code runs in X 1.12.3
copy XDirectFB/programs/XServer/hw/directfb/ to xserver/hw/
copy XDirectFB/xorg-server-1.11.3-directfb.diff to xserver
then in the xserver directory
run patch -p1 < xorg-server-1.11.3-directfb.diff
run autoreconf
run ./configure --disable-xorg --disable-dmx --disable-xvfb --disable-dri --disable-dri2 --disable-glx
run make
run sudo make install

And before you run XDirectFB, you'll need to run ldconfig to update your .so references (you do have /usr/local/lib added to your ldconfig paths right?)
EDIT: Also, XDirectFB seems to run over an ipv6 socket, so you'll want to 'sudo modprobe ipv6' to enable ipv6 support on Rapsbian, if you haven't configured it to do so by default already.

But basically if you can get the stock xserver 1.12.3 source to compile on your system, you can get XDirectFB working without too much trouble.

Hopefully the enhanced ELGS 2 support will make this 'just work' for my needs.

I can try to be clearer if this isn't detailed enough for people, but most of this is stuff I've learned from just general "build from source" stuff, and the instructions contained in the various directfb project README / google searches.
Last edited by factoid on Wed Sep 12, 2012 6:23 pm, edited 1 time in total.

pasnox
Posts: 9
Joined: Sat Aug 25, 2012 1:18 pm

Re: Simon's accelerated X development thread

Wed Sep 12, 2012 6:22 pm

Thanks you for your feedback, i will prepare my build scripts for native/cross build and create a dedicated github repository so people can grab them and build quickly and easily the stuff.

jbohac
Posts: 1
Joined: Thu Sep 13, 2012 11:01 am

anyone thought of using xglx?

Thu Sep 13, 2012 11:11 am

Has anyone thought of trying to resurrect the xglx X server and using it to get accelerated X on the RPi?
Isn't xglx exactly what we need? An X server running on top of the existing OpenGL-capable server that uses OpenGL to draw accelerated 2D and 3D...

I see two possible roadblocks:
- what would need to be done to make xglx work on OpenGL-ES instead of OpenGL?
- the code has been removed from Xorg for quite some time, I don't know how much it would take to make it work again.
Thoughts?

factoid
Posts: 45
Joined: Tue Jul 17, 2012 5:35 am

Re: Simon's accelerated X development thread

Thu Sep 13, 2012 5:37 pm

It seems there were several approaches to getting a native GL pipeline working in X. What you're proposing is similar to what I'm trying to achieve by way of the glamor library. Currently I'm trying to take the stock default xf86-video-fbdev, and integrate glamor support. The sticking point that I think I just got was the connection between EGL and OGL ES. glamor depends heavily upon EGL in their demo intel driver, which in turn ties to the intel DRM code.

The rpi doesn't seem to have DRM, but it does expose EGL through it's videocore library, which is I think how I go about creating the screens, buffers, and other native level objects I need to pass to the OGL ES 2.0 layer for rendering.

I'm really hoping this will gel into something that makes sense over the next week or two, and if the EGL implementation is a standard (which it seems like it is by definition), maybe this modified driver will 'just work' for anything that supports OGL ES2 and EGL, taking a lot of the frustration out of the X driver stack and letting SoC designers keep their secret sauce.


PS: XDirectFB bombed on my machine once there was an HDMI hookup, I opted not to dig further and refocus my efforts on glamor. Hopefully someone else can push that avenue along, or I'll look at it again once the EGL 2.0 support for DirectFB is released.

User avatar
teh_orph
Posts: 346
Joined: Mon Jan 30, 2012 2:09 pm
Location: London
Contact: Website

Re: Simon's accelerated X development thread

Mon Sep 24, 2012 10:57 pm

My beast template-based pixel compositor is taking shape...
A snippet from 'top'...74 MB!

Code: Select all

PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND
3732 root      20   0 79796  74m   64 D  28.0 34.4   0:43.39 as
Running just the assembler on the code is taking nearly a minute now!
I'm just trying to improve the code gen by massaging the C++ input. In terms of instruction count, the average function is at roughly 30% longer than the hand-written stuff used in pixman...except I've got 300 functions like this, not just the fast versions for the more frequently used cases!

factoid
Posts: 45
Joined: Tue Jul 17, 2012 5:35 am

Re: Simon's accelerated X development thread

Mon Oct 01, 2012 7:07 pm

Recent commits to my github https://github.com/Factoid/xf86-video-rpi. I'm slowing getting my head around the problem and it's just a matter of slogging through it.

First milestone is to make a "does nothing" driver that doesn't crash. Right now I'm in the process of setting up function hooks and allocating dummy structures where required. It's been educational, and the more work I do, the more I think I'm on the right path.

Currently this doesn't depend on anything other than the EGL, GLESV2, and BCM_HOST libraries, and makes use of the autotools build system now. If anyone is actually interested in following along I can put together some instructions on how to get the xserver setup for debugging and I'll need to upload the pkg-config .pc files to satisfy the above dependencies (or you can write your own)

It looks like the overall plan will be to implement OGL or OVG versions of all the GraphicsContext functions, with EGL providing access to the creation of textures and other native memory structures. Since this is so low level, I'm hoping that when it eventually works, it'll work well right up the stack. Ironcally I don't think this driver will support GLX immediately, but since it's using GL concepts for it's 2D rendering, adding support for that extension shouldn't be *too* hard.

Anyone with X or GL experience is going to be a huge help to me in the coming months, so please fork the repo if you think you can help.

Cheers,
Adrian

benjsc
Posts: 3
Joined: Wed Oct 03, 2012 4:36 am

Re: Simon's accelerated X development thread

Wed Oct 03, 2012 5:23 am

So is this the current state of the xorg accel driver? If so is your aim to use glamor and write a minimal rpi xorg driver which converts glamor calls to egs?

User avatar
teh_orph
Posts: 346
Joined: Mon Jan 30, 2012 2:09 pm
Location: London
Contact: Website

Re: Simon's accelerated X development thread

Wed Oct 03, 2012 11:54 am

I'm just finalising v1 of my driver on Raspbian now...
https://github.com/simonjhall/fbdev_exa/commits/master

Adrian, I'm thinking about chucking out the EXA layer and replacing it with something simpler that I've written myself. This sounds exactly like the "function hooks and allocating dummy structures" bit you mention. Is it really painful??

Hexxeh
Posts: 91
Joined: Thu Apr 05, 2012 3:07 pm
Contact: Website

Re: Simon's accelerated X development thread

Wed Oct 03, 2012 12:01 pm

teh_orph wrote:I'm just finalising v1 of my driver on Raspbian now...
https://github.com/simonjhall/fbdev_exa/commits/master

Adrian, I'm thinking about chucking out the EXA layer and replacing it with something simpler that I've written myself. This sounds exactly like the "function hooks and allocating dummy structures" bit you mention. Is it really painful??
How much work would it be to allow EGL contexts in an X window with this?

User avatar
teh_orph
Posts: 346
Joined: Mon Jan 30, 2012 2:09 pm
Location: London
Contact: Website

Re: Simon's accelerated X development thread

Wed Oct 03, 2012 12:20 pm

Who, me or him? :)
I think we need more than one thread here!


User avatar
teh_orph
Posts: 346
Joined: Mon Jan 30, 2012 2:09 pm
Location: London
Contact: Website

Re: Simon's accelerated X development thread

Wed Oct 03, 2012 12:28 pm

What model of operation were you thinking of, exactly?
What would you expect the X server to do for you and what would you expect to do yourself?

Return to “General discussion”