Mesa

FAQ

Article from Issue 197/2017
Author(s):

Peek below the shiny interface of your machine and you'll probably find Mesa in the engine room.

Q I've decided to do my own Wikipedia research for this FAQ, so I'm way ahead of you. Mesa is the US-English term for a flat-topped mountain with steep sides. The word came to English from the Spanish for table, which is easy to remember as Table Mountain in Cape Town is a perfect example.

A Before you get too carried away, do you see the disambiguation link at the top of the Wikipedia page?

Q Err, yes.

A Click that and then scroll down to the technology section.

Q Ah, right. Got it. Mesa is a high-level programming language developed at Xerox PARC in Palo Alto. The name comes from a pun on it being a high-level programming language and a mesa being both high and level.

A That's a bit closer, but still not what we're talking about here. As well as being a flat hill and a programing language, Mesa is also the name of an open source 3D graphics library.

Q Ah, yes. In Wikipedia terms, you mean Mesa (computer graphics). According to this font of all knowledge, Mesa is an implementation of OpenGL and Vulkan. That, frankly, leaves me even more confused.

A 3D graphics have become so commonplace on everything from desktops to mobile phones that it's easy to forget that the computation behind them is hugely complex. The complexity really comes in two different ways: working out exactly what it is you want to display and doing the computation fast enough to display the scene at an acceptable frame rate. Both of these problems are solved through Mesa (and other software like it).

OpenGL (or Open Graphics Library) is a system for managing this complexity. It gives programmers a way of handling 3D graphics that is about as intuitive as a high-performance system for mathematical computation ever can be. Programmers can build objects in a 3D space (usually using triangles to map out the surface) and then define how this space is lit. The screen is then a window into this world (Figure 1).

Figure 1: Mesa (and OpenGL) provides the graphical power for many desktop environments including Unity.

What makes OpenGL particularly useful is that it's not just a way for programmers to understand how to structure their code, but a standard for hardware manufacturers to implement with their drivers. Essentially, it's a meeting point between the people who design and build 3D hardware and those that write 3D software.

Q Ah, right, so Mesa is what my graphics card drivers connect to?

A Yes, well sometimes. Your graphics card needs to speak OpenGL with the rest of your system, and Mesa is one way of doing this. NVidia has their own software that works in a similar way to Mesa, but Intel and some AMD hardware use Mesa for their 3D graphical powers.

Q Graphics cards are often cited as a cause of non-free software on Linux systems. How does Mesa fit into this?

A Essentially, Mesa allows hardware manufacturers to work on a shared implementation of much of the graphics software. Companies such as AMD and Intel contribute to the development of the software, and as these are still in fierce competition with each other, the project can only succeed as open source software because neither party can close out the other. For supported hardware (and there's more every year), this means you can get open source graphics drivers and keep your machine as open as possible.

Q I've got an NVidia card on one of my machines, and you said that they don't use Mesa. Does this mean that I can't enjoy an open source graphics stack?

A Not necessarily. The official NVidia driver is proprietary, but there's also an open source driver for some NVidia hardware called Nouveau. This works with Mesa and provides graphics capabilities without the proprietary software. However, performance isn't as good as the official driver. It's fine for day-to-day usage, but may be a bit lacking if you want to play the latest games.

Q I don't have a graphics card. Do I still need Mesa?

A Probably, but this answer is a bit more complex than it first appears. The first thing to say is that it is possible to have graphics on Linux without Mesa (or any other implementation of OpenGL). However, even if you don't have a graphics card, you could still be using Mesa in a couple of ways. First, many modern CPUs come with graphics capabilities built in. This is true on phones, as well as desktops and laptops. In these cases, you'll still need Mesa or an equivalent to be able to use that power. Second, it's possible to use Mesa without dedicated 3D hardware. This works in exactly the same way as when running on graphics hardware, but the calculations are done on the CPU. This is sometimes (and erroneously in our opinion) called software rendering. However, this is much slower than running on a graphics card.

Q Why shouldn't you call that software rendering? It sounds like it's done in software.

A Well, yes, it is done in software, but all 3D rendering is done in software. When you play games using the latest-and-greatest chunk of silicon spitting out a few bazillion polygons on your super-duper-extra-even-more-high-definition screen at a refresh rate several times higher than the eye can see, all that 3D graphics is still being performed by software, it's just that the software is running on graphics chips.

Q Wait, if it's all in software anyway, what's the difference between rendering on the CPU and the graphics card, and why is the graphics card so much faster?

A Your CPU is designed to do almost anything that's thrown at it from database processing to web browsing to word processing. They're incredibly versatile, but this makes them big and bulky (in silicon chip terms). GPUs, on the other hand are designed to perform floating-point operations very efficiently. Not only that but the same floating-point operation on lots and lots of data. By focusing on just this type of processing, they can do it very quickly.

Q This is all very interesting, but I don't play games. Should I care about Mesa?

A Absolutely! The main reason being that many Linux desktop environments offload much of their graphics processing to the 3D hardware if it's available.

Q Ah yes, KDE's infamous wobbly windows. I'm not that fussed about the fancy 3D effects some desktops are peddling these days. So I can just not bother with Mesa, right?

A Nope! Even desktops that don't use gratuitous 3D effects often use Mesa to render the desktop because by using the GPU to do the graphics, it frees up the CPU for more important work. Even though the desktop could be rendered on the CPU, it can be much more efficient to render it on the GPU.

As well as graphics effects, video playback is often performed via Mesa (or similar software) to get smooth movement even on high definition screens (see Figure 2). It's one of those pieces of software that's vitally important (at least to desktop Linux users), but it's often forgotten about unless something goes wrong.

Figure 2: Mesa can even supercharge your web browsing via WebGL. This example is a reflective sphere animation rendered in real time [1].

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News