Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Keith Whitwell 8965f042b3 llvmpipe: don't store plane.ei value in binned data hace 15 años
..
.gitignore llvmpipe: Ignores! hace 15 años
Makefile llvmpipe: Add lp_rast_debug.c to Makefile. hace 15 años
README llvmpipe: Describe how to profile llvmpipe. hace 15 años
SConscript llvmpipe: simplified SSE2 swz/unswz routines hace 15 años
lp_bld_alpha.c llvmpipe: try to be sensible about whether to branch after mask updates hace 15 años
lp_bld_alpha.h llvmpipe: try to be sensible about whether to branch after mask updates hace 15 años
lp_bld_blend.h llvmpipe: fix up indexing of blend/colormask state for render targets hace 15 años
lp_bld_blend_aos.c llvmpipe: Special case complementary and identify blend factors in SoA. hace 15 años
lp_bld_blend_logicop.c gallivm/llvmpipe: move lp_bld_blend* files to llvmpipe/ directory hace 15 años
lp_bld_blend_soa.c llvmpipe: Special case complementary and identify blend factors in SoA. hace 15 años
lp_bld_depth.c llvmpipe: don't pass frontfacing as a float hace 15 años
lp_bld_depth.h llvmpipe: Unbreak Z32_FLOAT. hace 15 años
lp_bld_interp.c llvmpipe: defer attribute interpolation until after mask and ztest hace 15 años
lp_bld_interp.h llvmpipe: defer attribute interpolation until after mask and ztest hace 15 años
lp_clear.c llvmpipe: add LP_PERF flag to disable various aspects of rasterization hace 15 años
lp_clear.h llvmpipe: Rename preprocessor symbols too. hace 16 años
lp_context.c llvmpipe: point sprites rasterization hace 15 años
lp_context.h llvmpipe: native point rasterization hace 15 años
lp_debug.h llvmpipe: add DEBUG_FS to dump variant information hace 15 años
lp_draw_arrays.c gallium: Use draw_set_index_buffer and others. hace 15 años
lp_fence.c llvmpipe: move some fence functions into lp_screen.c hace 15 años
lp_fence.h llvmpipe: move some fence functions into lp_screen.c hace 15 años
lp_flush.c llvmpipe: Include missing header in lp_flush.c. hace 15 años
lp_flush.h llvmpipe: fence debugging, add llvmpipe_finish hace 15 años
lp_jit.c llvmpipe: Do not dispose the execution engine. hace 15 años
lp_jit.h llvmpipe: don't pass frontfacing as a float hace 15 años
lp_limits.h llvmpipe: limit the number of fragment shader variants kept around hace 15 años
lp_memory.c llvmpipe: use single swizzled tile hace 15 años
lp_memory.h llvmpipe: use single swizzled tile hace 15 años
lp_perf.c llvmpipe: more rasterization counters hace 15 años
lp_perf.h llvmpipe: brackets around macro arg hace 15 años
lp_public.h ws/xlib: remove self-knowledge about users of xlib winsys hace 15 años
lp_query.c llvmpipe: fix query bug when no there's no scene hace 15 años
lp_query.h llvmpipe: rework fences and queries hace 15 años
lp_rast.c llvmpipe: slightly shrink the size of a binned triangle hace 15 años
lp_rast.h llvmpipe: don't store plane.ei value in binned data hace 15 años
lp_rast_debug.c llvmpipe: slightly shrink the size of a binned triangle hace 15 años
lp_rast_priv.h llvmpipe: slightly shrink the size of a binned triangle hace 15 años
lp_rast_tri.c llvmpipe: slightly shrink the size of a binned triangle hace 15 años
lp_rast_tri_tmp.h llvmpipe: don't store plane.ei value in binned data hace 15 años
lp_scene.c llvmpipe: reintroduce SET_STATE binner command hace 15 años
lp_scene.h llvmpipe: reintroduce SET_STATE binner command hace 15 años
lp_scene_queue.c llvmpipe: Silence uninitialized variable warning. hace 15 años
lp_scene_queue.h llvmpipe: use new u_ringbuffer for scene queue hace 15 años
lp_screen.c llvmpipe: Default to no threading on single processor systems. hace 15 años
lp_screen.h llvmpipe: move rasterizer to screen instead of setup context hace 15 años
lp_setup.c llvmpipe: fail gracefully on oom in scene creation hace 15 años
lp_setup.h llvmpipe: Decouple sampler view and sampler state updates. hace 15 años
lp_setup_coef.c llvmpipe: slightly shrink the size of a binned triangle hace 15 años
lp_setup_coef.h llvmpipe: slightly shrink the size of a binned triangle hace 15 años
lp_setup_coef_intrin.c llvmpipe: slightly shrink the size of a binned triangle hace 15 años
lp_setup_context.h llvmpipe: fail gracefully on oom in scene creation hace 15 años
lp_setup_line.c llvmpipe: don't store plane.ei value in binned data hace 15 años
lp_setup_point.c llvmpipe: don't store plane.ei value in binned data hace 15 años
lp_setup_tri.c llvmpipe: don't store plane.ei value in binned data hace 15 años
lp_setup_vbuf.c llvmpipe: fail gracefully on oom in scene creation hace 15 años
lp_state.h llvmpipe: disconnect vertex texture sampling from the setup hace 15 años
lp_state_blend.c llvmpipe: add LP_PERF flag to disable various aspects of rasterization hace 15 años
lp_state_clip.c llvmpipe: make clip-related functions static, clean-up initializations hace 15 años
lp_state_derived.c llvmpipe: Use lp_tgsi_info. hace 15 años
lp_state_fs.c llvmpipe: don't pass frontfacing as a float hace 15 años
lp_state_fs.h llvmpipe: Use lp_tgsi_info. hace 15 años
lp_state_gs.c llvmpipe: Remove unnecessary header. hace 15 años
lp_state_rasterizer.c llvmpipe: rename sprite field, add sprite_coord_origin hace 15 años
lp_state_sampler.c draw/llvmpipe: replace DRAW_MAX_TEXTURE_LEVELS with PIPE_MAX_TEXTURE_LEVELS hace 15 años
lp_state_so.c llvmpipe: Remove unnecessary header. hace 15 años
lp_state_surface.c llvmpipe: add LP_PERF flag to disable various aspects of rasterization hace 15 años
lp_state_vertex.c gallium: Use draw_set_index_buffer and others. hace 15 años
lp_state_vs.c llvmpipe: make shader-related functions static, clean-up initializations hace 15 años
lp_surface.c llvmpipe: use opcodes instead of function pointers in bins hace 15 años
lp_surface.h llvmpipe: move/rename llvmpipe_init_surface_functions() hace 15 años
lp_test.h llvmpipe: new -s option to run single test hace 15 años
lp_test_blend.c llvmpipe: Special case complementary and identify blend factors in SoA. hace 15 años
lp_test_conv.c llvmpipe: don't call LLVMCreateJITCompiler() twice hace 15 años
lp_test_format.c gallivm: Support multiple pixels in lp_build_fetch_rgba_aos(). hace 15 años
lp_test_main.c llvmpipe: Special case complementary and identify blend factors in SoA. hace 15 años
lp_test_printf.c llvmpipe: Silence unused value warning. hace 15 años
lp_test_round.c llvmpipe: don't call LLVMCreateJITCompiler() twice hace 15 años
lp_test_sincos.c llvmpipe: silence warnings in lp_test_sincos.c hace 15 años
lp_tex_sample.c llvmpipe: make texture border_color dynamic state hace 15 años
lp_tex_sample.h gallivm/llvmpipe: rename os_llvm.h to lp_bld.h hace 15 años
lp_texture.c llvmpipe: use opcodes instead of function pointers in bins hace 15 años
lp_texture.h llvmpipe: use single swizzled tile hace 15 años
lp_tile_image.c llvmpipe: Always swizzle/unswizzle whole tiles. hace 15 años
lp_tile_image.h llvmpipe: Fix rendering to non 32bpp formats. hace 15 años
lp_tile_shuffle_mask.py llvmpipe: Addi ssse3 swizzling for B8G8R8A8_UNORM. hace 15 años
lp_tile_soa.h llvmpipe: Always swizzle/unswizzle whole tiles. hace 15 años
lp_tile_soa.py llvmpipe: Fix MSVC build. Enable the new SSE2 code on non SSE3 systems. hace 15 años
sse_mathfun.h llvmpipe: Remove some broken MinGW hacks in the sin/cos reference code. hace 15 años

README

LLVMPIPE -- a fork of softpipe that employs LLVM for code generation.


Status
======

Done so far is:

- the whole fragment pipeline is code generated in a single function

- input interpolation

- depth testing

- texture sampling
- 1D/2D/3D/cube maps supported
- all texture wrap modes supported
- all texture filtering modes supported
- perhaps not all texture formats yet supported

- fragment shader TGSI translation
- same level of support as the TGSI SSE2 exec machine, with the exception
we don't fallback to TGSI interpretation when an unsupported opcode is
found, but just ignore it
- done in SoA layout
- input interpolation also code generated

- alpha testing

- blend (including logic ops)
- both in SoA and AoS layouts, but only the former used for now

- code is generic
- intermediates can be vectors of floats, ubytes, fixed point, etc, and of
any width and length
- not all operations are implemented for these types yet though

Most mesa/progs/demos/* work.

To do (probably by this order):

- code generate stipple and stencil testing

- translate TGSI control flow instructions, and all other remaining opcodes

- integrate with the draw module for VS code generation

- code generate the triangle setup and rasterization


Requirements
============

- A x86 or amd64 processor. 64bit mode is preferred.

Support for sse2 is strongly encouraged. Support for ssse3, and sse4.1 will
yield the most efficient code. The less features the CPU has the more
likely is that you ran into underperforming, buggy, or incomplete code.

See /proc/cpuinfo to know what your CPU supports.

- LLVM 2.6 (or later)

For Linux, on a recent Debian based distribution do:

aptitude install llvm-dev

For Windows download pre-built MSVC 9.0 or MinGW binaries from
http://people.freedesktop.org/~jrfonseca/llvm/ and set the LLVM environment
variable to the extracted path.

For MSVC there are two set of binaries: llvm-x.x-msvc32mt.7z and
llvm-x.x-msvc32mtd.7z .

You have to set the LLVM=/path/to/llvm-x.x-msvc32mtd env var when passing
debug=yes to scons, and LLVM=/path/to/llvm-x.x-msvc32mt when building with
debug=no. This is necessary as LLVM builds as static library so the chosen
MS CRT must match.

The version of LLVM from SVN ("2.7svn") from mid-March 2010 is pretty
stable and has some features not in version 2.6.

- scons (optional)

- udis86, http://udis86.sourceforge.net/ (optional). My personal repository
supports more opcodes which haven't been merged upstream yet:

git clone git://anongit.freedesktop.org/~jrfonseca/udis86
cd udis86
./autogen.sh
./configure --with-pic
make
sudo make install


Building
========

To build everything on Linux invoke scons as:

scons debug=yes statetrackers=mesa drivers=llvmpipe winsys=xlib dri=false

Alternatively, you can build it with GNU make, if you prefer, by invoking it as

make linux-llvm

but the rest of these instructions assume that scons is used.

For windows is everything the except except the winsys:

scons debug=yes statetrackers=mesa drivers=llvmpipe winsys=gdi dri=false

Using
=====

On Linux, building will create a drop-in alternative for libGL.so. To use it
set the environment variables:

export LD_LIBRARY_PATH=$PWD/build/linux-x86_64-debug/lib:$LD_LIBRARY_PATH

or

export LD_LIBRARY_PATH=$PWD/build/linux-x86-debug/lib:$LD_LIBRARY_PATH

For performance evaluation pass debug=no to scons, and use the corresponding
lib directory without the "-debug" suffix.

On Windows, building will create a drop-in alternative for opengl32.dll. To use
it put it in the same directory as the application. It can also be used by
replacing the native ICD driver, but it's quite an advanced usage, so if you
need to ask, don't even try it.


Profiling
=========

To profile llvmpipe you should pass the options

scons debug=no profile=yes <same-as-before>

This will ensure that frame pointers are used both in C and JIT functions, and
that no tail call optimizations are done by gcc.


To better profile JIT code you'll need to build LLVM with oprofile integration.

source_dir=$PWD/llvm-2.6
build_dir=$source_dir/build/profile
install_dir=$source_dir-profile

mkdir -p "$build_dir"
cd "$build_dir" && \
$source_dir/configure \
--prefix=$install_dir \
--enable-optimized \
--disable-profiling \
--enable-targets=host-only \
--with-oprofile

make -C "$build_dir"
make -C "$build_dir" install

find "$install_dir/lib" -iname '*.a' -print0 | xargs -0 strip --strip-debug

The you should define

export LLVM=/path/to/llvm-2.6-profile

and rebuild.


Unit testing
============

Building will also create several unit tests in
build/linux-???-debug/gallium/drivers/llvmpipe:

- lp_test_blend: blending
- lp_test_conv: SIMD vector conversion
- lp_test_format: pixel unpacking/packing

Some of this tests can output results and benchmarks to a tab-separated-file
for posterior analysis, e.g.:

build/linux-x86_64-debug/gallium/drivers/llvmpipe/lp_test_blend -o blend.tsv


Development Notes
=================

- When looking to this code by the first time start in lp_state_fs.c, and
then skim through the lp_bld_* functions called in there, and the comments
at the top of the lp_bld_*.c functions.

- The driver-independent parts of the LLVM / Gallium code are found in
src/gallium/auxiliary/gallivm/. The filenames and function prefixes
need to be renamed from "lp_bld_" to something else though.

- We use LLVM-C bindings for now. They are not documented, but follow the C++
interfaces very closely, and appear to be complete enough for code
generation. See
http://npcontemplation.blogspot.com/2008/06/secret-of-llvm-c-bindings.html
for a stand-alone example.
See the llvm-c/Core.h file for reference.