The Linux graphics stack in a nutshell
lwn.net
lwn.net
Incidentally, one thing I noticed when I was trying to port Linux GPU drivers to Windows some time ago is what appeared to be an excessive amount of indirection; there are so many layers and places where things could be simpler.
(No, OpenVG is not viable. No, Xrender is not viable. cairo and Skia both use the 3D hardware in combination with a CPU render engine.)
The scanout-time hardware was often less useful that you might think - only in dynamic scenes where the GPU is otherwise idle (like playing video possibly with a static UI overlay was the premier use case).
For static scenes it's more efficient to render out to a buffer (using the GPU as the scanout overlay pipes often had limited feedback capability) and just output that using overlays disabled. It didn't take many frames for that to be worth it.
For apps that were animating or otherwise updating it's window, most UI toolkits used the GPU for widget rendering. And often the scanout pipes didn't hook into the (relatively large) system caches like the GPU did, so there were times it was again faster to composite the screen on the GPU to a single scanout buffer than flush already cached data, the get the scanout hardware to read it back from the memory bus.
And there weren't as cheap as people thought - one stat I remember was that the total area of the GPU on the omap4 platform was smaller than the display pipes. Though that is now a pretty old chip, and always had a bit of focus on "multimedia".
The overlay capabilities of the modern Snapdragons are also quite absurd. They support like upwards of a dozen overlays now and even have FP16 extended sRGB support. Some HWCs (like the one in the steam deck) even have per plane 3D LUTs for HDR tone mapping (ex https://github.com/ValveSoftware/gamescope/blob/master/src/d... )
The composition is bandwidth heavy of course, but for static scenes there's a cache after the HWC in the form of panel self refresh.
Personally, I don't see it as a "2D drawing API", it doesn't accelerate anything special about 2D, only blits and transforms, which a 3D API will eat for breakfast.
Edit: But actually, I couldn't find references to anything similar besides VBE/AF which even when current got almost no support directly in hardware, so folks had to resort to hardware-specific DOS TSR's. I'm not sure if there's anything newer than that.
The bigger issue is that there's little reason to farm vector graphics rendering out to the window server in the first place. The main reason would be to avoid a window blit on HiDPI displays. But the tradeoff is that the XRENDER API is all you get, and usually apps have more sophisticated needs than what it can provide. For instance, browsers can't really use XRENDER nowadays because there's no way to describe CSS 3D transforms in it. And if you use it you're at the mercy of the window server to implement it reasonably, which is not a safe assumption. (A lot of the reason Chrome on Linux was faster than Firefox in the early days is that Firefox used XRENDER, while Chrome rendered on CPU. I remember at least one engineer at Mozilla who was bitter about that, after putting in all the work to make Firefox use it only to have it be a net loss.) In any case, you can avoid the window blit by simply using scanout compositing, as detailed in my other reply, so there is really is no compelling reason to reinvent XRENDER.
The semantics of Xrender simply don't match with what modern GPUs give you, even ones with 2D pipelines.
[0] https://gitlab.freedesktop.org/search?search=sna_pixmap_move...
But if there was an API for 2D acceleration that was actually supported (and could be used simultaneously with desktop composition), then it could be added in to something like SDL then suddenly applications would support it.
On the client side, I think most Linux apps still draw their UIs on CPU, usually accelerated with SIMD. Firefox and Chrome (I think SkiaGL is enabled on Linux?) are exceptions; they use OpenGL and/or Vulkan to draw their UI. Video playback is a different beast and in theory relies on vendor-specific extensions to decode the video in hardware. However, the last time I looked at Linux video decoding (which was years ago), the drivers were awful and interfacing with each vendor's APIs was a huge pain, and so most apps just did video decoding on CPU. (Besides, the Linux ecosystem prefers open codecs, and hardware has only recently gotten support for non-patent-encumbered video formats.)
Firefox has Web Render running on top of ANGLE which is a generic OpenGL layer that converts the OpenGL calls into native platform calls. ANGLE is a Google project and it is the base library for Skia which is used by Chromium to render everything. IIRC Qt / QML also uses ANGLE for Windows.
Rasterizing small glyphs is super fast anyway, there's not much of a need to accelerate it if you can just cache the glyph bitmaps.
Nowadays VA-API is near universally supported, and any half-decent video player uses it to do hardware decoding.
So you end up doing a scene graph to imperitive API to internal renderer scene graph in some UI toolkits. In others they may share the same scene graph structure, applying those optimizations directly from the initial graph.
Although all that said a "pure" scene graph is often overkill and slow. They were all the rage in the early 2000s but less so these days. QML's QtQuick looks like the primary remaining example?
> mobile phones are not considered to be Embedded Systems.
> SixtyFPS hereby grants You a world-wide, royalty-free, non-exclusive license to use, reproduce, make available, modify, display, perform, distribute the Software as part of a Desktop or Web Application.
It's difficult for me to tell how much you know about graphics programming in general, so I can't really point you to any resources that would be better in your particular case!
https://fosstodon.org/@drewdevault/111607882208898175
Here are the two important posts:
———
The story of Wayland:
1. No one wanted to maintain X11 because it sucked
2. We made Wayland and it's much better
3. A vocal minority of change-averse people complained with little to no factual basis
4. They were asked to muster some labor to maintain X11
5. None of them did
6. All of the people who actually do get work done eventually stopped listening to them and moved on with Wayland
——
Some of these detractors built a tottering pile of godawful hacks on top of X11 where every piece depends on another critical design flaw of X11 and are upset that by fixing all of these design flaws their pile of hacks fell over when no one wanted to maintain the load bearing side of their hacks
Personally I’d prefer to use Sway, but last time I tried Zoom on Sway it gave me a lot of trouble. X11 might not be getting much future development, but it is done and it works, so who cares? It can just stay the same in perpetuity for all I care as long as it keeps working.
Sway's screensharing portal (via xdg-desktop-portal-wlr) only lets you share a full monitor at a time. You cant only share a screen region or a single window, so YMMV.
Some of the big proprietary clients have their own devs using linux. Devs tend to be that type of person, so them pushing for upgrades to tools they themselves use isn't too surprising. Discord just recently released an official flatpak and cited internal dev teams as a reason.
Does Discord support Wayland at all? I've heard a bunch of related complaints from people using its native client.
The only problem I know of is that screen sharing does not allow you to select an audio stream which has already spawned multiple hacks / modded clients over the years (and might also apply when running as a X client IDK)
But it depends on complexity. Wine for example implementing Wayland support is a big deal and it's not trivial.
Backwards compatibility really should be the primary focus for anything looking to replace a system component. We do have Xwayland for that but its an incomplete solution by design as X clients won't see non-X windows nor can they capture the whole desktop.
But something like freerdp for example managed to do it with SDL well enough.
SDL of all projects actually did think about translating older ABIs to avoid breaking changes. I.e. there is SDL 1 over SDL 2 helper. It would be nice to see more of such efforts on Linux.
Every post that even touches on Wayland in the smallest way gets flooded with “Wayland sux, just keep developing Xorg” posts.
Xorg is not getting useful/meaningful/future focused development. The fact new commits exist doesn’t mean it’s a healthy alternative.
I just happened to see this post yesterday and thought it was a pretty good summary, if pithy, about the state of X vs Wayland. I don’t blame them for being mad about people continuing to beat this horse.
It must feel a bit like if people continuing to demand that we give up on electric cars and go back to developing leaded gas.
I think I will not try to defend Xorg, as I don’t really even like it, and as you note the topic is kind of beating a dead horse at this point.
But I don’t think the answer is to not try; people use Waylands lack of support for things to justify not using it which then means there no testing or development of those things.
I am somewhat in favour of the wayland devs being a lot slower to the punch, because understanding the problem properly and creating a somewhat clean solution takes time by itself, and writing the software to do things the clean way (screen readers for example) also takes time and effort.
I am reminded that in the c64 days people would poke random memory addresses and it was normal. Protected mode in Windows was a huge step back for many developers who were used to just writing arbitrary bits to memory.
I’m not saying we should abandon everything for progress, it’s good to be critical. But in this case I think the critical eye is only really focused on preventing change, which as many people point out is sorely needed.
Which is rather in conflict with earlier promises about maintaining functionality.
This resulted in a whole chunk of work that was either badly done, or not done at all, or needed all sorts of hacks and extra work because it needed to be re-implemented in different ways on different distros.
So I'm really not sympathetic to the Wayland devs, they needlessly created this situation.
A more reasonable answer would have been "we don't like this, it's a security hole, but whatever, just implement a Wayland extension that matches the X11 one, and security conscious people can disable it, and everybody else can move forward productively in the short term"
The dead horse has been beaten enough and a decision has been made. We're a few years out from the major toolkits removing their X code paths altogether. Everybody who knows anything about how the graphics stack actually works is committed to Wayland. Nobody cares at this point if you're sticking with X11. One day, you'll wake up and find that your entire GUI environment has broken all around you.
I like the Wayland devs, and their occasional failures should not overshadow their successes.
The one doing the work decides how its done.
But Wayland decided to "boil the ocean" and entirely replace a stack of stuff that was working perfectly well for most people.
So perhaps the onus should be on the people who decided to do that, to make sure that things keep working instead of just dumping it?
An alternative design would have been to have built Wayland inside X.org and tunnel the new protocol over the existing protocol, and then migrate chunks of functionality one at a time.
Which is exactly how X11 replaced X10, and X10 replaced X9, etc.
But that would have been careful engineering practice, and not nearly as much fun, so I understand why it did not happen.
This is the kind of ignorance Drew was complaining about. Wayland is a fundamentally different design that cannot simply be embedded in the X protocol; and besides which, again, nobody wants to touch the Xorg code base.
Again. Every single person who knows or cares about the modern Linux graphics stack is pretty much in agreement that abandoning the X approach and starting from scratch was the correct choice. This has been explained time and time again by Drew, Daniel Stone, and others much more knowledgeable about this issue than I. Explaining it over and over again to the stubborn and ignorant is getting tiring. You want to stay on legacy, unsupported X11? Fine. Enjoy having no modern software available for your system, as toolkit and app developers remove their X code paths entirely. Red Hat is abandoning X11 already, and Red Hat IS userspace Linux.
Leaving that aside, Drew is mis-characterising things a little.
Wayland is fundamentally a different __compositor__ architecture. But the X11 system is about more than that, in fact compositors are a rather late addition to the X11 system.
And the protocol architectures are actually quite similar in shape. Which is not surprising, since good ideas last, and X11 has been around for a long time and has accumulated lots of good things (along with lots of cruft too).
So it would have been quite possible, but a good deal less fun, to do it differently.
With the XPresent extension, you effectively get "Wayland inside X11". It's a wonderful thing, as X engineering goes anyway, that precisely no one asked for.
The whole point of the Wayland project is to get rid of all the cruft that X has accumulated over the decades. Embedding Wayland inside Xorg would defeat the whole purpose of the project. The very essence of Wayland is to start over with something new, unhindered by legacy cruft, allowing innovation in the Linux graphics space to take place.
So it was decided, unanimously, by the X devs: the X team would become the Wayland team, Wayland would be the future and X would be abandonware. Anyone who wants to step up and take over maintainership of X can, but I don't see a lot of activity happening.
I am sure windows, like X, also made assumptions that were violated with the advent of things like HiDPI, multiple monitors, video streaming, etc,.
Once assumptions are broken, you pretty much have to pile on hack after hack to get around them. This is what windows does (10+ different APIs to do the exact same action A, for many values of A), and that is why it supports 30 years of software. This is technically horrible, but it is what is ultimately useful to users.
However, it is absolutely not fun work for developers, which is why unpaid ones won't do it, and prefer the easier start-from-scratch approach.
This seems to me no different than big monopoly corp obseleting old devices with software updates. However, that gets a reaction of opposite polarity usually (including from me).
You are looking at it from the wrong direction, though. But otherwise, that’s pretty much what wayland does for backwards compatibility with xwayland — it wraps an x session into a window you can normally use from wayland.
But if they had allowed more of the X11 APIs to be supported via that Xwayland, the transition would be a lot easier.
Unfortunately that was shot down, in favour of forcing every new wayland compositor to implement things like remote desktop and screen capture differently.
They’re doing, you’re complaining. All the X.org software is there for all the detractors to pick up and maintain. That is what happened when the XFree maintainers didn’t want to accept patches from a larger group: it was forked into X.org.
Now the people doing the work want to do Wayland. If it doesn’t please you, then by all means carry on with the old stuff and show them how it should’ve been done.
No ? You mean, I must still use the so infamous yet so helpfull X11 to actually print things on my screen ?
Guess I'll stick with X then ?
Come back when you have a working alternative, and please stop using some magical "authority" argument : "a decision has been made" (by whom, where, when, why, with whom authority ?)
Yes. Wayland is the protocol by which WSL programs display on the Windows desktop.
> Come back when you have a working alternative, and please stop using some magical "authority" argument : "a decision has been made" (by whom, where, when, why, with whom authority ?)
By the X developers, who decided en masse to abandon X and work on Wayland instead.
Then, as the project grows, you find people have been relying on hacks for so long you need to reimplement them. But your new, clean version is not designed to accomodate such abominations, so you need, very inelegantly, to hack them in.
Now you're back at square 1. Until the next naive engineer that decides to do the things the right way, once again.
You cannot, for example, move your own window in Wayland. If you have a multi-window application, like GIMP [1], you cannot have your application position its windows in a reasonable way.
[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/upl...
1. A bunch of developers decided to replace the windowing system with something more akin to Desqview.
2. People complained that this now broke their previously working remote desktop.
3. They got told that their use case was utterly unimportant compared to the very pressing issue of getting rid of screen tearing.
4. Upon comments that screen tearing is irrelevant if you don't actually have a desktop, they replied that someone could write a remote desktop extension for Wayland.
5. None of them did.
6. All of the people that actually wanted to get work done stopped listening to them and continued using X11.
6: continued using is not the same as maintaining/active development, not even close.
[1] https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests...
[2] https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests...
[3] https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests...
It'd be nice if we had software that was actually finished and solid and we could use it without change forever, but X11 isn't that, so if it's not going to get updates, we'll need something else, and hopefully it'll continue developing to be closer to that ideal.
> 2. People complained [...]
No FOSS developer is required to listen to you complain. The maintainers of Xorg decided they did not want to maintain it anymore.
Just BTW, there were no Wayland complaints taking over the thread till you started this with that somewhat inflammatory copypasta. Here's why your suggestion for controlling Wayland spam won't work: ...
Little to actual factual basis?? 1) How do you explain the time it has taken?? 2) prioritising "shallow security" over "accessibility" is a fact: see https://news.ycombinator.com/item?id=38696891 ??
Wayland design was "OK", Wayland's implementation is a disaster.. Nearly every DE reinventing its own server implementation is a recipe for incompatibility, bugs..
WaylandEnable=false
Surely there are interesting arguments to be made about how the design and philosophy behind Wayland is so much better than that of X, but the way I experience it is that Wayland is a nuisance, whereas X just does what it should do.