summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/llvmpipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r--src/gallium/drivers/llvmpipe/Makefile2
-rw-r--r--src/gallium/drivers/llvmpipe/README65
-rw-r--r--src/gallium/drivers/llvmpipe/SConscript6
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.c7
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup_line.c15
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup_tri.c44
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c9
-rw-r--r--src/gallium/drivers/llvmpipe/lp_tile_soa.py4
8 files changed, 65 insertions, 87 deletions
diff --git a/src/gallium/drivers/llvmpipe/Makefile b/src/gallium/drivers/llvmpipe/Makefile
index 08da2286b0..669e42e300 100644
--- a/src/gallium/drivers/llvmpipe/Makefile
+++ b/src/gallium/drivers/llvmpipe/Makefile
@@ -69,7 +69,7 @@ lp_test_sincos.o : sse_mathfun.h
PROGS_DEPS := ../../auxiliary/libgallium.a
lp_tile_soa.c: lp_tile_soa.py ../../auxiliary/util/u_format_parse.py ../../auxiliary/util/u_format_pack.py ../../auxiliary/util/u_format.csv
- python lp_tile_soa.py ../../auxiliary/util/u_format.csv > $@
+ $(PYTHON2) $(PYTHON_FLAGS) lp_tile_soa.py ../../auxiliary/util/u_format.csv > $@
LDFLAGS += $(LLVM_LDFLAGS)
LIBS += -L../../auxiliary/ -lgallium libllvmpipe.a $(LLVM_LIBS) $(GL_LIB_DEPS)
diff --git a/src/gallium/drivers/llvmpipe/README b/src/gallium/drivers/llvmpipe/README
index ec30d4d708..e9374cc6ef 100644
--- a/src/gallium/drivers/llvmpipe/README
+++ b/src/gallium/drivers/llvmpipe/README
@@ -1,53 +1,6 @@
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
============
@@ -98,7 +51,7 @@ Building
To build everything on Linux invoke scons as:
- scons debug=yes statetrackers=mesa drivers=llvmpipe winsys=xlib dri=false
+ scons build=debug libgl-xlib
Alternatively, you can build it with GNU make, if you prefer, by invoking it as
@@ -108,19 +61,16 @@ 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
+ scons build=debug libgl-gdi
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
+On Linux, building will create a drop-in alternative for libGL.so into
-or
+ build/foo/gallium/targets/libgl-xlib/libGL.so
- export LD_LIBRARY_PATH=$PWD/build/linux-x86-debug/lib:$LD_LIBRARY_PATH
+To use it set the LD_LIBRARY_PATH environment variable accordingly.
For performance evaluation pass debug=no to scons, and use the corresponding
lib directory without the "-debug" suffix.
@@ -136,7 +86,7 @@ Profiling
To profile llvmpipe you should pass the options
- scons debug=no profile=yes <same-as-before>
+ scons build=profile <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.
@@ -200,5 +150,4 @@ Development Notes
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.
+ for a stand-alone example. See the llvm-c/Core.h file for reference.
diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript
index 49950153a4..26b258b956 100644
--- a/src/gallium/drivers/llvmpipe/SConscript
+++ b/src/gallium/drivers/llvmpipe/SConscript
@@ -9,8 +9,6 @@ if not env['llvm']:
env = env.Clone()
-env.Tool('udis86')
-
env.Append(CPPPATH = ['.'])
env.CodeGenerate(
@@ -78,6 +76,8 @@ llvmpipe = env.ConvenienceLibrary(
lp_tile_soa_os,
])
+env.Alias('llvmpipe', llvmpipe)
+
if env['platform'] != 'embedded':
env = env.Clone()
@@ -92,7 +92,7 @@ if env['platform'] != 'embedded':
'sincos',
]
- if not msvc:
+ if not env['msvc']:
tests.append('round')
for test in tests:
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index d358a98394..decf3bd449 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -485,8 +485,11 @@ static void
lp_rast_end_query(struct lp_rasterizer_task *task,
const union lp_rast_cmd_arg arg)
{
- task->query->count[task->thread_index] += task->vis_counter;
- task->query = NULL;
+ assert(task->query);
+ if (task->query) {
+ task->query->count[task->thread_index] += task->vis_counter;
+ task->query = NULL;
+ }
}
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_line.c b/src/gallium/drivers/llvmpipe/lp_setup_line.c
index 827413bb33..29c231714e 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_line.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_line.c
@@ -569,7 +569,10 @@ try_setup_line( struct lp_setup_context *setup,
return TRUE;
}
- u_rect_find_intersection(&setup->draw_region, &bbox);
+ /* Can safely discard negative regions:
+ */
+ bbox.x0 = MAX2(bbox.x0, 0);
+ bbox.y0 = MAX2(bbox.y0, 0);
line = lp_setup_alloc_triangle(scene,
key->num_inputs,
@@ -680,24 +683,26 @@ try_setup_line( struct lp_setup_context *setup,
* these planes elsewhere.
*/
if (nr_planes == 8) {
+ const struct u_rect *scissor = &setup->scissor;
+
plane[4].dcdx = -1;
plane[4].dcdy = 0;
- plane[4].c = 1-bbox.x0;
+ plane[4].c = 1-scissor->x0;
plane[4].eo = 1;
plane[5].dcdx = 1;
plane[5].dcdy = 0;
- plane[5].c = bbox.x1+1;
+ plane[5].c = scissor->x1+1;
plane[5].eo = 0;
plane[6].dcdx = 0;
plane[6].dcdy = 1;
- plane[6].c = 1-bbox.y0;
+ plane[6].c = 1-scissor->y0;
plane[6].eo = 1;
plane[7].dcdx = 0;
plane[7].dcdy = -1;
- plane[7].c = bbox.y1+1;
+ plane[7].c = scissor->y1+1;
plane[7].eo = 0;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index 4ab0b72a57..bfb6bf277b 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -295,7 +295,12 @@ do_triangle_ccw(struct lp_setup_context *setup,
return TRUE;
}
- u_rect_find_intersection(&setup->draw_region, &bbox);
+ /* Can safely discard negative regions, but need to keep hold of
+ * information about when the triangle extends past screen
+ * boundaries. See trimmed_box in lp_setup_bin_triangle().
+ */
+ bbox.x0 = MAX2(bbox.x0, 0);
+ bbox.y0 = MAX2(bbox.y0, 0);
tri = lp_setup_alloc_triangle(scene,
key->num_inputs,
@@ -501,24 +506,26 @@ do_triangle_ccw(struct lp_setup_context *setup,
* these planes elsewhere.
*/
if (nr_planes == 7) {
+ const struct u_rect *scissor = &setup->scissor;
+
plane[3].dcdx = -1;
plane[3].dcdy = 0;
- plane[3].c = 1-bbox.x0;
+ plane[3].c = 1-scissor->x0;
plane[3].eo = 1;
plane[4].dcdx = 1;
plane[4].dcdy = 0;
- plane[4].c = bbox.x1+1;
+ plane[4].c = scissor->x1+1;
plane[4].eo = 0;
plane[5].dcdx = 0;
plane[5].dcdy = 1;
- plane[5].c = 1-bbox.y0;
+ plane[5].c = 1-scissor->y0;
plane[5].eo = 1;
plane[6].dcdx = 0;
plane[6].dcdy = -1;
- plane[6].c = bbox.y1+1;
+ plane[6].c = scissor->y1+1;
plane[6].eo = 0;
}
@@ -559,6 +566,7 @@ lp_setup_bin_triangle( struct lp_setup_context *setup,
int nr_planes )
{
struct lp_scene *scene = setup->scene;
+ struct u_rect trimmed_box = *bbox;
int i;
/* What is the largest power-of-two boundary this triangle crosses:
@@ -572,6 +580,13 @@ lp_setup_bin_triangle( struct lp_setup_context *setup,
int sz = floor_pot((bbox->x1 - (bbox->x0 & ~3)) |
(bbox->y1 - (bbox->y0 & ~3)));
+ /* Now apply scissor, etc to the bounding box. Could do this
+ * earlier, but it confuses the logic for tri-16 and would force
+ * the rasterizer to also respect scissor, etc, just for the rare
+ * cases where a small triangle extends beyond the scissor.
+ */
+ u_rect_find_intersection(&setup->draw_region, &trimmed_box);
+
/* Determine which tile(s) intersect the triangle's bounding box
*/
if (dx < TILE_SIZE)
@@ -626,15 +641,16 @@ lp_setup_bin_triangle( struct lp_setup_context *setup,
struct lp_rast_plane *plane = GET_PLANES(tri);
int c[MAX_PLANES];
int ei[MAX_PLANES];
+
int eo[MAX_PLANES];
int xstep[MAX_PLANES];
int ystep[MAX_PLANES];
int x, y;
- int ix0 = bbox->x0 / TILE_SIZE;
- int iy0 = bbox->y0 / TILE_SIZE;
- int ix1 = bbox->x1 / TILE_SIZE;
- int iy1 = bbox->y1 / TILE_SIZE;
+ int ix0 = trimmed_box.x0 / TILE_SIZE;
+ int iy0 = trimmed_box.y0 / TILE_SIZE;
+ int ix1 = trimmed_box.x1 / TILE_SIZE;
+ int iy1 = trimmed_box.y1 / TILE_SIZE;
for (i = 0; i < nr_planes; i++) {
c[i] = (plane[i].c +
@@ -799,6 +815,16 @@ static void triangle_both( struct lp_setup_context *setup,
{
float area = calc_area(v0, v1, v2);
+ if (0) {
+ assert(!util_is_inf_or_nan(v0[0][0]));
+ assert(!util_is_inf_or_nan(v0[0][1]));
+ assert(!util_is_inf_or_nan(v1[0][0]));
+ assert(!util_is_inf_or_nan(v1[0][1]));
+ assert(!util_is_inf_or_nan(v2[0][0]));
+ assert(!util_is_inf_or_nan(v2[0][1]));
+ assert(!util_is_inf_or_nan(area));
+ }
+
if (area > 0.0f)
retry_triangle_ccw( setup, v0, v1, v2, setup->ccw_is_frontface );
else if (area < 0.0f)
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 9fbedac165..48971510f2 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -761,11 +761,6 @@ generate_fragment(struct llvmpipe_screen *screen,
}
}
-#ifdef PIPE_ARCH_X86
- /* Avoid corrupting the FPU stack on 32bit OSes. */
- lp_build_intrinsic(builder, "llvm.x86.mmx.emms", LLVMVoidType(), NULL, 0);
-#endif
-
LLVMBuildRetVoid(builder);
LLVMDisposeBuilder(builder);
@@ -1067,11 +1062,11 @@ llvmpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
draw_flush(llvmpipe->draw);
+ llvmpipe->fs = (struct lp_fragment_shader *) fs;
+
draw_bind_fragment_shader(llvmpipe->draw,
(llvmpipe->fs ? llvmpipe->fs->draw_data : NULL));
- llvmpipe->fs = fs;
-
llvmpipe->dirty |= LP_NEW_FS;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py b/src/gallium/drivers/llvmpipe/lp_tile_soa.py
index e49f9c62fe..8df7b236fe 100644
--- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py
+++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-'''
+CopyRight = '''
/**************************************************************************
*
* Copyright 2009 VMware, Inc.
@@ -510,7 +510,7 @@ def main():
print '/* This file is autogenerated by lp_tile_soa.py from u_format.csv. Do not edit directly. */'
print
# This will print the copyright message on the top of this file
- print __doc__.strip()
+ print CopyRight.strip()
print
print '#include "pipe/p_compiler.h"'
print '#include "util/u_format.h"'