blob: 8ce6fdf8f064984676d6f5ec980534d03c641f1d [file] [log] [blame]
Erik Faye-Lund4d066832020-06-12 20:09:42 +02001Frequently Asked Questions
2==========================
3
4Last updated: 19 September 2018
5
6Index
7-----
8
9#. `High-level Questions and Answers <#part1>`__
10#. `Compilation and Installation Problems <#part2>`__
11#. `Runtime / Rendering Problems <#part3>`__
12#. `Developer Questions <#part4>`__
13
14.. _part1:
15
161. High-level Questions and Answers
17-----------------------------------
18
191.1 What is Mesa?
20~~~~~~~~~~~~~~~~~
21
22Mesa is an open-source implementation of the OpenGL specification.
23OpenGL is a programming library for writing interactive 3D applications.
24See the `OpenGL website <https://www.opengl.org/>`__ for more
25information.
26
27Mesa 9.x supports the OpenGL 3.1 specification.
28
291.2 Does Mesa support/use graphics hardware?
30--------------------------------------------
31
32Yes. Specifically, Mesa serves as the OpenGL core for the open-source
33DRI drivers for X.org.
34
35- See the `DRI website <https://dri.freedesktop.org/>`__ for more
36 information.
37- See `01.org <https://01.org/linuxgraphics>`__ for more information
38 about Intel drivers.
39- See `nouveau.freedesktop.org <https://nouveau.freedesktop.org>`__ for
40 more information about Nouveau drivers.
41- See
42 `www.x.org/wiki/RadeonFeature <https://www.x.org/wiki/RadeonFeature>`__
43 for more information about Radeon drivers.
44
451.3 What purpose does Mesa serve today?
46---------------------------------------
47
48Hardware-accelerated OpenGL implementations are available for most
49popular operating systems today. Still, Mesa serves at least these
50purposes:
51
52- Mesa is used as the core of the open-source X.org DRI hardware
53 drivers.
54- Mesa is quite portable and allows OpenGL to be used on systems that
55 have no other OpenGL solution.
56- Software rendering with Mesa serves as a reference for validating the
57 hardware drivers.
58- A software implementation of OpenGL is useful for experimentation,
59 such as testing new rendering techniques.
60- Mesa can render images with deep color channels: 16-bit integer and
61 32-bit floating point color channels are supported. This capability
62 is only now appearing in hardware.
63- Mesa's internal limits (max lights, clip planes, texture size, etc)
64 can be changed for special needs (hardware limits are hard to
65 overcome).
66
671.4 What's the difference between "Stand-Alone" Mesa and the DRI drivers?
68-------------------------------------------------------------------------
69
70*Stand-alone Mesa* is the original incarnation of Mesa. On systems
71running the X Window System it does all its rendering through the Xlib
72API:
73
74- The GLX API is supported, but it's really just an emulation of the
75 real thing.
76- The GLX wire protocol is not supported and there's no OpenGL
77 extension loaded by the X server.
78- There is no hardware acceleration.
79- The OpenGL library, ``libGL.so``, contains everything (the
80 programming API, the GLX functions and all the rendering code).
81
82Alternately, Mesa acts as the core for a number of OpenGL hardware
83drivers within the DRI (Direct Rendering Infrastructure):
84
85- The ``libGL.so`` library provides the GL and GLX API functions, a GLX
86 protocol encoder, and a device driver loader.
87- The device driver modules (such as ``r200_dri.so``) contain a
88 built-in copy of the core Mesa code.
89- The X server loads the GLX module. The GLX module decodes incoming
90 GLX protocol and dispatches the commands to a rendering module. For
91 the DRI, this module is basically a software Mesa renderer.
92
931.5 How do I upgrade my DRI installation to use a new Mesa release?
94-------------------------------------------------------------------
95
96This wasn't easy in the past. Now, the DRI drivers are included in the
97Mesa tree and can be compiled separately from the X server. Just follow
98the Mesa `compilation instructions <install.html>`__.
99
1001.6 Are there other open-source implementations of OpenGL?
101----------------------------------------------------------
102
103Yes, SGI's `OpenGL Sample Implementation
104(SI) <http://web.archive.org/web/20171010115110_/http://oss.sgi.com/projects/ogl-sample/index.html>`__
105is available. The SI was written during the time that OpenGL was
106originally designed. Unfortunately, development of the SI has stagnated.
107Mesa is much more up to date with modern features and extensions.
108
109`Vincent <https://sourceforge.net/projects/ogl-es/>`__ is an open-source
110implementation of OpenGL ES for mobile devices.
111
112`miniGL <http://web.archive.org/web/20130830162848/http://www.dsbox.com/minigl.html>`__
113is a subset of OpenGL for PalmOS devices. The website is gone, but the
114source code can still be found on
115`sourceforge.net <https://sourceforge.net/projects/minigl/>`__.
116
117`TinyGL <http://bellard.org/TinyGL/>`__ is a subset of OpenGL.
118
119`SoftGL <https://sourceforge.net/projects/softgl/>`__ is an OpenGL
120subset for mobile devices.
121
122`Chromium <http://chromium.sourceforge.net/>`__ isn't a conventional
123OpenGL implementation (it's layered upon OpenGL), but it does export the
124OpenGL API. It allows tiled rendering, sort-last rendering, etc.
125
126`ClosedGL <http://www.ticalc.org/archives/files/fileinfo/361/36173.html>`__
127is an OpenGL subset library for TI graphing calculators.
128
129There may be other open OpenGL implementations, but Mesa is the most
130popular and feature-complete.
131
132.. _part2:
133
1342. Compilation and Installation Problems
135----------------------------------------
136
1372.1 What's the easiest way to install Mesa?
138~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139
140If you're using a Linux-based system, your distro CD most likely already
141has Mesa packages (like RPM or DEB) which you can easily install.
142
1432.2 I get undefined symbols such as bgnpolygon, v3f, etc...
144~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
145
146You're application is written in IRIS GL, not OpenGL. IRIS GL was the
147predecessor to OpenGL and is a different thing (almost) entirely. Mesa's
148not the solution.
149
1502.3 Where is the GLUT library?
151~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152
153GLUT (OpenGL Utility Toolkit) is no longer in the separate
154``MesaGLUT-x.y.z.tar.gz`` file. If you don't already have GLUT
155installed, you should grab
156`freeglut <http://freeglut.sourceforge.net/>`__.
157
1582.4 Where is the GLw library?
159~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160
161GLw (OpenGL widget library) is now available from a separate `git
162repository <https://gitlab.freedesktop.org/mesa/glw>`__. Unless you're
163using very old Xt/Motif applications with OpenGL, you shouldn't need it.
164
1652.5 What's the proper place for the libraries and headers?
166----------------------------------------------------------
167
168On Linux-based systems you'll want to follow the `Linux
169ABI <https://www.khronos.org/registry/OpenGL/ABI/>`__ standard.
170Basically you'll want the following:
171
172``/usr/include/GL/gl.h``
173 the main OpenGL header
174``/usr/include/GL/glu.h``
175 the OpenGL GLU (utility) header
176``/usr/include/GL/glx.h``
177 the OpenGL GLX header
178``/usr/include/GL/glext.h``
179 the OpenGL extensions header
180``/usr/include/GL/glxext.h``
181 the OpenGL GLX extensions header
182``/usr/include/GL/osmesa.h``
183 the Mesa off-screen rendering header
184``/usr/lib/libGL.so``
185 a symlink to ``libGL.so.1``
186``/usr/lib/libGL.so.1``
187 a symlink to ``libGL.so.1.xyz``
188``/usr/lib/libGL.so.xyz``
189 the actual OpenGL/Mesa library. xyz denotes the Mesa version number.
190
191When configuring Mesa, there are three meson options that affect the
192install location that you should take care with: ``--prefix``,
193``--libdir``, and ``-D dri-drivers-path``. To install Mesa into the
194system location where it will be available for all programs to use, set
195``--prefix=/usr``. Set ``--libdir`` to where your Linux distribution
196installs system libraries, usually either ``/usr/lib`` or
197``/usr/lib64``. Set ``-D dri-drivers-path`` to the directory where your
198Linux distribution installs DRI drivers. To find your system's DRI
199driver directory, try executing ``find /usr -type d -name dri``. For
200example, if the ``find`` command listed ``/usr/lib64/dri``, then set
201``-D dri-drivers-path=/usr/lib64/dri``.
202
203After determining the correct values for the install location, configure
204Mesa with
205``meson configure --prefix=/usr --libdir=xxx -D dri-drivers-path=xxx``
206and then install with ``sudo ninja install``.
207
208.. _part3:
209
2103. Runtime / Rendering Problems
211-------------------------------
212
2133.1 Rendering is slow / why isn't my graphics hardware being used?
214~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
215
216If Mesa can't use its hardware accelerated drivers it falls back on one
217of its software renderers. (eg. classic swrast, softpipe or llvmpipe)
218
219You can run the ``glxinfo`` program to learn about your OpenGL library.
220Look for the ``OpenGL vendor`` and ``OpenGL renderer`` values. That will
221identify who's OpenGL library with which driver you're using and what
222sort of hardware it has detected.
223
224If you're using a hardware accelerated driver you want
225``direct rendering: Yes``.
226
227If your DRI-based driver isn't working, go to the `DRI
228website <https://dri.freedesktop.org/>`__ for trouble-shooting
229information.
230
2313.2 I'm seeing errors in depth (Z) buffering. Why?
232~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
233
234Make sure the ratio of the far to near clipping planes isn't too great.
235Look
236`here <https://www.opengl.org/archives/resources/faq/technical/depthbuffer.htm#0040>`__
237for details.
238
239Mesa uses a 16-bit depth buffer by default which is smaller and faster
240to clear than a 32-bit buffer but not as accurate. If you need a deeper
241you can modify the parameters to ``glXChooseVisual`` in your code.
242
2433.3 Why Isn't depth buffering working at all?
244~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
245
246Be sure you're requesting a depth buffered-visual. If you set the
247``MESA_DEBUG`` environment variable it will warn you about trying to
248enable depth testing when you don't have a depth buffer.
249
250Specifically, make sure ``glutInitDisplayMode`` is being called with
251``GLUT_DEPTH`` or ``glXChooseVisual`` is being called with a non-zero
252value for ``GLX_DEPTH_SIZE``.
253
254This discussion applies to stencil buffers, accumulation buffers and
255alpha channels too.
256
2573.4 Why does ``glGetString()`` always return ``NULL``?
258~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
259
260Be sure you have an active/current OpenGL rendering context before
261calling ``glGetString``.
262
2633.5 ``GL_POINTS`` and ``GL_LINES`` don't touch the right pixels
264~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
265
266If you're trying to draw a filled region by using ``GL_POINTS`` or
267``GL_LINES`` and seeing holes or gaps it's because of a float-to-int
268rounding problem. But this is not a bug. See Appendix H of the OpenGL
269Programming Guide - "OpenGL Correctness Tips". Basically, applying a
270translation of (0.375, 0.375, 0.0) to your coordinates will fix the
271problem.
272
273.. _part4:
274
2754. Developer Questions
276----------------------
277
2784.1 How can I contribute?
279~~~~~~~~~~~~~~~~~~~~~~~~~
280
281First, join the `mesa-dev mailing list <lists.html>`__. That's where
282Mesa development is discussed.
283
284The `OpenGL Specification <https://www.opengl.org/documentation>`__ is
285the bible for OpenGL implementation work. You should read it.
286
287Most of the Mesa development work involves implementing new OpenGL
288extensions, writing hardware drivers (for the DRI), and code
289optimization.
290
2914.2 How do I write a new device driver?
292~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
293
294Unfortunately, writing a device driver isn't easy. It requires detailed
295understanding of OpenGL, the Mesa code, and your target
296hardware/operating system. 3D graphics are not simple.
297
298The best way to get started is to use an existing driver as your
299starting point. For a classic hardware driver, the i965 driver is a good
300example. For a Gallium3D hardware driver, the r300g, r600g and the i915g
301are good examples.
302
303The DRI website has more information about writing hardware drivers. The
304process isn't well document because the Mesa driver interface changes
305over time, and we seldom have spare time for writing documentation. That
306being said, many people have managed to figure out the process.
307
308Joining the appropriate mailing lists and asking questions (and
309searching the archives) is a good way to get information.
310
3114.3 Why isn't ``GL_EXT_texture_compression_s3tc`` implemented in Mesa?
312~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
313
314Oh but it is! Prior to 2nd October 2017, the Mesa project did not
315include s3tc support due to intellectual property (IP) and/or patent
316issues around the s3tc algorithm.
317
318As of Mesa 17.3.0, Mesa now officially supports s3tc, as the patent has
319expired.
320
321In versions prior to this, a 3rd party `plug-in
322library <https://dri.freedesktop.org/wiki/S3TC>`__ was required.