Platform specifics: Linux: Difference between revisions
No edit summary |
No edit summary |
||
Line 74: | Line 74: | ||
====Checklist==== | ====Checklist==== | ||
* debian dri [ | * debian dri [V] | ||
* | * debian drm [V] | ||
Line 86: | Line 88: | ||
===debian dri=== | ====debian dri==== | ||
libgl1-mesa-dri (10.6.5-1 and others) | libgl1-mesa-dri (10.6.5-1 and others) | ||
Line 130: | Line 132: | ||
=== | |||
====debian drm==== | |||
Line 149: | Line 155: | ||
libdrm2 (2.4.64-1 and others) | libdrm2 (2.4.64-1 and others) | ||
Line 250: | Line 242: | ||
https://en.wikipedia.org/wiki/Hardware_acceleration | https://en.wikipedia.org/wiki/Hardware_acceleration | ||
Revision as of 18:51, 11 September 2015
This Section explains how to install Drivers to make OpenGL Programs run under Linux and how to use different Libraries/Toolkits to create Opengl Programs.
Mesa is an open-source OpenGL implementation, continually updated to support the latest OpenGL specification.
The Direct Rendering Infrastructure, also known as the DRI, is a framework for allowing direct access to graphics hardware under the X Window System in a safe and efficient manner.
http://dri.freedesktop.org/wiki/
Current version of EGL in Mesa implements EGL 1.4
Mesa implements OpenGL ES 1.1 and OpenGL ES 2.0
http://mesa3d.org/opengles.html
Mesa 10.6.7 implements the OpenGL 3.3 API OpenGL 3.3 is only available if requested at context creation because compatibility contexts are not supported
http://mesa3d.org/relnotes/10.6.7.html
Big Picture (DRI)
mesa
Mesa is an open-source implementation of the OpenGL specification - a system for rendering interactive 3D graphics
Mesa ties into several other open-source projects: the Direct Rendering Infrastructure and X.org to provide OpenGL support to users of X on Linux, FreeBSD and other operating systems
http://www.mesa3d.org/intro.html
Checklist
- Direct Rendering Infrastructure [V]
Direct Rendering Infrastructure
Direct Rendering Infrastructure (DRI) is a framework for allowing direct access to graphics hardware under the X Window System in a safe, efficient way.[5] The main use of DRI is to provide hardware acceleration for the Mesa implementation of OpenGL
https://en.wikipedia.org/wiki/Direct_Rendering_Infrastructure
Mesa is an open-source OpenGL implementation, continually updated to support the latest OpenGL specification
Direct Rendering Infrastructure, also known as the DRI, is a framework for allowing direct access to graphics hardware under the X Window System in a safe and efficient manner. It includes changes to the X server, to several client libraries, and to the kernel (DRM, Direct Rendering Manager)
http://dri.freedesktop.org/wiki/
Checklist
- debian dri [V]
- debian drm [V]
debian dri
libgl1-mesa-dri (10.6.5-1 and others)
OpenGL API -- DRI modules
Mesa provides GLX and DRI capabilities: it is capable of both direct and indirect rendering. For direct rendering, it can use DRI modules from the libgl1-mesa-dri package to accelerate drawing
does not include the OpenGL library itself, only the DRI modules
dep: libdrm-nouveau2 Userspace interface to nouveau-specific kernel DRM services -- runtime
dep: libdrm2 Userspace interface to kernel DRM services -- runtime
Similar packages:
- libgl1-mesa-glx
- libegl1-mesa
https://packages.debian.org/sid/libgl1-mesa-dri
libegl1-mesa (10.6.5-1 and others)
EGL API -- runtime
contains the EGL native platform graphics interface library. EGL provides a platform-agnostic mechanism for creating rendering surfaces for use with other graphics libraries, such as OpenGL|ES
contains modules to interface with the existing system GLX or DRI2 drivers to provide OpenGL via EGL
https://packages.debian.org/sid/libegl1-mesa
/usr/lib/x86_64-linux-gnu/libEGL.so.1 /usr/lib/x86_64-linux-gnu/libEGL.so.1.0.0
https://packages.debian.org/sid/amd64/libegl1-mesa/filelist
debian drm
Direct Rendering Manager (DRM) is a subsystem of the Linux kernel responsible for interfacing with GPUs of modern video cards. DRM exposes an API that user space programs can use to send commands and data to the GPU, and perform operations such as configuring the mode setting of the display. DRM was first developed as the kernel space component of the X Server's Direct Rendering Infrastructure
https://en.wikipedia.org/wiki/Direct_Rendering_Manager
DRM is a kernel module that gives direct hardware access to DRI clients
module deals with DMA, AGP memory management, resource locking, and secure hardware access.
DRM supports the DRI in three major ways:
- DRM provides synchronized access to the graphics hardware
- DRM enforces the DRI security policy for access to the graphics hardware
- DRM provides a generic DMA engine
http://dri.freedesktop.org/wiki/DRM/
libdrm2 (2.4.64-1 and others)
Userspace interface to kernel DRM services -- runtime
DRM stands for "Direct Rendering Manager", which is the kernelspace portion of the "Direct Rendering Infrastructure" (DRI). The DRI is currently used on Linux to provide hardware-accelerated OpenGL drivers
Similar packages: ...
- libdrm-nouveau2
...
https://packages.debian.org/sid/libdrm2
/usr/lib/x86_64-linux-gnu/libdrm.so.2 /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
https://packages.debian.org/sid/amd64/libdrm2/filelist
libdrm-nouveau2 (2.4.64-1 and others)
interface to nouveau-specific kernel DRM services -- runtime
implements the userspace interface to the kernel DRM services. DRM stands for "Direct Rendering Manager", which is the kernelspace portion of the "Direct Rendering Infrastructure" (DRI). The DRI is currently used on Linux to provide hardware-accelerated OpenGL drivers
https://packages.debian.org/sid/libdrm-nouveau2
/usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2 /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2.0.0
https://packages.debian.org/sid/amd64/libdrm-nouveau2/filelist
Checklist
- linux drm [V]
- hardware acceleration [V]
- kernelspace
- userspace
linux drm
- DRM Core
- Introduction
- DRM Internals
- Driver Initialization
- Memory management
- Mode Setting
- KMS Initialization and Cleanup
- Mode Setting Helper Functions
- KMS Properties
- Vertical Blanking
- Open/Close, File Operations and IOCTLs
- Legacy Support Code
- Userland interfaces
- DRM Drivers
https://www.kernel.org/doc/htmldocs/drm/
hardware acceleration
hardware acceleration is the use of computer hardware to perform some functions faster than is possible in software running on a more general-purpose CPU. Examples of hardware acceleration include blitting acceleration functionality in graphics processing units (GPUs)
https://en.wikipedia.org/wiki/Hardware_acceleration
Mesa3D GL* through EGL & XCB
OpenGL ABI
- ABI (Application Binary Interface) and runtime environment for applications using OpenGL under X11 on Linux enable applications using the OpenGL API for rendering to run on a variety of underlying implementations transparently. The intent is to address all of open source, commercial closed binary, OpenGL SI-based, and Mesa-based implementations.
- SDK for developing apps using OpenGL. This includes header file locations, conventions for use of extensions, etc.
https://www.opengl.org/registry/ABI/
Some Linux distributions may include support for hardware acceleration. Also, some GPUs have Open Source drivers developed by the community even though a closed source driver may be available from the manufacturer.
Prerequisites
/usr/lib/x86_64-linux-gnu/libEGL.so.1 /usr/lib/x86_64-linux-gnu/libEGL.so.1.0.0 /usr/share/bug/libegl1-mesa/control /usr/share/bug/libegl1-mesa/script /usr/share/doc/libegl1-mesa/changelog.Debian.gz /usr/share/doc/libegl1-mesa/copyright /usr/share/lintian/overrides/libegl1-mesa
https://packages.debian.org/sid/amd64/libegl1-mesa/filelist
/usr/include/EGL/egl.h /usr/include/EGL/eglext.h /usr/include/EGL/eglextchromium.h /usr/include/EGL/eglmesaext.h /usr/include/EGL/eglplatform.h /usr/include/KHR/khrplatform.h /usr/lib/x86_64-linux-gnu/libEGL.so /usr/lib/x86_64-linux-gnu/libwayland-egl.so /usr/lib/x86_64-linux-gnu/pkgconfig/egl.pc /usr/lib/x86_64-linux-gnu/pkgconfig/wayland-egl.pc /usr/share/bug/libegl1-mesa-dev/control /usr/share/bug/libegl1-mesa-dev/script /usr/share/doc/libegl1-mesa-dev/changelog.Debian.gz /usr/share/doc/libegl1-mesa-dev/copyright
https://packages.debian.org/sid/amd64/libegl1-mesa-dev/filelist
/usr/lib/x86_64-linux-gnu/libGLESv2.so.2 /usr/lib/x86_64-linux-gnu/libGLESv2.so.2.0.0 /usr/share/bug/libgles2-mesa/control /usr/share/bug/libgles2-mesa/script /usr/share/doc/libgles2-mesa/changelog.Debian.gz /usr/share/doc/libgles2-mesa/copyright /usr/share/lintian/overrides/libgles2-mesa
https://packages.debian.org/sid/amd64/libgles2-mesa/filelist
/usr/include/GLES2/gl2.h /usr/include/GLES2/gl2ext.h /usr/include/GLES2/gl2platform.h /usr/include/GLES3/gl3.h /usr/include/GLES3/gl31.h /usr/include/GLES3/gl3ext.h /usr/include/GLES3/gl3platform.h /usr/lib/x86_64-linux-gnu/libGLESv2.so /usr/lib/x86_64-linux-gnu/pkgconfig/glesv2.pc /usr/share/bug/libgles2-mesa-dev/control /usr/share/bug/libgles2-mesa-dev/script /usr/share/doc/libgles2-mesa-dev/changelog.Debian.gz /usr/share/doc/libgles2-mesa-dev/copyright
https://packages.debian.org/sid/amd64/libgles2-mesa-dev/filelist
Source Code
/*
MIT License
Copyright (c) 2015 Alex Cham
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Very Dirty Code! Test Purposes Only!
Why XCB?
X protocol C-language Binding (XCB) is a replacement for Xlib
http://xcb.freedesktop.org/
Basic Graphics Programming With The XCB Library
http://www.x.org/releases/X11R7.6/doc/libxcb/tutorial/index.html
Introduction to managing client API rendering through the EGL API.
https://www.khronos.org/registry/egl/sdk/docs/man/html/eglIntro.xhtml
Linking
Invoking: GCC C++ Linker
g++ -o "EGL14XCBGLES20MakeCurrentContext" ./src/EGL14XCBGLES20MakeCurrentContext.o -lxcb -lEGL -lGLESv2
See Also:
Documentation for the X Window System
http://www.x.org/releases/X11R7.6/doc/
*/
#include <stdlib.h>
//
#include <EGL/egl.h>
#include <GLES2/gl2.h>
//
#include <xcb/xcb.h>
xcb_window_t makeXcbWindow(uint16_t width, uint16_t height,
xcb_visualid_t eglConfAttrVisualID) {
xcb_connection_t *c;
xcb_screen_t *screen;
xcb_window_t win;
/* Open the connection to the X server */
c = xcb_connect(NULL, NULL);
/* Get the first screen */
screen = xcb_setup_roots_iterator(xcb_get_setup(c)).data;
/* Ask for our window's Id */
win = xcb_generate_id(c);
/* Create the window */
xcb_create_window(c,
XCB_COPY_FROM_PARENT, win, screen->root, 0, 0, width, height, 10,
XCB_WINDOW_CLASS_INPUT_OUTPUT, eglConfAttrVisualID, 0,
NULL);
/* Map the window on the screen */
xcb_map_window(c, win);
/* Make sure commands are sent before we pause, so window is shown */
xcb_flush(c);
return win;
}
int main(int argc, char ** argv) {
//@FIXME Black screen & cursor problems sometimes...
/* get an EGL display connection */
EGLDisplay display;
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
/* initialize the EGL display connection */
eglInitialize(display, NULL, NULL);
/* get an appropriate EGL frame buffer configuration */
/*
All attributes in attrib_list, including boolean attributes, are immediately
followed by the corresponding desired value. The list is terminated with EGL_NONE
https://www.khronos.org/registry/egl/sdk/docs/man/html/eglChooseConfig.xhtml
*/
static EGLint const attribute_list[] = {
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
EGL_NONE };
EGLConfig config;
EGLint num_config;
eglChooseConfig(display, attribute_list, &config, 1, &num_config);
/* create an EGL rendering context */
/*
#define EGL_OPENGL_ES_API 0x30A0
#define EGL_OPENVG_API 0x30A1
#define EGL_OPENGL_API 0x30A2
*/
eglBindAPI(EGL_OPENGL_ES_API);
/*
eglCreateContext — create a new EGL rendering context
attrib_list specifies a list of attributes for the context.
The list has the same structure as described for eglChooseConfig
https://www.khronos.org/registry/egl/sdk/docs/man/html/eglCreateContext.xhtml
*/
static const EGLint ctx_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE };
EGLContext context;
context = eglCreateContext(display, config, EGL_NO_CONTEXT, ctx_attribs);
//Request eglVisualID for native window
EGLint eglConfAttrVisualID;
if (!eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID,
&eglConfAttrVisualID)) {
//printf("Error: eglGetConfigAttrib() failed\n");
exit(1);
}
///////////////////////////////////////////////////////////////////////////////
/* create a native window */
//native_window = createNativeWindow();
uint16_t width = 640;
uint16_t height = 480;
NativeWindowType nativeWindow;
nativeWindow = makeXcbWindow(width, height,
(xcb_visualid_t) eglConfAttrVisualID);
///////////////////////////////////////////////////////////////////////////////
/* create an EGL window surface */
EGLSurface surface;
surface = eglCreateWindowSurface(display, config, nativeWindow, NULL);
/* connect the context to the surface */
eglMakeCurrent(display, surface, surface, context);
/* clear the color buffer */
while (1) {
glViewport(0, 0, (GLsizei) width, (GLsizei) height);
glClearColor(0., 0., 1., 0.);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glFlush();
eglSwapBuffers(display, surface);
}
return EXIT_SUCCESS;
}