I spent some time reading up on modern low-level interfaces to video hardware in Linux.


So let’s say, from Linux, that you want to render directly to a display device that a windowing system has no business getting involved with coughvrheadsetcough. Here’s a quick run-down of all the subsystems that you’ll probably need to know something about in order to interface with graphics hardware without the help of X, Wayland, or similar system.

  • DRI – Direct Rendering Infrastructure
  • DRM – Direct Rendering Manager
  • GEM – Graphics Execution Manager
  • KMS – Kernel Mode Switching
  • GBM – General Buffer Manager
  • EGL – Embedded Graphics Library Native Platform Interface
  • OpenGL – Open Graphics Library

OMG WTF TLA (and a special thank-you for the no-longer-an-acronym there!)

Alright, so DRI is basically the kernel driver(s) with the DRM and GBM libraries exposing specific functionality. GEM and KMS refer to subsets of DRM functionality for managing video memory and video resolutions respectively. The GBM library offers an abstraction over DRM for interfacing with EGL. The EGL API provides a common interface between a handful of rendering APIs (OpenGL, OpenGL ES, OpenVG). And OpenGL is the API that allows you to actually render something.

So if you’ve managed to follow along, the plumbing there looks something like follows:

DRI <- DRM <- GBM <- EGL <- OpenGL

The whole stack roots itself in DRI. With DRM you can configure the display hardware, including GEM & KMS. With GBM you can initialize EGL and create a display buffer for it. At some point, some tom-foolery is necessary to negotiate graphics display between GBM and DRM. And EGL provides a common means of requesting the OpenGL-family graphics API of your choice.

About five years ago I took a brief look at this stack (sans GBM), threw up my hands and said, “I’m sure this will all get sorted out and become simpler,” and walked away. And in some ways, it probably has!

Note that Nvidia does not currently offer GBM support. Instead, they have a similar-but-different setup substituting GBM with a handful of EGL extensions. Unfortunately for everyone, regardless of whatever trade-off those EGL extensions offer, this means that Nvidia cards currently require special handling.

Also note that Vulkan has some VK_EXT_KHR_display extension for rendering directly to a graphics device. I’ll leave it as an exercise for the reader to figure out how (if?) that ties into everything.