3 ms·
How does X interact with your graphics card?
by person_of_color 7y ago
How does X interact with your graphics card?
- Jasper_ 7y agoThat boils down to two main questions: 1. How do X11 clients render using your GPU, like using OpenGL or Vulkan? 2. How does an X11 server talk to your graphics card to get stuff on screen? Clients render through a magic secret backdoor. libGL.so / the Vulkan ICD, provided by the vendor talks to their graphics driver, and then there's typically an Xorg extension to do the buffer handoff. In the open-source world, the libGL.so is mesa, it talks to the kernel using a kernel API called "DRM" (Direct Rendering Manager) to render your graphics to a buffer, and then the resulting rendered buffer is shoved across and composited using an Xorg extension known as DRI3, which is initialized as part of the video driver. Most of the open source xf86-video-* drivers support DRI3. For the latter question, the X11 server has a series of video drivers that can take the buffers you have and show them on screen. I won't go into the exact details of how these buffers are composited (it's not very pretty, but the typical approach these days is the server itself using GL the same way a client would to composite the buffers together), but ultimately a final composited scanout buffer comes out the other side, which is sent to the screen through some driver-specific mechanism. In the open-source world, this mechanism is called "Kernel Mode-Setting", or "KMS", and it's part of the kernel DRM APIs mentioned above.