Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Linux, do I need an X server to do off-screen rendering?

And if so why? What does X do for me beyond piping my rendering commands to the graphics card driver?

I'm not clear on the relationship X - OpenGL. I've searched the internet but couldn't find a concise answer.

If it matters, assuming a minimal modern distribution, like a headless Ubuntu 13 machine.

like image 524
Luis Avatar asked Sep 27 '13 09:09

Luis


People also ask

How does X display server work?

The X display server is a program that keeps track of all input coming from input devices, such as the keyboard and mouse, and input from any other clients that are running. As the display server receives information from a client, it updates the appropriate window on your display.

How does X work Linux?

The X clients are application programs talking to the server using the X protocol, either using a local Unix Domain socket or a TCP/IP connection. The X protocol is used by the client to both send requests to the server and receive event messages from the server.

How do displays work in Linux?

The display system runs on top of the Linux kernel in user space which allows the kernel(the heart of a linux OS) to continue to function if the display system crashes. The display system is flexible allowing the user to configure it to suite their needs.

Does X11 use OpenGL?

OpenGL with X11 can run in two different modes: direct rendering and indirect rendering. The difference between them is that indirect rendering uses the GLX protocol to relay the OpenGL commands from the program to the hardware, which limits OpenGL capabilities to OpenGL 1.4.


1 Answers

With the current drivers: Yes.

And if so why?

Because the X server is the host for the actual graphics driver talking to the GPU. At the moment Linux GPU drivers require a X server that gives them an environment to live in and a channel to the kernel interfaces to talk through with the GPU.

On the DRI/DRM/Gallium front a new driver model has been created that allows to use the GPU without an X server, for example using the EGL-API. However only a small range of GPUs is supported by this right now; most Intel and AMD; none NVidia.

I'm not clear on the relationship X - OpenGL

I covered that in detail in the SO answers found at https://stackoverflow.com/a/7967211/524368 and https://stackoverflow.com/a/8777891/524368

In short the X server acts like a "proxy" to the GPU. You send the X server commands like "open a window" or "draw a line there". And there's an extension to the X protocol called "GLX", where each OpenGL command gets translated into a stream of GLX/X opcodes and the X server executes those commands on the GPU on behalf of the calling client. Also most OpenGL/GLX implementations provide a mechanism to bypass the X server if the client process could actually talk directly to the GPU (because it runs on the same machine as the X server and has permissions to access the kernel API); that is called Direct Rendering. It however still requires the X server for opening the window, creating the context and to general housekeeping.

Update due to comment

Also if you can live without GPU acceleration, you can use Mesa3D using the osmesa (off-screen mesa) mode and the LLVMpipe software rasterizer.

like image 170
datenwolf Avatar answered Oct 02 '22 19:10

datenwolf