José Fonseca | 9285f15 | 2009-08-10 12:35:16 +0100 | [diff] [blame] | 1 | LLVMPIPE -- a fork of softpipe that employs LLVM for code generation. |
| 2 | |
| 3 | |
José Fonseca | 8df64bb | 2009-08-18 17:36:13 +0100 | [diff] [blame] | 4 | Status |
| 5 | ====== |
| 6 | |
| 7 | Done so far is: |
| 8 | |
José Fonseca | 5811ed8 | 2009-08-22 22:26:55 +0100 | [diff] [blame] | 9 | - the whole fragment pipeline is code generated in a single function |
| 10 | |
José Fonseca | 1fc4100 | 2009-09-11 11:24:00 +0100 | [diff] [blame] | 11 | - input interpolation |
| 12 | |
José Fonseca | 5811ed8 | 2009-08-22 22:26:55 +0100 | [diff] [blame] | 13 | - depth testing |
| 14 | |
Brian Paul | d0b3535 | 2010-03-15 11:46:41 -0600 | [diff] [blame] | 15 | - texture sampling |
| 16 | - 1D/2D/3D/cube maps supported |
| 17 | - all texture wrap modes supported |
| 18 | - all texture filtering modes supported |
| 19 | - perhaps not all texture formats yet supported |
José Fonseca | 1fc4100 | 2009-09-11 11:24:00 +0100 | [diff] [blame] | 20 | |
José Fonseca | 5811ed8 | 2009-08-22 22:26:55 +0100 | [diff] [blame] | 21 | - fragment shader TGSI translation |
| 22 | - same level of support as the TGSI SSE2 exec machine, with the exception |
| 23 | we don't fallback to TGSI interpretation when an unsupported opcode is |
| 24 | found, but just ignore it |
José Fonseca | 5811ed8 | 2009-08-22 22:26:55 +0100 | [diff] [blame] | 25 | - done in SoA layout |
| 26 | - input interpolation also code generated |
| 27 | |
| 28 | - alpha testing |
| 29 | |
| 30 | - blend (including logic ops) |
| 31 | - both in SoA and AoS layouts, but only the former used for now |
| 32 | |
| 33 | - code is generic |
| 34 | - intermediates can be vectors of floats, ubytes, fixed point, etc, and of |
| 35 | any width and length |
| 36 | - not all operations are implemented for these types yet though |
José Fonseca | 8df64bb | 2009-08-18 17:36:13 +0100 | [diff] [blame] | 37 | |
José Fonseca | 1fc4100 | 2009-09-11 11:24:00 +0100 | [diff] [blame] | 38 | Most mesa/progs/demos/* work. |
José Fonseca | 8df64bb | 2009-08-18 17:36:13 +0100 | [diff] [blame] | 39 | |
| 40 | To do (probably by this order): |
José Fonseca | 5811ed8 | 2009-08-22 22:26:55 +0100 | [diff] [blame] | 41 | |
| 42 | - code generate stipple and stencil testing |
| 43 | |
José Fonseca | 5811ed8 | 2009-08-22 22:26:55 +0100 | [diff] [blame] | 44 | - translate TGSI control flow instructions, and all other remaining opcodes |
José Fonseca | 1fc4100 | 2009-09-11 11:24:00 +0100 | [diff] [blame] | 45 | |
| 46 | - integrate with the draw module for VS code generation |
José Fonseca | 5811ed8 | 2009-08-22 22:26:55 +0100 | [diff] [blame] | 47 | |
| 48 | - code generate the triangle setup and rasterization |
José Fonseca | 8df64bb | 2009-08-18 17:36:13 +0100 | [diff] [blame] | 49 | |
| 50 | |
José Fonseca | 9285f15 | 2009-08-10 12:35:16 +0100 | [diff] [blame] | 51 | Requirements |
| 52 | ============ |
| 53 | |
José Fonseca | da1c402 | 2009-11-26 11:15:08 +0000 | [diff] [blame] | 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. |
José Fonseca | 818d444 | 2009-08-16 11:50:17 +0100 | [diff] [blame] | 61 | |
Brian Paul | d0b3535 | 2010-03-15 11:46:41 -0600 | [diff] [blame] | 62 | - LLVM 2.6 (or later) |
José Fonseca | 818d444 | 2009-08-16 11:50:17 +0100 | [diff] [blame] | 63 | |
José Fonseca | 1257655 | 2010-01-10 18:37:07 +0000 | [diff] [blame] | 64 | For Linux, on a recent Debian based distribution do: |
José Fonseca | 9285f15 | 2009-08-10 12:35:16 +0100 | [diff] [blame] | 65 | |
| 66 | aptitude install llvm-dev |
José Fonseca | 19b31d0 | 2009-08-10 15:43:04 +0100 | [diff] [blame] | 67 | |
José Fonseca | 1257655 | 2010-01-10 18:37:07 +0000 | [diff] [blame] | 68 | For Windows download pre-built MSVC 9.0 or MinGW binaries from |
| 69 | http://people.freedesktop.org/~jrfonseca/llvm/ and set the LLVM environment |
| 70 | variable to the extracted path. |
José Fonseca | 19b31d0 | 2009-08-10 15:43:04 +0100 | [diff] [blame] | 71 | |
José Fonseca | f379e7d | 2010-05-13 16:18:05 +0100 | [diff] [blame^] | 72 | For MSVC there are two set of binaries: llvm-x.x-msvc32mt.7z and |
| 73 | llvm-x.x-msvc32mtd.7z . |
| 74 | |
| 75 | You have to set the LLVM=/path/to/llvm-x.x-msvc32mtd env var when passing |
| 76 | debug=yes to scons, and LLVM=/path/to/llvm-x.x-msvc32mt when building with |
| 77 | debug=no. This is necessary as LLVM builds as static library so the chosen |
| 78 | MS CRT must match. |
| 79 | |
| 80 | The version of LLVM from SVN ("2.7svn") from mid-March 2010 is pretty |
Brian Paul | d0b3535 | 2010-03-15 11:46:41 -0600 | [diff] [blame] | 81 | stable and has some features not in version 2.6. |
| 82 | |
José Fonseca | 8bf4e5d | 2009-11-24 16:01:01 +0000 | [diff] [blame] | 83 | - scons (optional) |
José Fonseca | 9285f15 | 2009-08-10 12:35:16 +0100 | [diff] [blame] | 84 | |
José Fonseca | 8bf4e5d | 2009-11-24 16:01:01 +0000 | [diff] [blame] | 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 | |
José Fonseca | 9285f15 | 2009-08-10 12:35:16 +0100 | [diff] [blame] | 94 | |
| 95 | Building |
| 96 | ======== |
| 97 | |
José Fonseca | 1257655 | 2010-01-10 18:37:07 +0000 | [diff] [blame] | 98 | To build everything on Linux invoke scons as: |
José Fonseca | 9285f15 | 2009-08-10 12:35:16 +0100 | [diff] [blame] | 99 | |
José Fonseca | e243e87 | 2010-02-27 23:49:58 +0000 | [diff] [blame] | 100 | scons debug=yes statetrackers=mesa drivers=llvmpipe winsys=xlib dri=false |
José Fonseca | 9285f15 | 2009-08-10 12:35:16 +0100 | [diff] [blame] | 101 | |
José Fonseca | 5811ed8 | 2009-08-22 22:26:55 +0100 | [diff] [blame] | 102 | Alternatively, you can build it with GNU make, if you prefer, by invoking it as |
| 103 | |
| 104 | make linux-llvm |
| 105 | |
José Fonseca | 1fc4100 | 2009-09-11 11:24:00 +0100 | [diff] [blame] | 106 | but the rest of these instructions assume that scons is used. |
José Fonseca | 5811ed8 | 2009-08-22 22:26:55 +0100 | [diff] [blame] | 107 | |
José Fonseca | 1257655 | 2010-01-10 18:37:07 +0000 | [diff] [blame] | 108 | For windows is everything the except except the winsys: |
| 109 | |
José Fonseca | e243e87 | 2010-02-27 23:49:58 +0000 | [diff] [blame] | 110 | scons debug=yes statetrackers=mesa drivers=llvmpipe winsys=gdi dri=false |
José Fonseca | 9285f15 | 2009-08-10 12:35:16 +0100 | [diff] [blame] | 111 | |
| 112 | Using |
| 113 | ===== |
| 114 | |
José Fonseca | 1257655 | 2010-01-10 18:37:07 +0000 | [diff] [blame] | 115 | On Linux, building will create a drop-in alternative for libGL.so. To use it |
| 116 | set the environment variables: |
José Fonseca | 9285f15 | 2009-08-10 12:35:16 +0100 | [diff] [blame] | 117 | |
José Fonseca | 50d7714 | 2009-08-10 16:12:51 +0100 | [diff] [blame] | 118 | export LD_LIBRARY_PATH=$PWD/build/linux-x86_64-debug/lib:$LD_LIBRARY_PATH |
José Fonseca | 9285f15 | 2009-08-10 12:35:16 +0100 | [diff] [blame] | 119 | |
José Fonseca | 5811ed8 | 2009-08-22 22:26:55 +0100 | [diff] [blame] | 120 | or |
| 121 | |
| 122 | export LD_LIBRARY_PATH=$PWD/build/linux-x86-debug/lib:$LD_LIBRARY_PATH |
| 123 | |
José Fonseca | 1fc4100 | 2009-09-11 11:24:00 +0100 | [diff] [blame] | 124 | For performance evaluation pass debug=no to scons, and use the corresponding |
| 125 | lib directory without the "-debug" suffix. |
| 126 | |
José Fonseca | 1257655 | 2010-01-10 18:37:07 +0000 | [diff] [blame] | 127 | On Windows, building will create a drop-in alternative for opengl32.dll. To use |
| 128 | it put it in the same directory as the application. It can also be used by |
| 129 | replacing the native ICD driver, but it's quite an advanced usage, so if you |
| 130 | need to ask, don't even try it. |
| 131 | |
José Fonseca | 9285f15 | 2009-08-10 12:35:16 +0100 | [diff] [blame] | 132 | |
| 133 | Unit testing |
| 134 | ============ |
| 135 | |
| 136 | Building will also create several unit tests in |
| 137 | build/linux-???-debug/gallium/drivers/llvmpipe: |
| 138 | |
| 139 | - lp_test_blend: blending |
| 140 | - lp_test_conv: SIMD vector conversion |
| 141 | - lp_test_format: pixel unpacking/packing |
| 142 | |
José Fonseca | 1fc4100 | 2009-09-11 11:24:00 +0100 | [diff] [blame] | 143 | Some of this tests can output results and benchmarks to a tab-separated-file |
José Fonseca | 89146cd | 2009-08-20 10:21:49 +0100 | [diff] [blame] | 144 | for posterior analysis, e.g.: |
| 145 | |
José Fonseca | 5811ed8 | 2009-08-22 22:26:55 +0100 | [diff] [blame] | 146 | build/linux-x86_64-debug/gallium/drivers/llvmpipe/lp_test_blend -o blend.tsv |
José Fonseca | 9285f15 | 2009-08-10 12:35:16 +0100 | [diff] [blame] | 147 | |
José Fonseca | c5531f5 | 2009-08-21 10:57:48 +0100 | [diff] [blame] | 148 | |
| 149 | Development Notes |
| 150 | ================= |
| 151 | |
José Fonseca | 5811ed8 | 2009-08-22 22:26:55 +0100 | [diff] [blame] | 152 | - When looking to this code by the first time start in lp_state_fs.c, and |
| 153 | then skim through the lp_bld_* functions called in there, and the comments |
| 154 | at the top of the lp_bld_*.c functions. |
| 155 | |
Brian Paul | d0b3535 | 2010-03-15 11:46:41 -0600 | [diff] [blame] | 156 | - The driver-independent parts of the LLVM / Gallium code are found in |
| 157 | src/gallium/auxiliary/gallivm/. The filenames and function prefixes |
| 158 | need to be renamed from "lp_bld_" to something else though. |
José Fonseca | 5811ed8 | 2009-08-22 22:26:55 +0100 | [diff] [blame] | 159 | |
José Fonseca | c5531f5 | 2009-08-21 10:57:48 +0100 | [diff] [blame] | 160 | - We use LLVM-C bindings for now. They are not documented, but follow the C++ |
| 161 | interfaces very closely, and appear to be complete enough for code |
| 162 | generation. See |
| 163 | http://npcontemplation.blogspot.com/2008/06/secret-of-llvm-c-bindings.html |
José Fonseca | 1fc4100 | 2009-09-11 11:24:00 +0100 | [diff] [blame] | 164 | for a stand-alone example. |
Brian Paul | d0b3535 | 2010-03-15 11:46:41 -0600 | [diff] [blame] | 165 | See the llvm-c/Core.h file for reference. |