0c3f00fd58f89b69b57821c803a37d00f3b7c3aa
[mesa.git] / src / gallium / drivers / llvmpipe / README
1 LLVMPIPE -- a fork of softpipe that employs LLVM for code generation.
2
3
4 Status
5 ======
6
7 Done so far is:
8
9 - the whole fragment pipeline is code generated in a single function
10
11 - input interpolation
12
13 - depth testing
14
15 - texture sampling (not all state/formats are supported)
16
17 - fragment shader TGSI translation
18 - same level of support as the TGSI SSE2 exec machine, with the exception
19 we don't fallback to TGSI interpretation when an unsupported opcode is
20 found, but just ignore it
21 - done in SoA layout
22 - input interpolation also code generated
23
24 - alpha testing
25
26 - blend (including logic ops)
27 - both in SoA and AoS layouts, but only the former used for now
28
29 - code is generic
30 - intermediates can be vectors of floats, ubytes, fixed point, etc, and of
31 any width and length
32 - not all operations are implemented for these types yet though
33
34 Most mesa/progs/demos/* work.
35
36 To do (probably by this order):
37
38 - code generate stipple and stencil testing
39
40 - translate the remaining bits of texture sampling state
41
42 - translate TGSI control flow instructions, and all other remaining opcodes
43
44 - integrate with the draw module for VS code generation
45
46 - code generate the triangle setup and rasterization
47
48
49 Requirements
50 ============
51
52 - Linux
53
54 - A x86 or amd64 processor. 64bit mode is preferred.
55
56 Support for sse2 is strongly encouraged. Support for ssse3, and sse4.1 will
57 yield the most efficient code. The less features the CPU has the more
58 likely is that you ran into underperforming, buggy, or incomplete code.
59
60 See /proc/cpuinfo to know what your CPU supports.
61
62 - LLVM 2.5 or greater. LLVM 2.6 is preferred.
63
64 On Debian based distributions do:
65
66 aptitude install llvm-dev
67
68 There is a typo in one of the llvm 2.5 headers, that may cause compilation
69 errors. To fix it apply the change:
70
71 --- /usr/include/llvm-c/Core.h.orig 2009-08-10 15:38:54.000000000 +0100
72 +++ /usr/include/llvm-c/Core.h 2009-08-10 15:38:25.000000000 +0100
73 @@ -831,7 +831,7 @@
74 template<typename T>
75 inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
76 #if DEBUG
77 - for (LLVMValueRef *I = Vals, E = Vals + Length; I != E; ++I)
78 + for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I)
79 cast<T>(*I);
80 #endif
81 return reinterpret_cast<T**>(Vals);
82
83 - scons (optional)
84
85 - udis86, http://udis86.sourceforge.net/ (optional):
86
87 git clone git://udis86.git.sourceforge.net/gitroot/udis86/udis86
88 cd udis86
89 ./autogen.sh
90 ./configure --with-pic
91 make
92 sudo make install
93
94
95 Building
96 ========
97
98 To build everything invoke scons as:
99
100 scons debug=yes statetrackers=mesa drivers=llvmpipe winsys=xlib dri=false -k
101
102 Alternatively, you can build it with GNU make, if you prefer, by invoking it as
103
104 make linux-llvm
105
106 but the rest of these instructions assume that scons is used.
107
108
109 Using
110 =====
111
112 Building will create a drop-in alternative for libGL.so. To use it set the
113 environment variables:
114
115 export LD_LIBRARY_PATH=$PWD/build/linux-x86_64-debug/lib:$LD_LIBRARY_PATH
116
117 or
118
119 export LD_LIBRARY_PATH=$PWD/build/linux-x86-debug/lib:$LD_LIBRARY_PATH
120
121 For performance evaluation pass debug=no to scons, and use the corresponding
122 lib directory without the "-debug" suffix.
123
124
125 Unit testing
126 ============
127
128 Building will also create several unit tests in
129 build/linux-???-debug/gallium/drivers/llvmpipe:
130
131 - lp_test_blend: blending
132 - lp_test_conv: SIMD vector conversion
133 - lp_test_format: pixel unpacking/packing
134
135 Some of this tests can output results and benchmarks to a tab-separated-file
136 for posterior analysis, e.g.:
137
138 build/linux-x86_64-debug/gallium/drivers/llvmpipe/lp_test_blend -o blend.tsv
139
140
141 Development Notes
142 =================
143
144 - When looking to this code by the first time start in lp_state_fs.c, and
145 then skim through the lp_bld_* functions called in there, and the comments
146 at the top of the lp_bld_*.c functions.
147
148 - All lp_bld_*.[ch] are isolated from the rest of the driver, and could/may be
149 put in a stand-alone Gallium state -> LLVM IR translation module.
150
151 - We use LLVM-C bindings for now. They are not documented, but follow the C++
152 interfaces very closely, and appear to be complete enough for code
153 generation. See
154 http://npcontemplation.blogspot.com/2008/06/secret-of-llvm-c-bindings.html
155 for a stand-alone example.