-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild-linux.html
More file actions
326 lines (326 loc) · 14 KB
/
build-linux.html
File metadata and controls
326 lines (326 loc) · 14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="description" content=
"OpenSWR : A High Performance, Highly Scalable software OpenGL implementation">
<link rel="stylesheet" type="text/css" media="screen" href=
"stylesheets/stylesheet.css">
<title>OpenSWR</title>
</head>
<body>
<!-- HEADER -->
<div id="header_wrap" class="outer">
<header class="inner">
<a id="mesa_banner" href=
"https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/swr">
View source in Mesa</a> <a href="index.html">
<h1 id="project_title">OpenSWR</h1></a> <a href=
"index.html">
<h2 id="project_tagline">A High Performance, Highly
Scalable Software Rasterizer for OpenGL</h2></a>
<nav>
<ul class="navbar">
<li class="navbar">
<a href="index.html">Overview</a>
</li>
<li class="navbar active">
<a href="index.html#build">Build</a>
</li>
<li class="navbar">
<a href="gallery.html">Gallery</a>
</li>
<li class="navbar">
<a href="perf.html">Performance</a>
</li>
<li class="navbar" style="float:right">
<a href="contact.html">Contact</a>
</li>
</ul>
</nav>
</header>
</div><!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<h2>Latest Linux Build Instructions</h2>
<div class="note">
<h6>NOTE</h6>
<p><b>Update: March 28, 2022. These are the latest
instructions for Linux OS.</b></p>
<p>For Mesa 19.x see the <a href=
"build-linux-2020.html">latest Linux OS
instructions</a>.</p>
<p>Previous versions—18.3.4 and older—used GNU
Autotools. If you are using a previous version
please click <a href=
"build-linux-autotools.html">here</a>.</p>
</div>
<p>These instructions describe how to build OpenSWR
within Mesa for Linux OS. The build uses the Meson
build system with Ninja, as described in Mesa's
<a href="http://www.mesa3d.org/meson.html">Meson
installation page</a>. OpenSWR is built in Mesa with
the addition of <code>swr</code> to the list of gallium
drivers.</p>
<ol class="toc">
<li class="toc">
<a href="#intro">Introduction</a>
</li>
<li class="toc">
<a href="#setup">Setup</a>
<ol class="toc">
<li class="toc">
<a href="#building-llvm">Building and
Installing LLVM</a>
</li>
</ol>
</li>
<li class="toc">
<a href="#building-openswr">Building Mesa with
OpenSWR</a>
</li>
<li class="toc">
<a href="#using-openswr">Using Mesa with
OpenSWR</a>
</li>
</ol><a name="intro" id="intro">
<h3>Introduction</h3></a>
<p>As of March 2022, OpenSWR has been moved to the
Amber branch of Mesa. This walkthrough uses the Amber
branch (21.3.x), as committed to Mesa 21.3.7. OpenSWR
has been removed from the primary Mesa branch. Thus,
the Mesa 22.x branch and higher has OpenSWR removed.
Review the latest <a href=
"https://cgit.freedesktop.org/mesa/mesa/">Mesa
branches</a> for more information.</p>
<p>The instructions below describe how to compile Mesa
using the Mesa <a href=
"https://docs.mesa3d.org/download.html">released source
tarballs</a>. Compiling directly from the git
repository is more complex and is beyond the scope of
these instructions. If you want to compile from the git
repository and you run into issues, please contact us
directly.</p><a name="setup" id="setup">
<h3>Setup</h3></a>
<p>Mesa requires dependencies to build:</p>
<ul>
<li><code>libtool-bin</code></li>
<li><code>meson</code></li>
<li><code>ninja</code></li>
<li><code>python-pip</code></li>
<li><code>g++</code></li>
<li><code>git</code></li>
<li><code>cmake</code></li>
<li><code>xz-utils</code></li>
<li><code>libx11-dev</code></li>
<li><code>libxext-dev</code></li>
<li><code>x11proto-core-dev</code></li>
<li><code>x11proto-gl-dev</code></li>
<li><code>libglew-dev</code></li>
<li><code>freeglut3-dev</code></li>
<li><code>bison</code></li>
<li><code>flex</code></li>
<li><code>libx11-xcb-dev</code></li>
<li><code>pkg-config</code></li>
<li><code>libxcb-randr0-dev</code></li>
</ul>
<p>as well as the following two Python modules
installed via <code>pip</code>:</p>
<ul>
<li><code>mako</code></li>
<li><code>lxml</code></li>
</ul>
<p>for testing:</p>
<ul>
<li><code>mesa-utils</code></li>
</ul>
<p>Please make sure you install them prior to building.
Refer to Mesa's <a href=
"https://www.mesa3d.org/install.html">installation
page</a> for more information on its
requirements.</p><a name="building-llvm" id=
"building-llvm">
<h4>Building and Installing LLVM</h4></a>
<p>One of the major Mesa requirements is LLVM, but with
some additional flags required at compile time. If you
do not already have LLVM, you will need to build and
install it first. Precompiled releases of LLVM were not
compatable on the walkthrough system. LLVM source is
available as a tarball on the LLVM <a href=
"http://releases.llvm.org/">release download page</a>.
Currently, LLVM version 12.0.1 is recommended. 13.x or
14.x are not recommended and have sighted portability
limitations on the Mesa discussion board. Once
downloaded, use the following steps to build and
install LLVM. In this example we are installing them
locally.</p>
<pre>
$ pwd
/home/openswr/llvm
$ ls
llvm-x.y.z.src.tar.xz
$ tar xJf llvm-x.y.z.src.tar.xz
$ mkdir build
$ cd build
$ cmake -G "Unix Makefiles" \
-D CMAKE_BUILD_TYPE=Release \
-D LLVM_TARGETS_TO_BUILD=X86 \
-D BUILD_SHARED_LIBS=1 \
-D LLVM_ENABLE_RTTI=1 \
-D CMAKE_INSTALL_PREFIX=/home/openswr/.local/ \
../llvm-x.y.z.src
$ make -j `nproc`
$ make install
</pre>If you do not install LLVM locally, make sure
you set your <code>LD_LIBRARY_PATH</code> and <code>PATH</code>
environment variables to include the LLVM <code>lib</code> and
<code>bin</code> directories, respectively.
<pre>
<code>export PATH=/home/openswr/.local/bin:${PATH}</code>
<code>export LD_LIBRARY_PATH=/home/openswr/.local/lib:${LD_LIBRARY_PATH}</code>
</pre><a name="building-openswr" id=
"building-openswr">
<h3>Building Mesa with OpenSWR</h3></a>
<p>Download a Mesa source distribution from Mesa's
<a href="http://www.mesa3d.org/download.html">download
page</a>. We recommend the latest non-release-candidate
version for the best compatibility.</p>
<p>Once downloaded, use the following steps to build
Mesa with OpenSWR.</p>
<pre>
$ pwd
/home/openswr/mesa
$ ls
mesa-x.y.z.tar.gz
$ tar xf mesa-x.y.z.tar.gz
$ cd mesa-x.y.z
$ mkdir build
</pre>
<p>Now we can configure Mesa with OpenSWR. In this
example, we are installing Mesa locally.</p>
<pre>
$ meson --buildtype=release \
-Dglx=gallium-xlib \
-Dvulkan-drivers= \
-Ddri-drivers= \
-Dgallium-drivers=swrast,swr \
-Dplatforms=x11 \
-Dgallium-omx=disabled \
-Dprefix=/home/openswr/.local \
build
</pre>
<p>If you also want to compile OSMesa (off-screen
rendering support), please add the following flag:</p>
<pre>
-Dosmesa=gallium
</pre>
<p>By default, the build will compile with support for
AVX and AVX2 targets. If you want to also compile for
Skylake and/or Knight's Landing architectures (AVX512),
please add the following flag. Make sure your compiler
supports the necessary compiler flags to compile for
the specified architectures.</p>
<pre>
-Dswr-arches=avx,avx2,skx,knl
</pre>
<p>Check <a href="https://ark.intel.com">the ark
processor database</a> for architecture information for
your target CPU SKUs</p>
<p>Once configured, you can use <code>ninja</code> to
build Mesa.</p>
<pre>
$ ninja -C build
</pre>
<p>And you can use <code>meson</code> to install.</p>
<pre>
$ meson install -C build
</pre>
<p>Once installed, you will see <code>libGL.so</code>,
<code>libOSMesa.so</code> (if it was enabled), and
<code>libSWR<arch>.so</code> for each
architecture selected.</p><a name="using-openswr" id=
"using-openswr">
<h3>Using Mesa with OpenSWR</h3></a>
<p>If you installed Mesa with OpenSWR to a local
directory as in the examples above, it should already
be usable by applications. If you installed elsewhere,
you will need to include the path in your
<code>LD_LIBRARY_PATH</code> environment variable. Make
sure you specifically add the <code>lib</code> or
<code>lib/gallium</code> directory to
<code>LD_LIBRARY_PATH</code>. You will also need the
LLVM <code>lib</code> directory appended to your
LD_LIBRARY_PATH if it is not present already.</p>
<pre>
$ export LD_LIBRARY_PATH=/your/path/to/mesa/lib:/your/path/to/llvm/lib:${LD_LIBRARY_PATH}
</pre>
<p>Now any application seeking GL will use the Mesa
installation. To enable the OpenSWR driver, you need to
specify it with the <code>GALLIUM_DRIVER</code>
environment variable:</p>
<pre>
$ export GALLIUM_DRIVER=swr
</pre>
<p>You can verify that OpenSWR is used for rendering
using the following command:</p>
<pre>
$ glxinfo | grep "OpenGL\ renderer\ string"
OpenGL renderer string: SWR (LLVM 12.0.1, 256 bits)
</pre>
<p>Instrument OpenSWR-based applications with useful
environment variables. In particular, review the
<code>GALLIUM_</code> prefixed variables. Refer to the
<a href=
"https://docs.mesa3d.org/envvars.html">enviornment
variable document</a> on mesa3d.org for details on
variables like:</p>
<pre><code>GALLIUM_HUD
GALLIUM_LOG_FILE
GALLIUM_PRINT_OPTIONS
GALLIUM_DUMP_CPU
LIBGL_ALWAYS_SOFTWARE
</code></pre>
<p>To send any runtime information to stderr, ensure
GALLIUM_PRINT_OPTIONS is set!:</p>
<pre><code>export GALLIUM_PRINT_OPTIONS=1</code></pre>
<p><code>SWR_PRINT_INFO</code> can cause the runtime to
emit SWR status. Documentation is limited since OpenSWR
has moved to the Amber Branch. You may set it before
running a program:</p>
<pre><code>export SWR_PRINT_INFO=1
</code></pre>
<p>Look for a message like:</p>
<pre>
<code>SWR detected AVX2 instruction support (using: libswrAVX2.so).</code></pre>
<p><strong>Hello GL Quickstart</strong></p>
<p>Many users employ <code>glxgears</code> and
<code>glxinfo</code> from the Mesa demos repository to
check that their distribution of Mesa is running.
<code>glxinfo</code> and <code>glxgears</code> are
found in the <code>mesa-utils</code> package. View the
Mesa <a href=
"https://gitlab.freedesktop.org/mesa/demos">demos</a>
for more information.</p>
<p>Note: The performance advantages of OpenSWR tend to
be realized in scenes with much more geometry than
<code>glxgears</code>.</p><br>
<!-- FOOTER -->
<div id="footer_wrap" class="outer">
<footer class="inner">
<p class="copyright">OpenSWR maintained by
<a href=
"https://github.com/OpenSWR">OpenSWR</a><br>
For information about compiler optimizations,
see our <a href=
"https://software.intel.com/en-us/articles/optimization-notice#opt-en">
Optimization Notice</a>.<br>
©2009-2022 Intel Corporation<br>
<a href=
"https://www.intel.com/privacy">Privacy</a></p>
</footer>
</div>
</section>
</div>
</body>
</html>