Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does OpenGL Communicate with the GPU? [duplicate]

OpenGL is an interface to perform graphical commands. Now, if the library is multi-platform how does it interact with the GPU is it by making system calls and thus making it multi-platform or does it use drivers to perform its operations?

like image 390
boompow Avatar asked Apr 21 '14 12:04

boompow


People also ask

How does OpenGL communicate with the GPU?

In OpenGL, an image is sent to the GPU through Texture Objects. This Texture Object is placed in a Texture-Unit. The fragment shader references this texture-unit through a Sampler. The fragment shader then uses the U-V coordinates along with the sampler data to properly map an image to the game character.

Does OpenGL work without a GPU?

Sure. Many software only implementations of OpenGL exist. Check out the Mesa project at http://www.mesa3d.org/ for one of the most popular. There are parts of the shading language not fully supported, and it tends to lag the standard a bit in general, but that is the case of all software API emulators.

How does OpenGL driver work?

The graphics driver keeps track of the GPUs state and all the resources application programs that make use of the GPU. Also it is responsible for conversion or any other processing the data sent by applications (convert textures into the pixelformat supported by the GPU, compile shaders in the machine code of the GPU).

Is OpenGL open source?

Is OpenGL Open Source? No, OpenGL doesn't have any source code. GL is a specification which can be found on this website. It describes the interface the programmer uses and expected behavior.


1 Answers

OpenGL is typically implemented as part of the graphics drivers. Each implementation will use implementation-specific interfaces to talk to some kernel-space component and the real HW.

One can see a bit more how these things might be done by looking at the MESA based open-source GL implementation on Linux. They actually use the DRM (direct rendering manager) API of the Linux kernel to talk to the HW. MESA's current implementation is organised such that for each GPU, there is a drm kernel driver and a user-space DRI client. Mesa now uses the gallium API as an abstraction layer to keep the GPU-specifc code small and make it more portable. The OpenGL API is implemented on top of that as a "state tracker:, and is independent of the GPU drivers. (There even has been a D3D10/11 state tracker, but it was more like a test and was later removed because it became unmaintained.)

The fact that OpenGL is defined as a plaform-independent API does not mean that the OpenGL library will be platform-independent at all. This is the same situation as with the C library API is part of the language standard, but the implementation is very platform-specific.

like image 54
derhass Avatar answered Nov 02 '22 13:11

derhass