The Linux Graphics Stack
blog.mecheye.net
blog.mecheye.net
Wayland doesn't have network transparency as a first-class citizen, but it's easy to fit it into the mix. A bit of background:
In X11, the client sends the actual drawing commands (draw a line here, a smooth gradient here, a pixmap here, a curved line here, etc.) over a network pipe. The X server on the other end takes those commands and builds the resulting image.
In Wayland, your program just transfers (well, using shared memory) complete images of the entire window to the Wayland server.
The X11 solution is absolutely excellent and very efficient assuming your programs primarily use the X11 primitives. Most modern programs and toolkits do not use the drawing primitives; they just build the images they want and send a bunch of pixmaps to the X server. They do this primarily because X11 doesn't have a number of useful drawing primitives, like anti-aliased text. The result is that you're doing more or less what Wayland intends to do. (Though sending things like Xclock or Xeyes will be less efficient under Wayland, seeing as they use the X11 drawing primitives.)
In the end, Wayland will probably have something very much like per-window VNC. Your program will produce an image, some stub Wayland server will send that image over the network, and a Wayland compositor on the other end will receive it and display it.
The philosophy is different, I admit, and it needs certain setup, but it is totally worth it.
I work on Linux on a program which is entirely drawn by OpenGL (I target ARM devices, but I test on the desktop before doing an ARM build). Application GL performance suffers immensely under a compositor, so on most machines I can't use GNOME3 (though I would like to). On machines where I get acceptable GL performance in my app, vsync is broken so there is constant tearing.
I'm sure there are some caveats with unredirecting the frontmost window -- like when it becomes occluded it would have to be redirected and that requires a round trip to the client (which might hang, etc), but there are probably other situations like this which the window manager has to deal with already (resize timers?) so maybe there is a way to implement it...
I do realtime graphics with GL for a living, and I'm really sad at the state of the linux desktop, but especially worried at the future. GL performance with any modern distribution is worrysome due to the compositors, and removing it is the first thing that I need to tell any customer lamenting performance issues. Being unable to set vsync on a per-window/context basis is really a major problem, and the performance hit that you get is unacceptable. It seems that removing vsync is all hip these days for games and toys, yet tearing is unacceptable in any other context when you can actually get triple buffering with modern hardware.
Why are we optimizing for toys, when what matters are actual applications and everyday's performance? People don't seem to realize that while the GPU can be used as a general purpose computing unit, the usage pattern is vastly different. The process handling the screen often must have either higher or total control over it many times. You immediately notice video stutter and frames lagging.
But what do I know... I do the same with audio trying to squeeze decent latency with PortAudio and/or alsa directly, while people go through the pulseaudio pipeline...
I suppose you could just restrict the optimization to windows with an RGB visual, though. But then you need to make sure there isn't something else modifying the opacity of the window. I've written a standalone compositor before (that is, a compositor that runs independently of the window manager, as a separate process), so you can't always assume that the compositor "knows best"; for example, the WM may want to make the window decorations semi-transparent. Or maybe the user has specified slight transparency for all their windows. Or something.
Hmm... in the end, though, you could probably come up with a heuristic that works in most cases.
Some questions...
Would this mean that window managers themselves would have to be re-implemented in order to support the Wayland protocol?
Is anyone working to create a non-reference optimized implementation of libwayland?
Have the Wayland developers said anything about supporting multiple monitors yet?
Yes, an a lot more than that will have to be partially or fully rewritten. Thankfully, many if not most desktop apps use a widget toolkit like GTK+ or Qt for UI, so it's enough to make the widget toolkits work on Wayland.
Your window manager of choice can just link into Wayland/Weston and ignore all the underlying graphics driver bits; they'll Just Work.
But rather than hacking Weston to support proprietary drivers, I would advocate using it as a carrot to beat AMD/Nvidia into submission.
And the WMs would link to the wayland server library, so a lot of code would be shared between them.
I don't think properietary drivers need to have their own wayland server. However, they do need to add EGL support, so that wayland can use the driver outside of X, and a few specific GL extensions that wayland needs. See e.g: http://ppaalanen.blogspot.fr/2012/03/what-does-egl-do-in-way...
There is nothing special about multiple monitors in wayland. The KMS/Mesa drivers allows setup and rendering to multiple monitors fine, then its up to the wayland server to decide what to draw on each monitor.
This is the kind of "mechanism without any policy" thinking that I was hoping to escape from. What does Weston actually do in the presence of multiple monitors?
This isn't really true. Even if the kernel does cow pipes (on both ends), the writer is almost certainly going to trash the page and cause a fault. The data is just copied around without being bundled into TCP packets.
There is also a SHM extension which does use shared memory, but that's separate and mostly only used for pixmaps and the like.
Isn't it a bit early to be saying something like that? While I hope that Wayland will succeed, it has an equal chance of ending up as vaporware.
Canonical is investing in making Compiz Wayland-enabled and running Unity on top.
While it does not completely refute your concern of Wayland becoming vaporware, a commitment from Canonical is about as close as anything in the Linux Desktop world ever comes to being a hard milestone. Put another way: it's more reliable than a random user on the Arch forums* talking up grand plans to rebuild WMFS to work with Wayland.
*A purely random example, and not a knock on Arch forums, which are an awesome/informative place.
Furthermore, most Xorg and desktop developers are pro-Wayland if the OP is to be believed.
And X isn't going away since we'll probably be stuck using Xwayland for quite sometime for backward-compatibility (yes they've thought of that).