blob: 1fc7746a834a7a0d52317cf405b729dd6120ddc7 [file] [log] [blame]
José Fonseca9285f152009-08-10 12:35:16 +01001LLVMPIPE -- a fork of softpipe that employs LLVM for code generation.
2
3
4Requirements
5============
6
José Fonsecada1c4022009-11-26 11:15:08 +00007 - A x86 or amd64 processor. 64bit mode is preferred.
8
9 Support for sse2 is strongly encouraged. Support for ssse3, and sse4.1 will
10 yield the most efficient code. The less features the CPU has the more
11 likely is that you ran into underperforming, buggy, or incomplete code.
12
13 See /proc/cpuinfo to know what your CPU supports.
José Fonseca818d4442009-08-16 11:50:17 +010014
José Fonsecae6314db2011-03-13 19:24:26 +000015 - LLVM. Version 2.8 recommended. 2.6 or later required.
José Fonseca818d4442009-08-16 11:50:17 +010016
José Fonseca12576552010-01-10 18:37:07 +000017 For Linux, on a recent Debian based distribution do:
José Fonseca9285f152009-08-10 12:35:16 +010018
19 aptitude install llvm-dev
José Fonseca19b31d02009-08-10 15:43:04 +010020
José Fonseca12576552010-01-10 18:37:07 +000021 For Windows download pre-built MSVC 9.0 or MinGW binaries from
22 http://people.freedesktop.org/~jrfonseca/llvm/ and set the LLVM environment
23 variable to the extracted path.
José Fonseca19b31d02009-08-10 15:43:04 +010024
José Fonsecaf379e7d2010-05-13 16:18:05 +010025 For MSVC there are two set of binaries: llvm-x.x-msvc32mt.7z and
26 llvm-x.x-msvc32mtd.7z .
27
28 You have to set the LLVM=/path/to/llvm-x.x-msvc32mtd env var when passing
29 debug=yes to scons, and LLVM=/path/to/llvm-x.x-msvc32mt when building with
30 debug=no. This is necessary as LLVM builds as static library so the chosen
31 MS CRT must match.
32
José Fonseca8bf4e5d2009-11-24 16:01:01 +000033 - scons (optional)
José Fonseca9285f152009-08-10 12:35:16 +010034
35
36Building
37========
38
José Fonseca12576552010-01-10 18:37:07 +000039To build everything on Linux invoke scons as:
José Fonseca9285f152009-08-10 12:35:16 +010040
José Fonseca601498a2010-11-01 13:30:22 +000041 scons build=debug libgl-xlib
José Fonseca9285f152009-08-10 12:35:16 +010042
José Fonseca5811ed82009-08-22 22:26:55 +010043Alternatively, you can build it with GNU make, if you prefer, by invoking it as
44
45 make linux-llvm
46
José Fonseca1fc41002009-09-11 11:24:00 +010047but the rest of these instructions assume that scons is used.
José Fonseca5811ed82009-08-22 22:26:55 +010048
José Fonseca12576552010-01-10 18:37:07 +000049For windows is everything the except except the winsys:
50
José Fonseca601498a2010-11-01 13:30:22 +000051 scons build=debug libgl-gdi
José Fonseca9285f152009-08-10 12:35:16 +010052
53Using
54=====
55
José Fonseca601498a2010-11-01 13:30:22 +000056On Linux, building will create a drop-in alternative for libGL.so into
José Fonseca9285f152009-08-10 12:35:16 +010057
José Fonseca601498a2010-11-01 13:30:22 +000058 build/foo/gallium/targets/libgl-xlib/libGL.so
José Fonseca9285f152009-08-10 12:35:16 +010059
José Fonseca601498a2010-11-01 13:30:22 +000060To use it set the LD_LIBRARY_PATH environment variable accordingly.
José Fonseca5811ed82009-08-22 22:26:55 +010061
José Fonseca1fc41002009-09-11 11:24:00 +010062For performance evaluation pass debug=no to scons, and use the corresponding
63lib directory without the "-debug" suffix.
64
José Fonseca12576552010-01-10 18:37:07 +000065On Windows, building will create a drop-in alternative for opengl32.dll. To use
66it put it in the same directory as the application. It can also be used by
67replacing the native ICD driver, but it's quite an advanced usage, so if you
68need to ask, don't even try it.
69
José Fonseca9285f152009-08-10 12:35:16 +010070
José Fonseca388c9412010-09-21 17:50:30 +010071Profiling
72=========
73
74To profile llvmpipe you should pass the options
75
José Fonseca601498a2010-11-01 13:30:22 +000076 scons build=profile <same-as-before>
José Fonseca388c9412010-09-21 17:50:30 +010077
78This will ensure that frame pointers are used both in C and JIT functions, and
79that no tail call optimizations are done by gcc.
80
81
82To better profile JIT code you'll need to build LLVM with oprofile integration.
83
José Fonsecae6314db2011-03-13 19:24:26 +000084 ./configure \
José Fonseca388c9412010-09-21 17:50:30 +010085 --prefix=$install_dir \
86 --enable-optimized \
87 --disable-profiling \
88 --enable-targets=host-only \
89 --with-oprofile
90
91 make -C "$build_dir"
92 make -C "$build_dir" install
93
94 find "$install_dir/lib" -iname '*.a' -print0 | xargs -0 strip --strip-debug
95
96The you should define
97
98 export LLVM=/path/to/llvm-2.6-profile
99
100and rebuild.
101
102
José Fonseca9285f152009-08-10 12:35:16 +0100103Unit testing
104============
105
106Building will also create several unit tests in
107build/linux-???-debug/gallium/drivers/llvmpipe:
108
109 - lp_test_blend: blending
110 - lp_test_conv: SIMD vector conversion
111 - lp_test_format: pixel unpacking/packing
112
José Fonseca1fc41002009-09-11 11:24:00 +0100113Some of this tests can output results and benchmarks to a tab-separated-file
José Fonseca89146cd2009-08-20 10:21:49 +0100114for posterior analysis, e.g.:
115
José Fonseca5811ed82009-08-22 22:26:55 +0100116 build/linux-x86_64-debug/gallium/drivers/llvmpipe/lp_test_blend -o blend.tsv
José Fonseca9285f152009-08-10 12:35:16 +0100117
José Fonsecac5531f52009-08-21 10:57:48 +0100118
119Development Notes
120=================
121
José Fonseca5811ed82009-08-22 22:26:55 +0100122- When looking to this code by the first time start in lp_state_fs.c, and
123 then skim through the lp_bld_* functions called in there, and the comments
124 at the top of the lp_bld_*.c functions.
125
Brian Pauld0b35352010-03-15 11:46:41 -0600126- The driver-independent parts of the LLVM / Gallium code are found in
127 src/gallium/auxiliary/gallivm/. The filenames and function prefixes
128 need to be renamed from "lp_bld_" to something else though.
José Fonseca5811ed82009-08-22 22:26:55 +0100129
José Fonsecac5531f52009-08-21 10:57:48 +0100130- We use LLVM-C bindings for now. They are not documented, but follow the C++
131 interfaces very closely, and appear to be complete enough for code
132 generation. See
133 http://npcontemplation.blogspot.com/2008/06/secret-of-llvm-c-bindings.html
José Fonseca601498a2010-11-01 13:30:22 +0000134 for a stand-alone example. See the llvm-c/Core.h file for reference.