1848b8605Smrg<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2848b8605Smrg<html lang="en">
3848b8605Smrg<head>
4848b8605Smrg  <meta http-equiv="content-type" content="text/html; charset=utf-8">
5848b8605Smrg  <title>Mesa FAQ</title>
6848b8605Smrg  <link rel="stylesheet" type="text/css" href="mesa.css">
7848b8605Smrg</head>
8848b8605Smrg<body>
9848b8605Smrg
10848b8605Smrg<div class="header">
11848b8605Smrg  <h1>The Mesa 3D Graphics Library</h1>
12848b8605Smrg</div>
13848b8605Smrg
14848b8605Smrg<iframe src="contents.html"></iframe>
15848b8605Smrg<div class="content">
16848b8605Smrg
17848b8605Smrg<h1>Mesa Frequently Asked Questions</h1>
18b8e80941SmrgLast updated: 19 September 2018
19848b8605Smrg
20848b8605Smrg<br>
21848b8605Smrg<br>
22848b8605Smrg<h2>Index</h2>
23b8e80941Smrg<ol>
24b8e80941Smrg  <li><a href="#part1">High-level Questions and Answers</a></li>
25b8e80941Smrg  <li><a href="#part2">Compilation and Installation Problems</a></li>
26b8e80941Smrg  <li><a href="#part3">Runtime / Rendering Problems</a></li>
27b8e80941Smrg  <li><a href="#part4">Developer Questions</a></li>
28b8e80941Smrg</ol>
29848b8605Smrg<br>
30848b8605Smrg<br>
31848b8605Smrg
32848b8605Smrg
33848b8605Smrg
34848b8605Smrg<h1 id="part1">1. High-level Questions and Answers</h1>
35848b8605Smrg
36848b8605Smrg<h2>1.1 What is Mesa?</h2>
37848b8605Smrg<p>
38848b8605SmrgMesa is an open-source implementation of the OpenGL specification.
39848b8605SmrgOpenGL is a programming library for writing interactive 3D applications.
40b8e80941SmrgSee the <a href="https://www.opengl.org/">OpenGL website</a> for more
41848b8605Smrginformation.
42848b8605Smrg</p>
43848b8605Smrg<p>
44848b8605SmrgMesa 9.x supports the OpenGL 3.1 specification.
45848b8605Smrg</p>
46848b8605Smrg
47848b8605Smrg
48848b8605Smrg<h2>1.2 Does Mesa support/use graphics hardware?</h2>
49848b8605Smrg<p>
50848b8605SmrgYes.  Specifically, Mesa serves as the OpenGL core for the open-source DRI
51848b8605Smrgdrivers for X.org.
52848b8605Smrg</p>
53848b8605Smrg<ul>
54b8e80941Smrg  <li>See the <a href="https://dri.freedesktop.org/">DRI website</a>
55848b8605Smrg  for more information.</li>
56b8e80941Smrg  <li>See <a href="https://01.org/linuxgraphics">01.org</a>
57848b8605Smrg  for more information about Intel drivers.</li>
58b8e80941Smrg  <li>See <a href="https://nouveau.freedesktop.org">nouveau.freedesktop.org</a>
59848b8605Smrg  for more information about Nouveau drivers.</li>
60b8e80941Smrg  <li>See <a href="https://www.x.org/wiki/RadeonFeature">www.x.org/wiki/RadeonFeature</a>
61848b8605Smrg  for more information about Radeon drivers.</li>
62848b8605Smrg</ul>
63848b8605Smrg
64848b8605Smrg<h2>1.3 What purpose does Mesa serve today?</h2>
65848b8605Smrg<p>
66848b8605SmrgHardware-accelerated OpenGL implementations are available for most popular
67848b8605Smrgoperating systems today.
68848b8605SmrgStill, Mesa serves at least these purposes:
69848b8605Smrg</p>
70848b8605Smrg<ul>
71848b8605Smrg<li>Mesa is used as the core of the open-source X.org DRI
72848b8605Smrg    hardware drivers.
73848b8605Smrg</li>
74848b8605Smrg<li>Mesa is quite portable and allows OpenGL to be used on systems
75848b8605Smrg    that have no other OpenGL solution.
76848b8605Smrg</li>
77848b8605Smrg<li>Software rendering with Mesa serves as a reference for validating the
78848b8605Smrg    hardware drivers.
79848b8605Smrg</li>
80848b8605Smrg<li>A software implementation of OpenGL is useful for experimentation,
81848b8605Smrg    such as testing new rendering techniques.
82848b8605Smrg</li>
83848b8605Smrg<li>Mesa can render images with deep color channels: 16-bit integer
84848b8605Smrg    and 32-bit floating point color channels are supported.
85848b8605Smrg    This capability is only now appearing in hardware.
86848b8605Smrg</li>
87848b8605Smrg<li>Mesa's internal limits (max lights, clip planes, texture size, etc) can be
88848b8605Smrg    changed for special needs (hardware limits are hard to overcome).
89848b8605Smrg</li>
90848b8605Smrg</ul>
91848b8605Smrg
92848b8605Smrg
93848b8605Smrg<h2>1.4 What's the difference between "Stand-Alone" Mesa and the DRI drivers?</h2>
94848b8605Smrg<p>
95848b8605Smrg<em>Stand-alone Mesa</em> is the original incarnation of Mesa.
96848b8605SmrgOn systems running the X Window System it does all its rendering through
97848b8605Smrgthe Xlib API:
98848b8605Smrg</p>
99848b8605Smrg<ul>
100848b8605Smrg<li>The GLX API is supported, but it's really just an emulation of the
101848b8605Smrg     real thing.
102848b8605Smrg<li>The GLX wire protocol is not supported and there's no OpenGL extension
103848b8605Smrg    loaded by the X server.
104848b8605Smrg<li>There is no hardware acceleration.
105848b8605Smrg<li>The OpenGL library, libGL.so, contains everything (the programming API,
106848b8605Smrg    the GLX functions and all the rendering code).
107848b8605Smrg</ul>
108848b8605Smrg<p>
109848b8605SmrgAlternately, Mesa acts as the core for a number of OpenGL hardware drivers
110848b8605Smrgwithin the DRI (Direct Rendering Infrastructure):
111848b8605Smrg<ul>
112848b8605Smrg<li>The libGL.so library provides the GL and GLX API functions, a GLX
113848b8605Smrg    protocol encoder, and a device driver loader.
114848b8605Smrg<li>The device driver modules (such as r200_dri.so) contain a built-in
115848b8605Smrg    copy of the core Mesa code.
116848b8605Smrg<li>The X server loads the GLX module.
117848b8605Smrg    The GLX module decodes incoming GLX protocol and dispatches the commands
118848b8605Smrg    to a rendering module.
119848b8605Smrg    For the DRI, this module is basically a software Mesa renderer.
120848b8605Smrg</ul>
121848b8605Smrg
122848b8605Smrg
123848b8605Smrg
124848b8605Smrg<h2>1.5 How do I upgrade my DRI installation to use a new Mesa release?</h2>
125848b8605Smrg<p>
126848b8605SmrgThis wasn't easy in the past.
127848b8605SmrgNow, the DRI drivers are included in the Mesa tree and can be compiled
128848b8605Smrgseparately from the X server.
129848b8605SmrgJust follow the Mesa <a href="install.html">compilation instructions</a>.
130848b8605Smrg</p>
131848b8605Smrg
132848b8605Smrg
133848b8605Smrg<h2>1.6 Are there other open-source implementations of OpenGL?</h2>
134848b8605Smrg<p>
135848b8605SmrgYes, SGI's <a href="http://oss.sgi.com/projects/ogl-sample/index.html">
136848b8605SmrgOpenGL Sample Implementation (SI)</a> is available.
137848b8605SmrgThe SI was written during the time that OpenGL was originally designed.
138848b8605SmrgUnfortunately, development of the SI has stagnated.
139848b8605SmrgMesa is much more up to date with modern features and extensions.
140848b8605Smrg</p>
141848b8605Smrg
142848b8605Smrg<p>
143b8e80941Smrg<a href="https://sourceforge.net/projects/ogl-es/">Vincent</a> is
144848b8605Smrgan open-source implementation of OpenGL ES for mobile devices.
145848b8605Smrg
146848b8605Smrg<p>
147848b8605Smrg<a href="http://www.dsbox.com/minigl.html">miniGL</a>
148848b8605Smrgis a subset of OpenGL for PalmOS devices.
149848b8605Smrg
150848b8605Smrg<p>
151848b8605Smrg<a href="http://bellard.org/TinyGL/">TinyGL</a>
152848b8605Smrgis a subset of OpenGL.
153848b8605Smrg</p>
154848b8605Smrg
155848b8605Smrg<p>
156b8e80941Smrg<a href="https://sourceforge.net/projects/softgl/">SoftGL</a>
157848b8605Smrgis an OpenGL subset for mobile devices.
158848b8605Smrg</p>
159848b8605Smrg
160848b8605Smrg<p>
161848b8605Smrg<a href="http://chromium.sourceforge.net/">Chromium</a>
162848b8605Smrgisn't a conventional OpenGL implementation (it's layered upon OpenGL),
163848b8605Smrgbut it does export the OpenGL API.  It allows tiled rendering, sort-last
164848b8605Smrgrendering, etc.
165848b8605Smrg</p>
166848b8605Smrg
167848b8605Smrg<p>
168848b8605Smrg<a href="http://www.ticalc.org/archives/files/fileinfo/361/36173.html">ClosedGL</a>
169848b8605Smrgis an OpenGL subset library for TI graphing calculators.
170848b8605Smrg</p>
171848b8605Smrg
172848b8605Smrg<p>
173848b8605SmrgThere may be other open OpenGL implementations, but Mesa is the most
174848b8605Smrgpopular and feature-complete.
175848b8605Smrg</p>
176848b8605Smrg
177848b8605Smrg
178848b8605Smrg
179848b8605Smrg<br>
180848b8605Smrg<br>
181848b8605Smrg
182848b8605Smrg
183848b8605Smrg<h1 id="part2">2. Compilation and Installation Problems</h1>
184848b8605Smrg
185848b8605Smrg
186848b8605Smrg<h2>2.1 What's the easiest way to install Mesa?</h2>
187848b8605Smrg<p>
188848b8605SmrgIf you're using a Linux-based system, your distro CD most likely already
189848b8605Smrghas Mesa packages (like RPM or DEB) which you can easily install.
190848b8605Smrg</p>
191848b8605Smrg
192848b8605Smrg
193848b8605Smrg<h2>2.2 I get undefined symbols such as bgnpolygon, v3f, etc...</h2>
194848b8605Smrg<p>
195848b8605SmrgYou're application is written in IRIS GL, not OpenGL.
196848b8605SmrgIRIS GL was the predecessor to OpenGL and is a different thing (almost)
197848b8605Smrgentirely.
198848b8605SmrgMesa's not the solution.
199848b8605Smrg</p>
200848b8605Smrg
201848b8605Smrg
202848b8605Smrg<h2>2.3 Where is the GLUT library?</h2>
203848b8605Smrg<p>
204848b8605SmrgGLUT (OpenGL Utility Toolkit) is no longer in the separate MesaGLUT-x.y.z.tar.gz file.
205848b8605SmrgIf you don't already have GLUT installed, you should grab 
206848b8605Smrg<a href="http://freeglut.sourceforge.net/">freeglut</a>.
207848b8605Smrg</p>
208848b8605Smrg
209848b8605Smrg
210848b8605Smrg<h2>2.4 Where is the GLw library?</h2>
211848b8605Smrg<p>
212b8e80941SmrgGLw (OpenGL widget library) is now available from a separate <a href="https://cgit.freedesktop.org/mesa/glw/">git repository</a>.  Unless you're using very old Xt/Motif applications with OpenGL, you shouldn't need it.
213848b8605Smrg</p>
214848b8605Smrg
215848b8605Smrg
216848b8605Smrg<h2>2.5 What's the proper place for the libraries and headers?</h2>
217848b8605Smrg<p>
218848b8605SmrgOn Linux-based systems you'll want to follow the
219848b8605Smrg<a href="http://oss.sgi.com/projects/ogl-sample/ABI/index.html">Linux ABI</a> standard.
220848b8605SmrgBasically you'll want the following:
221848b8605Smrg</p>
222848b8605Smrg<ul>
223848b8605Smrg<li>/usr/include/GL/gl.h - the main OpenGL header
224848b8605Smrg</li><li>/usr/include/GL/glu.h - the OpenGL GLU (utility) header
225848b8605Smrg</li><li>/usr/include/GL/glx.h - the OpenGL GLX header
226848b8605Smrg</li><li>/usr/include/GL/glext.h - the OpenGL extensions header
227848b8605Smrg</li><li>/usr/include/GL/glxext.h - the OpenGL GLX extensions header
228848b8605Smrg</li><li>/usr/include/GL/osmesa.h - the Mesa off-screen rendering header
229848b8605Smrg</li><li>/usr/lib/libGL.so - a symlink to libGL.so.1
230848b8605Smrg</li><li>/usr/lib/libGL.so.1 - a symlink to libGL.so.1.xyz
231848b8605Smrg</li><li>/usr/lib/libGL.so.xyz - the actual OpenGL/Mesa library.  xyz denotes the
232848b8605SmrgMesa version number.
233848b8605Smrg</li></ul>
234848b8605Smrg<p>
235b8e80941SmrgWhen configuring Mesa, there are three meson options that affect the install
236848b8605Smrglocation that you should take care with: <code>--prefix</code>,
237b8e80941Smrg<code>--libdir</code>, and <code>-D dri-drivers-path</code>. To install Mesa
238848b8605Smrginto the system location where it will be available for all programs to use, set
239848b8605Smrg<code>--prefix=/usr</code>. Set <code>--libdir</code> to where your Linux
240848b8605Smrgdistribution installs system libraries, usually either <code>/usr/lib</code> or
241b8e80941Smrg<code>/usr/lib64</code>. Set <code>-D dri-drivers-path</code> to the directory
242848b8605Smrgwhere your Linux distribution installs DRI drivers. To find your system's DRI
243848b8605Smrgdriver directory, try executing <code>find /usr -type d -name dri</code>. For
244848b8605Smrgexample, if the <code>find</code> command listed <code>/usr/lib64/dri</code>,
245b8e80941Smrgthen set <code>-D dri-drivers-path=/usr/lib64/dri</code>.
246848b8605Smrg</p>
247848b8605Smrg<p>
248848b8605SmrgAfter determining the correct values for the install location, configure Mesa
249b8e80941Smrgwith <code>meson configure --prefix=/usr --libdir=xxx -D dri-drivers-path=xxx</code>
250b8e80941Smrgand then install with <code>sudo ninja install</code>.
251848b8605Smrg</p>
252848b8605Smrg<br>
253848b8605Smrg<br>
254848b8605Smrg
255848b8605Smrg
256848b8605Smrg<h1 id="part3">3. Runtime / Rendering Problems</h1>
257848b8605Smrg
258848b8605Smrg<h2>3.1 Rendering is slow / why isn't my graphics hardware being used?</h2>
259848b8605Smrg<p>
260848b8605SmrgIf Mesa can't use its hardware accelerated drivers it falls back on one of its software renderers.
261848b8605Smrg(eg. classic swrast, softpipe or llvmpipe)
262848b8605Smrg</p>
263848b8605Smrg<p>
264848b8605SmrgYou can run the <code>glxinfo</code> program to learn about your OpenGL
265848b8605Smrglibrary.
266848b8605SmrgLook for the <code>OpenGL vendor</code> and <code>OpenGL renderer</code> values.
267848b8605SmrgThat will identify who's OpenGL library with which driver you're using and what sort of
268848b8605Smrghardware it has detected.
269848b8605Smrg</p>
270848b8605Smrg<p>
271848b8605SmrgIf you're using a hardware accelerated driver you want <code>direct rendering: Yes</code>.
272848b8605Smrg</p>
273848b8605Smrg<p>
274848b8605SmrgIf your DRI-based driver isn't working, go to the
275b8e80941Smrg<a href="https://dri.freedesktop.org/">DRI website</a> for trouble-shooting information.
276848b8605Smrg</p>
277848b8605Smrg
278848b8605Smrg
279848b8605Smrg<h2>3.2 I'm seeing errors in depth (Z) buffering.  Why?</h2>
280848b8605Smrg<p>
281848b8605SmrgMake sure the ratio of the far to near clipping planes isn't too great.
282848b8605SmrgLook
283b8e80941Smrg<a href="https://www.opengl.org/resources/faq/technical/depthbuffer.htm#0040">here</a>
284848b8605Smrgfor details.
285848b8605Smrg</p>
286848b8605Smrg<p>
287848b8605SmrgMesa uses a 16-bit depth buffer by default which is smaller and faster
288848b8605Smrgto clear than a 32-bit buffer but not as accurate.
289848b8605SmrgIf you need a deeper you can modify the parameters to
290848b8605Smrg<code> glXChooseVisual</code> in your code.
291848b8605Smrg</p>
292848b8605Smrg
293848b8605Smrg
294848b8605Smrg<h2>3.3 Why Isn't depth buffering working at all?</h2>
295848b8605Smrg<p>
296848b8605SmrgBe sure you're requesting a depth buffered-visual.  If you set the MESA_DEBUG
297848b8605Smrgenvironment variable it will warn you about trying to enable depth testing
298848b8605Smrgwhen you don't have a depth buffer.
299848b8605Smrg</p>
300848b8605Smrg<p>Specifically, make sure <code>glutInitDisplayMode</code> is being called
301848b8605Smrgwith <code>GLUT_DEPTH</code> or <code>glXChooseVisual</code> is being
302848b8605Smrgcalled with a non-zero value for GLX_DEPTH_SIZE.
303848b8605Smrg</p>
304848b8605Smrg<p>This discussion applies to stencil buffers, accumulation buffers and
305848b8605Smrgalpha channels too.
306848b8605Smrg</p>
307848b8605Smrg
308848b8605Smrg
309848b8605Smrg<h2>3.4 Why does glGetString() always return NULL?</h2>
310848b8605Smrg<p>
311848b8605SmrgBe sure you have an active/current OpenGL rendering context before
312848b8605Smrgcalling glGetString.
313848b8605Smrg</p>
314848b8605Smrg
315848b8605Smrg
316848b8605Smrg<h2>3.5 GL_POINTS and GL_LINES don't touch the right pixels</h2>
317848b8605Smrg<p>
318848b8605SmrgIf you're trying to draw a filled region by using GL_POINTS or GL_LINES
319848b8605Smrgand seeing holes or gaps it's because of a float-to-int rounding problem.
320848b8605SmrgBut this is not a bug.
321848b8605SmrgSee Appendix H of the OpenGL Programming Guide - "OpenGL Correctness Tips".
322848b8605SmrgBasically, applying a translation of (0.375, 0.375, 0.0) to your coordinates
323848b8605Smrgwill fix the problem.
324848b8605Smrg</p>
325848b8605Smrg
326848b8605Smrg<br>
327848b8605Smrg<br>
328848b8605Smrg
329848b8605Smrg
330848b8605Smrg<h1 id="part4">4. Developer Questions</h1>
331848b8605Smrg
332848b8605Smrg<h2>4.1 How can I contribute?</h2>
333848b8605Smrg<p>
334848b8605SmrgFirst, join the <a href="lists.html">mesa-dev mailing list</a>.
335848b8605SmrgThat's where Mesa development is discussed.
336848b8605Smrg</p>
337848b8605Smrg<p>
338b8e80941SmrgThe <a href="https://www.opengl.org/documentation">
339848b8605SmrgOpenGL Specification</a> is the bible for OpenGL implementation work.
340848b8605SmrgYou should read it.
341848b8605Smrg</p>
342848b8605Smrg<p>Most of the Mesa development work involves implementing new OpenGL
343848b8605Smrgextensions, writing hardware drivers (for the DRI), and code optimization.
344848b8605Smrg</p>
345848b8605Smrg
346848b8605Smrg<h2>4.2 How do I write a new device driver?</h2>
347848b8605Smrg<p>
348848b8605SmrgUnfortunately, writing a device driver isn't easy.
349848b8605SmrgIt requires detailed understanding of OpenGL, the Mesa code, and your
350848b8605Smrgtarget hardware/operating system.
351848b8605Smrg3D graphics are not simple.
352848b8605Smrg</p>
353848b8605Smrg<p>
354848b8605SmrgThe best way to get started is to use an existing driver as your starting
355848b8605Smrgpoint.
356848b8605SmrgFor a classic hardware driver, the i965 driver is a good example.
357848b8605SmrgFor a Gallium3D hardware driver, the r300g, r600g and the i915g are good examples.
358848b8605Smrg</p>
359848b8605Smrg<p>The DRI website has more information about writing hardware drivers.
360848b8605SmrgThe process isn't well document because the Mesa driver interface changes
361848b8605Smrgover time, and we seldom have spare time for writing documentation.
362848b8605SmrgThat being said, many people have managed to figure out the process.
363848b8605Smrg</p>
364848b8605Smrg<p>
365848b8605SmrgJoining the appropriate mailing lists and asking questions (and searching
366848b8605Smrgthe archives) is a good way to get information.
367848b8605Smrg</p>
368848b8605Smrg
369848b8605Smrg
370848b8605Smrg<h2>4.3 Why isn't GL_EXT_texture_compression_s3tc implemented in Mesa?</h2>
371848b8605Smrg<p>
372b8e80941SmrgOh but it is! Prior to 2nd October 2017, the Mesa project did not include s3tc
373b8e80941Smrgsupport due to intellectual property (IP) and/or patent issues around the s3tc
374b8e80941Smrgalgorithm.
375848b8605Smrg</p>
376b8e80941Smrg<p>
377b8e80941SmrgAs of Mesa 17.3.0, Mesa now officially supports s3tc, as the patent has expired.
378848b8605Smrg</p>
379848b8605Smrg<p>
380b8e80941SmrgIn versions prior to this, a 3rd party <a href="https://dri.freedesktop.org/wiki/S3TC">
381b8e80941Smrgplug-in library</a> was required.
382848b8605Smrg</p>
383848b8605Smrg
384848b8605Smrg</div>
385848b8605Smrg</body>
386848b8605Smrg</html>
387