What is the relationship between the graphics card driver and OpenGL on Linux?

3

I have the latest proprietary Nvidia driver installed, which is nvidia-415 (according to the "Driver Manager" interface). Some programs complain that I don't have OpenGL 3.3.

So I ran the command to check:

$ glxinfo | grep "OpenGL version"
OpenGL version string: 3.0 Mesa 12.0.6
OpenGL core profile version string: 4.3 (Core Profile) Mesa 12.0.6

OK, so it looks like I have version 3.0. BUT- when I look at Mesa, it's called a "graphics stack" and includes the FOSS nvidia driver and the latest OpenGL.

There's also a "core profile version" that's 4.3. So am I at 4.3 or 3.0?

So now I'm confused. Does the proprietary Nvidia driver work with the Mesa OpenGL? Or does the nouveau open source driver only work with Mesa's open GL, and I should install a non-mesa, proprietary, OpenGL from Nvidia to work with their proprietary driver?

Nick

Posted 2019-02-11T00:15:03.997

Reputation: 849

Answers

3

I'm going to start with a brief API definition and move down from there just to make sure all the bases are covered. There's also a TL;DR below.

APIs Overview

In the first place, OpenGL describes an abstract, language-agnostic API meant to facilitate easy access to a machine's graphical capabilities. This allows software developers - like video game developers - to efficiently interface with the hardware at a lower-level, ensuring speed, reliability, and ease of programming among other things. Concretely, if a software developer wanted to speak directly to the graphics hardware, they would need to write code in Assembly Language or other hardware-level languages which are cumbersome and time-consuming to write. Instead, OpenGL allows for the high-level OpenGL Shading Language to be used which is much easier to use and can be thought of as only a step "above" speaking to the hardware in its own language. This means that calls to the hardware will be really fast, among other things.

Mesa

As mentioned above, OpenGL is only a specification for an API. OpenGL provides a library with its install(the version of which you're seeing in your output) but in order to make these work, it needs to be implemented for a given OS. This is where Mesa comes in. Mesa(aka Mesa 3D) is open source and used in many Linux distros. It originally was conceived as just an implementation of OpenGL but these days it's a lot more. It also implements other API specs like OpenCL, and it comes bundled with hardware drivers.

Hardware Drivers

Up until now, we've been relatively high level. Mesa, and the OpenGL spec are just middlemen between the application(or game) and the hardware driver for the graphics card, which is lower-level. Here we have a couple options and Mesa will provide one of these depending on the manufacturer of the graphics hardware and how cooperative they are with open source initiatives. For example, Intel's integrated graphics almost always use Mesa for everything, for the OpenGL implementation and for the hardware drivers. Intel contributes directly to Mesa's source code so that the whole graphics solution can be Mesa. Nvidia on the other hand...

Nvidia & Nouveau

Nvidia has classically been obstinate when it comes to working with the open source community, prefering to develop their own closed-source alternatives. This obstinance famously led Linus Torvalds to share his two cents about the company during one interview. Where Linux is concerned Nvidia provides its own OpenGL implementation and also its own hardware driver - all closed source. Nvidia has released some of their product drivers as open source but this is a limited range of products. Nouveau, on the other hand, is actually an effort by the open source community to provide a hardware driver that's deliberately reverse engineered from Nvidia's driver releases. As valiant an effort as this is, it often means that new graphics card features are necessarily behind in the Nouveau drivers compared to Nvidia's propreitary stack since the open source community is forced to play catch up.

TL;DR

It's hard to know for sure what your graphics stack is using without knowing your exact card model but it's almost certainly either:

  1. Nvidia is providing the proprietary OpenGL implementation and hardware driver.
  2. Mesa is used for the OpenGL implementation and Nouveau for the hardware driver.

Since glxinfo is just meant as a utility to show the OpenGL implementation and won't have access to the hardware, you could try viewing the hardware driver used with:

lspci -k | grep -EA3 'VGA|3D|Display' 

Look for the "kernel driver in use" field. Then get info about that driver with:

modinfo drivername

You might get a lot of output so you could just check the top of it for the license to see if it's GPL or another open source license. It's not likely that you'll be using Nvidia kernel-space drivers with Mesa.

baelx

Posted 2019-02-11T00:15:03.997

Reputation: 2 083