Mesa (master): llvmpipe: remove misleading debug string

2010-11-30 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: d9169364d4ec05f766b0835785c6fd76294d9967
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d9169364d4ec05f766b0835785c6fd76294d9967

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Nov 30 11:22:46 2010 +

llvmpipe: remove misleading debug string

---

 src/gallium/drivers/llvmpipe/lp_setup.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c 
b/src/gallium/drivers/llvmpipe/lp_setup.c
index 6118434..07acdb2 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -263,7 +263,6 @@ execute_clears( struct lp_setup_context *setup )
 
 const char *states[] = {
FLUSHED,
-   EMPTY  ,
CLEARED,
ACTIVE 
 };

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: raise dirty flag on transfers to bound constbuf

2010-11-30 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 2d31f048cec5d408c8bac758566c49fe14fac2ac
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2d31f048cec5d408c8bac758566c49fe14fac2ac

Author: Keith Whitwell kei...@vmware.com
Date:   Mon Nov 29 19:18:54 2010 +

llvmpipe: raise dirty flag on transfers to bound constbuf

Need this to trigger the scene to update its shadow of the constant
state.

---

 src/gallium/drivers/llvmpipe/lp_texture.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c 
b/src/gallium/drivers/llvmpipe/lp_texture.c
index a4b9f25..f78cd60 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -49,6 +49,7 @@
 #include lp_tile_image.h
 #include lp_texture.h
 #include lp_setup.h
+#include lp_state.h
 
 #include state_tracker/sw_winsys.h
 
@@ -566,6 +567,7 @@ llvmpipe_get_transfer(struct pipe_context *pipe,
  unsigned usage,
  const struct pipe_box *box)
 {
+   struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
struct llvmpipe_resource *lprex = llvmpipe_resource(resource);
struct llvmpipe_transfer *lpr;
 
@@ -594,6 +596,9 @@ llvmpipe_get_transfer(struct pipe_context *pipe,
   }
}
 
+   if (resource == llvmpipe-constants[PIPE_SHADER_FRAGMENT][0])
+  llvmpipe-dirty |= LP_NEW_CONSTANTS;
+
lpr = CALLOC_STRUCT(llvmpipe_transfer);
if (lpr) {
   struct pipe_transfer *pt = lpr-base;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: shortcircuit some calls to set_scene_state

2010-11-30 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 68a4f6324712d7eae327ee438a41c432ec72f11d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=68a4f6324712d7eae327ee438a41c432ec72f11d

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Nov 30 12:00:25 2010 +

llvmpipe: shortcircuit some calls to set_scene_state

---

 src/gallium/drivers/llvmpipe/lp_setup.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c 
b/src/gallium/drivers/llvmpipe/lp_setup.c
index 07acdb2..a173e71 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -927,7 +927,7 @@ lp_setup_update_state( struct lp_setup_context *setup,
setup-setup.variant-key.size) == 0);
}
 
-   if (update_scene) {
+   if (update_scene  setup-state != SETUP_ACTIVE) {
   if (!set_scene_state( setup, SETUP_ACTIVE, __FUNCTION__ ))
  return FALSE;
}

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: turn off draw offset/twoside when we can handle it

2010-11-22 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: a1ca5ac7c27c8bc3e294b50ab9ad340095f3030d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a1ca5ac7c27c8bc3e294b50ab9ad340095f3030d

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Oct 22 18:58:36 2010 +0100

llvmpipe: turn off draw offset/twoside when we can handle it

---

 src/gallium/drivers/llvmpipe/lp_state_rasterizer.c |   99 ++--
 1 files changed, 72 insertions(+), 27 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c 
b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
index dbd7381..574f9e9 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
@@ -32,16 +32,64 @@
 #include lp_setup.h
 #include draw/draw_context.h
 
+struct lp_rast_state {
+   struct pipe_rasterizer_state lp_state;
+   struct pipe_rasterizer_state draw_state;
+};
+
+/* State which might be handled in either the draw module or locally.
+ * This function is used to turn that state off in one of the two
+ * places.
+ */
+static void
+clear_flags(struct pipe_rasterizer_state *rast)
+{
+   rast-light_twoside = 0;
+   rast-offset_tri = 0;
+}
+
 
 
 static void *
 llvmpipe_create_rasterizer_state(struct pipe_context *pipe,
  const struct pipe_rasterizer_state *rast)
 {
-   /* We do nothing special with rasterizer state.
-* The CSO handle is just a pointer to a pipe_rasterizer_state object.
+   boolean need_pipeline;
+
+   /* Partition rasterizer state into what we want the draw module to
+* handle, and what we'll look after ourselves.
+*/
+   struct lp_rast_state *state = MALLOC_STRUCT(lp_rast_state);
+   if (state == NULL)
+  return NULL;
+
+   memcpy(state-draw_state, rast, sizeof *rast);
+   memcpy(state-lp_state, rast, sizeof *rast);
+
+   /* We rely on draw module to do unfilled polyons, AA lines and
+* points and stipple.
+* 
+* Over time, reduce this list of conditions, and expand the list
+* of flags which get cleared in clear_flags().
 */
-   return mem_dup(rast, sizeof(*rast));
+   need_pipeline = (rast-fill_front != PIPE_POLYGON_MODE_FILL ||
+   rast-fill_back != PIPE_POLYGON_MODE_FILL ||
+   rast-point_smooth ||
+   rast-line_smooth ||
+   rast-line_stipple_enable ||
+   rast-poly_stipple_enable);
+
+   /* If not using the pipeline, clear out the flags which we can
+* handle ourselves.  If we *are* using the pipeline, do everything
+* on the pipeline and clear those flags on our internal copy of
+* the state.
+*/
+   if (need_pipeline)
+  clear_flags(state-lp_state);
+   else
+  clear_flags(state-draw_state);
+
+   return state;
 }
 
 
@@ -50,36 +98,33 @@ static void
 llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, void *handle)
 {
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
-   const struct pipe_rasterizer_state *rasterizer =
-  (const struct pipe_rasterizer_state *) handle;
-
-   if (llvmpipe-rasterizer == rasterizer)
-  return;
+   const struct lp_rast_state *state =
+  (const struct lp_rast_state *) handle;
 
-   /* pass-through to draw module */
-   draw_set_rasterizer_state(llvmpipe-draw, rasterizer, handle);
+   if (state) {
+  llvmpipe-rasterizer = state-lp_state;
+  draw_set_rasterizer_state(llvmpipe-draw, state-draw_state, handle);
 
-   llvmpipe-rasterizer = rasterizer;
-
-   /* Note: we can immediately set the triangle state here and
-* not worry about binning because we handle culling during
-* triangle setup, not when rasterizing the bins.
-*/
-   if (llvmpipe-rasterizer) {
+  /* XXX: just pass lp_state directly to setup.
+   */
   lp_setup_set_triangle_state( llvmpipe-setup,
-   llvmpipe-rasterizer-cull_face,
-   llvmpipe-rasterizer-front_ccw,
-   llvmpipe-rasterizer-scissor,
-   llvmpipe-rasterizer-gl_rasterization_rules);
+  state-lp_state.cull_face,
+  state-lp_state.front_ccw,
+  state-lp_state.scissor,
+  state-lp_state.gl_rasterization_rules);
   lp_setup_set_flatshade_first( llvmpipe-setup,
-   llvmpipe-rasterizer-flatshade_first);
+   state-lp_state.flatshade_first);
   lp_setup_set_line_state( llvmpipe-setup,
-   llvmpipe-rasterizer-line_width);
+  state-lp_state.line_width);
   lp_setup_set_point_state( llvmpipe-setup,
-   llvmpipe-rasterizer-point_size,
-   llvmpipe-rasterizer-point_size_per_vertex,
-   llvmpipe-rasterizer-sprite_coord_enable,
-   llvmpipe-rasterizer-sprite_coord_mode);
+   state-lp_state.point_size

Mesa (master): llvmpipe: Moved draw pipeline twoside function to llvm setup code

2010-11-22 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 7f0dc5ea1bb330c6589125baf4017c51a14dce8e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f0dc5ea1bb330c6589125baf4017c51a14dce8e

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Fri Oct 29 00:47:13 2010 +0100

llvmpipe: Moved draw pipeline twoside function to llvm setup code

---

 src/gallium/drivers/llvmpipe/lp_context.h   |6 ++
 src/gallium/drivers/llvmpipe/lp_state_derived.c |   14 -
 src/gallium/drivers/llvmpipe/lp_state_setup.c   |   85 ++-
 src/gallium/drivers/llvmpipe/lp_state_setup.h   |3 +-
 4 files changed, 103 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_context.h 
b/src/gallium/drivers/llvmpipe/lp_context.h
index db09c95..2230d50 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_context.h
@@ -104,6 +104,12 @@ struct llvmpipe_context {
/** Vertex format */
struct vertex_info vertex_info;

+   /** Which vertex shader output slot contains color */
+   int color_slot;
+
+   /** Which vertex shader output slot contains bcolor */
+   int bcolor_slot;
+
/** Which vertex shader output slot contains point size */
int psize_slot;
 
diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c 
b/src/gallium/drivers/llvmpipe/lp_state_derived.c
index 0f5f736..1c9f03a 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_derived.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c
@@ -75,13 +75,25 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe)
   vs_index = draw_find_shader_output(llvmpipe-draw,
  
lpfs-info.base.input_semantic_name[i],
  
lpfs-info.base.input_semantic_index[i]);
-
+  if (lpfs-info.base.input_semantic_name[i]==TGSI_SEMANTIC_COLOR){
+ llvmpipe-color_slot = vinfo-num_attribs;
+  }
   /*
* Emit the requested fs attribute for all but position.
*/
   draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
}
 
+   /* Figure out if we need bcolor as well.
+*/
+   vs_index = draw_find_shader_output(llvmpipe-draw,
+  TGSI_SEMANTIC_BCOLOR, 0);
+
+   if (vs_index  0) {
+  llvmpipe-bcolor_slot = vinfo-num_attribs;
+  draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
+   }
+
/* Figure out if we need pointsize as well.
 */
vs_index = draw_find_shader_output(llvmpipe-draw,
diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index 2c8b8b9..8383494 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -33,6 +33,7 @@
 #include gallivm/lp_bld_debug.h
 #include gallivm/lp_bld_init.h
 #include gallivm/lp_bld_intr.h
+#include gallivm/lp_bld_flow.h
 #include llvm-c/Analysis.h   /* for LLVMVerifyFunction */
 
 #include lp_perf.h
@@ -74,6 +75,14 @@ struct lp_setup_args
LLVMValueRef dy01_ooa;
LLVMValueRef dx20_ooa;
LLVMValueRef dx01_ooa;
+
+   /* For twoside calcs 
+*/
+   LLVMValueRef det;
+   LLVMValueRef sign;
+   LLVMValueRef bcolor_slot;
+   LLVMValueRef color_slot;
+   
 };
 
 static LLVMTypeRef type4f(void)
@@ -472,13 +481,78 @@ init_args(LLVMBuilderRef b,
args-y0_center = vec4f_from_scalar(b, y0_center, y0_center_4f);
 }
 
+static void
+set_args_attr(struct llvmpipe_context *lp,
+   struct lp_setup_args *args)
+{
+   args-color_slot = LLVMConstInt(LLVMInt32Type(), lp-color_slot, 0);
+   args-bcolor_slot = LLVMConstInt(LLVMInt32Type(), lp-bcolor_slot, 0);
+   args-sign =  LLVMConstReal(LLVMFloatType(), (lp-rasterizer-front_ccw ? 
-1.0f : 1.0f));
+}
+
+static void
+lp_twoside(LLVMBuilderRef b, 
+   struct lp_setup_args *args,
+   const struct lp_setup_variant_key *key)
+{
+   struct lp_build_if_state if_state;
+ 
+   LLVMValueRef a0_old, a1_old, a2_old;
+   LLVMValueRef a0_new, a1_new, a2_new;
+
+   LLVMValueRef idx1 = args-color_slot;
+   LLVMValueRef idx2 = args-bcolor_slot;
+
+   LLVMValueRef facing = args-facing;
+   LLVMValueRef front_facing = LLVMBuildICmp(b, LLVMIntEQ, facing, 
LLVMConstInt(LLVMInt32Type(), 0, 0), ); /** need i1 for loop condition */
+   
+#if 0 
+/*Probably can delete this, just tried to follow draw_pipe_twoside way of 
+  calculating det*/
+   /* edge vectors: e = v0 - v2, f = v1 - v2 */
+   LLVMValueRef e = LLVMBuildFSub(b, args-v0, args-v2, e);
+   LLVMValueRef f = LLVMBuildFSub(b, args-v1, args-v2, f);
+   LLVMValueRef dx02 = vert_attrib(b, e, 0, 0, dx02);
+   LLVMValueRef dy02 = vert_attrib(b, e, 0, 1, dy02);
+   LLVMValueRef dx12 = vert_attrib(b, f, 0, 0, dx12);
+   LLVMValueRef dy12 = vert_attrib(b, f, 0, 1, dy12);
+ 
+   /* det = cross(e,f).z */
+   LLVMValueRef dx02_dy12  = LLVMBuildFMul(b, dx02, dy12, dx02_dy12);
+   LLVMValueRef dy02_dx12  = LLVMBuildFMul(b, dy02, dx12, dy02_dx12);
+   LLVMValueRef det  = 

Mesa (master): llvmpipe: added llvm offset setup code

2010-11-22 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 315f8daab1598a4de709d469a559b5aa09107404
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=315f8daab1598a4de709d469a559b5aa09107404

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Thu Nov  4 11:42:55 2010 +

llvmpipe: added llvm offset setup code

---

 src/gallium/drivers/llvmpipe/lp_context.h   |3 +
 src/gallium/drivers/llvmpipe/lp_state_setup.c   |  179 +--
 src/gallium/drivers/llvmpipe/lp_state_setup.h   |6 +-
 src/gallium/drivers/llvmpipe/lp_state_surface.c |1 +
 4 files changed, 143 insertions(+), 46 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_context.h 
b/src/gallium/drivers/llvmpipe/lp_context.h
index 2230d50..4515dbb 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_context.h
@@ -113,6 +113,9 @@ struct llvmpipe_context {
/** Which vertex shader output slot contains point size */
int psize_slot;
 
+   /** minimum resolvable depth value, for polygon offset */   
+   double mrd;
+   
/** The tiling engine */
struct lp_setup_context *setup;
struct lp_setup_variant setup_variant;
diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index 8383494..7751b7d 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -30,10 +30,12 @@
 #include util/u_memory.h
 #include util/u_simple_list.h
 #include os/os_time.h
+#include gallivm/lp_bld_arit.h
 #include gallivm/lp_bld_debug.h
 #include gallivm/lp_bld_init.h
 #include gallivm/lp_bld_intr.h
 #include gallivm/lp_bld_flow.h
+#include gallivm/lp_bld_type.h
 #include llvm-c/Analysis.h   /* for LLVMVerifyFunction */
 
 #include lp_perf.h
@@ -74,15 +76,7 @@ struct lp_setup_args
LLVMValueRef dy20_ooa;
LLVMValueRef dy01_ooa;
LLVMValueRef dx20_ooa;
-   LLVMValueRef dx01_ooa;
-
-   /* For twoside calcs 
-*/
-   LLVMValueRef det;
-   LLVMValueRef sign;
-   LLVMValueRef bcolor_slot;
-   LLVMValueRef color_slot;
-   
+   LLVMValueRef dx01_ooa;   
 };
 
 static LLVMTypeRef type4f(void)
@@ -204,7 +198,34 @@ vert_attrib(LLVMBuilderRef b,
return LLVMBuildLoad(b, LLVMBuildGEP(b, vert, idx, 2, ), name);
 }
 
-
+static LLVMValueRef
+vert_clamp(LLVMBuilderRef b,
+   LLVMValueRef x,
+   LLVMValueRef min,
+   LLVMValueRef max,
+   LLVMValueRef clamp_ptr)
+{
+   struct lp_build_if_state if_state;
+   LLVMValueRef min_result = LLVMBuildFCmp(b, LLVMRealUGT, min, x, );
+   LLVMValueRef max_result = LLVMBuildFCmp(b, LLVMRealUGT, x, max, );
+   
+   lp_build_if(if_state, b, min_result);
+   {
+  LLVMBuildStore(b, min, clamp_ptr);
+   }   
+   lp_build_endif(if_state);
+   lp_build_if(if_state, b, max_result);
+   {
+  LLVMBuildStore(b, max, clamp_ptr);
+   }  
+   lp_build_else(if_state);
+   {
+  LLVMBuildStore(b, x, clamp_ptr);
+   }
+   lp_build_endif(if_state);
+   
+   return LLVMBuildLoad(b, clamp_ptr,);
+}
 
 static void 
 emit_coef4( LLVMBuilderRef b,
@@ -482,15 +503,6 @@ init_args(LLVMBuilderRef b,
 }
 
 static void
-set_args_attr(struct llvmpipe_context *lp,
-   struct lp_setup_args *args)
-{
-   args-color_slot = LLVMConstInt(LLVMInt32Type(), lp-color_slot, 0);
-   args-bcolor_slot = LLVMConstInt(LLVMInt32Type(), lp-bcolor_slot, 0);
-   args-sign =  LLVMConstReal(LLVMFloatType(), (lp-rasterizer-front_ccw ? 
-1.0f : 1.0f));
-}
-
-static void
 lp_twoside(LLVMBuilderRef b, 
struct lp_setup_args *args,
const struct lp_setup_variant_key *key)
@@ -499,32 +511,13 @@ lp_twoside(LLVMBuilderRef b,
  
LLVMValueRef a0_old, a1_old, a2_old;
LLVMValueRef a0_new, a1_new, a2_new;
-
-   LLVMValueRef idx1 = args-color_slot;
-   LLVMValueRef idx2 = args-bcolor_slot;
+   
+   LLVMValueRef idx1 = LLVMConstInt(LLVMInt32Type(), key-color_slot, 0);
+   LLVMValueRef idx2 = LLVMConstInt(LLVMInt32Type(), key-bcolor_slot, 0);
 
LLVMValueRef facing = args-facing;
-   LLVMValueRef front_facing = LLVMBuildICmp(b, LLVMIntEQ, facing, 
LLVMConstInt(LLVMInt32Type(), 0, 0), ); /** need i1 for loop condition */
+   LLVMValueRef front_facing = LLVMBuildICmp(b, LLVMIntEQ, facing, 
LLVMConstInt(LLVMInt32Type(), 0, 0), ); /** need i1 for if condition */

-#if 0 
-/*Probably can delete this, just tried to follow draw_pipe_twoside way of 
-  calculating det*/
-   /* edge vectors: e = v0 - v2, f = v1 - v2 */
-   LLVMValueRef e = LLVMBuildFSub(b, args-v0, args-v2, e);
-   LLVMValueRef f = LLVMBuildFSub(b, args-v1, args-v2, f);
-   LLVMValueRef dx02 = vert_attrib(b, e, 0, 0, dx02);
-   LLVMValueRef dy02 = vert_attrib(b, e, 0, 1, dy02);
-   LLVMValueRef dx12 = vert_attrib(b, f, 0, 0, dx12);
-   LLVMValueRef dy12 = vert_attrib(b, f, 0, 1, dy12);
- 
-   /* det = cross(e,f).z */
-   LLVMValueRef dx02_dy12  = LLVMBuildFMul(b, dx02, dy12, dx02_dy12);
-   LLVMValueRef dy02_dx12  = LLVMBuildFMul(b, dy02, dx12, dy02_dx12);
-   LLVMValueRef det  = 

Mesa (master): llvmpipe: clean up polygon offset function in lp setup code

2010-11-22 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: e3f106b5fe36ad558b3971ba88802c5d80b007de
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e3f106b5fe36ad558b3971ba88802c5d80b007de

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Sat Nov 13 21:39:50 2010 +

llvmpipe: clean up polygon offset function in lp setup code

---

 src/gallium/drivers/llvmpipe/lp_state_setup.c |   60 +++--
 1 files changed, 16 insertions(+), 44 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index 7751b7d..03b411a 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -202,29 +202,16 @@ static LLVMValueRef
 vert_clamp(LLVMBuilderRef b,
LLVMValueRef x,
LLVMValueRef min,
-   LLVMValueRef max,
-   LLVMValueRef clamp_ptr)
+   LLVMValueRef max)
 {
-   struct lp_build_if_state if_state;
LLVMValueRef min_result = LLVMBuildFCmp(b, LLVMRealUGT, min, x, );
LLVMValueRef max_result = LLVMBuildFCmp(b, LLVMRealUGT, x, max, );
-   
-   lp_build_if(if_state, b, min_result);
-   {
-  LLVMBuildStore(b, min, clamp_ptr);
-   }   
-   lp_build_endif(if_state);
-   lp_build_if(if_state, b, max_result);
-   {
-  LLVMBuildStore(b, max, clamp_ptr);
-   }  
-   lp_build_else(if_state);
-   {
-  LLVMBuildStore(b, x, clamp_ptr);
-   }
-   lp_build_endif(if_state);
-   
-   return LLVMBuildLoad(b, clamp_ptr,);
+   LLVMValueRef clamp_value;
+
+   clamp_value = LLVMBuildSelect(b, min_result, min, x, );
+   clamp_value = LLVMBuildSelect(b, max_result, max, x, );
+
+   return clamp_value;
 }
 
 static void 
@@ -542,11 +529,11 @@ lp_do_offset_tri(LLVMBuilderRef b,
  struct lp_setup_args *args,
  const struct lp_setup_variant_key *key)
 {
-   struct lp_build_if_state if_state;
struct lp_build_context bld;
LLVMValueRef zoffset, mult;
LLVMValueRef z0_new, z1_new, z2_new;
-   LLVMValueRef dzdx0, dzdx, dzdy0, dzdy, max;
+   LLVMValueRef dzdx0, dzdx, dzdy0, dzdy;
+   LLVMValueRef max, max_value;
 
LLVMValueRef idx[2];
LLVMValueRef one  = LLVMConstReal(LLVMFloatType(), 1.0);
@@ -584,10 +571,6 @@ lp_do_offset_tri(LLVMBuilderRef b,
LLVMValueRef dx02_dz12= LLVMBuildFMul(b, dx02, dz12, dx02_dz12);
LLVMValueRef res1  = LLVMBuildFSub(b, dy02_dz12, dz02_dy12, res1);
LLVMValueRef res2  = LLVMBuildFSub(b, dz02_dx12, dx02_dz12, res2);
-
-   /* for the if-else functions phi's */
-   LLVMValueRef zoffset_ptr = lp_build_alloca(b, LLVMFloatType(), );
-   LLVMValueRef clamp_ptr = lp_build_alloca(b, LLVMFloatType(), );
  
/* dzdx = fabsf(res1 * inv_det), dydx = fabsf(res2 * inv_det)*/
lp_build_context_init(bld, b, lp_type_float(32));
@@ -598,26 +581,15 @@ lp_do_offset_tri(LLVMBuilderRef b,
 
/* zoffset = offset-units + MAX2(dzdx, dzdy) * offset-scale */
max = LLVMBuildFCmp(b, LLVMRealUGT, dzdx, dzdy, );
-   lp_build_if(if_state, b, max);
-   {
-  mult = LLVMBuildFMul(b, dzdx, LLVMConstReal(LLVMFloatType(), 
key-scale), );
-  zoffset = LLVMBuildFAdd(b, LLVMConstReal(LLVMFloatType(), key-units), 
mult, zoffset);
-  LLVMBuildStore(b, zoffset, zoffset_ptr);
-   }   
-   lp_build_else(if_state);
-   {
-  mult = LLVMBuildFMul(b, dzdy, LLVMConstReal(LLVMFloatType(), 
key-scale), );
-  zoffset = LLVMBuildFAdd(b, LLVMConstReal(LLVMFloatType(), key-units), 
mult, zoffset); 
-  LLVMBuildStore(b, zoffset, zoffset_ptr);
-   }
-   lp_build_endif(if_state);
+   max_value = LLVMBuildSelect(b, max, dzdx, dzdy, max); 
 
-   zoffset = LLVMBuildLoad(b, zoffset_ptr,);
+   mult = LLVMBuildFMul(b, max_value, LLVMConstReal(LLVMFloatType(), 
key-scale), );
+   zoffset = LLVMBuildFAdd(b, LLVMConstReal(LLVMFloatType(), key-units), 
mult, zoffset); 
 
/* clamp and do offset */
-   z0_new = vert_clamp(b, LLVMBuildFAdd(b, v0_z, zoffset, ), zero, one, 
clamp_ptr);
-   z1_new = vert_clamp(b, LLVMBuildFAdd(b, v1_z, zoffset, ), zero, one, 
clamp_ptr);
-   z2_new = vert_clamp(b, LLVMBuildFAdd(b, v2_z, zoffset, ), zero, one, 
clamp_ptr);
+   z0_new = vert_clamp(b, LLVMBuildFAdd(b, v0_z, zoffset, ), zero, one);
+   z1_new = vert_clamp(b, LLVMBuildFAdd(b, v1_z, zoffset, ), zero, one);
+   z2_new = vert_clamp(b, LLVMBuildFAdd(b, v2_z, zoffset, ), zero, one);

/* store back new offsetted z values */
idx[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
@@ -716,7 +688,7 @@ generate_setup_variant(struct llvmpipe_screen *screen,
if (variant-key.twoside){
   lp_twoside(builder, args, variant-key);
}
-   if (variant-key.scale){
+   if (variant-key.scale || variant-key.units){
   lp_do_offset_tri(builder, args, variant-key);
}
emit_tri_coef(builder, variant-key, args);

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: fix such that offset/ twoside function only does in-place modification

2010-11-22 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: d4b5cf6c05d4fcb0acaa36490f7d3379e7fb3c0e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d4b5cf6c05d4fcb0acaa36490f7d3379e7fb3c0e

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Fri Nov 19 12:53:51 2010 +

llvmpipe: fix such that offset/twoside function only does in-place modification

---

 src/gallium/drivers/llvmpipe/lp_state_setup.c |  314 +
 1 files changed, 159 insertions(+), 155 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index 03b411a..c3c2c8b 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -76,7 +76,13 @@ struct lp_setup_args
LLVMValueRef dy20_ooa;
LLVMValueRef dy01_ooa;
LLVMValueRef dx20_ooa;
-   LLVMValueRef dx01_ooa;   
+   LLVMValueRef dx01_ooa;
+
+   /* Temporary, per-attribute:
+*/
+   LLVMValueRef v0a;
+   LLVMValueRef v1a;
+   LLVMValueRef v2a;
 };
 
 static LLVMTypeRef type4f(void)
@@ -152,16 +158,11 @@ static void
 emit_constant_coef4( LLVMBuilderRef builder,
 struct lp_setup_args *args,
 unsigned slot,
-LLVMValueRef vert,
-unsigned attr)
+LLVMValueRef vert)
 {
LLVMValueRef zero  = LLVMConstReal(LLVMFloatType(), 0.0);
LLVMValueRef zerovec   = vec4f_from_scalar(builder, zero, zero);
-   LLVMValueRef idx   = LLVMConstInt(LLVMInt32Type(), attr, 0);
-   LLVMValueRef attr_ptr  = LLVMBuildGEP(builder, vert, idx, 1, attr_ptr);
-   LLVMValueRef vert_attr = LLVMBuildLoad(builder, attr_ptr, vert_attr);
-
-   store_coef(builder, args, slot, vert_attr, zerovec, zerovec);
+   store_coef(builder, args, slot, vert, zerovec, zerovec);
 }
 
 
@@ -214,6 +215,132 @@ vert_clamp(LLVMBuilderRef b,
return clamp_value;
 }
 
+static void
+lp_twoside(LLVMBuilderRef b, 
+   struct lp_setup_args *args,
+   const struct lp_setup_variant_key *key)
+{
+   LLVMValueRef a0_back, a1_back, a2_back;
+   LLVMValueRef idx2 = LLVMConstInt(LLVMInt32Type(), key-bcolor_slot, 0);
+
+   LLVMValueRef facing = args-facing;
+   LLVMValueRef front_facing = LLVMBuildICmp(b, LLVMIntEQ, facing, 
LLVMConstInt(LLVMInt32Type(), 0, 0), ); /** need i1 for if condition */
+   
+   a0_back = LLVMBuildLoad(b, LLVMBuildGEP(b, args-v0, idx2, 1, ), 
v0a_back);
+   a1_back = LLVMBuildLoad(b, LLVMBuildGEP(b, args-v1, idx2, 1, ), 
v1a_back);
+   a2_back = LLVMBuildLoad(b, LLVMBuildGEP(b, args-v2, idx2, 1, ), 
v2a_back);
+
+   /* Possibly swap the front and back attrib values,
+*
+* Prefer select to if so we don't have to worry about phis or
+* allocas.
+*/
+   args-v0a = LLVMBuildSelect(b, front_facing, args-v0a, a0_back, );
+   args-v1a = LLVMBuildSelect(b, front_facing, args-v1a, a1_back, );
+   args-v2a = LLVMBuildSelect(b, front_facing, args-v2a, a2_back, );
+
+}
+
+static void
+lp_do_offset_tri(LLVMBuilderRef b, 
+ struct lp_setup_args *args,
+ const struct lp_setup_variant_key *key)
+{
+   struct lp_build_context bld;
+   LLVMValueRef zoffset, mult;
+   LLVMValueRef z0_new, z1_new, z2_new;
+   LLVMValueRef dzdx0, dzdx, dzdy0, dzdy;
+   LLVMValueRef max, max_value;
+   
+   LLVMValueRef one  = LLVMConstReal(LLVMFloatType(), 1.0);
+   LLVMValueRef zero  = LLVMConstReal(LLVMFloatType(), 0.0);
+
+   /* edge vectors: e = v0 - v2, f = v1 - v2 */
+   LLVMValueRef v0_x = vert_attrib(b, args-v0, 0, 0, v0_x);
+   LLVMValueRef v1_x = vert_attrib(b, args-v1, 0, 0, v1_x);
+   LLVMValueRef v2_x = vert_attrib(b, args-v2, 0, 0, v2_x);
+   LLVMValueRef v0_y = vert_attrib(b, args-v0, 0, 1, v0_y);
+   LLVMValueRef v1_y = vert_attrib(b, args-v1, 0, 1, v1_y);
+   LLVMValueRef v2_y = vert_attrib(b, args-v2, 0, 1, v2_y);
+   LLVMValueRef v0_z = vert_attrib(b, args-v0, 0, 2, v0_z);
+   LLVMValueRef v1_z = vert_attrib(b, args-v1, 0, 2, v1_z);
+   LLVMValueRef v2_z = vert_attrib(b, args-v2, 0, 2, v2_z);
+ 
+   /* edge vectors: e = v0 - v2, f = v1 - v2 */
+   LLVMValueRef dx02 = LLVMBuildFSub(b, v0_x, v2_x, dx02);
+   LLVMValueRef dy02 = LLVMBuildFSub(b, v0_y, v2_y, dy02);
+   LLVMValueRef dz02 = LLVMBuildFSub(b, v0_z, v2_z, dz02);
+   LLVMValueRef dx12 = LLVMBuildFSub(b, v1_x, v2_x, dx12); 
+   LLVMValueRef dy12 = LLVMBuildFSub(b, v1_y, v2_y, dy12);
+   LLVMValueRef dz12 = LLVMBuildFSub(b, v1_z, v2_z, dz12);
+ 
+   /* det = cross(e,f).z */
+   LLVMValueRef dx02_dy12  = LLVMBuildFMul(b, dx02, dy12, dx02_dy12);
+   LLVMValueRef dy02_dx12  = LLVMBuildFMul(b, dy02, dx12, dy02_dx12);
+   LLVMValueRef det  = LLVMBuildFSub(b, dx02_dy12, dy02_dx12, det);
+   LLVMValueRef inv_det = LLVMBuildFDiv(b, one, det, inv_det); 
+   
+   /* (res1,res2) = cross(e,f).xy */
+   LLVMValueRef dy02_dz12= LLVMBuildFMul(b, dy02, dz12, dy02_dz12);
+   LLVMValueRef dz02_dy12= LLVMBuildFMul(b, dz02, dy12, dz02_dy12);
+   LLVMValueRef dz02_dx12= LLVMBuildFMul(b, dz02, dx12, 

Mesa (master): llvmpipe: fix up twoside after recent changes

2010-11-22 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 081ce2680eb94f4f322faa26800a3906db6e2571
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=081ce2680eb94f4f322faa26800a3906db6e2571

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Nov 19 16:16:30 2010 +

llvmpipe: fix up twoside after recent changes

Fix my slot/attr confusion.

---

 src/gallium/drivers/llvmpipe/lp_state_setup.c |   15 +++
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index c3c2c8b..129ec0a 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -235,9 +235,9 @@ lp_twoside(LLVMBuilderRef b,
 * Prefer select to if so we don't have to worry about phis or
 * allocas.
 */
-   args-v0a = LLVMBuildSelect(b, front_facing, args-v0a, a0_back, );
-   args-v1a = LLVMBuildSelect(b, front_facing, args-v1a, a1_back, );
-   args-v2a = LLVMBuildSelect(b, front_facing, args-v2a, a2_back, );
+   args-v0a = LLVMBuildSelect(b, front_facing, a0_back, args-v0a, );
+   args-v1a = LLVMBuildSelect(b, front_facing, a1_back, args-v1a, );
+   args-v2a = LLVMBuildSelect(b, front_facing, a2_back, args-v2a, );
 
 }
 
@@ -318,7 +318,6 @@ static void
 load_attribute(LLVMBuilderRef b, 
struct lp_setup_args *args,
const struct lp_setup_variant_key *key,
-   unsigned slot,
unsigned vert_attr)
 {
LLVMValueRef idx = LLVMConstInt(LLVMInt32Type(), vert_attr, 0);
@@ -332,11 +331,11 @@ load_attribute(LLVMBuilderRef b,
 
/* Potentially modify it according to twoside, offset, etc:
 */
-   if (slot == 0  (key-scale != 0.0f || key-units != 0.0f)) {
+   if (vert_attr == 0  (key-scale != 0.0f || key-units != 0.0f)) {
   lp_do_offset_tri(b, args, key);
}
 
-   if (key-twoside  slot == key-color_slot) {
+   if (key-twoside  vert_attr == key-color_slot) {
   lp_twoside(b, args, key);
}
 }
@@ -448,7 +447,7 @@ emit_tri_coef( LLVMBuilderRef builder,
 
/* The internal position input is in slot zero:
 */
-   load_attribute(builder, args, key, 0, 0);
+   load_attribute(builder, args, key, 0);
emit_position_coef(builder, args, 0);
 
/* setup interpolation for all the remaining attributes:
@@ -458,7 +457,7 @@ emit_tri_coef( LLVMBuilderRef builder,
   if (key-inputs[slot].interp == LP_INTERP_CONSTANT ||
   key-inputs[slot].interp == LP_INTERP_LINEAR ||
   key-inputs[slot].interp == LP_INTERP_PERSPECTIVE)
- load_attribute(builder, args, key, slot, key-inputs[slot].src_index);
+ load_attribute(builder, args, key, key-inputs[slot].src_index);
 
   switch (key-inputs[slot].interp) {
   case LP_INTERP_CONSTANT:

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: twoside for specular color also

2010-11-22 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 546c5ffa11d70631348e5776df7a4168f07600f6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=546c5ffa11d70631348e5776df7a4168f07600f6

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Nov 19 16:17:36 2010 +

llvmpipe: twoside for specular color also

---

 src/gallium/drivers/llvmpipe/lp_context.h   |4 +-
 src/gallium/drivers/llvmpipe/lp_state_derived.c |   26 --
 src/gallium/drivers/llvmpipe/lp_state_setup.c   |   20 +++--
 src/gallium/drivers/llvmpipe/lp_state_setup.h   |   12 +++---
 4 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_context.h 
b/src/gallium/drivers/llvmpipe/lp_context.h
index 4515dbb..a35e09e 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_context.h
@@ -105,10 +105,10 @@ struct llvmpipe_context {
struct vertex_info vertex_info;

/** Which vertex shader output slot contains color */
-   int color_slot;
+   int color_slot[2];
 
/** Which vertex shader output slot contains bcolor */
-   int bcolor_slot;
+   int bcolor_slot[2];
 
/** Which vertex shader output slot contains point size */
int psize_slot;
diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c 
b/src/gallium/drivers/llvmpipe/lp_state_derived.c
index 1c9f03a..8725ea3 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_derived.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c
@@ -53,6 +53,11 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe)
unsigned vs_index;
uint i;
 
+   llvmpipe-color_slot[0] = ~0;
+   llvmpipe-color_slot[1] = ~0;
+   llvmpipe-bcolor_slot[0] = ~0;
+   llvmpipe-bcolor_slot[1] = ~0;
+
/*
 * Match FS inputs against VS outputs, emitting the necessary
 * attributes.  Could cache these structs and look them up with a
@@ -75,9 +80,13 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe)
   vs_index = draw_find_shader_output(llvmpipe-draw,
  
lpfs-info.base.input_semantic_name[i],
  
lpfs-info.base.input_semantic_index[i]);
-  if (lpfs-info.base.input_semantic_name[i]==TGSI_SEMANTIC_COLOR){
- llvmpipe-color_slot = vinfo-num_attribs;
+
+  if (lpfs-info.base.input_semantic_name[i] == TGSI_SEMANTIC_COLOR 
+  lpfs-info.base.input_semantic_index[i]  2) {
+ int idx = lpfs-info.base.input_semantic_index[i];
+ llvmpipe-color_slot[idx] = vinfo-num_attribs;
   }
+
   /*
* Emit the requested fs attribute for all but position.
*/
@@ -86,14 +95,17 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe)
 
/* Figure out if we need bcolor as well.
 */
-   vs_index = draw_find_shader_output(llvmpipe-draw,
-  TGSI_SEMANTIC_BCOLOR, 0);
+   for (i = 0; i  2; i++) {
+  vs_index = draw_find_shader_output(llvmpipe-draw,
+ TGSI_SEMANTIC_BCOLOR, i);
 
-   if (vs_index  0) {
-  llvmpipe-bcolor_slot = vinfo-num_attribs;
-  draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
+  if (vs_index  0) {
+ llvmpipe-bcolor_slot[i] = vinfo-num_attribs;
+ draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
+  }
}
 
+
/* Figure out if we need pointsize as well.
 */
vs_index = draw_find_shader_output(llvmpipe-draw,
diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index 129ec0a..194b014 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -218,10 +218,11 @@ vert_clamp(LLVMBuilderRef b,
 static void
 lp_twoside(LLVMBuilderRef b, 
struct lp_setup_args *args,
-   const struct lp_setup_variant_key *key)
+   const struct lp_setup_variant_key *key,
+   int bcolor_slot)
 {
LLVMValueRef a0_back, a1_back, a2_back;
-   LLVMValueRef idx2 = LLVMConstInt(LLVMInt32Type(), key-bcolor_slot, 0);
+   LLVMValueRef idx2 = LLVMConstInt(LLVMInt32Type(), bcolor_slot, 0);
 
LLVMValueRef facing = args-facing;
LLVMValueRef front_facing = LLVMBuildICmp(b, LLVMIntEQ, facing, 
LLVMConstInt(LLVMInt32Type(), 0, 0), ); /** need i1 for if condition */
@@ -335,8 +336,11 @@ load_attribute(LLVMBuilderRef b,
   lp_do_offset_tri(b, args, key);
}
 
-   if (key-twoside  vert_attr == key-color_slot) {
-  lp_twoside(b, args, key);
+   if (key-twoside) {
+  if (vert_attr == key-color_slot  key-bcolor_slot != ~0)
+ lp_twoside(b, args, key, key-bcolor_slot);
+  else if (vert_attr == key-spec_slot  key-bspec_slot != ~0)
+ lp_twoside(b, args, key, key-bspec_slot);
}
 }
 
@@ -746,9 +750,11 @@ lp_make_setup_variant_key(struct llvmpipe_context *lp,
key-pixel_center_half = lp-rasterizer-gl_rasterization_rules;
key-twoside = lp

Mesa (master): Merge branch 'lp-offset-twoside'

2010-11-22 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: b2ddb93ff3b8c88682634ccdef247967e31fab84
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b2ddb93ff3b8c88682634ccdef247967e31fab84

Author: Keith Whitwell kei...@vmware.com
Date:   Mon Nov 22 10:36:01 2010 +

Merge branch 'lp-offset-twoside'

---



___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (lp-offset-twoside): llvmpipe: fix such that offset/ twoside function only does in-place modification

2010-11-19 Thread Keith Whitwell
Module: Mesa
Branch: lp-offset-twoside
Commit: d4b5cf6c05d4fcb0acaa36490f7d3379e7fb3c0e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d4b5cf6c05d4fcb0acaa36490f7d3379e7fb3c0e

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Fri Nov 19 12:53:51 2010 +

llvmpipe: fix such that offset/twoside function only does in-place modification

---

 src/gallium/drivers/llvmpipe/lp_state_setup.c |  314 +
 1 files changed, 159 insertions(+), 155 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index 03b411a..c3c2c8b 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -76,7 +76,13 @@ struct lp_setup_args
LLVMValueRef dy20_ooa;
LLVMValueRef dy01_ooa;
LLVMValueRef dx20_ooa;
-   LLVMValueRef dx01_ooa;   
+   LLVMValueRef dx01_ooa;
+
+   /* Temporary, per-attribute:
+*/
+   LLVMValueRef v0a;
+   LLVMValueRef v1a;
+   LLVMValueRef v2a;
 };
 
 static LLVMTypeRef type4f(void)
@@ -152,16 +158,11 @@ static void
 emit_constant_coef4( LLVMBuilderRef builder,
 struct lp_setup_args *args,
 unsigned slot,
-LLVMValueRef vert,
-unsigned attr)
+LLVMValueRef vert)
 {
LLVMValueRef zero  = LLVMConstReal(LLVMFloatType(), 0.0);
LLVMValueRef zerovec   = vec4f_from_scalar(builder, zero, zero);
-   LLVMValueRef idx   = LLVMConstInt(LLVMInt32Type(), attr, 0);
-   LLVMValueRef attr_ptr  = LLVMBuildGEP(builder, vert, idx, 1, attr_ptr);
-   LLVMValueRef vert_attr = LLVMBuildLoad(builder, attr_ptr, vert_attr);
-
-   store_coef(builder, args, slot, vert_attr, zerovec, zerovec);
+   store_coef(builder, args, slot, vert, zerovec, zerovec);
 }
 
 
@@ -214,6 +215,132 @@ vert_clamp(LLVMBuilderRef b,
return clamp_value;
 }
 
+static void
+lp_twoside(LLVMBuilderRef b, 
+   struct lp_setup_args *args,
+   const struct lp_setup_variant_key *key)
+{
+   LLVMValueRef a0_back, a1_back, a2_back;
+   LLVMValueRef idx2 = LLVMConstInt(LLVMInt32Type(), key-bcolor_slot, 0);
+
+   LLVMValueRef facing = args-facing;
+   LLVMValueRef front_facing = LLVMBuildICmp(b, LLVMIntEQ, facing, 
LLVMConstInt(LLVMInt32Type(), 0, 0), ); /** need i1 for if condition */
+   
+   a0_back = LLVMBuildLoad(b, LLVMBuildGEP(b, args-v0, idx2, 1, ), 
v0a_back);
+   a1_back = LLVMBuildLoad(b, LLVMBuildGEP(b, args-v1, idx2, 1, ), 
v1a_back);
+   a2_back = LLVMBuildLoad(b, LLVMBuildGEP(b, args-v2, idx2, 1, ), 
v2a_back);
+
+   /* Possibly swap the front and back attrib values,
+*
+* Prefer select to if so we don't have to worry about phis or
+* allocas.
+*/
+   args-v0a = LLVMBuildSelect(b, front_facing, args-v0a, a0_back, );
+   args-v1a = LLVMBuildSelect(b, front_facing, args-v1a, a1_back, );
+   args-v2a = LLVMBuildSelect(b, front_facing, args-v2a, a2_back, );
+
+}
+
+static void
+lp_do_offset_tri(LLVMBuilderRef b, 
+ struct lp_setup_args *args,
+ const struct lp_setup_variant_key *key)
+{
+   struct lp_build_context bld;
+   LLVMValueRef zoffset, mult;
+   LLVMValueRef z0_new, z1_new, z2_new;
+   LLVMValueRef dzdx0, dzdx, dzdy0, dzdy;
+   LLVMValueRef max, max_value;
+   
+   LLVMValueRef one  = LLVMConstReal(LLVMFloatType(), 1.0);
+   LLVMValueRef zero  = LLVMConstReal(LLVMFloatType(), 0.0);
+
+   /* edge vectors: e = v0 - v2, f = v1 - v2 */
+   LLVMValueRef v0_x = vert_attrib(b, args-v0, 0, 0, v0_x);
+   LLVMValueRef v1_x = vert_attrib(b, args-v1, 0, 0, v1_x);
+   LLVMValueRef v2_x = vert_attrib(b, args-v2, 0, 0, v2_x);
+   LLVMValueRef v0_y = vert_attrib(b, args-v0, 0, 1, v0_y);
+   LLVMValueRef v1_y = vert_attrib(b, args-v1, 0, 1, v1_y);
+   LLVMValueRef v2_y = vert_attrib(b, args-v2, 0, 1, v2_y);
+   LLVMValueRef v0_z = vert_attrib(b, args-v0, 0, 2, v0_z);
+   LLVMValueRef v1_z = vert_attrib(b, args-v1, 0, 2, v1_z);
+   LLVMValueRef v2_z = vert_attrib(b, args-v2, 0, 2, v2_z);
+ 
+   /* edge vectors: e = v0 - v2, f = v1 - v2 */
+   LLVMValueRef dx02 = LLVMBuildFSub(b, v0_x, v2_x, dx02);
+   LLVMValueRef dy02 = LLVMBuildFSub(b, v0_y, v2_y, dy02);
+   LLVMValueRef dz02 = LLVMBuildFSub(b, v0_z, v2_z, dz02);
+   LLVMValueRef dx12 = LLVMBuildFSub(b, v1_x, v2_x, dx12); 
+   LLVMValueRef dy12 = LLVMBuildFSub(b, v1_y, v2_y, dy12);
+   LLVMValueRef dz12 = LLVMBuildFSub(b, v1_z, v2_z, dz12);
+ 
+   /* det = cross(e,f).z */
+   LLVMValueRef dx02_dy12  = LLVMBuildFMul(b, dx02, dy12, dx02_dy12);
+   LLVMValueRef dy02_dx12  = LLVMBuildFMul(b, dy02, dx12, dy02_dx12);
+   LLVMValueRef det  = LLVMBuildFSub(b, dx02_dy12, dy02_dx12, det);
+   LLVMValueRef inv_det = LLVMBuildFDiv(b, one, det, inv_det); 
+   
+   /* (res1,res2) = cross(e,f).xy */
+   LLVMValueRef dy02_dz12= LLVMBuildFMul(b, dy02, dz12, dy02_dz12);
+   LLVMValueRef dz02_dy12= LLVMBuildFMul(b, dz02, dy12, dz02_dy12);
+   LLVMValueRef dz02_dx12= LLVMBuildFMul(b, 

Mesa (lp-offset-twoside): llvmpipe: fix up twoside after recent changes

2010-11-19 Thread Keith Whitwell
Module: Mesa
Branch: lp-offset-twoside
Commit: 081ce2680eb94f4f322faa26800a3906db6e2571
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=081ce2680eb94f4f322faa26800a3906db6e2571

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Nov 19 16:16:30 2010 +

llvmpipe: fix up twoside after recent changes

Fix my slot/attr confusion.

---

 src/gallium/drivers/llvmpipe/lp_state_setup.c |   15 +++
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index c3c2c8b..129ec0a 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -235,9 +235,9 @@ lp_twoside(LLVMBuilderRef b,
 * Prefer select to if so we don't have to worry about phis or
 * allocas.
 */
-   args-v0a = LLVMBuildSelect(b, front_facing, args-v0a, a0_back, );
-   args-v1a = LLVMBuildSelect(b, front_facing, args-v1a, a1_back, );
-   args-v2a = LLVMBuildSelect(b, front_facing, args-v2a, a2_back, );
+   args-v0a = LLVMBuildSelect(b, front_facing, a0_back, args-v0a, );
+   args-v1a = LLVMBuildSelect(b, front_facing, a1_back, args-v1a, );
+   args-v2a = LLVMBuildSelect(b, front_facing, a2_back, args-v2a, );
 
 }
 
@@ -318,7 +318,6 @@ static void
 load_attribute(LLVMBuilderRef b, 
struct lp_setup_args *args,
const struct lp_setup_variant_key *key,
-   unsigned slot,
unsigned vert_attr)
 {
LLVMValueRef idx = LLVMConstInt(LLVMInt32Type(), vert_attr, 0);
@@ -332,11 +331,11 @@ load_attribute(LLVMBuilderRef b,
 
/* Potentially modify it according to twoside, offset, etc:
 */
-   if (slot == 0  (key-scale != 0.0f || key-units != 0.0f)) {
+   if (vert_attr == 0  (key-scale != 0.0f || key-units != 0.0f)) {
   lp_do_offset_tri(b, args, key);
}
 
-   if (key-twoside  slot == key-color_slot) {
+   if (key-twoside  vert_attr == key-color_slot) {
   lp_twoside(b, args, key);
}
 }
@@ -448,7 +447,7 @@ emit_tri_coef( LLVMBuilderRef builder,
 
/* The internal position input is in slot zero:
 */
-   load_attribute(builder, args, key, 0, 0);
+   load_attribute(builder, args, key, 0);
emit_position_coef(builder, args, 0);
 
/* setup interpolation for all the remaining attributes:
@@ -458,7 +457,7 @@ emit_tri_coef( LLVMBuilderRef builder,
   if (key-inputs[slot].interp == LP_INTERP_CONSTANT ||
   key-inputs[slot].interp == LP_INTERP_LINEAR ||
   key-inputs[slot].interp == LP_INTERP_PERSPECTIVE)
- load_attribute(builder, args, key, slot, key-inputs[slot].src_index);
+ load_attribute(builder, args, key, key-inputs[slot].src_index);
 
   switch (key-inputs[slot].interp) {
   case LP_INTERP_CONSTANT:

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (lp-offset-twoside): llvmpipe: clean up polygon offset function in lp setup code

2010-11-16 Thread Keith Whitwell
Module: Mesa
Branch: lp-offset-twoside
Commit: e3f106b5fe36ad558b3971ba88802c5d80b007de
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e3f106b5fe36ad558b3971ba88802c5d80b007de

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Sat Nov 13 21:39:50 2010 +

llvmpipe: clean up polygon offset function in lp setup code

---

 src/gallium/drivers/llvmpipe/lp_state_setup.c |   60 +++--
 1 files changed, 16 insertions(+), 44 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index 7751b7d..03b411a 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -202,29 +202,16 @@ static LLVMValueRef
 vert_clamp(LLVMBuilderRef b,
LLVMValueRef x,
LLVMValueRef min,
-   LLVMValueRef max,
-   LLVMValueRef clamp_ptr)
+   LLVMValueRef max)
 {
-   struct lp_build_if_state if_state;
LLVMValueRef min_result = LLVMBuildFCmp(b, LLVMRealUGT, min, x, );
LLVMValueRef max_result = LLVMBuildFCmp(b, LLVMRealUGT, x, max, );
-   
-   lp_build_if(if_state, b, min_result);
-   {
-  LLVMBuildStore(b, min, clamp_ptr);
-   }   
-   lp_build_endif(if_state);
-   lp_build_if(if_state, b, max_result);
-   {
-  LLVMBuildStore(b, max, clamp_ptr);
-   }  
-   lp_build_else(if_state);
-   {
-  LLVMBuildStore(b, x, clamp_ptr);
-   }
-   lp_build_endif(if_state);
-   
-   return LLVMBuildLoad(b, clamp_ptr,);
+   LLVMValueRef clamp_value;
+
+   clamp_value = LLVMBuildSelect(b, min_result, min, x, );
+   clamp_value = LLVMBuildSelect(b, max_result, max, x, );
+
+   return clamp_value;
 }
 
 static void 
@@ -542,11 +529,11 @@ lp_do_offset_tri(LLVMBuilderRef b,
  struct lp_setup_args *args,
  const struct lp_setup_variant_key *key)
 {
-   struct lp_build_if_state if_state;
struct lp_build_context bld;
LLVMValueRef zoffset, mult;
LLVMValueRef z0_new, z1_new, z2_new;
-   LLVMValueRef dzdx0, dzdx, dzdy0, dzdy, max;
+   LLVMValueRef dzdx0, dzdx, dzdy0, dzdy;
+   LLVMValueRef max, max_value;
 
LLVMValueRef idx[2];
LLVMValueRef one  = LLVMConstReal(LLVMFloatType(), 1.0);
@@ -584,10 +571,6 @@ lp_do_offset_tri(LLVMBuilderRef b,
LLVMValueRef dx02_dz12= LLVMBuildFMul(b, dx02, dz12, dx02_dz12);
LLVMValueRef res1  = LLVMBuildFSub(b, dy02_dz12, dz02_dy12, res1);
LLVMValueRef res2  = LLVMBuildFSub(b, dz02_dx12, dx02_dz12, res2);
-
-   /* for the if-else functions phi's */
-   LLVMValueRef zoffset_ptr = lp_build_alloca(b, LLVMFloatType(), );
-   LLVMValueRef clamp_ptr = lp_build_alloca(b, LLVMFloatType(), );
  
/* dzdx = fabsf(res1 * inv_det), dydx = fabsf(res2 * inv_det)*/
lp_build_context_init(bld, b, lp_type_float(32));
@@ -598,26 +581,15 @@ lp_do_offset_tri(LLVMBuilderRef b,
 
/* zoffset = offset-units + MAX2(dzdx, dzdy) * offset-scale */
max = LLVMBuildFCmp(b, LLVMRealUGT, dzdx, dzdy, );
-   lp_build_if(if_state, b, max);
-   {
-  mult = LLVMBuildFMul(b, dzdx, LLVMConstReal(LLVMFloatType(), 
key-scale), );
-  zoffset = LLVMBuildFAdd(b, LLVMConstReal(LLVMFloatType(), key-units), 
mult, zoffset);
-  LLVMBuildStore(b, zoffset, zoffset_ptr);
-   }   
-   lp_build_else(if_state);
-   {
-  mult = LLVMBuildFMul(b, dzdy, LLVMConstReal(LLVMFloatType(), 
key-scale), );
-  zoffset = LLVMBuildFAdd(b, LLVMConstReal(LLVMFloatType(), key-units), 
mult, zoffset); 
-  LLVMBuildStore(b, zoffset, zoffset_ptr);
-   }
-   lp_build_endif(if_state);
+   max_value = LLVMBuildSelect(b, max, dzdx, dzdy, max); 
 
-   zoffset = LLVMBuildLoad(b, zoffset_ptr,);
+   mult = LLVMBuildFMul(b, max_value, LLVMConstReal(LLVMFloatType(), 
key-scale), );
+   zoffset = LLVMBuildFAdd(b, LLVMConstReal(LLVMFloatType(), key-units), 
mult, zoffset); 
 
/* clamp and do offset */
-   z0_new = vert_clamp(b, LLVMBuildFAdd(b, v0_z, zoffset, ), zero, one, 
clamp_ptr);
-   z1_new = vert_clamp(b, LLVMBuildFAdd(b, v1_z, zoffset, ), zero, one, 
clamp_ptr);
-   z2_new = vert_clamp(b, LLVMBuildFAdd(b, v2_z, zoffset, ), zero, one, 
clamp_ptr);
+   z0_new = vert_clamp(b, LLVMBuildFAdd(b, v0_z, zoffset, ), zero, one);
+   z1_new = vert_clamp(b, LLVMBuildFAdd(b, v1_z, zoffset, ), zero, one);
+   z2_new = vert_clamp(b, LLVMBuildFAdd(b, v2_z, zoffset, ), zero, one);

/* store back new offsetted z values */
idx[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
@@ -716,7 +688,7 @@ generate_setup_variant(struct llvmpipe_screen *screen,
if (variant-key.twoside){
   lp_twoside(builder, args, variant-key);
}
-   if (variant-key.scale){
+   if (variant-key.scale || variant-key.units){
   lp_do_offset_tri(builder, args, variant-key);
}
emit_tri_coef(builder, variant-key, args);

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): r600g: guard experimental s3tc code with R600_ENABLE_S3TC

2010-11-11 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 6baad55f157387d0bb44144680a96bc32280109f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6baad55f157387d0bb44144680a96bc32280109f

Author: Keith Whitwell kei...@vmware.com
Date:   Thu Nov 11 14:26:52 2010 +

r600g: guard experimental s3tc code with R600_ENABLE_S3TC

---

 src/gallium/drivers/r600/r600_texture.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index ef5adaf..a590858 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -832,6 +832,15 @@ uint32_t r600_translate_texformat(enum pipe_format format,
 
/* S3TC formats. TODO */
if (desc-layout == UTIL_FORMAT_LAYOUT_S3TC) {
+static int r600_enable_s3tc = -1;
+
+if (r600_enable_s3tc == -1)
+r600_enable_s3tc = 
+debug_get_bool_option(R600_ENABLE_S3TC, 
FALSE);
+
+if (!r600_enable_s3tc)
+goto out_unknown;
+
switch (format) {
case PIPE_FORMAT_DXT1_RGB:
case PIPE_FORMAT_DXT1_RGBA:

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): r600g: do not try to use staging resource for depth textures

2010-11-11 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 8a3c181e9cc761abb647a8e813f25e3fa4441a9a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8a3c181e9cc761abb647a8e813f25e3fa4441a9a

Author: Keith Whitwell kei...@vmware.com
Date:   Thu Nov 11 15:41:49 2010 +

r600g: do not try to use staging resource for depth textures

Currently r600_resource_copy_region() will turn these copies into
transfers + memcpys, so to avoid recursion we must not turn those
transfers back into blits.

---

 src/gallium/drivers/r600/r600_texture.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index a590858..56313e9 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -479,6 +479,15 @@ static boolean permit_hardware_blit(struct pipe_screen 
*screen,
 else
 bind = PIPE_BIND_RENDER_TARGET;
 
+   /* See r600_resource_copy_region: there is something wrong
+ * with depth resource copies at the moment so avoid them for
+ * now.
+ */
+   if (util_format_get_component_bits(res-format,
+   UTIL_FORMAT_COLORSPACE_ZS,
+   0) != 0)
+return FALSE;
+
 if (!screen-is_format_supported(screen,
  res-format,
  res-target,

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): r600g: enforce minimum stride on render target texture images

2010-11-11 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 7fb16423cc325efcdcf6e4954a5ac71d8f96dbf8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7fb16423cc325efcdcf6e4954a5ac71d8f96dbf8

Author: Keith Whitwell kei...@vmware.com
Date:   Thu Nov 11 16:20:24 2010 +

r600g: enforce minimum stride on render target texture images

Fixes piglit/fbo_readpixels since staging upload changes.

---

 src/gallium/drivers/r600/r600_texture.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index 56313e9..e719f7f 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -169,6 +169,10 @@ static unsigned r600_texture_get_stride(struct pipe_screen 
*screen,
stride = util_format_get_stride(ptex-format, width);
if (chipc == EVERGREEN)
stride = align(stride, 512);
+
+if (ptex-bind  PIPE_BIND_RENDER_TARGET)
+   stride = align(stride, 512);
+
return stride;
 }
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): ws/r600: match bo_busy shared/fence logic in bo_wait

2010-11-10 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 9a04eca2f865dc3eca31b34ae570cd489b18c240
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9a04eca2f865dc3eca31b34ae570cd489b18c240

Author: Keith Whitwell kei...@vmware.com
Date:   Wed Nov 10 11:03:07 2010 +

ws/r600: match bo_busy shared/fence logic in bo_wait

Fixes crash in piglit depthrange-clear.

---

 src/gallium/winsys/r600/drm/radeon_bo.c |   17 +
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/gallium/winsys/r600/drm/radeon_bo.c 
b/src/gallium/winsys/r600/drm/radeon_bo.c
index 3054782..557cfb9 100644
--- a/src/gallium/winsys/r600/drm/radeon_bo.c
+++ b/src/gallium/winsys/r600/drm/radeon_bo.c
@@ -153,14 +153,15 @@ int radeon_bo_wait(struct radeon *radeon, struct 
radeon_bo *bo)
struct drm_radeon_gem_wait_idle args;
int ret;
 
-   if (!bo-fence  !bo-shared)
-   return 0;
-
-   if (bo-fence = *bo-ctx-cfence) {
-   LIST_DELINIT(bo-fencedlist);
-   bo-fence = 0;
-   return 0;
-   }
+if (!bo-shared) {
+if (!bo-fence)
+   return 0;
+   if (bo-fence = *bo-ctx-cfence) {
+   LIST_DELINIT(bo-fencedlist);
+   bo-fence = 0;
+   return 0;
+   }
+}
 
/* Zero out args to make valgrind happy */
memset(args, 0, sizeof(args));

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): r600g: attempt to turn on DXTn formats

2010-11-09 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: c2c55547dc36f404e29dbc9253166f90df6783af
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c2c55547dc36f404e29dbc9253166f90df6783af

Author: Keith Whitwell kei...@vmware.com
Date:   Wed Nov  3 14:23:45 2010 +

r600g: attempt to turn on DXTn formats

Seems to sort-of work for non-mipmapped textures.  Better than just
black anyway.

---

 src/gallium/drivers/r600/eg_state_inlines.h   |2 +-
 src/gallium/drivers/r600/r600_state_inlines.h |2 +-
 src/gallium/drivers/r600/r600_texture.c   |   17 +++--
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/r600/eg_state_inlines.h 
b/src/gallium/drivers/r600/eg_state_inlines.h
index be81c28..5964197 100644
--- a/src/gallium/drivers/r600/eg_state_inlines.h
+++ b/src/gallium/drivers/r600/eg_state_inlines.h
@@ -473,7 +473,7 @@ static INLINE uint32_t r600_translate_colorformat(enum 
pipe_format format)
case PIPE_FORMAT_UYVY:
case PIPE_FORMAT_YUYV:
default:
-   R600_ERR(unsupported color format %d\n, format);
+   //R600_ERR(unsupported color format %d\n, format);
return ~0; /* Unsupported. */
}
 }
diff --git a/src/gallium/drivers/r600/r600_state_inlines.h 
b/src/gallium/drivers/r600/r600_state_inlines.h
index 1c1978f..1be5b15 100644
--- a/src/gallium/drivers/r600/r600_state_inlines.h
+++ b/src/gallium/drivers/r600/r600_state_inlines.h
@@ -472,7 +472,7 @@ static INLINE uint32_t r600_translate_colorformat(enum 
pipe_format format)
case PIPE_FORMAT_UYVY:
case PIPE_FORMAT_YUYV:
default:
-   R600_ERR(unsupported color format %d %s\n, format, 
util_format_name(format));
+   //R600_ERR(unsupported color format %d %s\n, format, 
util_format_name(format));
return ~0; /* Unsupported. */
}
 }
diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index 06d17f7..02160fd 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -806,7 +806,7 @@ uint32_t r600_translate_texformat(enum pipe_format format,
result = FMT_24_8;
goto out_word4;
case PIPE_FORMAT_S8_USCALED:
-   result = V_0280A0_COLOR_8;
+   result = FMT_8;
word4 |= 
S_038010_NUM_FORMAT_ALL(V_038010_SQ_NUM_FORMAT_INT);
goto out_word4;
default:
@@ -835,7 +835,20 @@ uint32_t r600_translate_texformat(enum pipe_format format,
 
/* S3TC formats. TODO */
if (desc-layout == UTIL_FORMAT_LAYOUT_S3TC) {
-   goto out_unknown;
+   switch (format) {
+   case PIPE_FORMAT_DXT1_RGB:
+   case PIPE_FORMAT_DXT1_RGBA:
+result = FMT_BC1;
+goto out_word4;
+   case PIPE_FORMAT_DXT3_RGBA:
+result = FMT_BC2;
+goto out_word4;
+   case PIPE_FORMAT_DXT5_RGBA:
+result = FMT_BC3;
+goto out_word4;
+default:
+goto out_unknown;
+}
}
 
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): r600g: avoid recursion with staged uploads

2010-11-09 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: e3ea4aec033643a629e2fa48eb538fdb856adf4e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e3ea4aec033643a629e2fa48eb538fdb856adf4e

Author: Keith Whitwell kei...@vmware.com
Date:   Wed Nov  3 14:06:33 2010 +

r600g: avoid recursion with staged uploads

Don't use an intermediate for formats which don't support hardware
blits under u_blitter.c, as these will recursively attempt to create a
transfer.

---

 src/gallium/drivers/r600/r600_texture.c |   34 +++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index 0c9b999..06d17f7 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -466,6 +466,36 @@ static INLINE unsigned u_box_volume( const struct pipe_box 
*box )
 };
 
 
+/* Figure out whether u_blitter will fallback to a transfer operation.
+ * If so, don't use a staging resource.
+ */
+static boolean permit_hardware_blit(struct pipe_screen *screen,
+struct pipe_resource *res)
+{
+unsigned bind;
+
+if (util_format_is_depth_or_stencil(res-format))
+bind = PIPE_BIND_DEPTH_STENCIL;
+else
+bind = PIPE_BIND_RENDER_TARGET;
+
+if (!screen-is_format_supported(screen,
+ res-format,
+ res-target,
+ res-nr_samples,
+ bind, 0))
+return FALSE;
+
+if (!screen-is_format_supported(screen,
+ res-format,
+ res-target,
+ res-nr_samples,
+ PIPE_BIND_SAMPLER_VIEW, 0))
+return FALSE;
+
+return TRUE;
+}
+
 struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
struct pipe_resource *texture,
struct pipe_subresource sr,
@@ -506,6 +536,10 @@ struct pipe_transfer* r600_texture_get_transfer(struct 
pipe_context *ctx,
 !(usage  (PIPE_TRANSFER_DONTBLOCK | 
PIPE_TRANSFER_UNSYNCHRONIZED)))
 use_staging_texture = TRUE;
 
+if (!permit_hardware_blit(ctx-screen, texture) ||
+(texture-flags  R600_RESOURCE_FLAG_TRANSFER))
+use_staging_texture = FALSE;
+
trans = CALLOC_STRUCT(r600_transfer);
if (trans == NULL)
return NULL;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): r600g: translate ARR instruction

2010-11-09 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 9f7ec103e26c67cb077fd7d94d2fb68562b86c40
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9f7ec103e26c67cb077fd7d94d2fb68562b86c40

Author: Keith Whitwell kei...@vmware.com
Date:   Wed Nov  3 18:54:03 2010 +

r600g: translate ARR instruction

---

 src/gallium/drivers/r600/r600_shader.c |   15 +--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c 
b/src/gallium/drivers/r600/r600_shader.c
index 1a0b35d..f6153c0 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -2663,7 +2663,18 @@ static int tgsi_r600_arl(struct r600_shader_ctx *ctx)
int r;
memset(alu, 0, sizeof(struct r600_bc_alu));
 
-   alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_FLOOR;
+switch (inst-Instruction.Opcode) {
+case TGSI_OPCODE_ARL:
+   alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_FLOOR;
+   break;
+case TGSI_OPCODE_ARR:
+   alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA;
+   break;
+default:
+   assert(0);
+   return -1;
+}
+
 
r = tgsi_src(ctx, inst-Src[0], alu.src[0]);
if (r)
@@ -3070,7 +3081,7 @@ static struct r600_shader_tgsi_instruction 
r600_shader_tgsi_instruction[] = {
{TGSI_OPCODE_UP4UB, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, 
tgsi_unsupported},
{TGSI_OPCODE_X2D,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, 
tgsi_unsupported},
{TGSI_OPCODE_ARA,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, 
tgsi_unsupported},
-   {TGSI_OPCODE_ARR,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, 
tgsi_unsupported},
+   {TGSI_OPCODE_ARR,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, 
tgsi_r600_arl},
{TGSI_OPCODE_BRA,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, 
tgsi_unsupported},
{TGSI_OPCODE_CAL,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, 
tgsi_unsupported},
{TGSI_OPCODE_RET,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, 
tgsi_unsupported},

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): r600: fix my pessimism about PIPE_TRANSFER_x flags

2010-11-09 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 63c3e3a3dc73f8a72e0d08ac4453df57bccdfdb9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=63c3e3a3dc73f8a72e0d08ac4453df57bccdfdb9

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Nov  9 20:08:45 2010 +

r600: fix my pessimism about PIPE_TRANSFER_x flags

For some reason I though we needed the _DISCARD flag to avoid
readbacks, which isn't true at all.  Now write operations should
pipeline properly, gives a good speedup to demos/tunnel.

---

 src/gallium/drivers/r600/r600_texture.c |   13 +
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index 02160fd..ef5adaf 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -507,10 +507,6 @@ struct pipe_transfer* r600_texture_get_transfer(struct 
pipe_context *ctx,
struct r600_transfer *trans;
int r;
boolean use_staging_texture = FALSE;
-   boolean discard = FALSE;
-
-   if (!(usage  PIPE_TRANSFER_READ)  (usage  PIPE_TRANSFER_DISCARD))
-   discard = TRUE;
 
/* We cannot map a tiled texture directly because the data is
 * in a different order, therefore we do detiling using a blit.
@@ -522,7 +518,7 @@ struct pipe_transfer* r600_texture_get_transfer(struct 
pipe_context *ctx,
if (rtex-tiled)
use_staging_texture = TRUE;
 
-if (usage  PIPE_TRANSFER_READ 
+   if ((usage  PIPE_TRANSFER_READ) 
 u_box_volume(box)  1024)
 use_staging_texture = TRUE;
 
@@ -532,8 +528,9 @@ struct pipe_transfer* r600_texture_get_transfer(struct 
pipe_context *ctx,
  * and might block.
  */
 if ((usage  PIPE_TRANSFER_WRITE) 
-discard 
-!(usage  (PIPE_TRANSFER_DONTBLOCK | 
PIPE_TRANSFER_UNSYNCHRONIZED)))
+!(usage  (PIPE_TRANSFER_READ |
+   PIPE_TRANSFER_DONTBLOCK |
+   PIPE_TRANSFER_UNSYNCHRONIZED)))
 use_staging_texture = TRUE;
 
 if (!permit_hardware_blit(ctx-screen, texture) ||
@@ -591,7 +588,7 @@ struct pipe_transfer* r600_texture_get_transfer(struct 
pipe_context *ctx,
 
trans-transfer.stride =
 ((struct r600_resource_texture 
*)trans-staging_texture)-pitch_in_bytes[0];
-   if (!discard) {
+   if (usage  PIPE_TRANSFER_READ) {
r600_copy_to_staging_texture(ctx, trans);
/* Always referenced in the blit. */
ctx-flush(ctx, 0, NULL);

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (lp-offset-twoside): llvmpipe: added llvm offset setup code

2010-11-04 Thread Keith Whitwell
Module: Mesa
Branch: lp-offset-twoside
Commit: 315f8daab1598a4de709d469a559b5aa09107404
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=315f8daab1598a4de709d469a559b5aa09107404

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Thu Nov  4 11:42:55 2010 +

llvmpipe: added llvm offset setup code

---

 src/gallium/drivers/llvmpipe/lp_context.h   |3 +
 src/gallium/drivers/llvmpipe/lp_state_setup.c   |  179 +--
 src/gallium/drivers/llvmpipe/lp_state_setup.h   |6 +-
 src/gallium/drivers/llvmpipe/lp_state_surface.c |1 +
 4 files changed, 143 insertions(+), 46 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_context.h 
b/src/gallium/drivers/llvmpipe/lp_context.h
index 2230d50..4515dbb 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_context.h
@@ -113,6 +113,9 @@ struct llvmpipe_context {
/** Which vertex shader output slot contains point size */
int psize_slot;
 
+   /** minimum resolvable depth value, for polygon offset */   
+   double mrd;
+   
/** The tiling engine */
struct lp_setup_context *setup;
struct lp_setup_variant setup_variant;
diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index 8383494..7751b7d 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -30,10 +30,12 @@
 #include util/u_memory.h
 #include util/u_simple_list.h
 #include os/os_time.h
+#include gallivm/lp_bld_arit.h
 #include gallivm/lp_bld_debug.h
 #include gallivm/lp_bld_init.h
 #include gallivm/lp_bld_intr.h
 #include gallivm/lp_bld_flow.h
+#include gallivm/lp_bld_type.h
 #include llvm-c/Analysis.h   /* for LLVMVerifyFunction */
 
 #include lp_perf.h
@@ -74,15 +76,7 @@ struct lp_setup_args
LLVMValueRef dy20_ooa;
LLVMValueRef dy01_ooa;
LLVMValueRef dx20_ooa;
-   LLVMValueRef dx01_ooa;
-
-   /* For twoside calcs 
-*/
-   LLVMValueRef det;
-   LLVMValueRef sign;
-   LLVMValueRef bcolor_slot;
-   LLVMValueRef color_slot;
-   
+   LLVMValueRef dx01_ooa;   
 };
 
 static LLVMTypeRef type4f(void)
@@ -204,7 +198,34 @@ vert_attrib(LLVMBuilderRef b,
return LLVMBuildLoad(b, LLVMBuildGEP(b, vert, idx, 2, ), name);
 }
 
-
+static LLVMValueRef
+vert_clamp(LLVMBuilderRef b,
+   LLVMValueRef x,
+   LLVMValueRef min,
+   LLVMValueRef max,
+   LLVMValueRef clamp_ptr)
+{
+   struct lp_build_if_state if_state;
+   LLVMValueRef min_result = LLVMBuildFCmp(b, LLVMRealUGT, min, x, );
+   LLVMValueRef max_result = LLVMBuildFCmp(b, LLVMRealUGT, x, max, );
+   
+   lp_build_if(if_state, b, min_result);
+   {
+  LLVMBuildStore(b, min, clamp_ptr);
+   }   
+   lp_build_endif(if_state);
+   lp_build_if(if_state, b, max_result);
+   {
+  LLVMBuildStore(b, max, clamp_ptr);
+   }  
+   lp_build_else(if_state);
+   {
+  LLVMBuildStore(b, x, clamp_ptr);
+   }
+   lp_build_endif(if_state);
+   
+   return LLVMBuildLoad(b, clamp_ptr,);
+}
 
 static void 
 emit_coef4( LLVMBuilderRef b,
@@ -482,15 +503,6 @@ init_args(LLVMBuilderRef b,
 }
 
 static void
-set_args_attr(struct llvmpipe_context *lp,
-   struct lp_setup_args *args)
-{
-   args-color_slot = LLVMConstInt(LLVMInt32Type(), lp-color_slot, 0);
-   args-bcolor_slot = LLVMConstInt(LLVMInt32Type(), lp-bcolor_slot, 0);
-   args-sign =  LLVMConstReal(LLVMFloatType(), (lp-rasterizer-front_ccw ? 
-1.0f : 1.0f));
-}
-
-static void
 lp_twoside(LLVMBuilderRef b, 
struct lp_setup_args *args,
const struct lp_setup_variant_key *key)
@@ -499,32 +511,13 @@ lp_twoside(LLVMBuilderRef b,
  
LLVMValueRef a0_old, a1_old, a2_old;
LLVMValueRef a0_new, a1_new, a2_new;
-
-   LLVMValueRef idx1 = args-color_slot;
-   LLVMValueRef idx2 = args-bcolor_slot;
+   
+   LLVMValueRef idx1 = LLVMConstInt(LLVMInt32Type(), key-color_slot, 0);
+   LLVMValueRef idx2 = LLVMConstInt(LLVMInt32Type(), key-bcolor_slot, 0);
 
LLVMValueRef facing = args-facing;
-   LLVMValueRef front_facing = LLVMBuildICmp(b, LLVMIntEQ, facing, 
LLVMConstInt(LLVMInt32Type(), 0, 0), ); /** need i1 for loop condition */
+   LLVMValueRef front_facing = LLVMBuildICmp(b, LLVMIntEQ, facing, 
LLVMConstInt(LLVMInt32Type(), 0, 0), ); /** need i1 for if condition */

-#if 0 
-/*Probably can delete this, just tried to follow draw_pipe_twoside way of 
-  calculating det*/
-   /* edge vectors: e = v0 - v2, f = v1 - v2 */
-   LLVMValueRef e = LLVMBuildFSub(b, args-v0, args-v2, e);
-   LLVMValueRef f = LLVMBuildFSub(b, args-v1, args-v2, f);
-   LLVMValueRef dx02 = vert_attrib(b, e, 0, 0, dx02);
-   LLVMValueRef dy02 = vert_attrib(b, e, 0, 1, dy02);
-   LLVMValueRef dx12 = vert_attrib(b, f, 0, 0, dx12);
-   LLVMValueRef dy12 = vert_attrib(b, f, 0, 1, dy12);
- 
-   /* det = cross(e,f).z */
-   LLVMValueRef dx02_dy12  = LLVMBuildFMul(b, dx02, dy12, dx02_dy12);
-   LLVMValueRef dy02_dx12  = LLVMBuildFMul(b, dy02, dx12, dy02_dx12);
-   

Mesa (master): r300g: Do not use buf param before checking for NULL.

2010-11-04 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 560ad7e59940423a696e93e62ec3c41b1e553421
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=560ad7e59940423a696e93e62ec3c41b1e553421

Author: Guillermo S. Romero gsrom...@infernal-iceberg.com
Date:   Wed Nov  3 22:14:00 2010 +0100

r300g: Do not use buf param before checking for NULL.

Commit 8dfafbf0861fe3d2542332658dd5493851053c78 forgot to update r300g.
There is a buf == NULL check, but buf is used before for var init.

Tested-by: Guillermo S. Romero gsrom...@infernal-iceberg.com

---

 src/gallium/drivers/r300/r300_state.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_state.c 
b/src/gallium/drivers/r300/r300_state.c
index f2479a9..f513f87 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -1789,7 +1789,7 @@ static void r300_set_constant_buffer(struct pipe_context 
*pipe,
 {
 struct r300_context* r300 = r300_context(pipe);
 struct r300_constant_buffer *cbuf;
-uint32_t *mapped = r300_buffer(buf)-user_buffer;
+uint32_t *mapped;
 
 switch (shader) {
 case PIPE_SHADER_VERTEX:

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): r600g: propagate usage flags in texture transfers

2010-11-03 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 14c0bbf469642722f86df315b9f85d23f9753956
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=14c0bbf469642722f86df315b9f85d23f9753956

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Oct 15 14:44:30 2010 +0100

r600g: propagate usage flags in texture transfers

---

 src/gallium/drivers/r600/r600_texture.c |   27 ++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index 4ebd5b7..7222b43 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -31,6 +31,7 @@
 #include util/u_inlines.h
 #include util/u_memory.h
 #include state_tracker/drm_driver.h
+#include pipebuffer/pb_buffer.h
 #include r600_pipe.h
 #include r600_resource.h
 #include r600_state_inlines.h
@@ -537,6 +538,7 @@ void* r600_texture_transfer_map(struct pipe_context *ctx,
enum pipe_format format = transfer-resource-format;
struct radeon *radeon = (struct radeon *)ctx-screen-winsys;
unsigned offset = 0;
+   unsigned usage = 0;
char *map;
 
if (rtransfer-linear_texture) {
@@ -553,7 +555,30 @@ void* r600_texture_transfer_map(struct pipe_context *ctx,
transfer-box.y / util_format_get_blockheight(format) * 
transfer-stride +
transfer-box.x / util_format_get_blockwidth(format) * 
util_format_get_blocksize(format);
}
-   map = r600_bo_map(radeon, bo, 0, ctx);
+
+   if (transfer-usage  PIPE_TRANSFER_WRITE) {
+   usage |= PB_USAGE_CPU_WRITE;
+
+   if (transfer-usage  PIPE_TRANSFER_DISCARD) {
+   }
+
+   if (transfer-usage  PIPE_TRANSFER_FLUSH_EXPLICIT) {
+   }
+   }
+
+   if (transfer-usage  PIPE_TRANSFER_READ) {
+   usage |= PB_USAGE_CPU_READ;
+   }
+
+   if (transfer-usage  PIPE_TRANSFER_DONTBLOCK) {
+   usage |= PB_USAGE_DONTBLOCK;
+   }
+
+   if (transfer-usage  PIPE_TRANSFER_UNSYNCHRONIZED) {
+   usage |= PB_USAGE_UNSYNCHRONIZED;
+   }
+
+   map = r600_bo_map(radeon, bo, usage, ctx);
if (!map) {
return NULL;
}

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): r600g: propogate resource usage flags to winsys, use to choose bo domains

2010-11-03 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 29c4a15bf61a76cd71ffa5b8f09706d0eab84281
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=29c4a15bf61a76cd71ffa5b8f09706d0eab84281

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Nov  2 17:47:06 2010 +

r600g: propogate resource usage flags to winsys, use to choose bo domains

This opens the question of what interface the winsys layer should
really have for talking about these concepts.

For now I'm using the existing gallium resource usage concept, but
there is no reason not use terms closer to what the hardware
understands - eg. the domains themselves.

---

 src/gallium/drivers/r600/r600.h   |3 ++-
 src/gallium/drivers/r600/r600_buffer.c|7 ---
 src/gallium/drivers/r600/r600_shader.c|2 +-
 src/gallium/drivers/r600/r600_texture.c   |2 +-
 src/gallium/winsys/r600/drm/r600_bo.c |   24 +---
 src/gallium/winsys/r600/drm/r600_hw_context.c |   13 +
 src/gallium/winsys/r600/drm/r600_priv.h   |1 +
 7 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h
index 62d9832..5ec607b 100644
--- a/src/gallium/drivers/r600/r600.h
+++ b/src/gallium/drivers/r600/r600.h
@@ -112,7 +112,8 @@ struct r600_tiling_info *r600_get_tiling_info(struct radeon 
*radeon);
 /* r600_bo.c */
 struct r600_bo;
 struct r600_bo *r600_bo(struct radeon *radeon,
- unsigned size, unsigned alignment, unsigned 
usage);
+unsigned size, unsigned alignment,
+unsigned binding, unsigned usage);
 struct r600_bo *r600_bo_handle(struct radeon *radeon,
   unsigned handle, unsigned *array_mode);
 void *r600_bo_map(struct radeon *radeon, struct r600_bo *bo, unsigned usage, 
void *ctx);
diff --git a/src/gallium/drivers/r600/r600_buffer.c 
b/src/gallium/drivers/r600/r600_buffer.c
index 455aa2e..3c45d78 100644
--- a/src/gallium/drivers/r600/r600_buffer.c
+++ b/src/gallium/drivers/r600/r600_buffer.c
@@ -86,7 +86,7 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen 
*screen,
rbuffer-r.base.vtbl = r600_buffer_vtbl;
rbuffer-r.size = rbuffer-r.base.b.width0;
rbuffer-r.domain = r600_domain_from_usage(rbuffer-r.base.b.bind);
-   bo = r600_bo((struct radeon*)screen-winsys, rbuffer-r.base.b.width0, 
alignment, rbuffer-r.base.b.bind);
+   bo = r600_bo((struct radeon*)screen-winsys, rbuffer-r.base.b.width0, 
alignment, rbuffer-r.base.b.bind, rbuffer-r.base.b.usage);
if (bo == NULL) {
FREE(rbuffer);
return NULL;
@@ -156,8 +156,9 @@ static void *r600_buffer_transfer_map(struct pipe_context 
*pipe,
r600_bo_reference((struct radeon*)pipe-winsys, 
rbuffer-r.bo, NULL);
rbuffer-num_ranges = 0;
rbuffer-r.bo = r600_bo((struct 
radeon*)pipe-winsys,
-
rbuffer-r.base.b.width0, 0,
-
rbuffer-r.base.b.bind);
+
rbuffer-r.base.b.width0, 0,
+rbuffer-r.base.b.bind,
+
rbuffer-r.base.b.usage);
break;
}
}
diff --git a/src/gallium/drivers/r600/r600_shader.c 
b/src/gallium/drivers/r600/r600_shader.c
index 4106587..1a0b35d 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -218,7 +218,7 @@ static int r600_pipe_shader(struct pipe_context *ctx, 
struct r600_pipe_shader *s
 
/* copy new shader */
if (shader-bo == NULL) {
-   shader-bo = r600_bo(rctx-radeon, rshader-bc.ndw * 4, 4096, 
0);
+   shader-bo = r600_bo(rctx-radeon, rshader-bc.ndw * 4, 4096, 
0, 0);
if (shader-bo == NULL) {
return -ENOMEM;
}
diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index 7222b43..9a52cfa 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -294,7 +294,7 @@ r600_texture_create_object(struct pipe_screen *screen,
resource-size = rtex-size;
 
if (!resource-bo) {
-   resource-bo = r600_bo(radeon, rtex-size, 4096, 0);
+   resource-bo = r600_bo(radeon, rtex-size, 4096, base-bind, 
base-usage);
if (!resource-bo) {
FREE(rtex);
return NULL;
diff --git a/src/gallium/winsys/r600/drm/r600_bo.c 
b/src/gallium/winsys/r600/drm/r600_bo.c
index 7d54ff1..9b9aec5 100644
--- a/src/gallium/winsys/r600/drm/r600_bo.c
+++ b/src/gallium/winsys

Mesa (master): r600g: use a buffer in GTT as intermediate on texture up and downloads

2010-11-03 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: d4fab99c1c20334131b446b0032303a8b3c5c1a1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d4fab99c1c20334131b446b0032303a8b3c5c1a1

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Nov  2 17:51:34 2010 +

r600g: use a buffer in GTT as intermediate on texture up and downloads

Generalize the existing tiled_buffer path in texture transfers for use
in some non-tiled up and downloads.

Use a staging buffer, which the winsys will restrict to GTT memory.

GTT buffers have the major advantage when they are mapped, they are
cachable, which is a very nice property for downloads, usually the CPU
will want to do look at the data it downloaded.

---

 src/gallium/drivers/r600/r600_resource.h |2 +-
 src/gallium/drivers/r600/r600_texture.c  |   85 ++
 2 files changed, 64 insertions(+), 23 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_resource.h 
b/src/gallium/drivers/r600/r600_resource.h
index d152285..d24d5a1 100644
--- a/src/gallium/drivers/r600/r600_resource.h
+++ b/src/gallium/drivers/r600/r600_resource.h
@@ -35,7 +35,7 @@ struct r600_transfer {
/* Buffer transfer. */
struct pipe_transfer*buffer_transfer;
unsignedoffset;
-   struct pipe_resource*linear_texture;
+   struct pipe_resource*staging_texture;
 };
 
 /* This gets further specialized into either buffer or texture
diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index 9a52cfa..8fbe4a0 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -40,8 +40,8 @@
 
 extern struct u_resource_vtbl r600_texture_vtbl;
 
-/* Copy from a tiled texture to a detiled one. */
-static void r600_copy_from_tiled_texture(struct pipe_context *ctx, struct 
r600_transfer *rtransfer)
+/* Copy from a full GPU texture to a transfer's staging one. */
+static void r600_copy_to_staging_texture(struct pipe_context *ctx, struct 
r600_transfer *rtransfer)
 {
struct pipe_transfer *transfer = (struct pipe_transfer*)rtransfer;
struct pipe_resource *texture = transfer-resource;
@@ -49,15 +49,15 @@ static void r600_copy_from_tiled_texture(struct 
pipe_context *ctx, struct r600_t
 
subdst.face = 0;
subdst.level = 0;
-   ctx-resource_copy_region(ctx, rtransfer-linear_texture,
+   ctx-resource_copy_region(ctx, rtransfer-staging_texture,
subdst, 0, 0, 0, texture, transfer-sr,
transfer-box.x, transfer-box.y, 
transfer-box.z,
transfer-box.width, transfer-box.height);
 }
 
 
-/* Copy from a detiled texture to a tiled one. */
-static void r600_copy_into_tiled_texture(struct pipe_context *ctx, struct 
r600_transfer *rtransfer)
+/* Copy from a transfer's staging texture to a full GPU one. */
+static void r600_copy_from_staging_texture(struct pipe_context *ctx, struct 
r600_transfer *rtransfer)
 {
struct pipe_transfer *transfer = (struct pipe_transfer*)rtransfer;
struct pipe_resource *texture = transfer-resource;
@@ -67,7 +67,7 @@ static void r600_copy_into_tiled_texture(struct pipe_context 
*ctx, struct r600_t
subsrc.level = 0;
ctx-resource_copy_region(ctx, texture, transfer-sr,
  transfer-box.x, transfer-box.y, 
transfer-box.z,
- rtransfer-linear_texture, subsrc,
+ rtransfer-staging_texture, subsrc,
  0, 0, 0,
  transfer-box.width, transfer-box.height);
 
@@ -435,10 +435,20 @@ int r600_texture_depth_flush(struct pipe_context *ctx,
}
 
 out:
+   /* XXX: only do this if the depth texture has actually changed:
+*/
r600_blit_uncompress_depth_ptr(ctx, rtex);
return 0;
 }
 
+/* Needs adjustment for pixelformat:
+ */
+static INLINE unsigned u_box_volume( const struct pipe_box *box )
+{
+return box-width * box-depth * box-height;
+};
+
+
 struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
struct pipe_resource *texture,
struct pipe_subresource sr,
@@ -449,6 +459,35 @@ struct pipe_transfer* r600_texture_get_transfer(struct 
pipe_context *ctx,
struct pipe_resource resource;
struct r600_transfer *trans;
int r;
+   boolean use_staging_texture = FALSE;
+   boolean discard = FALSE;
+
+   if (!(usage  PIPE_TRANSFER_READ)  (usage  PIPE_TRANSFER_DISCARD))
+   discard = TRUE;
+
+   /* We cannot map a tiled texture directly because the data is
+* in a different order, therefore we do detiling using a blit.
+*
+* Also, use a temporary in GTT memory for read transfers, as
+* the CPU

Mesa (master): r600g: remove unused flink, domain fields from r600_resource

2010-11-03 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 7b120ceac8738b73dcffe4d39e3e32b473dea3cf
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7b120ceac8738b73dcffe4d39e3e32b473dea3cf

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Nov  2 15:49:44 2010 +

r600g: remove unused flink, domain fields from r600_resource

These were being set but not used anywhere.

---

 src/gallium/drivers/r600/r600_buffer.c   |   27 ---
 src/gallium/drivers/r600/r600_resource.h |5 -
 src/gallium/drivers/r600/r600_texture.c  |1 -
 3 files changed, 0 insertions(+), 33 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_buffer.c 
b/src/gallium/drivers/r600/r600_buffer.c
index 3c45d78..ed97b6e 100644
--- a/src/gallium/drivers/r600/r600_buffer.c
+++ b/src/gallium/drivers/r600/r600_buffer.c
@@ -38,32 +38,6 @@
 
 extern struct u_resource_vtbl r600_buffer_vtbl;
 
-u32 r600_domain_from_usage(unsigned usage)
-{
-   u32 domain = RADEON_GEM_DOMAIN_GTT;
-
-   if (usage  PIPE_BIND_RENDER_TARGET) {
-   domain |= RADEON_GEM_DOMAIN_VRAM;
-   }
-   if (usage  PIPE_BIND_DEPTH_STENCIL) {
-   domain |= RADEON_GEM_DOMAIN_VRAM;
-   }
-   if (usage  PIPE_BIND_SAMPLER_VIEW) {
-   domain |= RADEON_GEM_DOMAIN_VRAM;
-   }
-   /* also need BIND_BLIT_SOURCE/DESTINATION ? */
-   if (usage  PIPE_BIND_VERTEX_BUFFER) {
-   domain |= RADEON_GEM_DOMAIN_GTT;
-   }
-   if (usage  PIPE_BIND_INDEX_BUFFER) {
-   domain |= RADEON_GEM_DOMAIN_GTT;
-   }
-   if (usage  PIPE_BIND_CONSTANT_BUFFER) {
-   domain |= RADEON_GEM_DOMAIN_VRAM;
-   }
-
-   return domain;
-}
 
 struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
 const struct pipe_resource *templ)
@@ -85,7 +59,6 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen 
*screen,
rbuffer-r.base.b.screen = screen;
rbuffer-r.base.vtbl = r600_buffer_vtbl;
rbuffer-r.size = rbuffer-r.base.b.width0;
-   rbuffer-r.domain = r600_domain_from_usage(rbuffer-r.base.b.bind);
bo = r600_bo((struct radeon*)screen-winsys, rbuffer-r.base.b.width0, 
alignment, rbuffer-r.base.b.bind, rbuffer-r.base.b.usage);
if (bo == NULL) {
FREE(rbuffer);
diff --git a/src/gallium/drivers/r600/r600_resource.h 
b/src/gallium/drivers/r600/r600_resource.h
index d24d5a1..7a2d1f4 100644
--- a/src/gallium/drivers/r600/r600_resource.h
+++ b/src/gallium/drivers/r600/r600_resource.h
@@ -45,8 +45,6 @@ struct r600_transfer {
 struct r600_resource {
struct u_resource   base;
struct r600_bo  *bo;
-   u32 domain;
-   u32 flink;
u32 size;
 };
 
@@ -68,9 +66,6 @@ struct r600_resource_texture {
 
 void r600_init_screen_resource_functions(struct pipe_screen *screen);
 
-/* r600_buffer */
-u32 r600_domain_from_usage(unsigned usage);
-
 /* r600_texture */
 struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
const struct pipe_resource *templ);
diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index 8fbe4a0..c92f634 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -284,7 +284,6 @@ r600_texture_create_object(struct pipe_screen *screen,
pipe_reference_init(resource-base.b.reference, 1);
resource-base.b.screen = screen;
resource-bo = bo;
-   resource-domain = r600_domain_from_usage(resource-base.b.bind);
rtex-pitch_override = pitch_in_bytes_override;
 
if (array_mode)

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): r600g: set hardware pixel centers according to gl_rasterization_rules

2010-11-03 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: c3974dc837b4a11a30603bb00fa1d346e721af59
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3974dc837b4a11a30603bb00fa1d346e721af59

Author: Keith Whitwell kei...@vmware.com
Date:   Sun Oct 17 11:45:49 2010 -0700

r600g: set hardware pixel centers according to gl_rasterization_rules

These were previously being left in the default (D3D) mode.  This mean
that triangles were drawn slightly incorrectly, but also because this
state is relied on by the u_blitter code, all blits were half a pixel
off.

---

 src/gallium/drivers/r600/r600_state.c |5 +
 src/gallium/drivers/r600/r600d.h  |4 
 src/gallium/winsys/r600/drm/r600_hw_context.c |1 +
 src/gallium/winsys/r600/drm/r600d.h   |1 +
 4 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_state.c 
b/src/gallium/drivers/r600/r600_state.c
index ccd7421..17e64b1 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -475,6 +475,11 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
r600_pipe_state_add_reg(rstate, R_028A0C_PA_SC_LINE_STIPPLE, 
0x0005, 0x, NULL);
r600_pipe_state_add_reg(rstate, R_028A48_PA_SC_MPASS_PS_CNTL, 
0x, 0x, NULL);
r600_pipe_state_add_reg(rstate, R_028C00_PA_SC_LINE_CNTL, 0x0400, 
0x, NULL);
+
+   r600_pipe_state_add_reg(rstate, R_028C08_PA_SU_VTX_CNTL,
+   
S_028C08_PIX_CENTER_HALF(state-gl_rasterization_rules),
+   0x, NULL);
+
r600_pipe_state_add_reg(rstate, R_028C0C_PA_CL_GB_VERT_CLIP_ADJ, 
0x3F80, 0x, NULL);
r600_pipe_state_add_reg(rstate, R_028C10_PA_CL_GB_VERT_DISC_ADJ, 
0x3F80, 0x, NULL);
r600_pipe_state_add_reg(rstate, R_028C14_PA_CL_GB_HORZ_CLIP_ADJ, 
0x3F80, 0x, NULL);
diff --git a/src/gallium/drivers/r600/r600d.h b/src/gallium/drivers/r600/r600d.h
index a3cb5b8..ae19bfb 100644
--- a/src/gallium/drivers/r600/r600d.h
+++ b/src/gallium/drivers/r600/r600d.h
@@ -2100,6 +2100,10 @@
 #define   G_028C00_LAST_PIXEL(x)   (((x)  10)  0x1)
 #define   C_028C00_LAST_PIXEL  0xFBFF
 #define R_028C04_PA_SC_AA_CONFIG 0x028C04
+#define R_028C08_PA_SU_VTX_CNTL  0x028C08
+#define   S_028C08_PIX_CENTER_HALF(x)  (((x)  0x1)  0)
+#define   G_028C08_PIX_CENTER_HALF(x)  (((x)  0)  0x1)
+#define   C_028C08_PIX_CENTER_HALF 0xFFFE
 #define R_028C1C_PA_SC_AA_SAMPLE_LOCS_MCTX   0x028C1C
 #define R_028C48_PA_SC_AA_MASK   0x028C48
 #define R_028810_PA_CL_CLIP_CNTL 0x028810
diff --git a/src/gallium/winsys/r600/drm/r600_hw_context.c 
b/src/gallium/winsys/r600/drm/r600_hw_context.c
index 8b4521b..bcbe71e 100644
--- a/src/gallium/winsys/r600/drm/r600_hw_context.c
+++ b/src/gallium/winsys/r600/drm/r600_hw_context.c
@@ -384,6 +384,7 @@ static const struct r600_reg r600_context_reg_list[] = {
{PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, 
R_028A0C_PA_SC_LINE_STIPPLE, 0, 0, 0},
{PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, 
R_028A48_PA_SC_MPASS_PS_CNTL, 0, 0, 0},
{PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, 
R_028C00_PA_SC_LINE_CNTL, 0, 0, 0},
+   {PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, 
R_028C08_PA_SU_VTX_CNTL, 0, 0, 0},
{PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, 
R_028C0C_PA_CL_GB_VERT_CLIP_ADJ, 0, 0, 0},
{PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, 
R_028C10_PA_CL_GB_VERT_DISC_ADJ, 0, 0, 0},
{PKT3_SET_CONTEXT_REG, R600_CONTEXT_REG_OFFSET, 
R_028C14_PA_CL_GB_HORZ_CLIP_ADJ, 0, 0, 0},
diff --git a/src/gallium/winsys/r600/drm/r600d.h 
b/src/gallium/winsys/r600/drm/r600d.h
index d91f773..5ca7456 100644
--- a/src/gallium/winsys/r600/drm/r600d.h
+++ b/src/gallium/winsys/r600/drm/r600d.h
@@ -795,6 +795,7 @@
 #define R_028A48_PA_SC_MPASS_PS_CNTL 0x028A48
 #define R_028C00_PA_SC_LINE_CNTL 0x028C00
 #define R_028C04_PA_SC_AA_CONFIG 0x028C04
+#define R_028C08_PA_SU_VTX_CNTL  0x028C08
 #define R_028C1C_PA_SC_AA_SAMPLE_LOCS_MCTX   0x028C1C
 #define R_028C48_PA_SC_AA_MASK   0x028C48
 #define R_028810_PA_CL_CLIP_CNTL 0x028810

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): evergreeng: protect against null constant buffers

2010-11-03 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: b3462601cb69f277b9aafc2ee5179a0c2cf6cbcd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b3462601cb69f277b9aafc2ee5179a0c2cf6cbcd

Author: Keith Whitwell kei...@vmware.com
Date:   Wed Nov  3 10:24:28 2010 +

evergreeng: protect against null constant buffers

Should do better than this and actually unbind the buffer, but haven't
yet gotten it to work.

---

 src/gallium/drivers/r600/evergreen_state.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index 7222348..ce8e93a 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -826,6 +826,13 @@ static void evergreen_set_constant_buffer(struct 
pipe_context *ctx, uint shader,
struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
struct r600_resource *rbuffer = (struct r600_resource*)buffer;
 
+   /* Note that the state tracker can unbind constant buffers by
+* passing NULL here.
+*/
+   if (buffer == NULL) {
+   return;
+   }
+
switch (shader) {
case PIPE_SHADER_VERTEX:
rctx-vs_const_buffer.nregs = 0;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): r600g: don' t call debug_get_bool_option for tiling more than once

2010-11-03 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: ee07e0e39ad1c4d13d540b23220fecc564d07b16
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ee07e0e39ad1c4d13d540b23220fecc564d07b16

Author: Keith Whitwell kei...@vmware.com
Date:   Wed Nov  3 10:31:55 2010 +

r600g: don't call debug_get_bool_option for tiling more than once

---

 src/gallium/drivers/r600/r600_texture.c |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_texture.c 
b/src/gallium/drivers/r600/r600_texture.c
index c92f634..a63990f 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -306,8 +306,14 @@ struct pipe_resource *r600_texture_create(struct 
pipe_screen *screen,
const struct pipe_resource 
*templ)
 {
unsigned array_mode = 0;
+static int force_tiling = -1;
 
-   if (debug_get_bool_option(R600_FORCE_TILING, FALSE)) {
+/* Would like some magic get_bool_option_once routine.
+*/
+   if (force_tiling == -1)
+force_tiling = debug_get_bool_option(R600_FORCE_TILING, 
FALSE);
+
+   if (force_tiling) {
if (!(templ-flags  R600_RESOURCE_FLAG_TRANSFER) 
!(templ-bind  PIPE_BIND_SCANOUT)) {
array_mode = V_038000_ARRAY_2D_TILED_THIN1;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): evergreeng: respect linewidth state, use integer widths only

2010-11-03 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: d6b6a0bc170bd61abbbe9cb6ba777c7192dbd018
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d6b6a0bc170bd61abbbe9cb6ba777c7192dbd018

Author: Keith Whitwell kei...@vmware.com
Date:   Mon Nov  1 14:19:18 2010 +

evergreeng: respect linewidth state, use integer widths only

Discard fractional bits from linewidth.  This matches the nvidia
closed drivers, my reading of the OpenGL SI and current llvmpipe
behaviour.

It looks a lot nicer  avoids ugliness where lines alternate between n
and n+1 pixels in width along their length.

Also fix up r600g to match.

---

 src/gallium/drivers/r600/evergreen_state.c |5 -
 src/gallium/drivers/r600/evergreend.h  |3 +++
 src/gallium/drivers/r600/r600_state.c  |2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index ce8e93a..7dd261d 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -281,7 +281,10 @@ static void *evergreen_create_rs_state(struct pipe_context 
*ctx,
tmp = (unsigned)(state-point_size * 8.0);
r600_pipe_state_add_reg(rstate, R_028A00_PA_SU_POINT_SIZE, 
S_028A00_HEIGHT(tmp) | S_028A00_WIDTH(tmp), 0x, NULL);
r600_pipe_state_add_reg(rstate, R_028A04_PA_SU_POINT_MINMAX, 
0x8000, 0x, NULL);
-   r600_pipe_state_add_reg(rstate, R_028A08_PA_SU_LINE_CNTL, 0x0008, 
0x, NULL);
+
+   tmp = (unsigned)state-line_width * 8;
+   r600_pipe_state_add_reg(rstate, R_028A08_PA_SU_LINE_CNTL, 
S_028A08_WIDTH(tmp), 0x, NULL);
+
r600_pipe_state_add_reg(rstate, R_028C00_PA_SC_LINE_CNTL, 0x0400, 
0x, NULL);
r600_pipe_state_add_reg(rstate, R_028C0C_PA_CL_GB_VERT_CLIP_ADJ, 
0x3F80, 0x, NULL);
r600_pipe_state_add_reg(rstate, R_028C10_PA_CL_GB_VERT_DISC_ADJ, 
0x3F80, 0x, NULL);
diff --git a/src/gallium/drivers/r600/evergreend.h 
b/src/gallium/drivers/r600/evergreend.h
index 8e96f93..7e7bd01 100644
--- a/src/gallium/drivers/r600/evergreend.h
+++ b/src/gallium/drivers/r600/evergreend.h
@@ -1636,6 +1636,9 @@
 #define R_028980_ALU_CONST_CACHE_VS_00x00028980
 #define R_028A04_PA_SU_POINT_MINMAX  0x00028A04
 #define R_028A08_PA_SU_LINE_CNTL 0x00028A08
+#define   S_028A08_WIDTH(x)(((x)  0x)  0)
+#define   G_028A08_WIDTH(x)(((x)  0)  0x)
+#define   C_028A08_WIDTH   0x
 #define R_028A10_VGT_OUTPUT_PATH_CNTL0x00028A10
 #define R_028A14_VGT_HOS_CNTL0x00028A14
 #define R_028A18_VGT_HOS_MAX_TESS_LEVEL  0x00028A18
diff --git a/src/gallium/drivers/r600/r600_state.c 
b/src/gallium/drivers/r600/r600_state.c
index 17e64b1..54cc79b 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -469,7 +469,7 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
r600_pipe_state_add_reg(rstate, R_028A00_PA_SU_POINT_SIZE, 
S_028A00_HEIGHT(tmp) | S_028A00_WIDTH(tmp), 0x, NULL);
r600_pipe_state_add_reg(rstate, R_028A04_PA_SU_POINT_MINMAX, 
0x8000, 0x, NULL);
 
-   tmp = (unsigned)(state-line_width * 8.0);
+   tmp = (unsigned)state-line_width * 8;
r600_pipe_state_add_reg(rstate, R_028A08_PA_SU_LINE_CNTL, 
S_028A08_WIDTH(tmp), 0x, NULL);
 
r600_pipe_state_add_reg(rstate, R_028A0C_PA_SC_LINE_STIPPLE, 
0x0005, 0x, NULL);

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): evergreeng: set hardware pixelcenters according to gl_rasterization_rules

2010-11-03 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 32bb65217ed048817d314062f2804c79f80d0ec7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=32bb65217ed048817d314062f2804c79f80d0ec7

Author: Keith Whitwell kei...@vmware.com
Date:   Wed Nov  3 11:15:43 2010 +

evergreeng: set hardware pixelcenters according to gl_rasterization_rules

---

 src/gallium/drivers/r600/evergreen_state.c |6 +-
 src/gallium/drivers/r600/evergreend.h  |3 +++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index 7dd261d..4725b5e 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -291,7 +291,11 @@ static void *evergreen_create_rs_state(struct pipe_context 
*ctx,
r600_pipe_state_add_reg(rstate, R_028C14_PA_CL_GB_HORZ_CLIP_ADJ, 
0x3F80, 0x, NULL);
r600_pipe_state_add_reg(rstate, R_028C18_PA_CL_GB_HORZ_DISC_ADJ, 
0x3F80, 0x, NULL);
r600_pipe_state_add_reg(rstate, R_028B7C_PA_SU_POLY_OFFSET_CLAMP, 0x0, 
0x, NULL);
-   r600_pipe_state_add_reg(rstate, R_028C08_PA_SU_VTX_CNTL, 0x0005, 
0x, NULL);
+
+   r600_pipe_state_add_reg(rstate, R_028C08_PA_SU_VTX_CNTL,
+   
S_028C08_PIX_CENTER_HALF(state-gl_rasterization_rules),
+   0x, NULL);
+
r600_pipe_state_add_reg(rstate, R_02820C_PA_SC_CLIPRECT_RULE, 
clip_rule, 0x, NULL);
return rstate;
 }
diff --git a/src/gallium/drivers/r600/evergreend.h 
b/src/gallium/drivers/r600/evergreend.h
index 7e7bd01..a337916 100644
--- a/src/gallium/drivers/r600/evergreend.h
+++ b/src/gallium/drivers/r600/evergreend.h
@@ -1690,6 +1690,9 @@
 #define R_028C00_PA_SC_LINE_CNTL 0x00028C00
 #define R_028C04_PA_SC_AA_CONFIG 0x00028C04
 #define R_028C08_PA_SU_VTX_CNTL  0x00028C08
+#define   S_028C08_PIX_CENTER_HALF(x)  (((x)  0x1)  0)
+#define   G_028C08_PIX_CENTER_HALF(x)  (((x)  0)  0x1)
+#define   C_028C08_PIX_CENTER_HALF 0xFFFE
 #define R_028C0C_PA_CL_GB_VERT_CLIP_ADJ  0x00028C0C
 #define R_028C10_PA_CL_GB_VERT_DISC_ADJ  0x00028C10
 #define R_028C14_PA_CL_GB_HORZ_CLIP_ADJ  0x00028C14

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: guard against NULL task-query pointer

2010-11-02 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: debcb434891756573ed2dc102ad1b673a8dce7da
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=debcb434891756573ed2dc102ad1b673a8dce7da

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Nov  2 12:05:46 2010 +

llvmpipe: guard against NULL task-query pointer

This doesn't seem like it should be possible, but some test suites
manage to hit this case.  Avoid crashing release builds under those
circumstances.

---

 src/gallium/drivers/llvmpipe/lp_rast.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c 
b/src/gallium/drivers/llvmpipe/lp_rast.c
index d358a98..decf3bd 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;
+   }
 }
 
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: avoid generating tri_16 for tris which extend past tile bounds

2010-11-02 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 98445b43071414a6bd82d0618002611c6ad70257
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=98445b43071414a6bd82d0618002611c6ad70257

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Nov  2 14:20:20 2010 +

llvmpipe: avoid generating tri_16 for tris which extend past tile bounds

Don't trim triangle bounding box to scissor/draw-region until after
the logic for emitting tri_16.  Don't generate tri_16 commands for
triangles with untrimmed bounding boxes outside the current tile.

This is important as the tri-16 itself can extend past tile bounds and
we don't want to add code to it to check against tile bounds (slow) or
restrict it to locations within a tile (pessimistic).

---

 src/gallium/drivers/llvmpipe/lp_setup_line.c |   15 +++
 src/gallium/drivers/llvmpipe/lp_setup_tri.c  |   34 +++---
 2 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup_line.c 
b/src/gallium/drivers/llvmpipe/lp_setup_line.c
index 827413b..29c2317 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 4ab0b72..11dfe63 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

Mesa (master): st/mesa: unbind constant buffer when not in use

2010-11-02 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 8dfafbf0861fe3d2542332658dd5493851053c78
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8dfafbf0861fe3d2542332658dd5493851053c78

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Nov  2 16:29:10 2010 +

st/mesa: unbind constant buffer when not in use

Important as more constant buffers per shader start to get used.

Fix up r600 (tested) and nv50 (untested) to cope with this.  Drivers
previously didn't see unbinds of constant buffers often or ever, so
this isn't always dealt with cleanly.

For r600 just return and keep the reference.  Will try to do better in
a followup change.

---

 src/gallium/drivers/nv50/nv50_shader_state.c |3 +++
 src/gallium/drivers/r600/r600_state.c|7 +++
 src/mesa/state_tracker/st_atom_constbuf.c|5 -
 3 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_shader_state.c 
b/src/gallium/drivers/nv50/nv50_shader_state.c
index 6c41e8f..306aa81 100644
--- a/src/gallium/drivers/nv50/nv50_shader_state.c
+++ b/src/gallium/drivers/nv50/nv50_shader_state.c
@@ -39,6 +39,9 @@ nv50_transfer_constbuf(struct nv50_context *nv50,
uint32_t *map;
unsigned count, start;
 
+   if (buf == NULL)
+  return;
+
map = pipe_buffer_map(pipe, buf, PIPE_TRANSFER_READ, transfer);
if (!map)
   return;
diff --git a/src/gallium/drivers/r600/r600_state.c 
b/src/gallium/drivers/r600/r600_state.c
index b3e0d49..ccd7421 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -1018,6 +1018,13 @@ static void r600_set_constant_buffer(struct pipe_context 
*ctx, uint shader, uint
struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
struct r600_resource *rbuffer = (struct r600_resource*)buffer;
 
+   /* Note that the state tracker can unbind constant buffers by
+* passing NULL here.
+*/
+   if (buffer == NULL) {
+   return;
+   }
+
switch (shader) {
case PIPE_SHADER_VERTEX:
rctx-vs_const_buffer.nregs = 0;
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c 
b/src/mesa/state_tracker/st_atom_constbuf.c
index 6f9d71e..8d1dc79 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -90,8 +90,11 @@ void st_upload_constants( struct st_context *st,
 
   st-pipe-set_constant_buffer(st-pipe, shader_type, 0, *cbuf);
}
-   else {
+   else if (*cbuf) {
   st-constants.tracked_state[shader_type].dirty.mesa = 0x0;
+
+  pipe_resource_reference(cbuf, NULL);
+  st-pipe-set_constant_buffer(st-pipe, shader_type, 0, NULL);
}
 }
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (lp-offset-twoside): llvmpipe: Moved draw pipeline twoside function to llvm setup code

2010-11-01 Thread Keith Whitwell
Module: Mesa
Branch: lp-offset-twoside
Commit: 7f0dc5ea1bb330c6589125baf4017c51a14dce8e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f0dc5ea1bb330c6589125baf4017c51a14dce8e

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Fri Oct 29 00:47:13 2010 +0100

llvmpipe: Moved draw pipeline twoside function to llvm setup code

---

 src/gallium/drivers/llvmpipe/lp_context.h   |6 ++
 src/gallium/drivers/llvmpipe/lp_state_derived.c |   14 -
 src/gallium/drivers/llvmpipe/lp_state_setup.c   |   85 ++-
 src/gallium/drivers/llvmpipe/lp_state_setup.h   |3 +-
 4 files changed, 103 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_context.h 
b/src/gallium/drivers/llvmpipe/lp_context.h
index db09c95..2230d50 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_context.h
@@ -104,6 +104,12 @@ struct llvmpipe_context {
/** Vertex format */
struct vertex_info vertex_info;

+   /** Which vertex shader output slot contains color */
+   int color_slot;
+
+   /** Which vertex shader output slot contains bcolor */
+   int bcolor_slot;
+
/** Which vertex shader output slot contains point size */
int psize_slot;
 
diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c 
b/src/gallium/drivers/llvmpipe/lp_state_derived.c
index 0f5f736..1c9f03a 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_derived.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c
@@ -75,13 +75,25 @@ compute_vertex_info(struct llvmpipe_context *llvmpipe)
   vs_index = draw_find_shader_output(llvmpipe-draw,
  
lpfs-info.base.input_semantic_name[i],
  
lpfs-info.base.input_semantic_index[i]);
-
+  if (lpfs-info.base.input_semantic_name[i]==TGSI_SEMANTIC_COLOR){
+ llvmpipe-color_slot = vinfo-num_attribs;
+  }
   /*
* Emit the requested fs attribute for all but position.
*/
   draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
}
 
+   /* Figure out if we need bcolor as well.
+*/
+   vs_index = draw_find_shader_output(llvmpipe-draw,
+  TGSI_SEMANTIC_BCOLOR, 0);
+
+   if (vs_index  0) {
+  llvmpipe-bcolor_slot = vinfo-num_attribs;
+  draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
+   }
+
/* Figure out if we need pointsize as well.
 */
vs_index = draw_find_shader_output(llvmpipe-draw,
diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index 2c8b8b9..8383494 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -33,6 +33,7 @@
 #include gallivm/lp_bld_debug.h
 #include gallivm/lp_bld_init.h
 #include gallivm/lp_bld_intr.h
+#include gallivm/lp_bld_flow.h
 #include llvm-c/Analysis.h   /* for LLVMVerifyFunction */
 
 #include lp_perf.h
@@ -74,6 +75,14 @@ struct lp_setup_args
LLVMValueRef dy01_ooa;
LLVMValueRef dx20_ooa;
LLVMValueRef dx01_ooa;
+
+   /* For twoside calcs 
+*/
+   LLVMValueRef det;
+   LLVMValueRef sign;
+   LLVMValueRef bcolor_slot;
+   LLVMValueRef color_slot;
+   
 };
 
 static LLVMTypeRef type4f(void)
@@ -472,13 +481,78 @@ init_args(LLVMBuilderRef b,
args-y0_center = vec4f_from_scalar(b, y0_center, y0_center_4f);
 }
 
+static void
+set_args_attr(struct llvmpipe_context *lp,
+   struct lp_setup_args *args)
+{
+   args-color_slot = LLVMConstInt(LLVMInt32Type(), lp-color_slot, 0);
+   args-bcolor_slot = LLVMConstInt(LLVMInt32Type(), lp-bcolor_slot, 0);
+   args-sign =  LLVMConstReal(LLVMFloatType(), (lp-rasterizer-front_ccw ? 
-1.0f : 1.0f));
+}
+
+static void
+lp_twoside(LLVMBuilderRef b, 
+   struct lp_setup_args *args,
+   const struct lp_setup_variant_key *key)
+{
+   struct lp_build_if_state if_state;
+ 
+   LLVMValueRef a0_old, a1_old, a2_old;
+   LLVMValueRef a0_new, a1_new, a2_new;
+
+   LLVMValueRef idx1 = args-color_slot;
+   LLVMValueRef idx2 = args-bcolor_slot;
+
+   LLVMValueRef facing = args-facing;
+   LLVMValueRef front_facing = LLVMBuildICmp(b, LLVMIntEQ, facing, 
LLVMConstInt(LLVMInt32Type(), 0, 0), ); /** need i1 for loop condition */
+   
+#if 0 
+/*Probably can delete this, just tried to follow draw_pipe_twoside way of 
+  calculating det*/
+   /* edge vectors: e = v0 - v2, f = v1 - v2 */
+   LLVMValueRef e = LLVMBuildFSub(b, args-v0, args-v2, e);
+   LLVMValueRef f = LLVMBuildFSub(b, args-v1, args-v2, f);
+   LLVMValueRef dx02 = vert_attrib(b, e, 0, 0, dx02);
+   LLVMValueRef dy02 = vert_attrib(b, e, 0, 1, dy02);
+   LLVMValueRef dx12 = vert_attrib(b, f, 0, 0, dx12);
+   LLVMValueRef dy12 = vert_attrib(b, f, 0, 1, dy12);
+ 
+   /* det = cross(e,f).z */
+   LLVMValueRef dx02_dy12  = LLVMBuildFMul(b, dx02, dy12, dx02_dy12);
+   LLVMValueRef dy02_dx12  = LLVMBuildFMul(b, dy02, dx12, dy02_dx12);
+   LLVMValueRef det  = 

Mesa (lp-offset-twoside): llvmpipe: turn off draw offset/ twoside when we can handle it

2010-10-22 Thread Keith Whitwell
Module: Mesa
Branch: lp-offset-twoside
Commit: a1ca5ac7c27c8bc3e294b50ab9ad340095f3030d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a1ca5ac7c27c8bc3e294b50ab9ad340095f3030d

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Oct 22 18:58:36 2010 +0100

llvmpipe: turn off draw offset/twoside when we can handle it

---

 src/gallium/drivers/llvmpipe/lp_state_rasterizer.c |   99 ++--
 1 files changed, 72 insertions(+), 27 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c 
b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
index dbd7381..574f9e9 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
@@ -32,16 +32,64 @@
 #include lp_setup.h
 #include draw/draw_context.h
 
+struct lp_rast_state {
+   struct pipe_rasterizer_state lp_state;
+   struct pipe_rasterizer_state draw_state;
+};
+
+/* State which might be handled in either the draw module or locally.
+ * This function is used to turn that state off in one of the two
+ * places.
+ */
+static void
+clear_flags(struct pipe_rasterizer_state *rast)
+{
+   rast-light_twoside = 0;
+   rast-offset_tri = 0;
+}
+
 
 
 static void *
 llvmpipe_create_rasterizer_state(struct pipe_context *pipe,
  const struct pipe_rasterizer_state *rast)
 {
-   /* We do nothing special with rasterizer state.
-* The CSO handle is just a pointer to a pipe_rasterizer_state object.
+   boolean need_pipeline;
+
+   /* Partition rasterizer state into what we want the draw module to
+* handle, and what we'll look after ourselves.
+*/
+   struct lp_rast_state *state = MALLOC_STRUCT(lp_rast_state);
+   if (state == NULL)
+  return NULL;
+
+   memcpy(state-draw_state, rast, sizeof *rast);
+   memcpy(state-lp_state, rast, sizeof *rast);
+
+   /* We rely on draw module to do unfilled polyons, AA lines and
+* points and stipple.
+* 
+* Over time, reduce this list of conditions, and expand the list
+* of flags which get cleared in clear_flags().
 */
-   return mem_dup(rast, sizeof(*rast));
+   need_pipeline = (rast-fill_front != PIPE_POLYGON_MODE_FILL ||
+   rast-fill_back != PIPE_POLYGON_MODE_FILL ||
+   rast-point_smooth ||
+   rast-line_smooth ||
+   rast-line_stipple_enable ||
+   rast-poly_stipple_enable);
+
+   /* If not using the pipeline, clear out the flags which we can
+* handle ourselves.  If we *are* using the pipeline, do everything
+* on the pipeline and clear those flags on our internal copy of
+* the state.
+*/
+   if (need_pipeline)
+  clear_flags(state-lp_state);
+   else
+  clear_flags(state-draw_state);
+
+   return state;
 }
 
 
@@ -50,36 +98,33 @@ static void
 llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, void *handle)
 {
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
-   const struct pipe_rasterizer_state *rasterizer =
-  (const struct pipe_rasterizer_state *) handle;
-
-   if (llvmpipe-rasterizer == rasterizer)
-  return;
+   const struct lp_rast_state *state =
+  (const struct lp_rast_state *) handle;
 
-   /* pass-through to draw module */
-   draw_set_rasterizer_state(llvmpipe-draw, rasterizer, handle);
+   if (state) {
+  llvmpipe-rasterizer = state-lp_state;
+  draw_set_rasterizer_state(llvmpipe-draw, state-draw_state, handle);
 
-   llvmpipe-rasterizer = rasterizer;
-
-   /* Note: we can immediately set the triangle state here and
-* not worry about binning because we handle culling during
-* triangle setup, not when rasterizing the bins.
-*/
-   if (llvmpipe-rasterizer) {
+  /* XXX: just pass lp_state directly to setup.
+   */
   lp_setup_set_triangle_state( llvmpipe-setup,
-   llvmpipe-rasterizer-cull_face,
-   llvmpipe-rasterizer-front_ccw,
-   llvmpipe-rasterizer-scissor,
-   llvmpipe-rasterizer-gl_rasterization_rules);
+  state-lp_state.cull_face,
+  state-lp_state.front_ccw,
+  state-lp_state.scissor,
+  state-lp_state.gl_rasterization_rules);
   lp_setup_set_flatshade_first( llvmpipe-setup,
-   llvmpipe-rasterizer-flatshade_first);
+   state-lp_state.flatshade_first);
   lp_setup_set_line_state( llvmpipe-setup,
-   llvmpipe-rasterizer-line_width);
+  state-lp_state.line_width);
   lp_setup_set_point_state( llvmpipe-setup,
-   llvmpipe-rasterizer-point_size,
-   llvmpipe-rasterizer-point_size_per_vertex,
-   llvmpipe-rasterizer-sprite_coord_enable,
-   llvmpipe-rasterizer-sprite_coord_mode);
+   state

Mesa (master): draw: cliptest and viewport done in a single loop in vertex shader

2010-10-19 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 94f65d095a1365b69a041302b473e40c6ccae3c3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=94f65d095a1365b69a041302b473e40c6ccae3c3

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Tue Sep 28 17:49:25 2010 +0100

draw: cliptest and viewport done in a single loop in vertex shader

Cliptesting now done at the end of vs in draw_llvm instead of
draw_pt_post_vs.

Added viewport mapping transformation and further cliptesting to
vertex shader in draw_llvm.c

Alternative path where vertex header setup, clip coordinates store,
cliptesting and viewport mapping are done earlier in the vertex
shader.

Still need to hook this up properly according to the return value of
draw_llvm_shader function.

---

 src/gallium/auxiliary/draw/draw_llvm.c |  314 +---
 src/gallium/auxiliary/draw/draw_llvm.h |6 +-
 2 files changed, 293 insertions(+), 27 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 5154c1f..36254d3 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -31,6 +31,9 @@
 #include draw_vs.h
 
 #include gallivm/lp_bld_arit.h
+#include gallivm/lp_bld_logic.h
+#include gallivm/lp_bld_const.h
+#include gallivm/lp_bld_swizzle.h
 #include gallivm/lp_bld_struct.h
 #include gallivm/lp_bld_type.h
 #include gallivm/lp_bld_flow.h
@@ -549,19 +552,28 @@ static void
 store_aos(LLVMBuilderRef builder,
   LLVMValueRef io_ptr,
   LLVMValueRef index,
-  LLVMValueRef value)
+  LLVMValueRef value,
+  LLVMValueRef clipmask)
 {
LLVMValueRef id_ptr = draw_jit_header_id(builder, io_ptr);
LLVMValueRef data_ptr = draw_jit_header_data(builder, io_ptr);
LLVMValueRef indices[3];
+   LLVMValueRef val, shift;
 
indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
indices[1] = index;
indices[2] = LLVMConstInt(LLVMInt32Type(), 0, 0);
 
-   /* undefined vertex */
-   LLVMBuildStore(builder, LLVMConstInt(LLVMInt32Type(),
-0x, 0), id_ptr);
+   /* initialize vertex id:16 = 0x, pad:3 = 0, edgeflag:1 = 1 */
+   val = LLVMConstInt(LLVMInt32Type(), 0x1, 0); 
+   shift  = LLVMConstInt(LLVMInt32Type(), 12, 0);  
+   val = LLVMBuildShl(builder, val, shift, );
+   /* add clipmask:12 */   
+   val = LLVMBuildOr(builder, val, clipmask, );   
+
+   /* store vertex header */
+   LLVMBuildStore(builder, val, id_ptr);
+
 
 #if DEBUG_STORE
lp_build_printf(builder,  %p storing attribute %d (io = %p)\n, 
data_ptr, index, io_ptr);
@@ -616,7 +628,8 @@ store_aos_array(LLVMBuilderRef builder,
 LLVMValueRef io_ptr,
 LLVMValueRef aos[NUM_CHANNELS],
 int attrib,
-int num_outputs)
+int num_outputs,
+LLVMValueRef clipmask)
 {
LLVMValueRef attr_index = LLVMConstInt(LLVMInt32Type(), attrib, 0);
LLVMValueRef ind0 = LLVMConstInt(LLVMInt32Type(), 0, 0);
@@ -624,7 +637,8 @@ store_aos_array(LLVMBuilderRef builder,
LLVMValueRef ind2 = LLVMConstInt(LLVMInt32Type(), 2, 0);
LLVMValueRef ind3 = LLVMConstInt(LLVMInt32Type(), 3, 0);
LLVMValueRef io0_ptr, io1_ptr, io2_ptr, io3_ptr;
-
+   LLVMValueRef clipmask0, clipmask1, clipmask2, clipmask3;
+   
debug_assert(NUM_CHANNELS == 4);
 
io0_ptr = LLVMBuildGEP(builder, io_ptr,
@@ -636,21 +650,31 @@ store_aos_array(LLVMBuilderRef builder,
io3_ptr = LLVMBuildGEP(builder, io_ptr,
   ind3, 1, );
 
+   clipmask0 = LLVMBuildExtractElement(builder, clipmask,
+   ind0, );
+   clipmask1 = LLVMBuildExtractElement(builder, clipmask,
+   ind1, );
+   clipmask2 = LLVMBuildExtractElement(builder, clipmask,
+   ind2, );
+   clipmask3 = LLVMBuildExtractElement(builder, clipmask,
+   ind3, );
+
 #if DEBUG_STORE
-   lp_build_printf(builder,io = %p, indexes[%d, %d, %d, %d]\n,
-   io_ptr, ind0, ind1, ind2, ind3);
+   lp_build_printf(builder, io = %p, indexes[%d, %d, %d, %d]\n, clipmask0 = 
%x, clipmask1 = %x, clipmask2 = %x, clipmask3 = %x\n,
+   io_ptr, ind0, ind1, ind2, ind3, clipmask0, clipmask1, 
clipmask2, clipmask3);
 #endif
-
-   store_aos(builder, io0_ptr, attr_index, aos[0]);
-   store_aos(builder, io1_ptr, attr_index, aos[1]);
-   store_aos(builder, io2_ptr, attr_index, aos[2]);
-   store_aos(builder, io3_ptr, attr_index, aos[3]);
+   /* store for each of the 4 vertices */
+   store_aos(builder, io0_ptr, attr_index, aos[0], clipmask0);
+   store_aos(builder, io1_ptr, attr_index, aos[1], clipmask1);
+   store_aos(builder, io2_ptr, attr_index, aos[2], clipmask2);
+   store_aos(builder, io3_ptr, attr_index, aos[3], clipmask3);
 }
 
 static void
 convert_to_aos(LLVMBuilderRef builder,

Mesa (master): draw: added viewport and cliptest flags

2010-10-19 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 3744d1c7d30543520cede8a6c580f26985978953
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3744d1c7d30543520cede8a6c580f26985978953

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Tue Sep 28 17:52:14 2010 +0100

draw: added viewport and cliptest flags

Corrections in store_clip to store clip coordinates in AoS form.
Viewport  cliptest flag options based on variant key.
Put back draw_pt_post_vs and now 2 paths based on whether clipping
occurs or not.

---

 src/gallium/auxiliary/draw/draw_llvm.c |  130 +---
 src/gallium/auxiliary/draw/draw_llvm.h |6 +-
 .../draw/draw_pt_fetch_shade_pipeline_llvm.c   |   12 ++-
 3 files changed, 98 insertions(+), 50 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 36254d3..940b2d7 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -736,10 +736,10 @@ store_clip(LLVMBuilderRef builder,
indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
indices[1] = LLVMConstInt(LLVMInt32Type(), 0, 0);

-   out[0] = LLVMBuildLoad(builder, outputs[0][0], ); /*x0 y0 z0 w0*/
-   out[1] = LLVMBuildLoad(builder, outputs[0][1], ); /*x1 y1 z1 w1*/
-   out[2] = LLVMBuildLoad(builder, outputs[0][2], ); /*x2 y2 z2 w2*/
-   out[3] = LLVMBuildLoad(builder, outputs[0][3], ); /*x3 y3 z3 w3*/  
+   out[0] = LLVMBuildLoad(builder, outputs[0][0], ); /*x0 x1 x2 x3*/
+   out[1] = LLVMBuildLoad(builder, outputs[0][1], ); /*y0 y1 y2 y3*/
+   out[2] = LLVMBuildLoad(builder, outputs[0][2], ); /*z0 z1 z2 z3*/
+   out[3] = LLVMBuildLoad(builder, outputs[0][3], ); /*w0 w1 w2 w3*/  
 
io0_ptr = LLVMBuildGEP(builder, io_ptr, ind0, 1, );
io1_ptr = LLVMBuildGEP(builder, io_ptr, ind1, 1, );
@@ -753,22 +753,22 @@ store_clip(LLVMBuilderRef builder,
 
for (int i = 0; i4; i++){
   clip0_ptr = LLVMBuildGEP(builder, clip_ptr0,
-   indices, 2, ); //x1
+   indices, 2, ); //x0
   clip1_ptr = LLVMBuildGEP(builder, clip_ptr1,
-   indices, 2, ); //y1
+   indices, 2, ); //x1
   clip2_ptr = LLVMBuildGEP(builder, clip_ptr2,
-   indices, 2, ); //z1
+   indices, 2, ); //x2
   clip3_ptr = LLVMBuildGEP(builder, clip_ptr3,
-   indices, 2, ); //w1
-
-  out0elem = LLVMBuildExtractElement(builder, out[0],
- indices[1], ); //x1
-  out1elem = LLVMBuildExtractElement(builder, out[1],
- indices[1], ); //y1
-  out2elem = LLVMBuildExtractElement(builder, out[2],
- indices[1], ); //z1
-  out3elem = LLVMBuildExtractElement(builder, out[3],
- indices[1], ); //w1
+   indices, 2, ); //x3
+
+  out0elem = LLVMBuildExtractElement(builder, out[i],
+ ind0, ); //x0
+  out1elem = LLVMBuildExtractElement(builder, out[i],
+ ind1, ); //x1
+  out2elem = LLVMBuildExtractElement(builder, out[i],
+ ind2, ); //x2
+  out3elem = LLVMBuildExtractElement(builder, out[i],
+ ind3, ); //x3
   
   LLVMBuildStore(builder, out0elem, clip0_ptr);
   LLVMBuildStore(builder, out1elem, clip1_ptr);
@@ -822,7 +822,9 @@ generate_viewport(struct draw_llvm *llvm,
  */
 static LLVMValueRef 
 generate_clipmask(LLVMBuilderRef builder,
-  LLVMValueRef (*outputs)[NUM_CHANNELS])
+  LLVMValueRef (*outputs)[NUM_CHANNELS],
+  boolean disable_zclipping,
+  boolean enable_d3dclipping)
 {
LLVMValueRef mask; /* stores the 4xi32 clipmasks */ 
LLVMValueRef test, temp; 
@@ -866,22 +868,31 @@ generate_clipmask(LLVMBuilderRef builder,
temp = LLVMBuildShl(builder, temp, shift, );
test = LLVMBuildAnd(builder, test, temp, ); 
mask = LLVMBuildOr(builder, mask, test, );
-   
-   /* plane 5 */
-   test = LLVMBuildFAdd(builder, pos_z, pos_w, );
-   test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, test);
-   temp = LLVMBuildShl(builder, temp, shift, );
-   test = LLVMBuildAnd(builder, test, temp, ); 
-   mask = LLVMBuildOr(builder, mask, test, );
-   
-   /* plane 6 */
-   test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, pos_z, pos_w);
-   temp = LLVMBuildShl(builder, temp, shift, );
-   test = LLVMBuildAnd(builder, test, temp, ); 
-   mask = LLVMBuildOr(builder, mask, test, ); 
-
+
+   if (!disable_zclipping){
+  if (enable_d3dclipping){
+ /* plane 5 */
+ test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, 
pos_z);
+ 

Mesa (master): draw: some changes to allow for runtime changes to userclip planes

2010-10-19 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 08f890d4c3b8376d1840f90474f7c56329432d95
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=08f890d4c3b8376d1840f90474f7c56329432d95

Author: delphi tayhuiqi...@gmail.com
Date:   Sun Oct 10 00:31:16 2010 +0100

draw: some changes to allow for runtime changes to userclip planes

---

 src/gallium/auxiliary/draw/draw_context.c  |1 +
 src/gallium/auxiliary/draw/draw_llvm.c |   70 +++-
 src/gallium/auxiliary/draw/draw_llvm.h |   10 ++-
 src/gallium/auxiliary/draw/draw_private.h  |3 +
 .../draw/draw_pt_fetch_shade_pipeline_llvm.c   |3 +
 5 files changed, 67 insertions(+), 20 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_context.c 
b/src/gallium/auxiliary/draw/draw_context.c
index b07de76..c52234d 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -335,6 +335,7 @@ draw_set_mapped_constant_buffer(struct draw_context *draw,
case PIPE_SHADER_VERTEX:
   draw-pt.user.vs_constants[slot] = buffer;
   draw-pt.user.vs_constants_size[slot] = size;
+  draw-pt.user.planes = (float (*) [12][4]) (draw-plane[0]);
   draw_vs_set_constants(draw, slot, buffer, size);
   break;
case PIPE_SHADER_GEOMETRY:
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 9c17e77..5f11b82 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -130,12 +130,13 @@ init_globals(struct draw_llvm *llvm)
 
/* struct draw_jit_context */
{
-  LLVMTypeRef elem_types[3];
+  LLVMTypeRef elem_types[4];
   LLVMTypeRef context_type;
 
   elem_types[0] = LLVMPointerType(LLVMFloatType(), 0); /* vs_constants */
-  elem_types[1] = LLVMPointerType(LLVMFloatType(), 0); /* vs_constants */
-  elem_types[2] = LLVMArrayType(texture_type,
+  elem_types[1] = LLVMPointerType(LLVMFloatType(), 0); /* gs_constants */
+  elem_types[2] = 
LLVMPointerType(LLVMArrayType(LLVMArrayType(LLVMFloatType(), 4), 12), 0); /* 
planes */
+  elem_types[3] = LLVMArrayType(texture_type,
 PIPE_MAX_VERTEX_SAMPLERS); /* textures */
 
   context_type = LLVMStructType(elem_types, Elements(elem_types), 0);
@@ -144,6 +145,8 @@ init_globals(struct draw_llvm *llvm)
  llvm-target, context_type, 0);
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, gs_constants,
  llvm-target, context_type, 1);
+  LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, planes,
+ llvm-target, context_type, 2);
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, textures,
  llvm-target, context_type,
  DRAW_JIT_CTX_TEXTURES);
@@ -817,6 +820,23 @@ generate_viewport(struct draw_llvm *llvm,

 }
 
+/* Equivalent of _mm_set1_ps(a)
+ */
+static LLVMValueRef vec4f_from_scalar(LLVMBuilderRef bld,
+ LLVMValueRef a,
+ const char *name)
+{
+   LLVMValueRef res = LLVMGetUndef(LLVMVectorType(LLVMFloatType(), 4));
+   int i;
+
+   for(i = 0; i  4; ++i) {
+  LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
+  res = LLVMBuildInsertElement(bld, res, a, index, i == 3 ? name : );
+   }
+
+   return res;
+}
+
 /*
  * Returns clipmask as 4xi32 bitmask for the 4 vertices
  */
@@ -827,17 +847,16 @@ generate_clipmask(LLVMBuilderRef builder,
   boolean clip_z,
   boolean clip_user,
   boolean enable_d3dclipping,
-  struct draw_llvm *llvm)
+  unsigned nr,
+  LLVMValueRef context_ptr)
 {
LLVMValueRef mask; /* stores the 4xi32 clipmasks */ 
LLVMValueRef test, temp; 
LLVMValueRef zero, shift;
LLVMValueRef pos_x, pos_y, pos_z, pos_w;
-   LLVMValueRef planes, sum;
+   LLVMValueRef plane1, planes, plane_ptr, sum;
 
-   unsigned nr;
unsigned i;
-   float (*plane)[4];
 
struct lp_type f32_type = lp_type_float_vec(32); 
 
@@ -903,22 +922,38 @@ generate_clipmask(LLVMBuilderRef builder,
}   
 
if (clip_user){
+  LLVMValueRef planes_ptr = draw_jit_context_planes(builder, context_ptr);
+  LLVMValueRef indices[3];
+
   /* userclip planes */
-  nr = llvm-draw-nr_planes;
-  plane = llvm-draw-plane;
   for (i = 6; i  nr; i++) {
- planes = lp_build_const_vec(f32_type, plane[i][0]);
+ indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
+ indices[1] = LLVMConstInt(LLVMInt32Type(), i, 0);
+
+ indices[2] = LLVMConstInt(LLVMInt32Type(), 0, 0);
+ plane_ptr = LLVMBuildGEP(builder, planes_ptr, indices, 3, );
+ plane1 = LLVMBuildLoad(builder, plane_ptr, plane_x);
+ planes = vec4f_from_scalar(builder, plane1, plane4_x);
  sum = LLVMBuildMul(builder, 

Mesa (master): draw: added userclip planes and updated variant_key

2010-10-19 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 25bb05fef075a87ec6e5f2a989049faff2afedd2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=25bb05fef075a87ec6e5f2a989049faff2afedd2

Author: delphi tayhuiqi...@gmail.com
Date:   Mon Oct  4 17:08:33 2010 +0100

draw: added userclip planes and updated variant_key

---

 src/gallium/auxiliary/draw/draw_llvm.c |  138 ++--
 src/gallium/auxiliary/draw/draw_llvm.h |8 +-
 2 files changed, 99 insertions(+), 47 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 940b2d7..9c17e77 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -823,13 +823,21 @@ generate_viewport(struct draw_llvm *llvm,
 static LLVMValueRef 
 generate_clipmask(LLVMBuilderRef builder,
   LLVMValueRef (*outputs)[NUM_CHANNELS],
-  boolean disable_zclipping,
-  boolean enable_d3dclipping)
+  boolean clip_xy,
+  boolean clip_z,
+  boolean clip_user,
+  boolean enable_d3dclipping,
+  struct draw_llvm *llvm)
 {
LLVMValueRef mask; /* stores the 4xi32 clipmasks */ 
LLVMValueRef test, temp; 
LLVMValueRef zero, shift;
LLVMValueRef pos_x, pos_y, pos_z, pos_w;
+   LLVMValueRef planes, sum;
+
+   unsigned nr;
+   unsigned i;
+   float (*plane)[4];
 
struct lp_type f32_type = lp_type_float_vec(32); 
 
@@ -843,33 +851,35 @@ generate_clipmask(LLVMBuilderRef builder,
pos_w = LLVMBuildLoad(builder, outputs[0][3], ); /*w0 w1 w2 w3*/   
 
/* Cliptest, for hardwired planes */
-   /* plane 1 */
-   test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, pos_x , 
pos_w);
-   temp = shift;
-   test = LLVMBuildAnd(builder, test, temp, ); 
-   mask = test;
+   if (clip_xy){
+  /* plane 1 */
+  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, pos_x , 
pos_w);
+  temp = shift;
+  test = LLVMBuildAnd(builder, test, temp, ); 
+  mask = test;

-   /* plane 2 */
-   test = LLVMBuildFAdd(builder, pos_x, pos_w, );
-   test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, test);
-   temp = LLVMBuildShl(builder, temp, shift, );
-   test = LLVMBuildAnd(builder, test, temp, ); 
-   mask = LLVMBuildOr(builder, mask, test, );
+  /* plane 2 */
+  test = LLVMBuildFAdd(builder, pos_x, pos_w, );
+  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, 
test);
+  temp = LLVMBuildShl(builder, temp, shift, );
+  test = LLVMBuildAnd(builder, test, temp, ); 
+  mask = LLVMBuildOr(builder, mask, test, );

-   /* plane 3 */
-   test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, pos_y, pos_w);
-   temp = LLVMBuildShl(builder, temp, shift, );
-   test = LLVMBuildAnd(builder, test, temp, ); 
-   mask = LLVMBuildOr(builder, mask, test, );
-
-   /* plane 4 */
-   test = LLVMBuildFAdd(builder, pos_y, pos_w, );
-   test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, test);
-   temp = LLVMBuildShl(builder, temp, shift, );
-   test = LLVMBuildAnd(builder, test, temp, ); 
-   mask = LLVMBuildOr(builder, mask, test, );
-
-   if (!disable_zclipping){
+  /* plane 3 */
+  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, pos_y, 
pos_w);
+  temp = LLVMBuildShl(builder, temp, shift, );
+  test = LLVMBuildAnd(builder, test, temp, ); 
+  mask = LLVMBuildOr(builder, mask, test, );
+
+  /* plane 4 */
+  test = LLVMBuildFAdd(builder, pos_y, pos_w, );
+  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, 
test);
+  temp = LLVMBuildShl(builder, temp, shift, );
+  test = LLVMBuildAnd(builder, test, temp, ); 
+  mask = LLVMBuildOr(builder, mask, test, );
+   }
+
+   if (clip_z){
   if (enable_d3dclipping){
  /* plane 5 */
  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, 
pos_z);
@@ -892,6 +902,32 @@ generate_clipmask(LLVMBuilderRef builder,
   mask = LLVMBuildOr(builder, mask, test, );
}   
 
+   if (clip_user){
+  /* userclip planes */
+  nr = llvm-draw-nr_planes;
+  plane = llvm-draw-plane;
+  for (i = 6; i  nr; i++) {
+ planes = lp_build_const_vec(f32_type, plane[i][0]);
+ sum = LLVMBuildMul(builder, planes, pos_x, );
+
+ planes = lp_build_const_vec(f32_type, plane[i][1]);
+ test = LLVMBuildMul(builder, planes, pos_y, );
+ sum = LLVMBuildFAdd(builder, sum, test, );
+
+ planes = lp_build_const_vec(f32_type, plane[i][2]);
+ test = LLVMBuildMul(builder, planes, pos_z, );
+ sum = LLVMBuildFAdd(builder, sum, test, );
+
+ planes = lp_build_const_vec(f32_type, plane[i][3]);
+ test = LLVMBuildMul(builder, planes, pos_w, );
+ sum = LLVMBuildFAdd(builder, sum, test, );
+
+ test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, 

Mesa (master): draw: corrections for w coordinate

2010-10-19 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: c1d6b318661de2acdee38254d3750ed8dfc09e8b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c1d6b318661de2acdee38254d3750ed8dfc09e8b

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Sat Oct 16 11:02:11 2010 +0100

draw: corrections for w coordinate

---

 src/gallium/auxiliary/draw/draw_llvm.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 1c18d90..7afa37b 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -800,9 +800,10 @@ generate_viewport(struct draw_llvm *llvm,

/* for 1/w convention*/
out3 = LLVMBuildFDiv(builder, const1, out3, );
-
+   LLVMBuildStore(builder, out3, outputs[0][3]);
+  
/* Viewport Mapping */
-   for (i=0; i4; i++){
+   for (i=0; i3; i++){
   LLVMValueRef out = LLVMBuildLoad(builder, outputs[0][i], ); /*x0 x1 x2 
x3*/
   LLVMValueRef scale = lp_build_const_vec(f32_type, scaleA[i]); /*sx sx sx 
sx*/ 
   LLVMValueRef trans = lp_build_const_vec(f32_type, transA[i]); /*tx tx tx 
tx*/

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): draw: sanitize llvm variant key

2010-10-19 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 26ff7523b69ddb377ade29296d20abfc46e69489
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=26ff7523b69ddb377ade29296d20abfc46e69489

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Thu Oct 14 14:04:39 2010 +0100

draw: sanitize llvm variant key

Fixes recompilation, but seems to be broken with llvm 2.8.

---

 src/gallium/auxiliary/draw/draw_llvm.c |1 +
 src/gallium/auxiliary/draw/draw_llvm.h |3 ++-
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 5f11b82..1c18d90 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1430,6 +1430,7 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char 
*store)
key-enable_d3dclipping = 
(boolean)!llvm-draw-rasterizer-gl_rasterization_rules;
key-need_edgeflags = (llvm-draw-vs.edgeflag_output ? TRUE : FALSE);
key-nr_planes = llvm-draw-nr_planes;
+   key-pad = 0;
 
/* All variants of this shader will have the same value for
 * nr_samplers.  Not yet trying to compact away holes in the
diff --git a/src/gallium/auxiliary/draw/draw_llvm.h 
b/src/gallium/auxiliary/draw/draw_llvm.h
index fc78854..def0681 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.h
+++ b/src/gallium/auxiliary/draw/draw_llvm.h
@@ -168,7 +168,8 @@ struct draw_llvm_variant_key
unsigned bypass_viewport:1;
unsigned enable_d3dclipping:1;
unsigned need_edgeflags:1;
-   unsigned nr_planes;
+   unsigned nr_planes:4;
+   unsigned pad:26;
 
/* Variable number of vertex elements:
 */

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: clean up fields in draw_llvm_variant_key

2010-10-19 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: b5236f3da482665567a9d53264e6203092120c31
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b5236f3da482665567a9d53264e6203092120c31

Author: Keith Whitwell kei...@vmware.com
Date:   Sun Oct 17 17:53:29 2010 -0700

llvmpipe: clean up fields in draw_llvm_variant_key

---

 src/gallium/auxiliary/draw/draw_llvm.c |   15 +--
 src/gallium/auxiliary/draw/draw_llvm.h |8 
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 7afa37b..ebd8b9d 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -847,7 +847,7 @@ generate_clipmask(LLVMBuilderRef builder,
   boolean clip_xy,
   boolean clip_z,
   boolean clip_user,
-  boolean enable_d3dclipping,
+  boolean clip_halfz,
   unsigned nr,
   LLVMValueRef context_ptr)
 {
@@ -900,7 +900,7 @@ generate_clipmask(LLVMBuilderRef builder,
}
 
if (clip_z){
-  if (enable_d3dclipping){
+  if (clip_halfz){
  /* plane 5 */
  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, 
pos_z);
  temp = LLVMBuildShl(builder, temp, shift, );
@@ -980,18 +980,13 @@ clipmask_bool(LLVMBuilderRef builder,
LLVMValueRef temp;
int i;
 
-   LLVMDumpValue(clipmask);
-
for (i=0; i4; i++){   
   temp = LLVMBuildExtractElement(builder, clipmask,
  LLVMConstInt(LLVMInt32Type(), i, 0) , );
   ret = LLVMBuildOr(builder, ret, temp, );
-  LLVMDumpValue(ret);  
}

LLVMBuildStore(builder, ret, ret_ptr);
-   LLVMDumpValue(ret_ptr); 
-
 }
 
 static void
@@ -1133,7 +1128,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant)
   variant-key.clip_xy,
   variant-key.clip_z, 
   variant-key.clip_user,
-  variant-key.enable_d3dclipping,
+  variant-key.clip_halfz,
   variant-key.nr_planes,
   context_ptr);
  /* return clipping boolean value for function */
@@ -1344,7 +1339,7 @@ draw_llvm_generate_elts(struct draw_llvm *llvm, struct 
draw_llvm_variant *varian
   variant-key.clip_xy,
   variant-key.clip_z, 
   variant-key.clip_user,
-  variant-key.enable_d3dclipping,
+  variant-key.clip_halfz,
   variant-key.nr_planes,
   context_ptr);
  /* return clipping boolean value for function */
@@ -1428,7 +1423,7 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char 
*store)
key-clip_z = llvm-draw-clip_z;
key-clip_user = llvm-draw-clip_user;
key-bypass_viewport = llvm-draw-identity_viewport;
-   key-enable_d3dclipping = 
(boolean)!llvm-draw-rasterizer-gl_rasterization_rules;
+   key-clip_halfz = !llvm-draw-rasterizer-gl_rasterization_rules;
key-need_edgeflags = (llvm-draw-vs.edgeflag_output ? TRUE : FALSE);
key-nr_planes = llvm-draw-nr_planes;
key-pad = 0;
diff --git a/src/gallium/auxiliary/draw/draw_llvm.h 
b/src/gallium/auxiliary/draw/draw_llvm.h
index def0681..b5b8c66 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.h
+++ b/src/gallium/auxiliary/draw/draw_llvm.h
@@ -160,16 +160,16 @@ typedef int
 
 struct draw_llvm_variant_key
 {
-   unsigned nr_vertex_elements:16;
-   unsigned nr_samplers:12;
+   unsigned nr_vertex_elements:8;
+   unsigned nr_samplers:8;
unsigned clip_xy:1;
unsigned clip_z:1;
unsigned clip_user:1;
+   unsigned clip_halfz:1;
unsigned bypass_viewport:1;
-   unsigned enable_d3dclipping:1;
unsigned need_edgeflags:1;
unsigned nr_planes:4;
-   unsigned pad:26;
+   unsigned pad:6;
 
/* Variable number of vertex elements:
 */

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): draw: corrections to allow for different cliptest cases

2010-10-19 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: ab2e1edd1fc6fbfd4f7d1949aa0d40cdb7142bd6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ab2e1edd1fc6fbfd4f7d1949aa0d40cdb7142bd6

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Mon Oct 18 18:48:18 2010 +0100

draw: corrections to allow for different cliptest cases

---

 src/gallium/auxiliary/draw/draw_llvm.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index ebd8b9d..622250e 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -861,9 +861,11 @@ generate_clipmask(LLVMBuilderRef builder,
 
struct lp_type f32_type = lp_type_float_vec(32); 
 
+   mask = lp_build_const_int_vec(lp_type_int_vec(32), 0);
+   temp = lp_build_const_int_vec(lp_type_int_vec(32), 0);
zero = lp_build_const_vec(f32_type, 0);/* 0.0f 0.0f 
0.0f 0.0f */
shift = lp_build_const_int_vec(lp_type_int_vec(32), 1);/* 1 1 1 1 */
-  
+
/* Assuming position stored at output[0] */
pos_x = LLVMBuildLoad(builder, outputs[0][0], ); /*x0 x1 x2 x3*/
pos_y = LLVMBuildLoad(builder, outputs[0][1], ); /*y0 y1 y2 y3*/
@@ -900,10 +902,10 @@ generate_clipmask(LLVMBuilderRef builder,
}
 
if (clip_z){
+  temp = lp_build_const_int_vec(lp_type_int_vec(32), 16);
   if (clip_halfz){
  /* plane 5 */
  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, 
pos_z);
- temp = LLVMBuildShl(builder, temp, shift, );
  test = LLVMBuildAnd(builder, test, temp, ); 
  mask = LLVMBuildOr(builder, mask, test, );
   }  
@@ -911,7 +913,6 @@ generate_clipmask(LLVMBuilderRef builder,
  /* plane 5 */
  test = LLVMBuildFAdd(builder, pos_z, pos_w, );
  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, 
test);
- temp = LLVMBuildShl(builder, temp, shift, );
  test = LLVMBuildAnd(builder, test, temp, ); 
  mask = LLVMBuildOr(builder, mask, test, );
   }
@@ -925,6 +926,7 @@ generate_clipmask(LLVMBuilderRef builder,
if (clip_user){
   LLVMValueRef planes_ptr = draw_jit_context_planes(builder, context_ptr);
   LLVMValueRef indices[3];
+  temp = lp_build_const_int_vec(lp_type_int_vec(32), 32);
 
   /* userclip planes */
   for (i = 6; i  nr; i++) {

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): Merge branch 'llvm-cliptest-viewport'

2010-10-19 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: cd6a31cd4a9ea6deef4778c2eaef2d47240c3a6e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd6a31cd4a9ea6deef4778c2eaef2d47240c3a6e

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Oct 19 21:41:28 2010 -0700

Merge branch 'llvm-cliptest-viewport'

---



___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): draw: make sure viewport gets updated in draw llvm shader

2010-10-19 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 05921fd4e5305da68bb269748cb0ef059e1db417
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=05921fd4e5305da68bb269748cb0ef059e1db417

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Oct 19 22:11:49 2010 -0700

draw: make sure viewport gets updated in draw llvm shader

The viewport state was being baked in at compile time (oops...)

---

 src/gallium/auxiliary/draw/draw_llvm.c |   66 
 src/gallium/auxiliary/draw/draw_llvm.h |6 ++-
 .../draw/draw_pt_fetch_shade_pipeline_llvm.c   |2 +
 3 files changed, 47 insertions(+), 27 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 338127d..beb955f 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -131,13 +131,14 @@ init_globals(struct draw_llvm *llvm)
 
/* struct draw_jit_context */
{
-  LLVMTypeRef elem_types[4];
+  LLVMTypeRef elem_types[5];
   LLVMTypeRef context_type;
 
   elem_types[0] = LLVMPointerType(LLVMFloatType(), 0); /* vs_constants */
   elem_types[1] = LLVMPointerType(LLVMFloatType(), 0); /* gs_constants */
   elem_types[2] = 
LLVMPointerType(LLVMArrayType(LLVMArrayType(LLVMFloatType(), 4), 12), 0); /* 
planes */
-  elem_types[3] = LLVMArrayType(texture_type,
+  elem_types[3] = LLVMPointerType(LLVMFloatType(), 0); /* viewport */
+  elem_types[4] = LLVMArrayType(texture_type,
 PIPE_MAX_VERTEX_SAMPLERS); /* textures */
 
   context_type = LLVMStructType(elem_types, Elements(elem_types), 0);
@@ -784,21 +785,38 @@ store_clip(LLVMBuilderRef builder,
 
 }
 
+/* Equivalent of _mm_set1_ps(a)
+ */
+static LLVMValueRef vec4f_from_scalar(LLVMBuilderRef bld,
+ LLVMValueRef a,
+ const char *name)
+{
+   LLVMValueRef res = LLVMGetUndef(LLVMVectorType(LLVMFloatType(), 4));
+   int i;
+
+   for(i = 0; i  4; ++i) {
+  LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
+  res = LLVMBuildInsertElement(bld, res, a, index, i == 3 ? name : );
+   }
+
+   return res;
+}
+
 /*
  * Transforms the outputs for viewport mapping
  */
 static void
 generate_viewport(struct draw_llvm *llvm,
   LLVMBuilderRef builder,
-  LLVMValueRef (*outputs)[NUM_CHANNELS])
+  LLVMValueRef (*outputs)[NUM_CHANNELS],
+  LLVMValueRef context_ptr)
 {
int i;
-   const float *scaleA = llvm-draw-viewport.scale;
-   const float *transA = llvm-draw-viewport.translate;
struct lp_type f32_type = lp_type_float_vec(32);
LLVMValueRef out3 = LLVMBuildLoad(builder, outputs[0][3], ); /*w0 w1 w2 
w3*/   
LLVMValueRef const1 = lp_build_const_vec(f32_type, 1.0);   /*1.0 1.0 
1.0 1.0*/ 
-   
+   LLVMValueRef vp_ptr = draw_jit_context_viewport(builder, context_ptr);
+
/* for 1/w convention*/
out3 = LLVMBuildFDiv(builder, const1, out3, );
LLVMBuildStore(builder, out3, outputs[0][3]);
@@ -806,9 +824,21 @@ generate_viewport(struct draw_llvm *llvm,
/* Viewport Mapping */
for (i=0; i3; i++){
   LLVMValueRef out = LLVMBuildLoad(builder, outputs[0][i], ); /*x0 x1 x2 
x3*/
-  LLVMValueRef scale = lp_build_const_vec(f32_type, scaleA[i]); /*sx sx sx 
sx*/ 
-  LLVMValueRef trans = lp_build_const_vec(f32_type, transA[i]); /*tx tx tx 
tx*/
+  LLVMValueRef scale;
+  LLVMValueRef trans;
+  LLVMValueRef scale_i;
+  LLVMValueRef trans_i;
+  LLVMValueRef index;
   
+  index = LLVMConstInt(LLVMInt32Type(), i, 0);
+  scale_i = LLVMBuildGEP(builder, vp_ptr, index, 1, );
+
+  index = LLVMConstInt(LLVMInt32Type(), i+4, 0);
+  trans_i = LLVMBuildGEP(builder, vp_ptr, index, 1, );
+
+  scale = vec4f_from_scalar(builder, LLVMBuildLoad(builder, scale_i, ), 
scale);
+  trans = vec4f_from_scalar(builder, LLVMBuildLoad(builder, trans_i, ), 
trans);
+
   /* divide by w */
   out = LLVMBuildMul(builder, out, out3, );
   /* mult by scale */
@@ -822,22 +852,6 @@ generate_viewport(struct draw_llvm *llvm,

 }
 
-/* Equivalent of _mm_set1_ps(a)
- */
-static LLVMValueRef vec4f_from_scalar(LLVMBuilderRef bld,
- LLVMValueRef a,
- const char *name)
-{
-   LLVMValueRef res = LLVMGetUndef(LLVMVectorType(LLVMFloatType(), 4));
-   int i;
-
-   for(i = 0; i  4; ++i) {
-  LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
-  res = LLVMBuildInsertElement(bld, res, a, index, i == 3 ? name : );
-   }
-
-   return res;
-}
 
 /*
  * Returns clipmask as 4xi32 bitmask for the 4 vertices
@@ -1143,7 +1157,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant)
   
   /* do viewport mapping */
   if (!bypass_viewport){
- generate_viewport(llvm, builder, outputs

Mesa (llvm-cliptest-viewport): draw: corrections for w coordinate

2010-10-17 Thread Keith Whitwell
Module: Mesa
Branch: llvm-cliptest-viewport
Commit: c1d6b318661de2acdee38254d3750ed8dfc09e8b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c1d6b318661de2acdee38254d3750ed8dfc09e8b

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Sat Oct 16 11:02:11 2010 +0100

draw: corrections for w coordinate

---

 src/gallium/auxiliary/draw/draw_llvm.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 1c18d90..7afa37b 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -800,9 +800,10 @@ generate_viewport(struct draw_llvm *llvm,

/* for 1/w convention*/
out3 = LLVMBuildFDiv(builder, const1, out3, );
-
+   LLVMBuildStore(builder, out3, outputs[0][3]);
+  
/* Viewport Mapping */
-   for (i=0; i4; i++){
+   for (i=0; i3; i++){
   LLVMValueRef out = LLVMBuildLoad(builder, outputs[0][i], ); /*x0 x1 x2 
x3*/
   LLVMValueRef scale = lp_build_const_vec(f32_type, scaleA[i]); /*sx sx sx 
sx*/ 
   LLVMValueRef trans = lp_build_const_vec(f32_type, transA[i]); /*tx tx tx 
tx*/

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (llvm-cliptest-viewport): llvmpipe: clean up fields in draw_llvm_variant_key

2010-10-17 Thread Keith Whitwell
Module: Mesa
Branch: llvm-cliptest-viewport
Commit: b5236f3da482665567a9d53264e6203092120c31
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b5236f3da482665567a9d53264e6203092120c31

Author: Keith Whitwell kei...@vmware.com
Date:   Sun Oct 17 17:53:29 2010 -0700

llvmpipe: clean up fields in draw_llvm_variant_key

---

 src/gallium/auxiliary/draw/draw_llvm.c |   15 +--
 src/gallium/auxiliary/draw/draw_llvm.h |8 
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 7afa37b..ebd8b9d 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -847,7 +847,7 @@ generate_clipmask(LLVMBuilderRef builder,
   boolean clip_xy,
   boolean clip_z,
   boolean clip_user,
-  boolean enable_d3dclipping,
+  boolean clip_halfz,
   unsigned nr,
   LLVMValueRef context_ptr)
 {
@@ -900,7 +900,7 @@ generate_clipmask(LLVMBuilderRef builder,
}
 
if (clip_z){
-  if (enable_d3dclipping){
+  if (clip_halfz){
  /* plane 5 */
  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, 
pos_z);
  temp = LLVMBuildShl(builder, temp, shift, );
@@ -980,18 +980,13 @@ clipmask_bool(LLVMBuilderRef builder,
LLVMValueRef temp;
int i;
 
-   LLVMDumpValue(clipmask);
-
for (i=0; i4; i++){   
   temp = LLVMBuildExtractElement(builder, clipmask,
  LLVMConstInt(LLVMInt32Type(), i, 0) , );
   ret = LLVMBuildOr(builder, ret, temp, );
-  LLVMDumpValue(ret);  
}

LLVMBuildStore(builder, ret, ret_ptr);
-   LLVMDumpValue(ret_ptr); 
-
 }
 
 static void
@@ -1133,7 +1128,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant)
   variant-key.clip_xy,
   variant-key.clip_z, 
   variant-key.clip_user,
-  variant-key.enable_d3dclipping,
+  variant-key.clip_halfz,
   variant-key.nr_planes,
   context_ptr);
  /* return clipping boolean value for function */
@@ -1344,7 +1339,7 @@ draw_llvm_generate_elts(struct draw_llvm *llvm, struct 
draw_llvm_variant *varian
   variant-key.clip_xy,
   variant-key.clip_z, 
   variant-key.clip_user,
-  variant-key.enable_d3dclipping,
+  variant-key.clip_halfz,
   variant-key.nr_planes,
   context_ptr);
  /* return clipping boolean value for function */
@@ -1428,7 +1423,7 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char 
*store)
key-clip_z = llvm-draw-clip_z;
key-clip_user = llvm-draw-clip_user;
key-bypass_viewport = llvm-draw-identity_viewport;
-   key-enable_d3dclipping = 
(boolean)!llvm-draw-rasterizer-gl_rasterization_rules;
+   key-clip_halfz = !llvm-draw-rasterizer-gl_rasterization_rules;
key-need_edgeflags = (llvm-draw-vs.edgeflag_output ? TRUE : FALSE);
key-nr_planes = llvm-draw-nr_planes;
key-pad = 0;
diff --git a/src/gallium/auxiliary/draw/draw_llvm.h 
b/src/gallium/auxiliary/draw/draw_llvm.h
index def0681..b5b8c66 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.h
+++ b/src/gallium/auxiliary/draw/draw_llvm.h
@@ -160,16 +160,16 @@ typedef int
 
 struct draw_llvm_variant_key
 {
-   unsigned nr_vertex_elements:16;
-   unsigned nr_samplers:12;
+   unsigned nr_vertex_elements:8;
+   unsigned nr_samplers:8;
unsigned clip_xy:1;
unsigned clip_z:1;
unsigned clip_user:1;
+   unsigned clip_halfz:1;
unsigned bypass_viewport:1;
-   unsigned enable_d3dclipping:1;
unsigned need_edgeflags:1;
unsigned nr_planes:4;
-   unsigned pad:26;
+   unsigned pad:6;
 
/* Variable number of vertex elements:
 */

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: use llvm for attribute interpolant calculation

2010-10-17 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 5b4c43d98556c5a4806757513bcb196a724518c5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b4c43d98556c5a4806757513bcb196a724518c5

Author: Keith Whitwell kei...@vmware.com
Date:   Sun Sep  5 13:17:43 2010 +0100

llvmpipe: use llvm for attribute interpolant calculation

Basically no change relative to hard-coded version, but this will
be useful for other changes later.

---

 src/gallium/drivers/llvmpipe/SConscript|5 +-
 src/gallium/drivers/llvmpipe/lp_bld_interp.h   |   26 +-
 src/gallium/drivers/llvmpipe/lp_context.c  |3 +
 src/gallium/drivers/llvmpipe/lp_context.h  |   10 +-
 src/gallium/drivers/llvmpipe/lp_flush.h|1 +
 src/gallium/drivers/llvmpipe/lp_limits.h   |   10 +
 src/gallium/drivers/llvmpipe/lp_setup.c|   19 +-
 src/gallium/drivers/llvmpipe/lp_setup.h|   29 +-
 src/gallium/drivers/llvmpipe/lp_setup_coef.c   |  279 ---
 src/gallium/drivers/llvmpipe/lp_setup_coef.h   |   64 --
 .../drivers/llvmpipe/lp_setup_coef_intrin.c|  228 --
 src/gallium/drivers/llvmpipe/lp_setup_context.h|   12 +-
 src/gallium/drivers/llvmpipe/lp_setup_line.c   |   20 +-
 src/gallium/drivers/llvmpipe/lp_setup_point.c  |   13 +-
 src/gallium/drivers/llvmpipe/lp_setup_tri.c|   42 +-
 src/gallium/drivers/llvmpipe/lp_state.h|3 +
 src/gallium/drivers/llvmpipe/lp_state_derived.c|   69 +--
 src/gallium/drivers/llvmpipe/lp_state_fs.c |   80 ++-
 src/gallium/drivers/llvmpipe/lp_state_fs.h |4 +
 src/gallium/drivers/llvmpipe/lp_state_setup.c  |  768 
 src/gallium/drivers/llvmpipe/lp_state_setup.h  |   81 ++
 .../drivers/llvmpipe/lp_state_setup_fallback.c |  265 +++
 22 files changed, 1315 insertions(+), 716 deletions(-)

Diff:   
http://cgit.freedesktop.org/mesa/mesa/diff/?id=5b4c43d98556c5a4806757513bcb196a724518c5
___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): graw: add frag-face shader

2010-10-17 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 7ef3d171a0e535ba720d9c7a6cdc6bb165416a3c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7ef3d171a0e535ba720d9c7a6cdc6bb165416a3c

Author: Keith Whitwell kei...@vmware.com
Date:   Sat Sep 18 09:15:14 2010 +0100

graw: add frag-face shader

---

 .../tests/regress/fragment-shader/frag-face.sh |   14 ++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git 
a/src/gallium/tests/python/tests/regress/fragment-shader/frag-face.sh 
b/src/gallium/tests/python/tests/regress/fragment-shader/frag-face.sh
new file mode 100644
index 000..5745b6a
--- /dev/null
+++ b/src/gallium/tests/python/tests/regress/fragment-shader/frag-face.sh
@@ -0,0 +1,14 @@
+FRAG
+
+DCL IN[0], COLOR, LINEAR
+DCL IN[1], FACE, CONSTANT
+DCL OUT[0], COLOR
+DCL TEMP[0]
+IMM FLT32 { 0.5, 1.0, 0.0, 0.0 }
+
+MUL TEMP[0], IN[1]., IMM[0].
+ADD TEMP[0], TEMP[0], IMM[0].
+
+MOV OUT[0], TEMP[0]
+
+END

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: minor changes in llvm coefficient calcs

2010-10-17 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 75d22e71a812bbe78414d3f9519f4c7a7157c748
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=75d22e71a812bbe78414d3f9519f4c7a7157c748

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Sun Sep 26 16:01:59 2010 +0800

llvmpipe: minor changes in llvm coefficient calcs

---

 src/gallium/drivers/llvmpipe/lp_setup_debug.c |1 +
 src/gallium/drivers/llvmpipe/lp_state_setup.c |5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup_debug.c 
b/src/gallium/drivers/llvmpipe/lp_setup_debug.c
new file mode 100644
index 000..a71a471
--- /dev/null
+++ b/src/gallium/drivers/llvmpipe/lp_setup_debug.c
@@ -0,0 +1 @@
+/* Some debugging stuff */
diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index aa9147a..3261c53 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -173,8 +173,9 @@ emit_facing_coef( LLVMBuilderRef builder,
  unsigned slot )
 {
LLVMValueRef a0_0 = args-facing;
+   LLVMValueRef a0_0f = LLVMBuildSIToFP(builder, a0_0, LLVMFloatType(), );
LLVMValueRef zero = LLVMConstReal(LLVMFloatType(), 0.0);
-   LLVMValueRef a0  = vec4f(builder, a0_0, zero, zero, zero, facing);
+   LLVMValueRef a0  = vec4f(builder, a0_0f, zero, zero, zero, facing);
LLVMValueRef zerovec = vec4f_from_scalar(builder, zero, zero);
 
store_coef(builder, args, slot, a0, zerovec, zerovec);
@@ -520,7 +521,7 @@ generate_setup_variant(struct llvmpipe_screen *screen,
arg_types[4] = LLVMPointerType(vec4f_type, 0);  /* a0, aligned */
arg_types[5] = LLVMPointerType(vec4f_type, 0);  /* dadx, aligned */
arg_types[6] = LLVMPointerType(vec4f_type, 0);  /* dady, aligned */
-   arg_types[7] = LLVMPointerType(LLVMVoidType(), 0);  /* key, unused */
+   arg_types[7] = LLVMPointerType(vec4f_type, 0);   /* key, unused */
 
func_type = LLVMFunctionType(LLVMVoidType(), arg_types, 
Elements(arg_types), 0);
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): Merge remote branch 'origin/master' into lp-setup-llvm

2010-10-17 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 0072acd447dc6be652e63752e50215c3105322c8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0072acd447dc6be652e63752e50215c3105322c8

Author: Keith Whitwell kei...@vmware.com
Date:   Sun Oct 17 19:03:42 2010 -0700

Merge remote branch 'origin/master' into lp-setup-llvm

Conflicts:
src/gallium/drivers/llvmpipe/lp_setup_coef.c
src/gallium/drivers/llvmpipe/lp_setup_coef.h
src/gallium/drivers/llvmpipe/lp_setup_coef_intrin.c
src/gallium/drivers/llvmpipe/lp_setup_point.c
src/gallium/drivers/llvmpipe/lp_setup_tri.c
src/gallium/drivers/llvmpipe/lp_state_derived.c
src/gallium/drivers/llvmpipe/lp_state_fs.h

---



___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: remove unused file

2010-10-17 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 75799b8d02ff3bc6acc5157bf62ee2188e9f3ee3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=75799b8d02ff3bc6acc5157bf62ee2188e9f3ee3

Author: Keith Whitwell kei...@vmware.com
Date:   Sun Oct 17 19:11:47 2010 -0700

llvmpipe: remove unused file

---

 src/gallium/drivers/llvmpipe/SConscript   |1 -
 src/gallium/drivers/llvmpipe/lp_setup_debug.c |1 -
 2 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/SConscript 
b/src/gallium/drivers/llvmpipe/SConscript
index d63bdd7..4995015 100644
--- a/src/gallium/drivers/llvmpipe/SConscript
+++ b/src/gallium/drivers/llvmpipe/SConscript
@@ -55,7 +55,6 @@ llvmpipe = env.ConvenienceLibrary(
'lp_scene_queue.c',
'lp_screen.c',
'lp_setup.c',
-   'lp_setup_debug.c',
'lp_setup_line.c',
'lp_setup_point.c',
'lp_setup_tri.c',
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_debug.c 
b/src/gallium/drivers/llvmpipe/lp_setup_debug.c
deleted file mode 100644
index a71a471..000
--- a/src/gallium/drivers/llvmpipe/lp_setup_debug.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Some debugging stuff */

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: remove unused arg from jit_setup_tri function

2010-10-17 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 9da17fed2e7645a401a378ae690eb23513948e18
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9da17fed2e7645a401a378ae690eb23513948e18

Author: Keith Whitwell kei...@vmware.com
Date:   Sun Oct 17 19:23:40 2010 -0700

llvmpipe: remove unused arg from jit_setup_tri function

---

 src/gallium/drivers/llvmpipe/lp_setup_tri.c   |3 +--
 src/gallium/drivers/llvmpipe/lp_state_setup.c |3 +--
 src/gallium/drivers/llvmpipe/lp_state_setup.h |3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c 
b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index 03036cd..4ab0b72 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -323,8 +323,7 @@ do_triangle_ccw(struct lp_setup_context *setup,
   frontfacing,
   GET_A0(tri-inputs),
   GET_DADX(tri-inputs),
-  GET_DADY(tri-inputs),
-  setup-setup.variant-key );
+  GET_DADY(tri-inputs) );
 
tri-inputs.frontfacing = frontfacing;
tri-inputs.disable = FALSE;
diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index a8dee28..2c8b8b9 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -485,7 +485,7 @@ generate_setup_variant(struct llvmpipe_screen *screen,
char func_name[256];
LLVMTypeRef vec4f_type;
LLVMTypeRef func_type;
-   LLVMTypeRef arg_types[8];
+   LLVMTypeRef arg_types[7];
LLVMBasicBlockRef block;
LLVMBuilderRef builder;
int64_t t0, t1;
@@ -521,7 +521,6 @@ generate_setup_variant(struct llvmpipe_screen *screen,
arg_types[4] = LLVMPointerType(vec4f_type, 0);  /* a0, aligned */
arg_types[5] = LLVMPointerType(vec4f_type, 0);  /* dadx, aligned */
arg_types[6] = LLVMPointerType(vec4f_type, 0);  /* dady, aligned */
-   arg_types[7] = LLVMPointerType(vec4f_type, 0);   /* key, unused */
 
func_type = LLVMFunctionType(LLVMVoidType(), arg_types, 
Elements(arg_types), 0);
 
diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.h 
b/src/gallium/drivers/llvmpipe/lp_state_setup.h
index 2b080fb..b0c81ba 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.h
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.h
@@ -30,8 +30,7 @@ typedef void (*lp_jit_setup_triangle)( const float (*v0)[4],
   boolean front_facing,
   float (*a0)[4],
   float (*dadx)[4],
-  float (*dady)[4],
-  const struct lp_setup_variant_key *key );
+  float (*dady)[4] );
 
 
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: reintroduce SET_STATE binner command

2010-10-15 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 4195febeecd2d2f5571afdb90cbb185a4759f50a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4195febeecd2d2f5571afdb90cbb185a4759f50a

Author: Keith Whitwell kei...@vmware.com
Date:   Thu Oct 14 23:28:10 2010 +0100

llvmpipe: reintroduce SET_STATE binner command

But bin lazily only into bins which are receiving geometry.

---

 src/gallium/drivers/llvmpipe/lp_rast.c|   13 +-
 src/gallium/drivers/llvmpipe/lp_rast.h|6 +-
 src/gallium/drivers/llvmpipe/lp_rast_debug.c  |   35 +++--
 src/gallium/drivers/llvmpipe/lp_rast_priv.h   |7 +++-
 src/gallium/drivers/llvmpipe/lp_scene.c   |4 +-
 src/gallium/drivers/llvmpipe/lp_scene.h   |   28 +-
 src/gallium/drivers/llvmpipe/lp_setup_line.c  |1 -
 src/gallium/drivers/llvmpipe/lp_setup_point.c |1 -
 src/gallium/drivers/llvmpipe/lp_setup_tri.c   |   51 +---
 9 files changed, 100 insertions(+), 46 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c 
b/src/gallium/drivers/llvmpipe/lp_rast.c
index db9b2f9..35e2f73 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -334,7 +334,7 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
 {
const struct lp_scene *scene = task-scene;
const struct lp_rast_shader_inputs *inputs = arg.shade_tile;
-   const struct lp_rast_state *state = inputs-state;
+   const struct lp_rast_state *state = task-state;
struct lp_fragment_shader_variant *variant = state-variant;
const unsigned tile_x = task-x, tile_y = task-y;
unsigned x, y;
@@ -414,7 +414,7 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
  unsigned x, unsigned y,
  unsigned mask)
 {
-   const struct lp_rast_state *state = inputs-state;
+   const struct lp_rast_state *state = task-state;
struct lp_fragment_shader_variant *variant = state-variant;
const struct lp_scene *scene = task-scene;
uint8_t *color[PIPE_MAX_COLOR_BUFS];
@@ -490,6 +490,14 @@ lp_rast_end_query(struct lp_rasterizer_task *task,
 }
 
 
+void
+lp_rast_set_state(struct lp_rasterizer_task *task,
+  const union lp_rast_cmd_arg arg)
+{
+   task-state = arg.state;
+}
+
+
 
 /**
  * Set top row and left column of the tile's pixels to white.  For debugging.
@@ -602,6 +610,7 @@ static lp_rast_cmd_func dispatch[LP_RAST_OP_MAX] =
lp_rast_shade_tile_opaque,
lp_rast_begin_query,
lp_rast_end_query,
+   lp_rast_set_state,
 };
 
 
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h 
b/src/gallium/drivers/llvmpipe/lp_rast.h
index e2bcc45..f74b198 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast.h
@@ -85,8 +85,6 @@ struct lp_rast_shader_inputs {
float (*a0)[4];
float (*dadx)[4];
float (*dady)[4];
-
-   const struct lp_rast_state *state;
 };
 
 /* Note: the order of these values is important as they are loaded by
@@ -154,6 +152,7 @@ union lp_rast_cmd_arg {
   uint32_t value;
   uint32_t mask;
} clear_zstencil;
+   const struct lp_rast_state *state;
struct lp_fence *fence;
struct llvmpipe_query *query_obj;
 };
@@ -245,8 +244,9 @@ lp_rast_arg_null( void )
 #define LP_RAST_OP_SHADE_TILE_OPAQUE 0xe
 #define LP_RAST_OP_BEGIN_QUERY   0xf
 #define LP_RAST_OP_END_QUERY 0x10
+#define LP_RAST_OP_SET_STATE 0x11
 
-#define LP_RAST_OP_MAX   0x11
+#define LP_RAST_OP_MAX   0x12
 #define LP_RAST_OP_MASK  0xff
 
 void
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_debug.c 
b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
index 6f4ba1c..3113e19 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_debug.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
@@ -12,6 +12,7 @@ static INLINE int u_bit_scan(unsigned *mask)
 struct tile {
int coverage;
int overdraw;
+   const struct lp_rast_state *state;
char data[TILE_SIZE][TILE_SIZE];
 };
 
@@ -47,6 +48,7 @@ static const char *cmd_names[LP_RAST_OP_MAX] =
shade_tile_opaque,
begin_query,
end_query,
+   set_state,
 };
 
 static const char *cmd_name(unsigned cmd)
@@ -56,31 +58,31 @@ static const char *cmd_name(unsigned cmd)
 }
 
 static const struct lp_fragment_shader_variant *
-get_variant(  const struct cmd_block *block,
-  int k )
+get_variant( const struct lp_rast_state *state,
+ const struct cmd_block *block,
+ int k )
 {
if (block-cmd[k] == LP_RAST_OP_SHADE_TILE ||
-   block-cmd[k] == LP_RAST_OP_SHADE_TILE_OPAQUE)
-  return  block-arg[k].shade_tile-state-variant;
-
-   if (block-cmd[k] == LP_RAST_OP_TRIANGLE_1 ||
+   block-cmd[k] == LP_RAST_OP_SHADE_TILE_OPAQUE ||
+   block-cmd[k] == LP_RAST_OP_TRIANGLE_1 ||
block-cmd[k] == LP_RAST_OP_TRIANGLE_2 ||
block-cmd[k] == LP_RAST_OP_TRIANGLE_3 ||
block-cmd[k] == LP_RAST_OP_TRIANGLE_4 ||
block-cmd[k

Mesa (master): llvmpipe: don't pass frontfacing as a float

2010-10-15 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 0a1c9001037a13b69b157994e7983aa3dee158d3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a1c9001037a13b69b157994e7983aa3dee158d3

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Oct 15 00:12:19 2010 +0100

llvmpipe: don't pass frontfacing as a float

---

 src/gallium/drivers/llvmpipe/lp_bld_depth.c   |8 
 src/gallium/drivers/llvmpipe/lp_jit.h |2 +-
 src/gallium/drivers/llvmpipe/lp_rast.c|4 ++--
 src/gallium/drivers/llvmpipe/lp_rast.h|2 +-
 src/gallium/drivers/llvmpipe/lp_rast_priv.h   |2 +-
 src/gallium/drivers/llvmpipe/lp_setup_line.c  |2 +-
 src/gallium/drivers/llvmpipe/lp_setup_point.c |2 +-
 src/gallium/drivers/llvmpipe/lp_setup_tri.c   |2 +-
 src/gallium/drivers/llvmpipe/lp_state_fs.c|2 +-
 9 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c 
b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
index e4cfa97..ddf7da0 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
@@ -446,7 +446,7 @@ lp_build_occlusion_count(LLVMBuilderRef builder,
  * \param stencil_refs  the front/back stencil ref values (scalar)
  * \param z_src  the incoming depth/stencil values (a 2x2 quad, float32)
  * \param zs_dst_ptr  pointer to depth/stencil values in framebuffer
- * \param facing  contains float value indicating front/back facing polygon
+ * \param facing  contains boolean value indicating front/back facing polygon
  */
 void
 lp_build_depth_stencil_test(LLVMBuilderRef builder,
@@ -576,10 +576,10 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
if (stencil[0].enabled) {
 
   if (face) {
- LLVMValueRef zero = LLVMConstReal(LLVMFloatType(), 0.0);
+ LLVMValueRef zero = LLVMConstInt(LLVMInt32Type(), 0, 0);
 
- /* front_facing = face  0.0 ? ~0 : 0 */
- front_facing = LLVMBuildFCmp(builder, LLVMRealUGT, face, zero, );
+ /* front_facing = face != 0 ? ~0 : 0 */
+ front_facing = LLVMBuildICmp(builder, LLVMIntNE, face, zero, );
  front_facing = LLVMBuildSExt(builder, front_facing,
   
LLVMIntType(s_bld.type.length*s_bld.type.width),
   );
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h 
b/src/gallium/drivers/llvmpipe/lp_jit.h
index 16e04fc..114f21f 100644
--- a/src/gallium/drivers/llvmpipe/lp_jit.h
+++ b/src/gallium/drivers/llvmpipe/lp_jit.h
@@ -144,7 +144,7 @@ typedef void
 (*lp_jit_frag_func)(const struct lp_jit_context *context,
 uint32_t x,
 uint32_t y,
-float facing,
+uint32_t facing,
 const void *a0,
 const void *dadx,
 const void *dady,
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c 
b/src/gallium/drivers/llvmpipe/lp_rast.c
index 35e2f73..8e9be75 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -365,7 +365,7 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
  BEGIN_JIT_CALL(state);
  variant-jit_function[RAST_WHOLE]( state-jit_context,
 tile_x + x, tile_y + y,
-inputs-facing,
+inputs-frontfacing,
 inputs-a0,
 inputs-dadx,
 inputs-dady,
@@ -446,7 +446,7 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
BEGIN_JIT_CALL(state);
variant-jit_function[RAST_EDGE_TEST](state-jit_context,
  x, y,
- inputs-facing,
+ inputs-frontfacing,
  inputs-a0,
  inputs-dadx,
  inputs-dady,
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h 
b/src/gallium/drivers/llvmpipe/lp_rast.h
index f74b198..c5fb154 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast.h
@@ -78,7 +78,7 @@ struct lp_rast_state {
  * These pointers point into the bin data buffer.
  */
 struct lp_rast_shader_inputs {
-   float facing; /** Positive for front-facing, negative for back-facing */
+   unsigned frontfacing; /** One for front-facing */
unsigned disable:1;  /** Partially binned, disable this command */
unsigned opaque:1;   /** Is opaque */
 
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h 
b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
index 7ffd735..e5d04c6 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
@@ -261,7 +261,7 @@ lp_rast_shade_quads_all

Mesa (master): llvmpipe: slightly shrink the size of a binned triangle

2010-10-15 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 9bf8a55c4b29d55320fc2e7875ecf0e9ca164ee8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9bf8a55c4b29d55320fc2e7875ecf0e9ca164ee8

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Oct 15 12:23:22 2010 +0100

llvmpipe: slightly shrink the size of a binned triangle

---

 src/gallium/drivers/llvmpipe/lp_rast.c |   12 +-
 src/gallium/drivers/llvmpipe/lp_rast.h |   30 +++--
 src/gallium/drivers/llvmpipe/lp_rast_debug.c   |3 +-
 src/gallium/drivers/llvmpipe/lp_rast_priv.h|6 +-
 src/gallium/drivers/llvmpipe/lp_rast_tri.c |4 +-
 src/gallium/drivers/llvmpipe/lp_rast_tri_tmp.h |7 +-
 src/gallium/drivers/llvmpipe/lp_setup_coef.c   |   67 +
 src/gallium/drivers/llvmpipe/lp_setup_coef.h   |4 +
 .../drivers/llvmpipe/lp_setup_coef_intrin.c|   52 +++
 src/gallium/drivers/llvmpipe/lp_setup_line.c   |  154 ++--
 src/gallium/drivers/llvmpipe/lp_setup_point.c  |  141 +-
 src/gallium/drivers/llvmpipe/lp_setup_tri.c|  128 
 12 files changed, 316 insertions(+), 292 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c 
b/src/gallium/drivers/llvmpipe/lp_rast.c
index 8e9be75..d358a98 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -366,9 +366,9 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
  variant-jit_function[RAST_WHOLE]( state-jit_context,
 tile_x + x, tile_y + y,
 inputs-frontfacing,
-inputs-a0,
-inputs-dadx,
-inputs-dady,
+GET_A0(inputs),
+GET_DADX(inputs),
+GET_DADY(inputs),
 color,
 depth,
 0x,
@@ -447,9 +447,9 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
variant-jit_function[RAST_EDGE_TEST](state-jit_context,
  x, y,
  inputs-frontfacing,
- inputs-a0,
- inputs-dadx,
- inputs-dady,
+ GET_A0(inputs),
+ GET_DADX(inputs),
+ GET_DADY(inputs),
  color,
  depth,
  mask,
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h 
b/src/gallium/drivers/llvmpipe/lp_rast.h
index c5fb154..8d8b621 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast.h
@@ -78,13 +78,14 @@ struct lp_rast_state {
  * These pointers point into the bin data buffer.
  */
 struct lp_rast_shader_inputs {
-   unsigned frontfacing; /** One for front-facing */
-   unsigned disable:1;  /** Partially binned, disable this command */
-   unsigned opaque:1;   /** Is opaque */
-
-   float (*a0)[4];
-   float (*dadx)[4];
-   float (*dady)[4];
+   unsigned frontfacing:1;  /** True for front-facing */
+   unsigned disable:1;  /** Partially binned, disable this command */
+   unsigned opaque:1;   /** Is opaque */
+   unsigned pad0:29;/* wasted space */
+   unsigned stride; /* how much to advance data between a0, dadx, 
dady */
+   unsigned pad2;   /* wasted space */
+   unsigned pad3;   /* wasted space */
+   /* followed by a0, dadx, dady and planes[] */
 };
 
 /* Note: the order of these values is important as they are loaded by
@@ -111,17 +112,24 @@ struct lp_rast_plane {
  * Objects of this type are put into the lp_setup_context::data buffer.
  */
 struct lp_rast_triangle {
-   /* inputs for the shader */
-   struct lp_rast_shader_inputs inputs;
-
 #ifdef DEBUG
float v[3][2];
+   float pad0;
+   float pad1;
 #endif
 
-   struct lp_rast_plane plane[8]; /* NOTE: may allocate fewer planes */
+   /* inputs for the shader */
+   struct lp_rast_shader_inputs inputs;
+   /* planes are also allocated here */
 };
 
 
+#define GET_A0(inputs) ((float (*)[4])((inputs)+1))
+#define GET_DADX(inputs) ((float (*)[4])((char *)((inputs) + 1) + 
(inputs)-stride))
+#define GET_DADY(inputs) ((float (*)[4])((char *)((inputs) + 1) + 2 * 
(inputs)-stride))
+#define GET_PLANES(tri) ((struct lp_rast_plane *)((char *)((tri)-inputs + 1) 
+ 3 * (tri)-inputs.stride))
+
+
 
 struct lp_rasterizer *
 lp_rast_create( unsigned num_threads );
diff --git a/src/gallium/drivers

Mesa (master): llvmpipe: don't store plane.ei value in binned data

2010-10-15 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 8965f042b327ad8697963e757f4607f4bb13a045
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8965f042b327ad8697963e757f4607f4bb13a045

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Oct 15 13:04:19 2010 +0100

llvmpipe: don't store plane.ei value in binned data

Further reduce the size of a binned triangle.

---

 src/gallium/drivers/llvmpipe/lp_rast.h |3 ---
 src/gallium/drivers/llvmpipe/lp_rast_tri_tmp.h |6 --
 src/gallium/drivers/llvmpipe/lp_setup_line.c   |8 
 src/gallium/drivers/llvmpipe/lp_setup_point.c  |4 
 src/gallium/drivers/llvmpipe/lp_setup_tri.c|   13 -
 5 files changed, 8 insertions(+), 26 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h 
b/src/gallium/drivers/llvmpipe/lp_rast.h
index 8d8b621..a64c152 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast.h
@@ -100,9 +100,6 @@ struct lp_rast_plane {
 
/* one-pixel sized trivial reject offsets for each plane */
int eo;
-
-   /* one-pixel sized trivial accept offsets for each plane */
-   int ei;
 };
 
 /**
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri_tmp.h 
b/src/gallium/drivers/llvmpipe/lp_rast_tri_tmp.h
index 9976996..4825d65 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_tri_tmp.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_tri_tmp.h
@@ -82,7 +82,8 @@ TAG(do_block_16)(struct lp_rasterizer_task *task,
   const int dcdx = -plane[j].dcdx * 4;
   const int dcdy = plane[j].dcdy * 4;
   const int cox = plane[j].eo * 4;
-  const int cio = plane[j].ei * 4 - 1;
+  const int ei = plane[j].dcdy - plane[j].dcdx - plane[j].eo;
+  const int cio = ei * 4 - 1;
 
   build_masks(c[j] + cox,
  cio - cox,
@@ -181,7 +182,8 @@ TAG(lp_rast_triangle)(struct lp_rasterizer_task *task,
 const int dcdx = -plane[j].dcdx * 16;
 const int dcdy = plane[j].dcdy * 16;
 const int cox = plane[j].eo * 16;
-const int cio = plane[j].ei * 16 - 1;
+ const int ei = plane[j].dcdy - plane[j].dcdx - plane[j].eo;
+ const int cio = ei * 16 - 1;
 
 build_masks(c[j] + cox,
 cio - cox,
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_line.c 
b/src/gallium/drivers/llvmpipe/lp_setup_line.c
index 2fd9f2e..ece8638 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_line.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_line.c
@@ -654,10 +654,6 @@ try_setup_line( struct lp_setup_context *setup,
   plane[i].eo = 0;
   if (plane[i].dcdx  0) plane[i].eo -= plane[i].dcdx;
   if (plane[i].dcdy  0) plane[i].eo += plane[i].dcdy;
-
-  /* Calculate trivial accept offsets from the above.
-   */
-  plane[i].ei = plane[i].dcdy - plane[i].dcdx - plane[i].eo;
}
 
 
@@ -683,25 +679,21 @@ try_setup_line( struct lp_setup_context *setup,
   plane[4].dcdx = -1;
   plane[4].dcdy = 0;
   plane[4].c = 1-bbox.x0;
-  plane[4].ei = 0;
   plane[4].eo = 1;
 
   plane[5].dcdx = 1;
   plane[5].dcdy = 0;
   plane[5].c = bbox.x1+1;
-  plane[5].ei = -1;
   plane[5].eo = 0;
 
   plane[6].dcdx = 0;
   plane[6].dcdy = 1;
   plane[6].c = 1-bbox.y0;
-  plane[6].ei = 0;
   plane[6].eo = 1;
 
   plane[7].dcdx = 0;
   plane[7].dcdy = -1;
   plane[7].c = bbox.y1+1;
-  plane[7].ei = -1;
   plane[7].eo = 0;
}
 
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_point.c 
b/src/gallium/drivers/llvmpipe/lp_setup_point.c
index e30e70e..16d21df 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_point.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_point.c
@@ -386,25 +386,21 @@ try_setup_point( struct lp_setup_context *setup,
   plane[0].dcdx = -1;
   plane[0].dcdy = 0;
   plane[0].c = 1-bbox.x0;
-  plane[0].ei = 0;
   plane[0].eo = 1;
 
   plane[1].dcdx = 1;
   plane[1].dcdy = 0;
   plane[1].c = bbox.x1+1;
-  plane[1].ei = -1;
   plane[1].eo = 0;
 
   plane[2].dcdx = 0;
   plane[2].dcdy = 1;
   plane[2].c = 1-bbox.y0;
-  plane[2].ei = 0;
   plane[2].eo = 1;
 
   plane[3].dcdx = 0;
   plane[3].dcdy = -1;
   plane[3].c = bbox.y1+1;
-  plane[3].ei = -1;
   plane[3].eo = 0;
}
 
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c 
b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index 937821b..6ceda80 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -374,10 +374,6 @@ do_triangle_ccw(struct lp_setup_context *setup,
   plane[i].eo = 0;
   if (plane[i].dcdx  0) plane[i].eo -= plane[i].dcdx;
   if (plane[i].dcdy  0) plane[i].eo += plane[i].dcdy;
-
-  /* Calculate trivial accept offsets from the above.
-   */
-  plane[i].ei = plane[i].dcdy - plane[i].dcdx - plane[i].eo;
}
 
 
@@ -403,25 +399,21 @@ do_triangle_ccw(struct lp_setup_context *setup,
   plane[3].dcdx = -1

Mesa (master): gallium: move some intrinsics helpers to u_sse.h

2010-10-15 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 15f4e3a8b98b5f4ca2833c02192ed9e6c237c5c7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=15f4e3a8b98b5f4ca2833c02192ed9e6c237c5c7

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Oct 12 18:58:05 2010 +0100

gallium: move some intrinsics helpers to u_sse.h

---

 src/gallium/auxiliary/util/u_sse.h |   74 
 src/gallium/drivers/llvmpipe/lp_rast_tri.c |   58 --
 2 files changed, 74 insertions(+), 58 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_sse.h 
b/src/gallium/auxiliary/util/u_sse.h
index 8fd0e52..1df6c87 100644
--- a/src/gallium/auxiliary/util/u_sse.h
+++ b/src/gallium/auxiliary/util/u_sse.h
@@ -71,6 +71,12 @@ _mm_castps_si128(__m128 a)
 
 #endif /* defined(_MSC_VER)  _MSC_VER  1500 */
 
+union m128i {
+   __m128i m;
+   ubyte ub[16];
+   ushort us[8];
+   uint ui[4];
+};
 
 static INLINE void u_print_epi8(const char *name, __m128i r)
 {
@@ -149,6 +155,12 @@ static INLINE void u_print_ps(const char *name, __m128 r)
 }
 
 
+#define U_DUMP_EPI32(a) u_print_epi32(#a, a)
+#define U_DUMP_EPI16(a) u_print_epi16(#a, a)
+#define U_DUMP_EPI8(a)  u_print_epi8(#a, a)
+#define U_DUMP_PS(a)u_print_ps(#a, a)
+
+
 
 #if defined(PIPE_ARCH_SSSE3)
 
@@ -176,6 +188,68 @@ _mm_shuffle_epi8(__m128i a, __m128i mask)
 #endif /* !PIPE_ARCH_SSSE3 */
 
 
+
+
+/* Provide an SSE2 implementation of _mm_mullo_epi32() in terms of
+ * _mm_mul_epu32().
+ *
+ * I suspect this works fine for us because one of our operands is
+ * always positive, but not sure that this can be used for general
+ * signed integer multiplication.
+ *
+ * This seems close enough to the speed of SSE4 and the real
+ * _mm_mullo_epi32() intrinsic as to not justify adding an sse4
+ * dependency at this point.
+ */
+static INLINE __m128i mm_mullo_epi32(const __m128i a, const __m128i b)
+{
+   __m128i a4   = _mm_srli_epi64(a, 32);  /* shift by one dword */
+   __m128i b4   = _mm_srli_epi64(b, 32);  /* shift by one dword */
+   __m128i ba   = _mm_mul_epu32(b, a);   /* multply dwords 0, 2 */
+   __m128i b4a4 = _mm_mul_epu32(b4, a4); /* multiply dwords 1, 3 */
+
+   /* Interleave the results, either with shuffles or (slightly
+* faster) direct bit operations:
+*/
+#if 0
+   __m128i ba8 = _mm_shuffle_epi32(ba, 8);
+   __m128i b4a48   = _mm_shuffle_epi32(b4a4, 8);
+   __m128i result  = _mm_unpacklo_epi32(ba8, b4a48);
+#else
+   __m128i mask= _mm_setr_epi32(~0,0,~0,0);
+   __m128i ba_mask = _mm_and_si128(ba, mask);
+   __m128i b4a4_mask_shift = _mm_slli_epi64(b4a4, 32);
+   __m128i result  = _mm_or_si128(ba_mask, b4a4_mask_shift);
+#endif
+
+   return result;
+}
+
+
+static INLINE void
+transpose4_epi32(const __m128i * restrict a,
+ const __m128i * restrict b,
+ const __m128i * restrict c,
+ const __m128i * restrict d,
+ __m128i * restrict o,
+ __m128i * restrict p,
+ __m128i * restrict q,
+ __m128i * restrict r)
+{
+  __m128i t0 = _mm_unpacklo_epi32(*a, *b);
+  __m128i t1 = _mm_unpacklo_epi32(*c, *d);
+  __m128i t2 = _mm_unpackhi_epi32(*a, *b);
+  __m128i t3 = _mm_unpackhi_epi32(*c, *d);
+
+  *o = _mm_unpacklo_epi64(t0, t1);
+  *p = _mm_unpackhi_epi64(t0, t1);
+  *q = _mm_unpacklo_epi64(t2, t3);
+  *r = _mm_unpackhi_epi64(t2, t3);
+}
+
+#define SCALAR_EPI32(m, i) _mm_shuffle_epi32((m), _MM_SHUFFLE(i,i,i,i))
+
+
 #endif /* PIPE_ARCH_SSE */
 
 #endif /* U_SSE_H_ */
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c 
b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
index 5bdf197..659eb1c 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
@@ -240,68 +240,10 @@ sign_bits4(const __m128i *cstep, int cdiff)
 }
 
 
-static INLINE void
-transpose4_epi32(const __m128i * restrict a,
- const __m128i * restrict b,
- const __m128i * restrict c,
- const __m128i * restrict d,
- __m128i * restrict o,
- __m128i * restrict p,
- __m128i * restrict q,
- __m128i * restrict r)
-{
-  __m128i t0 = _mm_unpacklo_epi32(*a, *b);
-  __m128i t1 = _mm_unpacklo_epi32(*c, *d);
-  __m128i t2 = _mm_unpackhi_epi32(*a, *b);
-  __m128i t3 = _mm_unpackhi_epi32(*c, *d);
-
-  *o = _mm_unpacklo_epi64(t0, t1);
-  *p = _mm_unpackhi_epi64(t0, t1);
-  *q = _mm_unpacklo_epi64(t2, t3);
-  *r = _mm_unpackhi_epi64(t2, t3);
-}
-
-
-#define SCALAR_EPI32(m, i) _mm_shuffle_epi32((m), _MM_SHUFFLE(i,i,i,i))
-
 #define NR_PLANES 3
 
 
 
-/* Provide an SSE2 implementation of _mm_mullo_epi32() in terms of
- * _mm_mul_epu32().
- *
- * I suspect this works fine for us because one of our operands is
- * always positive, but not sure that this can be used for general
- * signed integer multiplication.
- *
- * This seems close enough to the speed of SSE4 and the real

Mesa (master): llvmpipe: do plane calculations with intrinsics

2010-10-15 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 9f9a17eba8d6080bf30f17c8a7eaed97b10a559f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9f9a17eba8d6080bf30f17c8a7eaed97b10a559f

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Oct 12 18:59:15 2010 +0100

llvmpipe: do plane calculations with intrinsics

This is a step towards moving this code into the rasterizer.

---

 src/gallium/drivers/llvmpipe/lp_setup_tri.c |  205 +++
 1 files changed, 148 insertions(+), 57 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c 
b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index 6ceda80..49ded9e 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -32,6 +32,7 @@
 #include util/u_math.h
 #include util/u_memory.h
 #include util/u_rect.h
+#include util/u_sse.h
 #include lp_perf.h
 #include lp_setup_context.h
 #include lp_setup_coef.h
@@ -40,7 +41,9 @@
 
 #define NUM_CHANNELS 4
 
-
+#if defined(PIPE_ARCH_SSE)
+#include emmintrin.h
+#endif

 static INLINE int
 subpixel_snap(float a)
@@ -230,11 +233,10 @@ do_triangle_ccw(struct lp_setup_context *setup,
struct lp_scene *scene = setup-scene;
struct lp_rast_triangle *tri;
struct lp_rast_plane *plane;
-   int x[3];
-   int y[3];
+   int x[4];
+   int y[4];
struct u_rect bbox;
unsigned tri_bytes;
-   int i;
int nr_planes = 3;
 
if (0)
@@ -251,10 +253,12 @@ do_triangle_ccw(struct lp_setup_context *setup,
x[0] = subpixel_snap(v0[0][0] - setup-pixel_offset);
x[1] = subpixel_snap(v1[0][0] - setup-pixel_offset);
x[2] = subpixel_snap(v2[0][0] - setup-pixel_offset);
+   x[3] = 0;
y[0] = subpixel_snap(v0[0][1] - setup-pixel_offset);
y[1] = subpixel_snap(v1[0][1] - setup-pixel_offset);
y[2] = subpixel_snap(v2[0][1] - setup-pixel_offset);
-
+   y[3] = 0;
+   
 
/* Bounding rectangle (in pixels) */
{
@@ -307,15 +311,6 @@ do_triangle_ccw(struct lp_setup_context *setup,
tri-v[2][1] = v2[0][1];
 #endif
 
-   plane = GET_PLANES(tri);
-   plane[0].dcdy = x[0] - x[1];
-   plane[1].dcdy = x[1] - x[2];
-   plane[2].dcdy = x[2] - x[0];
-
-   plane[0].dcdx = y[0] - y[1];
-   plane[1].dcdx = y[1] - y[2];
-   plane[2].dcdx = y[2] - y[0];
-
LP_COUNT(nr_tris);
 
/* Setup parameter interpolants:
@@ -326,54 +321,150 @@ do_triangle_ccw(struct lp_setup_context *setup,
tri-inputs.disable = FALSE;
tri-inputs.opaque = setup-fs.current.variant-opaque;
 
-  
-   for (i = 0; i  3; i++) {
-  /* half-edge constants, will be interated over the whole render
-   * target.
+   plane = GET_PLANES(tri);
+
+#if defined(PIPE_ARCH_SSE)
+   {
+  __m128i vertx, verty;
+  __m128i shufx, shufy;
+  __m128i dcdx, dcdy, c;
+  __m128i unused;
+  __m128i dcdx_neg_mask;
+  __m128i dcdy_neg_mask;
+  __m128i dcdx_zero_mask;
+  __m128i top_left_flag;
+  __m128i c_inc_mask, c_inc;
+  __m128i eo, p0, p1, p2;
+  __m128i zero = _mm_setzero_si128();
+
+  vertx = _mm_loadu_si128((__m128i *)x); /* vertex x coords */
+  verty = _mm_loadu_si128((__m128i *)y); /* vertex y coords */
+
+  shufx = _mm_shuffle_epi32(vertx, _MM_SHUFFLE(3,0,2,1));
+  shufy = _mm_shuffle_epi32(verty, _MM_SHUFFLE(3,0,2,1));
+
+  dcdx = _mm_sub_epi32(verty, shufy);
+  dcdy = _mm_sub_epi32(vertx, shufx);
+
+  dcdx_neg_mask = _mm_srai_epi32(dcdx, 31);
+  dcdx_zero_mask = _mm_cmpeq_epi32(dcdx, zero);
+  dcdy_neg_mask = _mm_srai_epi32(dcdy, 31);
+
+  top_left_flag = _mm_set1_epi32((setup-pixel_offset == 0) ? ~0 : 0);
+
+  c_inc_mask = _mm_or_si128(dcdx_neg_mask,
+_mm_and_si128(dcdx_zero_mask,
+  _mm_xor_si128(dcdy_neg_mask,
+top_left_flag)));
+
+  c_inc = _mm_srli_epi32(c_inc_mask, 31);
+
+  c = _mm_sub_epi32(mm_mullo_epi32(dcdx, vertx),
+mm_mullo_epi32(dcdy, verty));
+
+  c = _mm_add_epi32(c, c_inc);
+
+  /* Scale up to match c:
*/
-  plane[i].c = plane[i].dcdx * x[i] - plane[i].dcdy * y[i];
-
-  /* correct for top-left vs. bottom-left fill convention.  
-   *
-   * note that we're overloading gl_rasterization_rules to mean
-   * both (0.5,0.5) pixel centers *and* bottom-left filling
-   * convention.
-   *
-   * GL actually has a top-left filling convention, but GL's
-   * notion of top differs from gallium's...
-   *
-   * Also, sometimes (in FBO cases) GL will render upside down
-   * to its usual method, in which case it will probably want
-   * to use the opposite, top-left convention.
-   */ 
-  if (plane[i].dcdx  0) {
- /* both fill conventions want this - adjust for left edges */
- plane[i].c++;
-  }
-  else if (plane[i].dcdx == 0) {
- if (setup-pixel_offset == 0) {
-/* correct for top

Mesa (master): llvmpipe: use aligned loads/stores for plane values

2010-10-15 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 392b0954c265fdd66b2de99ab677d2e662935682
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=392b0954c265fdd66b2de99ab677d2e662935682

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Oct 15 13:52:00 2010 +0100

llvmpipe: use aligned loads/stores for plane values

---

 src/gallium/drivers/llvmpipe/lp_rast_tri.c  |   12 ++--
 src/gallium/drivers/llvmpipe/lp_setup_tri.c |6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c 
b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
index 659eb1c..042c315 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
@@ -261,9 +261,9 @@ lp_rast_triangle_3_16(struct lp_rasterizer_task *task,
struct { unsigned mask:16; unsigned i:8; unsigned j:8; } out[16];
unsigned nr = 0;
 
-   __m128i p0 = _mm_loadu_si128((__m128i *)plane[0]); /* c, dcdx, dcdy, eo */
-   __m128i p1 = _mm_loadu_si128((__m128i *)plane[1]); /* c, dcdx, dcdy, eo */
-   __m128i p2 = _mm_loadu_si128((__m128i *)plane[2]); /* c, dcdx, dcdy, eo */
+   __m128i p0 = _mm_load_si128((__m128i *)plane[0]); /* c, dcdx, dcdy, eo */
+   __m128i p1 = _mm_load_si128((__m128i *)plane[1]); /* c, dcdx, dcdy, eo */
+   __m128i p2 = _mm_load_si128((__m128i *)plane[2]); /* c, dcdx, dcdy, eo */
__m128i zero = _mm_setzero_si128();
 
__m128i c;
@@ -367,9 +367,9 @@ lp_rast_triangle_3_4(struct lp_rasterizer_task *task,
int x = (arg.triangle.plane_mask  0xff) + task-x;
int y = (arg.triangle.plane_mask  8) + task-y;
 
-   __m128i p0 = _mm_loadu_si128((__m128i *)plane[0]); /* c, dcdx, dcdy, eo */
-   __m128i p1 = _mm_loadu_si128((__m128i *)plane[1]); /* c, dcdx, dcdy, eo */
-   __m128i p2 = _mm_loadu_si128((__m128i *)plane[2]); /* c, dcdx, dcdy, eo */
+   __m128i p0 = _mm_load_si128((__m128i *)plane[0]); /* c, dcdx, dcdy, eo */
+   __m128i p1 = _mm_load_si128((__m128i *)plane[1]); /* c, dcdx, dcdy, eo */
+   __m128i p2 = _mm_load_si128((__m128i *)plane[2]); /* c, dcdx, dcdy, eo */
__m128i zero = _mm_setzero_si128();
 
__m128i c;
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c 
b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index 49ded9e..c6cb9af 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -382,9 +382,9 @@ do_triangle_ccw(struct lp_setup_context *setup,
   transpose4_epi32(c, dcdx, dcdy, eo,
p0, p1, p2, unused);
 
-  _mm_storeu_si128((__m128i *)plane[0], p0);
-  _mm_storeu_si128((__m128i *)plane[1], p1);
-  _mm_storeu_si128((__m128i *)plane[2], p2);
+  _mm_store_si128((__m128i *)plane[0], p0);
+  _mm_store_si128((__m128i *)plane[1], p1);
+  _mm_store_si128((__m128i *)plane[2], p2);
}
 #else
{

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: fix non-sse build after recent changes

2010-10-15 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 39185efd3a891b0d66b1ded10d165dd9aee94464
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=39185efd3a891b0d66b1ded10d165dd9aee94464

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Oct 15 14:11:22 2010 +0100

llvmpipe: fix non-sse build after recent changes

---

 src/gallium/drivers/llvmpipe/lp_setup_coef.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup_coef.c 
b/src/gallium/drivers/llvmpipe/lp_setup_coef.c
index a835df6..95d6615 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_coef.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_coef.c
@@ -145,12 +145,12 @@ setup_fragcoord_coef(struct lp_tri_info *info,
 
/*Z*/
if (usage_mask  TGSI_WRITEMASK_Z) {
-  linear_coef(inputs, info, slot, 0, 2);
+  linear_coef(info, slot, 0, 2);
}
 
/*W*/
if (usage_mask  TGSI_WRITEMASK_W) {
-  linear_coef(inputs, info, slot, 0, 3);
+  linear_coef(info, slot, 0, 3);
}
 }
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: validate color outputs against key-nr_cbufs

2010-10-15 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: ac98519c4eed0daf770a9ba380056978e4420352
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ac98519c4eed0daf770a9ba380056978e4420352

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Oct 15 13:23:30 2010 +0100

llvmpipe: validate color outputs against key-nr_cbufs

---

 src/gallium/drivers/llvmpipe/lp_state_fs.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index c4b1b86..c070b55 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -404,7 +404,8 @@ generate_fs(struct llvmpipe_context *lp,
/* Color write  */
for (attrib = 0; attrib  shader-info.base.num_outputs; ++attrib)
{
-  if (shader-info.base.output_semantic_name[attrib] == 
TGSI_SEMANTIC_COLOR)
+  if (shader-info.base.output_semantic_name[attrib] == 
TGSI_SEMANTIC_COLOR 
+  shader-info.base.output_semantic_index[attrib]  key-nr_cbufs)
   {
  unsigned cbuf = shader-info.base.output_semantic_index[attrib];
  for(chan = 0; chan  NUM_CHANNELS; ++chan) {

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: check shader outputs are non-null before using

2010-10-15 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: ffab84c9a27a229e6fa14c3de63868bb843c0f3e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ffab84c9a27a229e6fa14c3de63868bb843c0f3e

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Oct 15 13:23:05 2010 +0100

llvmpipe: check shader outputs are non-null before using

---

 src/gallium/drivers/llvmpipe/lp_state_fs.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 8df807c..c4b1b86 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -345,7 +345,7 @@ generate_fs(struct llvmpipe_context *lp,
TGSI_SEMANTIC_COLOR,
0);
 
-  if (color0 != -1) {
+  if (color0 != -1  outputs[color0][3]) {
  LLVMValueRef alpha = LLVMBuildLoad(builder, outputs[color0][3], 
alpha);
  LLVMValueRef alpha_ref_value;
 
@@ -364,7 +364,7 @@ generate_fs(struct llvmpipe_context *lp,
  TGSI_SEMANTIC_POSITION,
  0);
  
-  if (pos0 != -1) {
+  if (pos0 != -1  outputs[pos0][2]) {
  z = LLVMBuildLoad(builder, outputs[pos0][2], z);
  lp_build_name(z, output%u.%u.%c, i, pos0, xyzw[chan]);
   }

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: don't try to emit non-existent color outputs

2010-10-14 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: f0bd76f28d17da6eabf977a7e619e4ff943a70c7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f0bd76f28d17da6eabf977a7e619e4ff943a70c7

Author: Keith Whitwell kei...@vmware.com
Date:   Thu Oct 14 13:15:28 2010 +0100

llvmpipe: don't try to emit non-existent color outputs

---

 src/gallium/drivers/llvmpipe/lp_state_fs.c |   17 +
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index c098356..6e3c27e 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -406,14 +406,15 @@ generate_fs(struct llvmpipe_context *lp,
   if (shader-info.base.output_semantic_name[attrib] == 
TGSI_SEMANTIC_COLOR)
   {
  unsigned cbuf = shader-info.base.output_semantic_index[attrib];
- for(chan = 0; chan  NUM_CHANNELS; ++chan)
- {
-/* XXX: just initialize outputs to point at colors[] and
- * skip this.
- */
-LLVMValueRef out = LLVMBuildLoad(builder, outputs[attrib][chan], 
);
-lp_build_name(out, color%u.%u.%c, i, attrib, rgba[chan]);
-LLVMBuildStore(builder, out, color[cbuf][chan]);
+ for(chan = 0; chan  NUM_CHANNELS; ++chan) {
+if(outputs[attrib][chan]) {
+   /* XXX: just initialize outputs to point at colors[] and
+* skip this.
+*/
+   LLVMValueRef out = LLVMBuildLoad(builder, 
outputs[attrib][chan], );
+   lp_build_name(out, color%u.%u.%c, i, attrib, rgba[chan]);
+   LLVMBuildStore(builder, out, color[cbuf][chan]);
+}
  }
   }
}

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (llvm-cliptest-viewport): draw: sanitize llvm variant key

2010-10-14 Thread Keith Whitwell
Module: Mesa
Branch: llvm-cliptest-viewport
Commit: 26ff7523b69ddb377ade29296d20abfc46e69489
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=26ff7523b69ddb377ade29296d20abfc46e69489

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Thu Oct 14 14:04:39 2010 +0100

draw: sanitize llvm variant key

Fixes recompilation, but seems to be broken with llvm 2.8.

---

 src/gallium/auxiliary/draw/draw_llvm.c |1 +
 src/gallium/auxiliary/draw/draw_llvm.h |3 ++-
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 5f11b82..1c18d90 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1430,6 +1430,7 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char 
*store)
key-enable_d3dclipping = 
(boolean)!llvm-draw-rasterizer-gl_rasterization_rules;
key-need_edgeflags = (llvm-draw-vs.edgeflag_output ? TRUE : FALSE);
key-nr_planes = llvm-draw-nr_planes;
+   key-pad = 0;
 
/* All variants of this shader will have the same value for
 * nr_samplers.  Not yet trying to compact away holes in the
diff --git a/src/gallium/auxiliary/draw/draw_llvm.h 
b/src/gallium/auxiliary/draw/draw_llvm.h
index fc78854..def0681 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.h
+++ b/src/gallium/auxiliary/draw/draw_llvm.h
@@ -168,7 +168,8 @@ struct draw_llvm_variant_key
unsigned bypass_viewport:1;
unsigned enable_d3dclipping:1;
unsigned need_edgeflags:1;
-   unsigned nr_planes;
+   unsigned nr_planes:4;
+   unsigned pad:26;
 
/* Variable number of vertex elements:
 */

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: try to do more of rast_tri_3_16 with intrinsics

2010-10-12 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 2cf98d5a6dccba3fd69b8469e67f66dfb5fc9651
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2cf98d5a6dccba3fd69b8469e67f66dfb5fc9651

Author: Keith Whitwell kei...@vmware.com
Date:   Mon Oct 11 16:30:14 2010 +0100

llvmpipe: try to do more of rast_tri_3_16 with intrinsics

There was actually a large quantity of scalar code in these functions
previously.  This tries to move more into intrinsics.

Introduce an sse2 mm_mullo_epi32 replacement to avoid sse4 dependency
in the new rasterization code.

---

 src/gallium/drivers/llvmpipe/lp_rast.h |   16 +-
 src/gallium/drivers/llvmpipe/lp_rast_tri.c |  264 +++-
 2 files changed, 271 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h 
b/src/gallium/drivers/llvmpipe/lp_rast.h
index df0bea0..e2bcc45 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast.h
@@ -89,19 +89,21 @@ struct lp_rast_shader_inputs {
const struct lp_rast_state *state;
 };
 
-
+/* Note: the order of these values is important as they are loaded by
+ * sse code in rasterization:
+ */
 struct lp_rast_plane {
-   /* one-pixel sized trivial accept offsets for each plane */
-   int ei;
-
-   /* one-pixel sized trivial reject offsets for each plane */
-   int eo;
-
/* edge function values at minx,miny ?? */
int c;
 
int dcdx;
int dcdy;
+
+   /* one-pixel sized trivial reject offsets for each plane */
+   int eo;
+
+   /* one-pixel sized trivial accept offsets for each plane */
+   int ei;
 };
 
 /**
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c 
b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
index f870a18..7a6cbb8 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
@@ -32,6 +32,7 @@
 #include limits.h
 #include util/u_math.h
 #include lp_debug.h
+#include lp_debug_intrin.h
 #include lp_perf.h
 #include lp_rast_priv.h
 #include lp_tile_soa.h
@@ -254,8 +255,8 @@ sign_bits4(const __m128i *cstep, int cdiff)
 
 #define TAG(x) x##_3
 #define NR_PLANES 3
-#define TRI_4 lp_rast_triangle_3_4
-#define TRI_16 lp_rast_triangle_3_16
+/*#define TRI_4 lp_rast_triangle_3_4*/
+/*#define TRI_16 lp_rast_triangle_3_16*/
 #include lp_rast_tri_tmp.h
 
 #define TAG(x) x##_4
@@ -279,3 +280,262 @@ sign_bits4(const __m128i *cstep, int cdiff)
 #define NR_PLANES 8
 #include lp_rast_tri_tmp.h
 
+
+static INLINE void
+transpose4_epi32(__m128i a,
+ __m128i b,
+ __m128i c,
+ __m128i d,
+ __m128i *o,
+ __m128i *p,
+ __m128i *q,
+ __m128i *r)
+{
+  __m128i t0 = _mm_unpacklo_epi32(a, b);
+  __m128i t1 = _mm_unpacklo_epi32(c, d);
+  __m128i t2 = _mm_unpackhi_epi32(a, b);
+  __m128i t3 = _mm_unpackhi_epi32(c, d);
+
+  *o = _mm_unpacklo_epi64(t0, t1);
+  *p = _mm_unpackhi_epi64(t0, t1);
+  *q = _mm_unpacklo_epi64(t2, t3);
+  *r = _mm_unpackhi_epi64(t2, t3);
+}
+
+
+#define SCALAR_EPI32(m, i) _mm_shuffle_epi32((m), _MM_SHUFFLE(i,i,i,i))
+
+#define NR_PLANES 3
+
+
+
+/* Provide an SSE2 implementation of _mm_mullo_epi32() in terms of
+ * _mm_mul_epu32().
+ *
+ * I suspect this works fine for us because one of our operands is
+ * always positive, but not sure that this can be used for general
+ * signed integer multiplication.
+ *
+ * This seems close enough to the speed of SSE4 and the real
+ * _mm_mullo_epi32() intrinsic as to not justify adding an sse4
+ * dependency at this point.
+ */
+static INLINE __m128i mm_mullo_epi32(const __m128i a, const __m128i b)
+{
+   __m128i a4   = _mm_srli_si128(a, 4);  /* shift by one dword */
+   __m128i b4   = _mm_srli_si128(b, 4);  /* shift by one dword */
+   __m128i ba   = _mm_mul_epu32(b, a);   /* multply dwords 0, 2 */
+   __m128i b4a4 = _mm_mul_epu32(b4, a4); /* multiply dwords 1, 3 */
+
+   /* Interleave the results, either with shuffles or (slightly
+* faster) direct bit operations:
+*/
+#if 0
+   __m128i ba8 = _mm_shuffle_epi32(ba, 8);
+   __m128i b4a48   = _mm_shuffle_epi32(b4a4, 8);
+   __m128i result  = _mm_unpacklo_epi32(ba8, b4a48);
+#else
+   __m128i mask= _mm_setr_epi32(~0,0,~0,0);
+   __m128i ba_mask = _mm_and_si128(ba, mask);
+   __m128i b4a4_mask   = _mm_and_si128(b4a4, mask);
+   __m128i b4a4_mask_shift = _mm_slli_si128(b4a4_mask, 4);
+   __m128i result  = _mm_or_si128(ba_mask, b4a4_mask_shift);
+#endif
+
+   return result;
+}
+
+
+
+
+void
+lp_rast_triangle_3_16(struct lp_rasterizer_task *task,
+  const union lp_rast_cmd_arg arg)
+{
+   const struct lp_rast_triangle *tri = arg.triangle.tri;
+   const struct lp_rast_plane *plane = tri-plane;
+   int x = (arg.triangle.plane_mask  0xff) + task-x;
+   int y = (arg.triangle.plane_mask  8) + task-y;
+   unsigned i, j;
+
+   struct { unsigned mask:16; unsigned i:8; unsigned j:8; } out[16];
+   unsigned nr = 0;
+
+   __m128i

Mesa (master): llvmpipe: add debug helpers for epi32 etc

2010-10-12 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 9d59e148f86c1de2c69639d389398d7435cc193e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9d59e148f86c1de2c69639d389398d7435cc193e

Author: Keith Whitwell kei...@vmware.com
Date:   Mon Oct 11 18:20:02 2010 +0100

llvmpipe: add debug helpers for epi32 etc

---

 src/gallium/drivers/llvmpipe/lp_debug_intrin.h |  115 
 1 files changed, 115 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_debug_intrin.h 
b/src/gallium/drivers/llvmpipe/lp_debug_intrin.h
new file mode 100644
index 000..5237e78
--- /dev/null
+++ b/src/gallium/drivers/llvmpipe/lp_debug_intrin.h
@@ -0,0 +1,115 @@
+/**
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * Software), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ **/
+
+#ifndef _LP_DEBUG_INTRIN_H_
+#define _LP_DEBUG_INTRIN_H_
+
+#include pipe/p_config.h
+
+#if defined(PIPE_ARCH_SSE)
+
+#include emmintrin.h
+
+static INLINE void print_epi8(const char *name, __m128i r)
+{
+   union { __m128i m; ubyte ub[16]; } u;
+   u.m = r;
+
+   debug_printf(%s: 
+%02x/
+%02x/
+%02x/
+%02x/
+%02x/
+%02x/
+%02x/
+%02x/
+%02x/
+%02x/
+%02x/
+%02x/
+%02x/
+%02x/
+%02x/
+%02x\n,
+name,
+u.ub[0],  u.ub[1],  u.ub[2],  u.ub[3],
+u.ub[4],  u.ub[5],  u.ub[6],  u.ub[7],
+u.ub[8],  u.ub[9],  u.ub[10], u.ub[11],
+u.ub[12], u.ub[13], u.ub[14], u.ub[15]);
+}
+
+static INLINE void print_epi16(const char *name, __m128i r)
+{
+   union { __m128i m; ushort us[8]; } u;
+   u.m = r;
+
+   debug_printf(%s: 
+%04x/
+%04x/
+%04x/
+%04x/
+%04x/
+%04x/
+%04x/
+%04x\n,
+name,
+u.us[0],  u.us[1],  u.us[2],  u.us[3],
+u.us[4],  u.us[5],  u.us[6],  u.us[7]);
+}
+
+static INLINE void print_epi32(const char *name, __m128i r)
+{
+   union { __m128i m; uint ui[4]; } u;
+   u.m = r;
+
+   debug_printf(%s: 
+%08x/
+%08x/
+%08x/
+%08x\n,
+name,
+u.ui[0],  u.ui[1],  u.ui[2],  u.ui[3]);
+}
+
+static INLINE void print_ps(const char *name, __m128 r)
+{
+   union { __m128 m; float f[4]; } u;
+   u.m = r;
+
+   debug_printf(%s: 
+%f/
+%f/
+%f/
+%f\n,
+name,
+u.f[0],  u.f[1],  u.f[2],  u.f[3]);
+}
+
+ 
+#endif
+#endif

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: try to keep plane c values small

2010-10-12 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 9773722c2b09d5f0615a47cecf4347859474dc56
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9773722c2b09d5f0615a47cecf4347859474dc56

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Oct 12 11:02:19 2010 +0100

llvmpipe: try to keep plane c values small

Avoid accumulating more and more fixed point bits.

---

 src/gallium/drivers/llvmpipe/lp_setup_line.c |3 +-
 src/gallium/drivers/llvmpipe/lp_setup_tri.c  |   38 +++--
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup_line.c 
b/src/gallium/drivers/llvmpipe/lp_setup_line.c
index 693ac28..c940860 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_line.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_line.c
@@ -640,8 +640,7 @@ try_setup_line( struct lp_setup_context *setup,
  }
   }
 
-  plane-dcdx *= FIXED_ONE;
-  plane-dcdy *= FIXED_ONE;
+  plane-c = (plane-c + (FIXED_ONE-1)) / FIXED_ONE;
 
   /* find trivial reject offsets for each edge for a single-pixel
* sized block.  These will be scaled up at each recursive level to
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c 
b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index 8fd0346..dfe1bd1 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -343,26 +343,34 @@ do_triangle_ccw(struct lp_setup_context *setup,
* Also, sometimes (in FBO cases) GL will render upside down
* to its usual method, in which case it will probably want
* to use the opposite, top-left convention.
+   *
+   * XXX: Chances are this will get stripped away.  In fact this
+   * is only meaningful if:
+   *
+   *  (plane-c  (FIXED_ONE-1)) == 0
+   *
*/ 
-  if (plane-dcdx  0) {
- /* both fill conventions want this - adjust for left edges */
- plane-c++;
-  }
-  else if (plane-dcdx == 0) {
- if (setup-pixel_offset == 0) {
-/* correct for top-left fill convention:
- */
-if (plane-dcdy  0) plane-c++;
+  if ((plane-c  (FIXED_ONE-1)) == 0) {
+ if (plane-dcdx  0) {
+/* both fill conventions want this - adjust for left edges */
+plane-c++;
  }
- else {
-/* correct for bottom-left fill convention:
- */
-if (plane-dcdy  0) plane-c++;
+ else if (plane-dcdx == 0) {
+if (setup-pixel_offset == 0) {
+   /* correct for top-left fill convention:
+*/
+   if (plane-dcdy  0) plane-c++;
+}
+else {
+   /* correct for bottom-left fill convention:
+*/
+   if (plane-dcdy  0) plane-c++;
+}
  }
   }
 
-  plane-dcdx *= FIXED_ONE;
-  plane-dcdy *= FIXED_ONE;
+  plane-c = (plane-c + (FIXED_ONE-1)) / FIXED_ONE;
+
 
   /* find trivial reject offsets for each edge for a single-pixel
* sized block.  These will be scaled up at each recursive level to

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: fix typo in last commit

2010-10-12 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: b4277bc5843aca7f9e0ecc7e956733f1becd6ad6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4277bc5843aca7f9e0ecc7e956733f1becd6ad6

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Oct 12 11:51:28 2010 +0100

llvmpipe: fix typo in last commit

---

 src/gallium/drivers/llvmpipe/lp_rast_tri.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c 
b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
index 7a6cbb8..854fd5c 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
@@ -491,8 +491,8 @@ lp_rast_triangle_3_4(struct lp_rasterizer_task *task,
 */
dcdx = _mm_sub_epi32(zero, dcdx);
 
-   c = _mm_add_epi32(c, _mm_mullo_epi32(dcdx, _mm_set1_epi32(x)));
-   c = _mm_add_epi32(c, _mm_mullo_epi32(dcdy, _mm_set1_epi32(y)));
+   c = _mm_add_epi32(c, mm_mullo_epi32(dcdx, _mm_set1_epi32(x)));
+   c = _mm_add_epi32(c, mm_mullo_epi32(dcdy, _mm_set1_epi32(y)));
 
dcdx2 = _mm_add_epi32(dcdx, dcdx);
dcdx3 = _mm_add_epi32(dcdx2, dcdx);

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): r600g: add missing file to sconscript

2010-10-12 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: d0eb854f58ffb7d01fb37c0939078d8d117e7386
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d0eb854f58ffb7d01fb37c0939078d8d117e7386

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Oct  5 23:15:44 2010 +0100

r600g: add missing file to sconscript

---

 src/gallium/drivers/r600/SConscript |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/r600/SConscript 
b/src/gallium/drivers/r600/SConscript
index b6d9b7d..bf0ad85 100644
--- a/src/gallium/drivers/r600/SConscript
+++ b/src/gallium/drivers/r600/SConscript
@@ -18,6 +18,7 @@ r600 = env.ConvenienceLibrary(
 source = [
 'r600_asm.c',
 'r600_buffer.c',
+'r600_blit.c',
 'r600_helper.c',
 'r600_pipe.c',
 'r600_query.c',

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): Revert llvmpipe: try to keep plane c values small

2010-10-12 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 0ca0382d1bfd1e9128fa4b588ce1411f7b8a85df
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ca0382d1bfd1e9128fa4b588ce1411f7b8a85df

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Oct 12 13:20:39 2010 +0100

Revert llvmpipe: try to keep plane c values small

This reverts commit 9773722c2b09d5f0615a47cecf4347859474dc56.

Looks like there are some floor/rounding issues here that need
to be better understood.

---

 src/gallium/drivers/llvmpipe/lp_setup_line.c |3 +-
 src/gallium/drivers/llvmpipe/lp_setup_tri.c  |   38 ++---
 2 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup_line.c 
b/src/gallium/drivers/llvmpipe/lp_setup_line.c
index c940860..693ac28 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_line.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_line.c
@@ -640,7 +640,8 @@ try_setup_line( struct lp_setup_context *setup,
  }
   }
 
-  plane-c = (plane-c + (FIXED_ONE-1)) / FIXED_ONE;
+  plane-dcdx *= FIXED_ONE;
+  plane-dcdy *= FIXED_ONE;
 
   /* find trivial reject offsets for each edge for a single-pixel
* sized block.  These will be scaled up at each recursive level to
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c 
b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index dfe1bd1..8fd0346 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -343,34 +343,26 @@ do_triangle_ccw(struct lp_setup_context *setup,
* Also, sometimes (in FBO cases) GL will render upside down
* to its usual method, in which case it will probably want
* to use the opposite, top-left convention.
-   *
-   * XXX: Chances are this will get stripped away.  In fact this
-   * is only meaningful if:
-   *
-   *  (plane-c  (FIXED_ONE-1)) == 0
-   *
*/ 
-  if ((plane-c  (FIXED_ONE-1)) == 0) {
- if (plane-dcdx  0) {
-/* both fill conventions want this - adjust for left edges */
-plane-c++;
+  if (plane-dcdx  0) {
+ /* both fill conventions want this - adjust for left edges */
+ plane-c++;
+  }
+  else if (plane-dcdx == 0) {
+ if (setup-pixel_offset == 0) {
+/* correct for top-left fill convention:
+ */
+if (plane-dcdy  0) plane-c++;
  }
- else if (plane-dcdx == 0) {
-if (setup-pixel_offset == 0) {
-   /* correct for top-left fill convention:
-*/
-   if (plane-dcdy  0) plane-c++;
-}
-else {
-   /* correct for bottom-left fill convention:
-*/
-   if (plane-dcdy  0) plane-c++;
-}
+ else {
+/* correct for bottom-left fill convention:
+ */
+if (plane-dcdy  0) plane-c++;
  }
   }
 
-  plane-c = (plane-c + (FIXED_ONE-1)) / FIXED_ONE;
-
+  plane-dcdx *= FIXED_ONE;
+  plane-dcdy *= FIXED_ONE;
 
   /* find trivial reject offsets for each edge for a single-pixel
* sized block.  These will be scaled up at each recursive level to

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


RE: Mesa (master): llvmpipe: try to do more of rast_tri_3_16 with intrinsics

2010-10-12 Thread Keith Whitwell
Cool.  Isosurf is a good benchmark for these rasterization functions.

I found one reason why main is slower than master.  Master has this commit:



Author: Keith Whitwell kei...@vmware.com  2010-09-12 14:29:00
Committer: Keith Whitwell kei...@vmware.com  2010-10-11 23:43:53
Parent: 5d9de332bfef20c2e8b8942980f3e085915df251 (llvmpipe: add debug helpers 
for epi32 etc)
Child:  309d7bb01bdc306bd4f1964768e78f5479deb5ab (llvmpipe: remove 
perspective-divide-per-quad code)
Branch: main
Follows: mesa-7.8.1
Precedes: 

llvmpipe: fix wierd performance regression in isosurf

I really don't understand the mechanism behind this, but it
seems like the way data blocks for a scene are malloced, and in
particular whether we treat them as stack or a queue, and whether
we retain the most recently allocated or least recently allocated
has a real affect (~5%) on isosurf framerates...

This is probably specific to my distro or even just my machine,
but none the less, it's nicer not to see the framerates go in the
wrong direction.



which fixed a problem I thought didn't exist on main - turns out it does.

The problem as such is that although malloc/free are very fast, brk() and 
mmap() are not fast at all, and unfortunately it's hard to predict whether 
malloc() will end up calling brk() or not.  The fix above just removes a few 
mallocs  gets better behaviour out of the linux malloc implementation.  
Without this, we're doing a brk() every scene, it seems, which is responsible 
for (some of) the slowdown.

All of this is linux-specific  may not be relevant on more complex demos, but 
it is fairly interesting.

Keith





From: José Fonseca [jfons...@vmware.com]
Sent: Tuesday, October 12, 2010 1:57 PM
To: Keith Whitwell
Cc: mesa-commit@lists.freedesktop.org
Subject: Re: Mesa (master): llvmpipe: try to do more of rast_tri_3_16 with 
intrinsics

 +   __m128i b4a4_mask   = _mm_and_si128(b4a4, mask);
 +   __m128i b4a4_mask_shift = _mm_slli_si128(b4a4_mask, 4);

I think you could replace these two calls with _mm_slli_epi64(b4a4_mask,
32)

I also think you should replace the two _mm_sril_si128 above with
_mm_srli_epi64, as  _mm_sril_si128 could be up to 4x slower, according
to Intel's intrinsic guide.

There's a patch attached that does this, but I'm not sure how to
benchmark such a tiny optimization.

 +   __m128i result  = _mm_or_si128(ba_mask, b4a4_mask_shift);
 +#endif
 +
 +   return result;
 +}

Jose
___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llmvpipe: improve mm_mullo_epi32

2010-10-12 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: e3ec0fdd546259005c9ed2bf7b05cead2ab95b43
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e3ec0fdd546259005c9ed2bf7b05cead2ab95b43

Author: José Fonseca jfons...@vmware.com
Date:   Tue Oct 12 14:15:59 2010 +0100

llmvpipe: improve mm_mullo_epi32

Apply Jose's suggestions for a small but measurable improvement in
isosurf.

---

 src/gallium/drivers/llvmpipe/lp_rast_tri.c |7 +++
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c 
b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
index 19b0bd6..c3eefb7 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
@@ -321,8 +321,8 @@ transpose4_epi32(const __m128i * restrict a,
  */
 static INLINE __m128i mm_mullo_epi32(const __m128i a, const __m128i b)
 {
-   __m128i a4   = _mm_srli_si128(a, 4);  /* shift by one dword */
-   __m128i b4   = _mm_srli_si128(b, 4);  /* shift by one dword */
+   __m128i a4   = _mm_srli_epi64(a, 32);  /* shift by one dword */
+   __m128i b4   = _mm_srli_epi64(b, 32);  /* shift by one dword */
__m128i ba   = _mm_mul_epu32(b, a);   /* multply dwords 0, 2 */
__m128i b4a4 = _mm_mul_epu32(b4, a4); /* multiply dwords 1, 3 */
 
@@ -336,8 +336,7 @@ static INLINE __m128i mm_mullo_epi32(const __m128i a, const 
__m128i b)
 #else
__m128i mask= _mm_setr_epi32(~0,0,~0,0);
__m128i ba_mask = _mm_and_si128(ba, mask);
-   __m128i b4a4_mask   = _mm_and_si128(b4a4, mask);
-   __m128i b4a4_mask_shift = _mm_slli_si128(b4a4_mask, 4);
+   __m128i b4a4_mask_shift = _mm_slli_epi64(b4a4, 32);
__m128i result  = _mm_or_si128(ba_mask, b4a4_mask_shift);
 #endif
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: make sure intrinsics code is guarded with PIPE_ARCH_SSE

2010-10-12 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 7533c374570b333b5e0d626d36d18c41d4611cb5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7533c374570b333b5e0d626d36d18c41d4611cb5

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Oct 12 18:26:41 2010 +0100

llvmpipe: make sure intrinsics code is guarded with PIPE_ARCH_SSE

---

 src/gallium/drivers/llvmpipe/lp_rast_tri.c |   82 ++--
 1 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c 
b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
index c3eefb7..bae772b 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
@@ -239,46 +239,6 @@ sign_bits4(const __m128i *cstep, int cdiff)
return _mm_movemask_epi8(result);
 }
 
-#endif
-
-
-
-
-#define TAG(x) x##_1
-#define NR_PLANES 1
-#include lp_rast_tri_tmp.h
-
-#define TAG(x) x##_2
-#define NR_PLANES 2
-#include lp_rast_tri_tmp.h
-
-#define TAG(x) x##_3
-#define NR_PLANES 3
-/*#define TRI_4 lp_rast_triangle_3_4*/
-/*#define TRI_16 lp_rast_triangle_3_16*/
-#include lp_rast_tri_tmp.h
-
-#define TAG(x) x##_4
-#define NR_PLANES 4
-#define TRI_16 lp_rast_triangle_4_16
-#include lp_rast_tri_tmp.h
-
-#define TAG(x) x##_5
-#define NR_PLANES 5
-#include lp_rast_tri_tmp.h
-
-#define TAG(x) x##_6
-#define NR_PLANES 6
-#include lp_rast_tri_tmp.h
-
-#define TAG(x) x##_7
-#define NR_PLANES 7
-#include lp_rast_tri_tmp.h
-
-#define TAG(x) x##_8
-#define NR_PLANES 8
-#include lp_rast_tri_tmp.h
-
 
 static INLINE void
 transpose4_epi32(const __m128i * restrict a,
@@ -537,3 +497,45 @@ lp_rast_triangle_3_4(struct lp_rasterizer_task *task,
   0x  ~mask);
}
 }
+
+#undef NR_PLANES
+#endif
+
+
+
+
+#define TAG(x) x##_1
+#define NR_PLANES 1
+#include lp_rast_tri_tmp.h
+
+#define TAG(x) x##_2
+#define NR_PLANES 2
+#include lp_rast_tri_tmp.h
+
+#define TAG(x) x##_3
+#define NR_PLANES 3
+/*#define TRI_4 lp_rast_triangle_3_4*/
+/*#define TRI_16 lp_rast_triangle_3_16*/
+#include lp_rast_tri_tmp.h
+
+#define TAG(x) x##_4
+#define NR_PLANES 4
+#define TRI_16 lp_rast_triangle_4_16
+#include lp_rast_tri_tmp.h
+
+#define TAG(x) x##_5
+#define NR_PLANES 5
+#include lp_rast_tri_tmp.h
+
+#define TAG(x) x##_6
+#define NR_PLANES 6
+#include lp_rast_tri_tmp.h
+
+#define TAG(x) x##_7
+#define NR_PLANES 7
+#include lp_rast_tri_tmp.h
+
+#define TAG(x) x##_8
+#define NR_PLANES 8
+#include lp_rast_tri_tmp.h
+

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (llvm-cliptest-viewport): draw: some changes to allow for runtime changes to userclip planes

2010-10-10 Thread Keith Whitwell
Module: Mesa
Branch: llvm-cliptest-viewport
Commit: 08f890d4c3b8376d1840f90474f7c56329432d95
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=08f890d4c3b8376d1840f90474f7c56329432d95

Author: delphi tayhuiqi...@gmail.com
Date:   Sun Oct 10 00:31:16 2010 +0100

draw: some changes to allow for runtime changes to userclip planes

---

 src/gallium/auxiliary/draw/draw_context.c  |1 +
 src/gallium/auxiliary/draw/draw_llvm.c |   70 +++-
 src/gallium/auxiliary/draw/draw_llvm.h |   10 ++-
 src/gallium/auxiliary/draw/draw_private.h  |3 +
 .../draw/draw_pt_fetch_shade_pipeline_llvm.c   |3 +
 5 files changed, 67 insertions(+), 20 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_context.c 
b/src/gallium/auxiliary/draw/draw_context.c
index b07de76..c52234d 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -335,6 +335,7 @@ draw_set_mapped_constant_buffer(struct draw_context *draw,
case PIPE_SHADER_VERTEX:
   draw-pt.user.vs_constants[slot] = buffer;
   draw-pt.user.vs_constants_size[slot] = size;
+  draw-pt.user.planes = (float (*) [12][4]) (draw-plane[0]);
   draw_vs_set_constants(draw, slot, buffer, size);
   break;
case PIPE_SHADER_GEOMETRY:
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 9c17e77..5f11b82 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -130,12 +130,13 @@ init_globals(struct draw_llvm *llvm)
 
/* struct draw_jit_context */
{
-  LLVMTypeRef elem_types[3];
+  LLVMTypeRef elem_types[4];
   LLVMTypeRef context_type;
 
   elem_types[0] = LLVMPointerType(LLVMFloatType(), 0); /* vs_constants */
-  elem_types[1] = LLVMPointerType(LLVMFloatType(), 0); /* vs_constants */
-  elem_types[2] = LLVMArrayType(texture_type,
+  elem_types[1] = LLVMPointerType(LLVMFloatType(), 0); /* gs_constants */
+  elem_types[2] = 
LLVMPointerType(LLVMArrayType(LLVMArrayType(LLVMFloatType(), 4), 12), 0); /* 
planes */
+  elem_types[3] = LLVMArrayType(texture_type,
 PIPE_MAX_VERTEX_SAMPLERS); /* textures */
 
   context_type = LLVMStructType(elem_types, Elements(elem_types), 0);
@@ -144,6 +145,8 @@ init_globals(struct draw_llvm *llvm)
  llvm-target, context_type, 0);
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, gs_constants,
  llvm-target, context_type, 1);
+  LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, planes,
+ llvm-target, context_type, 2);
   LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, textures,
  llvm-target, context_type,
  DRAW_JIT_CTX_TEXTURES);
@@ -817,6 +820,23 @@ generate_viewport(struct draw_llvm *llvm,

 }
 
+/* Equivalent of _mm_set1_ps(a)
+ */
+static LLVMValueRef vec4f_from_scalar(LLVMBuilderRef bld,
+ LLVMValueRef a,
+ const char *name)
+{
+   LLVMValueRef res = LLVMGetUndef(LLVMVectorType(LLVMFloatType(), 4));
+   int i;
+
+   for(i = 0; i  4; ++i) {
+  LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
+  res = LLVMBuildInsertElement(bld, res, a, index, i == 3 ? name : );
+   }
+
+   return res;
+}
+
 /*
  * Returns clipmask as 4xi32 bitmask for the 4 vertices
  */
@@ -827,17 +847,16 @@ generate_clipmask(LLVMBuilderRef builder,
   boolean clip_z,
   boolean clip_user,
   boolean enable_d3dclipping,
-  struct draw_llvm *llvm)
+  unsigned nr,
+  LLVMValueRef context_ptr)
 {
LLVMValueRef mask; /* stores the 4xi32 clipmasks */ 
LLVMValueRef test, temp; 
LLVMValueRef zero, shift;
LLVMValueRef pos_x, pos_y, pos_z, pos_w;
-   LLVMValueRef planes, sum;
+   LLVMValueRef plane1, planes, plane_ptr, sum;
 
-   unsigned nr;
unsigned i;
-   float (*plane)[4];
 
struct lp_type f32_type = lp_type_float_vec(32); 
 
@@ -903,22 +922,38 @@ generate_clipmask(LLVMBuilderRef builder,
}   
 
if (clip_user){
+  LLVMValueRef planes_ptr = draw_jit_context_planes(builder, context_ptr);
+  LLVMValueRef indices[3];
+
   /* userclip planes */
-  nr = llvm-draw-nr_planes;
-  plane = llvm-draw-plane;
   for (i = 6; i  nr; i++) {
- planes = lp_build_const_vec(f32_type, plane[i][0]);
+ indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
+ indices[1] = LLVMConstInt(LLVMInt32Type(), i, 0);
+
+ indices[2] = LLVMConstInt(LLVMInt32Type(), 0, 0);
+ plane_ptr = LLVMBuildGEP(builder, planes_ptr, indices, 3, );
+ plane1 = LLVMBuildLoad(builder, plane_ptr, plane_x);
+ planes = vec4f_from_scalar(builder, plane1, plane4_x);
  sum = 

Mesa (master): llvmpipe: defer attribute interpolation until after mask and ztest

2010-10-09 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 8009886b0092df2783472deaac1bcaad4a802c19
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8009886b0092df2783472deaac1bcaad4a802c19

Author: Keith Whitwell kei...@vmware.com
Date:   Wed Oct  6 22:25:48 2010 +0100

llvmpipe: defer attribute interpolation until after mask and ztest

Don't calculate 1/w for quads which aren't visible...

---

 src/gallium/drivers/llvmpipe/lp_bld_interp.c |   25 ++---
 src/gallium/drivers/llvmpipe/lp_bld_interp.h |6 +-
 src/gallium/drivers/llvmpipe/lp_state_fs.c   |   17 +++--
 3 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.c 
b/src/gallium/drivers/llvmpipe/lp_bld_interp.c
index ee92ce3..c9da890 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_interp.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.c
@@ -272,7 +272,10 @@ coeffs_init(struct lp_build_interp_soa_context *bld,
  * This is called when we move from one quad to the next.
  */
 static void
-attribs_update(struct lp_build_interp_soa_context *bld, int quad_index)
+attribs_update(struct lp_build_interp_soa_context *bld,
+   int quad_index,
+   int start,
+   int end)
 {
struct lp_build_context *coeff_bld = bld-coeff_bld;
LLVMValueRef shuffle = lp_build_const_int_vec(coeff_bld-type, quad_index);
@@ -282,7 +285,7 @@ attribs_update(struct lp_build_interp_soa_context *bld, int 
quad_index)
 
assert(quad_index  4);
 
-   for(attrib = 0; attrib  bld-num_attribs; ++attrib) {
+   for(attrib = start; attrib  end; ++attrib) {
   const unsigned mask = bld-mask[attrib];
   const unsigned interp = bld-interp[attrib];
   for(chan = 0; chan  NUM_CHANNELS; ++chan) {
@@ -442,8 +445,6 @@ lp_build_interp_soa_init(struct lp_build_interp_soa_context 
*bld,
pos_init(bld, x0, y0);
 
coeffs_init(bld, a0_ptr, dadx_ptr, dady_ptr);
-
-   attribs_update(bld, 0);
 }
 
 
@@ -451,10 +452,20 @@ lp_build_interp_soa_init(struct 
lp_build_interp_soa_context *bld,
  * Advance the position and inputs to the given quad within the block.
  */
 void
-lp_build_interp_soa_update(struct lp_build_interp_soa_context *bld,
-   int quad_index)
+lp_build_interp_soa_update_inputs(struct lp_build_interp_soa_context *bld,
+  int quad_index)
+{
+   assert(quad_index  4);
+
+   attribs_update(bld, quad_index, 1, bld-num_attribs);
+}
+
+void
+lp_build_interp_soa_update_pos(struct lp_build_interp_soa_context *bld,
+  int quad_index)
 {
assert(quad_index  4);
 
-   attribs_update(bld, quad_index);
+   attribs_update(bld, quad_index, 0, 1);
 }
+
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.h 
b/src/gallium/drivers/llvmpipe/lp_bld_interp.h
index 3054030..6588f7f 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_interp.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.h
@@ -89,7 +89,11 @@ lp_build_interp_soa_init(struct lp_build_interp_soa_context 
*bld,
  LLVMValueRef y);
 
 void
-lp_build_interp_soa_update(struct lp_build_interp_soa_context *bld,
+lp_build_interp_soa_update_inputs(struct lp_build_interp_soa_context *bld,
+   int quad_index);
+
+void
+lp_build_interp_soa_update_pos(struct lp_build_interp_soa_context *bld,
int quad_index);
 
 
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 3ce8be5..0530c61 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -262,7 +262,7 @@ generate_fs(struct llvmpipe_context *lp,
 struct lp_type type,
 LLVMValueRef context_ptr,
 unsigned i,
-const struct lp_build_interp_soa_context *interp,
+struct lp_build_interp_soa_context *interp,
 struct lp_build_sampler_soa *sampler,
 LLVMValueRef *pmask,
 LLVMValueRef (*color)[4],
@@ -276,7 +276,7 @@ generate_fs(struct llvmpipe_context *lp,
LLVMTypeRef vec_type;
LLVMValueRef consts_ptr;
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS];
-   LLVMValueRef z = interp-pos[2];
+   LLVMValueRef z;
LLVMValueRef stencil_refs[2];
struct lp_build_flow_context *flow;
struct lp_build_mask_context mask;
@@ -307,7 +307,6 @@ generate_fs(struct llvmpipe_context *lp,
 lp_build_flow_scope_declare(flow, color[cbuf][chan]);
   }
}
-   lp_build_flow_scope_declare(flow, z);
 
/* do triangle edge testing */
if (partial_mask) {
@@ -321,6 +320,13 @@ generate_fs(struct llvmpipe_context *lp,
/* 'mask' will control execution based on quad's pixel alive/killed state */
lp_build_mask_begin(mask, flow, type, *pmask);
 
+   lp_build_interp_soa_update_pos(interp, i);
+
+   /* Try to avoid the 1/w for quads where mask is zero.  TODO: avoid
+* this for depth-fail quads also

Mesa (master): llvmpipe: use alloca for fs color outputs

2010-10-09 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 40d7be52619fbff2479dcdf56929e3e0c5b12e72
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=40d7be52619fbff2479dcdf56929e3e0c5b12e72

Author: Keith Whitwell kei...@vmware.com
Date:   Thu Oct  7 18:59:54 2010 +0100

llvmpipe: use alloca for fs color outputs

Don't try to emit our own phi's, let llvm mem2reg do it for us.

---

 src/gallium/drivers/llvmpipe/lp_state_fs.c |   16 
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 0530c61..f75ae28 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -303,8 +303,7 @@ generate_fs(struct llvmpipe_context *lp,
/* Declare the color and z variables */
for(cbuf = 0; cbuf  key-nr_cbufs; cbuf++) {
   for(chan = 0; chan  NUM_CHANNELS; ++chan) {
-color[cbuf][chan] = LLVMGetUndef(vec_type);
-lp_build_flow_scope_declare(flow, color[cbuf][chan]);
+color[cbuf][chan] = lp_build_alloca(builder, vec_type, color);
   }
}
 
@@ -369,7 +368,7 @@ generate_fs(struct llvmpipe_context *lp,
  mask, alpha, alpha_ref_value);
   }
 
- color[cbuf][chan] = out;
+  LLVMBuildStore(builder, out, color[cbuf][chan]);
   break;
}
 
@@ -665,9 +664,18 @@ generate_fragment(struct llvmpipe_context *lp,
* Convert the fs's output color and mask to fit to the blending type. 
*/
   for(chan = 0; chan  NUM_CHANNELS; ++chan) {
+ LLVMValueRef fs_color_vals[LP_MAX_VECTOR_LENGTH];
+ 
+ for (i = 0; i  num_fs; i++) {
+fs_color_vals[i] =
+   LLVMBuildLoad(builder, fs_out_color[cbuf][chan][i], 
fs_color_vals);
+ }
+
 lp_build_conv(builder, fs_type, blend_type,
-  fs_out_color[cbuf][chan], num_fs,
+   fs_color_vals,
+   num_fs,
   blend_in_color[chan], 1);
+
 lp_build_name(blend_in_color[chan], color%d.%c, cbuf, rgba[chan]);
   }
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: dump fragment shader ir and asm when LP_DEBUG=fs

2010-10-09 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 954965366fee3fa2eec8a11b6663d4cf218e1d5d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=954965366fee3fa2eec8a11b6663d4cf218e1d5d

Author: Keith Whitwell kei...@vmware.com
Date:   Thu Oct  7 19:01:12 2010 +0100

llvmpipe: dump fragment shader ir and asm when LP_DEBUG=fs

Better than GALLIVM_DEBUG if you're only interested in fragment shaders.

---

 src/gallium/drivers/llvmpipe/lp_state_fs.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index f75ae28..07b4f74 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -730,7 +730,7 @@ generate_fragment(struct llvmpipe_context *lp,
/* Apply optimizations to LLVM IR */
LLVMRunFunctionPassManager(screen-pass, function);
 
-   if (gallivm_debug  GALLIVM_DEBUG_IR) {
+   if ((gallivm_debug  GALLIVM_DEBUG_IR) || (LP_DEBUG  DEBUG_FS)) {
   /* Print the LLVM IR to stderr */
   lp_debug_dump_value(function);
   debug_printf(\n);
@@ -744,7 +744,7 @@ generate_fragment(struct llvmpipe_context *lp,
 
   variant-jit_function[partial_mask] = 
(lp_jit_frag_func)pointer_to_func(f);
 
-  if (gallivm_debug  GALLIVM_DEBUG_ASM) {
+  if ((gallivm_debug  GALLIVM_DEBUG_ASM) || (LP_DEBUG  DEBUG_FS)) {
  lp_disassemble(f);
   }
   lp_func_delete_body(function);

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: store zero into all alloca'd values

2010-10-09 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 6da29f36111edc821a4aa10128e9681fc75a43d7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6da29f36111edc821a4aa10128e9681fc75a43d7

Author: Keith Whitwell kei...@vmware.com
Date:   Thu Oct  7 19:49:20 2010 +0100

llvmpipe: store zero into all alloca'd values

Fixes slowdown in isosurf with earlier versions of llvm.

---

 src/gallium/auxiliary/gallivm/lp_bld_flow.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.c 
b/src/gallium/auxiliary/gallivm/lp_bld_flow.c
index 5bc9c74..cd5fbc2 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_flow.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.c
@@ -830,6 +830,7 @@ lp_build_alloca(LLVMBuilderRef builder,
}
 
res = LLVMBuildAlloca(first_builder, type, name);
+   LLVMBuildStore(builder, LLVMConstNull(type), res);
 
LLVMDisposeBuilder(first_builder);
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): gallivm: specialized x8z24 depthtest path

2010-10-09 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: d2cf757f44f4ee5554243f3279483a25886d9927
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d2cf757f44f4ee5554243f3279483a25886d9927

Author: Keith Whitwell kei...@vmware.com
Date:   Wed Oct  6 18:21:56 2010 +0100

gallivm: specialized x8z24 depthtest path

Avoid unnecessary masking of non-existant stencil component.

---

 src/gallium/drivers/llvmpipe/lp_bld_depth.c |   95 ++-
 src/gallium/drivers/llvmpipe/lp_state_fs.c  |   30 +
 2 files changed, 94 insertions(+), 31 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c 
b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
index 7eabe05..09b82fb 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
@@ -71,6 +71,7 @@
 #include gallivm/lp_bld_arit.h
 #include gallivm/lp_bld_bitarit.h
 #include gallivm/lp_bld_const.h
+#include gallivm/lp_bld_conv.h
 #include gallivm/lp_bld_logic.h
 #include gallivm/lp_bld_flow.h
 #include gallivm/lp_bld_intr.h
@@ -446,7 +447,7 @@ lp_build_occlusion_count(LLVMBuilderRef builder,
  * \param format_desc  description of the depth/stencil surface
  * \param mask  the alive/dead pixel mask for the quad (vector)
  * \param stencil_refs  the front/back stencil ref values (scalar)
- * \param z_src  the incoming depth/stencil values (a 2x2 quad)
+ * \param z_src  the incoming depth/stencil values (a 2x2 quad, float32)
  * \param zs_dst_ptr  pointer to depth/stencil values in framebuffer
  * \param facing  contains float value indicating front/back facing polygon
  */
@@ -454,7 +455,7 @@ void
 lp_build_depth_stencil_test(LLVMBuilderRef builder,
 const struct pipe_depth_state *depth,
 const struct pipe_stencil_state stencil[2],
-struct lp_type type,
+struct lp_type z_src_type,
 const struct util_format_description *format_desc,
 struct lp_build_mask_context *mask,
 LLVMValueRef stencil_refs[2],
@@ -463,6 +464,7 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
 LLVMValueRef face,
 LLVMValueRef counter)
 {
+   struct lp_type type;
struct lp_build_context bld;
struct lp_build_context sbld;
struct lp_type s_type;
@@ -473,6 +475,95 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
LLVMValueRef orig_mask = mask-value;
LLVMValueRef front_facing = NULL;
 
+   /* Prototype a simpler path:
+*/
+   if (z_src_type.floating 
+   format_desc-format == PIPE_FORMAT_X8Z24_UNORM 
+   depth-enabled) 
+   {
+  LLVMValueRef zscaled;
+  LLVMValueRef const_ff_float;
+  LLVMValueRef const_8_int;
+  LLVMTypeRef int32_vec_type;
+
+  /* We know the values in z_dst are all = 0, so allow
+   * lp_build_compare to use signed compare intrinsics:
+   */
+  type.floating = 0;
+  type.fixed = 0;
+  type.sign = 1;
+  type.norm = 1;
+  type.width = 32;
+  type.length = z_src_type.length;
+
+  int32_vec_type = LLVMVectorType(LLVMInt32Type(), z_src_type.length);
+
+  const_8_int = lp_build_const_int_vec(type, 8);
+  const_ff_float = lp_build_const_vec(z_src_type, (float)0xff);
+
+  zscaled = LLVMBuildFMul(builder, z_src, const_ff_float, zscaled);
+  z_src = LLVMBuildFPToSI(builder, zscaled, int32_vec_type, z_src);
+  
+  /* Load current z/stencil value from z/stencil buffer */
+  z_dst = LLVMBuildLoad(builder, zs_dst_ptr, zsbufval);
+  z_dst = LLVMBuildLShr(builder, z_dst, const_8_int, z_dst);
+
+  /* compare src Z to dst Z, returning 'pass' mask */
+  z_pass = lp_build_compare(builder,
+type,
+depth-func, z_src, z_dst);
+
+  lp_build_mask_update(mask, z_pass);
+
+  /* No need to worry about old stencil contents, just blend the
+   * old and new values and shift into the correct position for
+   * storage.
+   */
+  if (depth-writemask) {
+ type.sign = 0;
+ lp_build_context_init(bld, builder, type);
+
+ z_dst = lp_build_select(bld, mask-value, z_src, z_dst);
+ z_dst = LLVMBuildShl(builder, z_dst, const_8_int, z_dst);
+ LLVMBuildStore(builder, z_dst, zs_dst_ptr);
+  }
+
+  if (counter)
+ lp_build_occlusion_count(builder, type, mask-value, counter);
+
+  return;
+   }
+
+   /*
+* Depths are expected to be between 0 and 1, even if they are stored in
+* floats. Setting these bits here will ensure that the lp_build_conv() call
+* below won't try to unnecessarily clamp the incoming values.
+*/
+   if(z_src_type.floating) {
+  z_src_type.sign = FALSE;
+  z_src_type.norm = TRUE;
+   }
+   else {
+  assert(!z_src_type.sign);
+  assert(z_src_type.norm

Mesa (master): gallivm: prefer blendvb for integer arguments

2010-10-09 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: c79f162367b99d9438bd1589ecfdeba69baa9d3d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c79f162367b99d9438bd1589ecfdeba69baa9d3d

Author: Keith Whitwell kei...@vmware.com
Date:   Wed Oct  6 19:10:30 2010 +0100

gallivm: prefer blendvb for integer arguments

---

 src/gallium/auxiliary/gallivm/lp_bld_logic.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c 
b/src/gallium/auxiliary/gallivm/lp_bld_logic.c
index ce5d021..026b60a 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c
@@ -462,10 +462,12 @@ lp_build_select(struct lp_build_context *bld,
   LLVMTypeRef arg_type;
   LLVMValueRef args[3];
 
-  if (type.width == 64) {
+  if (type.floating 
+  type.width == 64) {
  intrinsic = llvm.x86.sse41.blendvpd;
  arg_type = LLVMVectorType(LLVMDoubleType(), 2);
-  } else if (type.width == 32) {
+  } else if (type.floating 
+ type.width == 32) {
  intrinsic = llvm.x86.sse41.blendvps;
  arg_type = LLVMVectorType(LLVMFloatType(), 4);
   } else {

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): gallivm: simpler uint8-float conversions

2010-10-09 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 2ef6f75ab410bb188e028024e18891d7877febad
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ef6f75ab410bb188e028024e18891d7877febad

Author: Keith Whitwell kei...@vmware.com
Date:   Wed Oct  6 19:09:03 2010 +0100

gallivm: simpler uint8-float conversions

LLVM seems to finds it easier to reason about these than our
mantissa-manipulation code.

---

 src/gallium/auxiliary/gallivm/lp_bld_conv.c |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c 
b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
index 3abb192..20aa257 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
@@ -178,6 +178,16 @@ lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
 
assert(dst_type.floating);
 
+   /* Special-case int8-float, though most cases could be handled
+* this way:
+*/
+   if (src_width == 8) {
+  scale = 1.0/255.0;
+  res = LLVMBuildSIToFP(builder, src, vec_type, );
+  res = LLVMBuildFMul(builder, res, lp_build_const_vec(dst_type, scale), 
);
+  return res;
+   }
+
mantissa = lp_mantissa(dst_type);
 
n = MIN2(mantissa, src_width);

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: try to be sensible about whether to branch after mask updates

2010-10-09 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: aa4cb5e2d8d48c7dcc9653c61a9e25494e3e7b2a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=aa4cb5e2d8d48c7dcc9653c61a9e25494e3e7b2a

Author: Keith Whitwell kei...@vmware.com
Date:   Thu Oct  7 15:01:07 2010 +0100

llvmpipe: try to be sensible about whether to branch after mask updates

Don't branch more than once in quick succession.  Don't branch at the
end of the shader.

---

 src/gallium/auxiliary/gallivm/lp_bld_flow.c |6 +--
 src/gallium/auxiliary/gallivm/lp_bld_flow.h |3 +
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c |   11 +++-
 src/gallium/drivers/llvmpipe/lp_bld_alpha.c |6 ++-
 src/gallium/drivers/llvmpipe/lp_bld_alpha.h |3 +-
 src/gallium/drivers/llvmpipe/lp_bld_depth.c |   14 -
 src/gallium/drivers/llvmpipe/lp_bld_depth.h |3 +-
 src/gallium/drivers/llvmpipe/lp_state_fs.c  |   69 ++
 8 files changed, 80 insertions(+), 35 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.c 
b/src/gallium/auxiliary/gallivm/lp_bld_flow.c
index cd5fbc2..1ec33c7 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_flow.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.c
@@ -450,7 +450,7 @@ lp_build_flow_skip_end(struct lp_build_flow_context *flow)
 /**
  * Check if the mask predicate is zero.  If so, jump to the end of the block.
  */
-static void
+void
 lp_build_mask_check(struct lp_build_mask_context *mask)
 {
LLVMBuilderRef builder = mask-flow-builder;
@@ -490,8 +490,6 @@ lp_build_mask_begin(struct lp_build_mask_context *mask,
lp_build_flow_scope_begin(flow);
lp_build_flow_scope_declare(flow, mask-value);
lp_build_flow_skip_begin(flow);
-
-   lp_build_mask_check(mask);
 }
 
 
@@ -505,8 +503,6 @@ lp_build_mask_update(struct lp_build_mask_context *mask,
  LLVMValueRef value)
 {
mask-value = LLVMBuildAnd( mask-flow-builder, mask-value, value, );
-
-   lp_build_mask_check(mask);
 }
 
 
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.h 
b/src/gallium/auxiliary/gallivm/lp_bld_flow.h
index fffb493..095c781 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_flow.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.h
@@ -94,6 +94,9 @@ void
 lp_build_mask_update(struct lp_build_mask_context *mask,
  LLVMValueRef value);
 
+void
+lp_build_mask_check(struct lp_build_mask_context *mask);
+
 LLVMValueRef
 lp_build_mask_end(struct lp_build_mask_context *mask);
 
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 441aeba..03020a6 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -959,8 +959,13 @@ emit_kil(
   }
}
 
-   if(mask)
+   if(mask) {
   lp_build_mask_update(bld-mask, mask);
+
+  /* XXX: figure out if we are at the end of the shader and skip this:
+   */
+  lp_build_mask_check(bld-mask);
+   }
 }
 
 
@@ -987,6 +992,10 @@ emit_kilp(struct lp_build_tgsi_soa_context *bld,
}
 
lp_build_mask_update(bld-mask, mask);
+
+   /* XXX: figure out if we are at the end of the shader and skip this:
+*/
+   lp_build_mask_check(bld-mask);
 }
 
 static void
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_alpha.c 
b/src/gallium/drivers/llvmpipe/lp_bld_alpha.c
index e28efe7..e506437 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_alpha.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_alpha.c
@@ -48,7 +48,8 @@ lp_build_alpha_test(LLVMBuilderRef builder,
 struct lp_type type,
 struct lp_build_mask_context *mask,
 LLVMValueRef alpha,
-LLVMValueRef ref)
+LLVMValueRef ref,
+boolean do_branch)
 {
struct lp_build_context bld;
LLVMValueRef test;
@@ -60,4 +61,7 @@ lp_build_alpha_test(LLVMBuilderRef builder,
lp_build_name(test, alpha_mask);
 
lp_build_mask_update(mask, test);
+
+   if (do_branch)
+  lp_build_mask_check(mask);
 }
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_alpha.h 
b/src/gallium/drivers/llvmpipe/lp_bld_alpha.h
index 44603b4..27ca8aa 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_alpha.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_alpha.h
@@ -48,7 +48,8 @@ lp_build_alpha_test(LLVMBuilderRef builder,
 struct lp_type type,
 struct lp_build_mask_context *mask,
 LLVMValueRef alpha,
-LLVMValueRef ref);
+LLVMValueRef ref,
+boolean do_branch);
 
 
 #endif /* !LP_BLD_ALPHA_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c 
b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
index 09b82fb..6b8ffb6 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
@@ -462,7 +462,8 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
 LLVMValueRef z_src

Mesa (master): llvmpipe: clean up shader pre/postamble, try to catch more early-z

2010-10-09 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 5b7eb868fde98388d80601d8dea39e679828f42f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b7eb868fde98388d80601d8dea39e679828f42f

Author: Keith Whitwell kei...@vmware.com
Date:   Sat Oct  9 11:28:00 2010 +0100

llvmpipe: clean up shader pre/postamble, try to catch more early-z

Specifically, can do early-depth-test even when alpahtest or
kill-pixel are active, providing we defer the actual z write until the
final mask is avaialable.

Improves demos/fire.c especially in the case where you get close to
the trees.

---

 src/gallium/drivers/llvmpipe/lp_bld_depth.c |   40 -
 src/gallium/drivers/llvmpipe/lp_bld_depth.h |   15 ++-
 src/gallium/drivers/llvmpipe/lp_state_fs.c  |  241 +--
 3 files changed, 193 insertions(+), 103 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c 
b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
index 6b8ffb6..8d9be2e 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
@@ -410,7 +410,7 @@ get_s_shift_and_mask(const struct util_format_description 
*format_desc,
  * \param maskvalue is the depth test mask.
  * \param counter is a pointer of the uint32 counter.
  */
-static void
+void
 lp_build_occlusion_count(LLVMBuilderRef builder,
  struct lp_type type,
  LLVMValueRef maskvalue,
@@ -462,7 +462,7 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
 LLVMValueRef z_src,
 LLVMValueRef zs_dst_ptr,
 LLVMValueRef face,
-LLVMValueRef counter,
+LLVMValueRef *zs_value,
 boolean do_branch)
 {
struct lp_type type;
@@ -524,17 +524,14 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
* storage.
*/
   if (depth-writemask) {
- type.sign = 0;
+ type.sign = 1;
  lp_build_context_init(bld, builder, type);
 
  z_dst = lp_build_select(bld, mask-value, z_src, z_dst);
  z_dst = LLVMBuildShl(builder, z_dst, const_8_int, z_dst);
- LLVMBuildStore(builder, z_dst, zs_dst_ptr);
+ *zs_value = z_dst;
   }
 
-  if (counter)
- lp_build_occlusion_count(builder, type, mask-value, counter);
-
   return;
}
 
@@ -779,7 +776,7 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
   else
  zs_dst = stencil_vals;
 
-  LLVMBuildStore(builder, zs_dst, zs_dst_ptr);
+  *zs_value = zs_dst;
}
 
if (s_pass_mask)
@@ -791,6 +788,29 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
if (do_branch)
   lp_build_mask_check(mask);
 
-   if (counter)
-  lp_build_occlusion_count(builder, type, mask-value, counter);
+}
+
+
+
+void
+lp_build_deferred_depth_write(LLVMBuilderRef builder,
+  struct lp_type z_src_type,
+  const struct util_format_description 
*format_desc,
+  struct lp_build_mask_context *mask,
+  LLVMValueRef zs_dst_ptr,
+  LLVMValueRef zs_value)
+{
+   struct lp_type type;
+   struct lp_build_context bld;
+   LLVMValueRef z_dst;
+
+   /* XXX: pointlessly redo type logic:
+*/
+   type = lp_depth_type(format_desc, z_src_type.width*z_src_type.length);
+   lp_build_context_init(bld, builder, type);
+
+   z_dst = LLVMBuildLoad(builder, zs_dst_ptr, zsbufval);
+   z_dst = lp_build_select(bld, mask-value, zs_value, z_dst);
+
+   LLVMBuildStore(builder, z_dst, zs_dst_ptr);
 }
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.h 
b/src/gallium/drivers/llvmpipe/lp_bld_depth.h
index 2a63bb9..0f89668 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_depth.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.h
@@ -61,8 +61,21 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
 LLVMValueRef zs_src,
 LLVMValueRef zs_dst_ptr,
 LLVMValueRef facing,
-LLVMValueRef counter,
+LLVMValueRef *zs_value,
 boolean do_branch);
 
+void
+lp_build_deferred_depth_write(LLVMBuilderRef builder,
+  struct lp_type z_src_type,
+  const struct util_format_description 
*format_desc,
+  struct lp_build_mask_context *mask,
+  LLVMValueRef zs_dst_ptr,
+  LLVMValueRef zs_value);
+
+void
+lp_build_occlusion_count(LLVMBuilderRef builder,
+ struct lp_type type,
+ LLVMValueRef maskvalue,
+ LLVMValueRef counter);
 
 #endif /* !LP_BLD_DEPTH_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c 
b/src/gallium/drivers/llvmpipe/lp_state_fs.c

Mesa (master): llvmpipe: fail gracefully on oom in scene creation

2010-10-08 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: ad6730fadbbeacea96322e31064ede9ea7ebad6f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ad6730fadbbeacea96322e31064ede9ea7ebad6f

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Oct  8 17:01:16 2010 +0100

llvmpipe: fail gracefully on oom in scene creation

---

 src/gallium/drivers/llvmpipe/lp_setup.c |   97 +--
 src/gallium/drivers/llvmpipe/lp_setup_context.h |6 +-
 src/gallium/drivers/llvmpipe/lp_setup_line.c|5 +-
 src/gallium/drivers/llvmpipe/lp_setup_point.c   |5 +-
 src/gallium/drivers/llvmpipe/lp_setup_tri.c |   15 ++--
 src/gallium/drivers/llvmpipe/lp_setup_vbuf.c|6 +-
 6 files changed, 92 insertions(+), 42 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c 
b/src/gallium/drivers/llvmpipe/lp_setup.c
index e72ead0..e96f012 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -56,7 +56,7 @@
 #include draw/draw_vbuf.h
 
 
-static void set_scene_state( struct lp_setup_context *, enum setup_state,
+static boolean set_scene_state( struct lp_setup_context *, enum setup_state,
  const char *reason);
 static boolean try_update_scene_state( struct lp_setup_context *setup );
 
@@ -167,7 +167,7 @@ lp_setup_rasterize_scene( struct lp_setup_context *setup )
 
 
 
-static void
+static boolean
 begin_binning( struct lp_setup_context *setup )
 {
struct lp_scene *scene = setup-scene;
@@ -181,6 +181,8 @@ begin_binning( struct lp_setup_context *setup )
/* Always create a fence:
 */
scene-fence = lp_fence_create(MAX2(1, setup-num_threads));
+   if (!scene-fence)
+  return FALSE;
 
/* Initialize the bin flags and x/y coords:
 */
@@ -192,7 +194,8 @@ begin_binning( struct lp_setup_context *setup )
}
 
ok = try_update_scene_state(setup);
-   assert(ok);
+   if (!ok)
+  return FALSE;
 
if (setup-fb.zsbuf 
((setup-clear.flags  PIPE_CLEAR_DEPTHSTENCIL) != 
PIPE_CLEAR_DEPTHSTENCIL) 
@@ -208,7 +211,8 @@ begin_binning( struct lp_setup_context *setup )
  ok = lp_scene_bin_everywhere( scene, 
LP_RAST_OP_CLEAR_COLOR, 
setup-clear.color );
- assert(ok);
+ if (!ok)
+return FALSE;
   }
}
 
@@ -216,12 +220,14 @@ begin_binning( struct lp_setup_context *setup )
   if (setup-clear.flags  PIPE_CLEAR_DEPTHSTENCIL) {
  if (!need_zsload)
 scene-has_depthstencil_clear = TRUE;
+
  ok = lp_scene_bin_everywhere( scene,
LP_RAST_OP_CLEAR_ZSTENCIL,
lp_rast_arg_clearzs(
   setup-clear.zsvalue,
   setup-clear.zsmask));
- assert(ok);
+ if (!ok)
+return FALSE;
   }
}
 
@@ -229,15 +235,16 @@ begin_binning( struct lp_setup_context *setup )
   ok = lp_scene_bin_everywhere( scene,
 LP_RAST_OP_BEGIN_QUERY,
 lp_rast_arg_query(setup-active_query) );
-  assert(ok);
+  if (!ok)
+ return FALSE;
}
-  
 
setup-clear.flags = 0;
setup-clear.zsmask = 0;
setup-clear.zsvalue = 0;
 
LP_DBG(DEBUG_SETUP, %s done\n, __FUNCTION__);
+   return TRUE;
 }
 
 
@@ -246,12 +253,12 @@ begin_binning( struct lp_setup_context *setup )
  *
  * TODO: fast path for fullscreen clears and no triangles.
  */
-static void
+static boolean
 execute_clears( struct lp_setup_context *setup )
 {
LP_DBG(DEBUG_SETUP, %s\n, __FUNCTION__);
 
-   begin_binning( setup );
+   return begin_binning( setup );
 }
 
 const char *states[] = {
@@ -262,7 +269,7 @@ const char *states[] = {
 };
 
 
-static void
+static boolean
 set_scene_state( struct lp_setup_context *setup,
  enum setup_state new_state,
  const char *reason)
@@ -270,7 +277,7 @@ set_scene_state( struct lp_setup_context *setup,
unsigned old_state = setup-state;
 
if (old_state == new_state)
-  return;
+  return TRUE;

if (LP_DEBUG  DEBUG_SCENE) {
   debug_printf(%s old %s new %s%s%s\n,
@@ -294,12 +301,14 @@ set_scene_state( struct lp_setup_context *setup,
   break;
 
case SETUP_ACTIVE:
-  begin_binning( setup );
+  if (!begin_binning( setup ))
+ goto fail;
   break;
 
case SETUP_FLUSHED:
   if (old_state == SETUP_CLEARED)
- execute_clears( setup );
+ if (!execute_clears( setup ))
+goto fail;
 
   lp_setup_rasterize_scene( setup );
   assert(setup-scene == NULL);
@@ -307,9 +316,21 @@ set_scene_state( struct lp_setup_context *setup,
 
default:
   assert(0  invalid setup state mode);
+  goto fail;
}
 
setup-state = new_state;
+   return TRUE;
+
+fail:
+   if (setup-scene

Mesa (master): llvmpipe: avoid overflow in triangle culling

2010-10-08 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 29d6a1483d6c4ecb9c34989423e025b3784ec019
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=29d6a1483d6c4ecb9c34989423e025b3784ec019

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Oct  8 17:06:05 2010 +0100

llvmpipe: avoid overflow in triangle culling

Avoid multiplying fixed-point values.  Calculate triangle area in
floating point use that for culling.

Lift area calculations up a level as we are already doing this in the
triangle_both() case.

Would like to share the calculated area with attribute interpolation,
but the way the code is structured makes this difficult.

---

 src/gallium/drivers/llvmpipe/lp_setup_tri.c |   79 +--
 1 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c 
b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index eeffbb5..0d57f13 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -228,7 +228,6 @@ do_triangle_ccw(struct lp_setup_context *setup,
struct lp_rast_triangle *tri;
int x[3];
int y[3];
-   int area;
struct u_rect bbox;
unsigned tri_bytes;
int i;
@@ -312,21 +311,8 @@ do_triangle_ccw(struct lp_setup_context *setup,
tri-plane[1].dcdx = y[1] - y[2];
tri-plane[2].dcdx = y[2] - y[0];
 
-   area = (tri-plane[0].dcdy * tri-plane[2].dcdx -
-   tri-plane[2].dcdy * tri-plane[0].dcdx);
-
LP_COUNT(nr_tris);
 
-   /* Cull non-ccw and zero-sized triangles. 
-*
-* XXX: subject to overflow??
-*/
-   if (area = 0) {
-  lp_scene_putback_data( scene, tri_bytes );
-  LP_COUNT(nr_culled_tris);
-  return TRUE;
-   }
-
/* Setup parameter interpolants:
 */
lp_setup_tri_coef( setup, tri-inputs, v0, v1, v2, frontfacing );
@@ -635,23 +621,36 @@ fail:
 
 
 /**
- * Draw triangle if it's CW, cull otherwise.
+ * Try to draw the triangle, restart the scene on failure.
  */
-static void triangle_cw( struct lp_setup_context *setup,
-const float (*v0)[4],
-const float (*v1)[4],
-const float (*v2)[4] )
+static void retry_triangle_ccw( struct lp_setup_context *setup,
+const float (*v0)[4],
+const float (*v1)[4],
+const float (*v2)[4],
+boolean front)
 {
-   if (!do_triangle_ccw( setup, v1, v0, v2, !setup-ccw_is_frontface ))
+   if (!do_triangle_ccw( setup, v0, v1, v2, front ))
{
   if (!lp_setup_flush_and_restart(setup))
  return;
 
-  if (!do_triangle_ccw( setup, v1, v0, v2, !setup-ccw_is_frontface ))
+  if (!do_triangle_ccw( setup, v0, v1, v2, front ))
  return;
}
 }
 
+static INLINE float
+calc_area(const float (*v0)[4],
+  const float (*v1)[4],
+  const float (*v2)[4])
+{
+   float dx01 = v0[0][0] - v1[0][0];
+   float dy01 = v0[0][1] - v1[0][1];
+   float dx20 = v2[0][0] - v0[0][0];
+   float dy20 = v2[0][1] - v0[0][1];
+   return dx01 * dy20 - dx20 * dy01;
+}
+
 
 /**
  * Draw triangle if it's CW, cull otherwise.
@@ -661,17 +660,23 @@ static void triangle_cw( struct lp_setup_context *setup,
 const float (*v1)[4],
 const float (*v2)[4] )
 {
-   if (!do_triangle_ccw( setup, v0, v1, v2, setup-ccw_is_frontface ))
-   {
-  if (!lp_setup_flush_and_restart(setup))
- return;
+   float area = calc_area(v0, v1, v2);
 
-  if (!do_triangle_ccw( setup, v0, v1, v2, setup-ccw_is_frontface ))
- return;
-   }
+   if (area  0.0f) 
+  retry_triangle_ccw(setup, v0, v2, v1, !setup-ccw_is_frontface);
 }
 
 
+static void triangle_ccw( struct lp_setup_context *setup,
+  const float (*v0)[4],
+  const float (*v1)[4],
+  const float (*v2)[4])
+{
+   float area = calc_area(v0, v1, v2);
+
+   if (area  0.0f) 
+  retry_triangle_ccw(setup, v0, v1, v2, setup-ccw_is_frontface);
+}
 
 /**
  * Draw triangle whether it's CW or CCW.
@@ -681,18 +686,12 @@ static void triangle_both( struct lp_setup_context *setup,
   const float (*v1)[4],
   const float (*v2)[4] )
 {
-   /* edge vectors e = v0 - v2, f = v1 - v2 */
-   const float ex = v0[0][0] - v2[0][0];
-   const float ey = v0[0][1] - v2[0][1];
-   const float fx = v1[0][0] - v2[0][0];
-   const float fy = v1[0][1] - v2[0][1];
-
-   /* det = cross(e,f).z */
-   const float det = ex * fy - ey * fx;
-   if (det  0.0f) 
-  triangle_ccw( setup, v0, v1, v2 );
-   else if (det  0.0f)
-  triangle_cw( setup, v0, v1, v2 );
+   float area = calc_area(v0, v1, v2);
+
+   if (area  0.0f) 
+  retry_triangle_ccw( setup, v0, v1, v2, setup-ccw_is_frontface );
+   else if (area  0.0f)
+  retry_triangle_ccw( setup, v0, v2, v1, !setup-ccw_is_frontface

Mesa (master): gallivm: special case conversion 4x4f to 1x16ub

2010-10-08 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 607e3c542cedd645da91c96abfe6698623acf503
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=607e3c542cedd645da91c96abfe6698623acf503

Author: Keith Whitwell kei...@vmware.com
Date:   Mon Oct  4 15:00:34 2010 +0100

gallivm: special case conversion 4x4f to 1x16ub

Nice reduction in the number of operations required for final color
output in many shaders.

---

 src/gallium/auxiliary/gallivm/lp_bld_conv.c |   84 +++
 1 files changed, 84 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c 
b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
index 8b47731..605eb04 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
@@ -69,6 +69,7 @@
 #include lp_bld_arit.h
 #include lp_bld_pack.h
 #include lp_bld_conv.h
+#include lp_bld_intr.h
 
 
 /**
@@ -241,6 +242,89 @@ lp_build_conv(LLVMBuilderRef builder,
}
num_tmps = num_srcs;
 
+
+   /* Special case 4x4f -- 1x16ub 
+*/
+   if (src_type.floating == 1 
+   src_type.fixed== 0 
+   src_type.sign == 1 
+   src_type.norm == 0 
+   src_type.width== 32 
+   src_type.length   == 4 
+
+   dst_type.floating == 0 
+   dst_type.fixed== 0 
+   dst_type.sign == 0 
+   dst_type.norm == 1 
+   dst_type.width== 8 
+   dst_type.length   == 16)
+   {
+  int i;
+
+  for (i = 0; i  num_dsts; i++, src += 4) {
+ struct lp_type int16_type = dst_type;
+ struct lp_type int32_type = dst_type;
+ LLVMValueRef lo, hi;
+ LLVMValueRef src_int0;
+ LLVMValueRef src_int1;
+ LLVMValueRef src_int2;
+ LLVMValueRef src_int3;
+ LLVMTypeRef int16_vec_type;
+ LLVMTypeRef int32_vec_type;
+ LLVMTypeRef src_vec_type;
+ LLVMTypeRef dst_vec_type;
+ LLVMValueRef const_255f;
+
+ int16_type.width *= 2;
+ int16_type.length /= 2;
+ int16_type.sign = 1;
+
+ int32_type.width *= 4;
+ int32_type.length /= 4;
+ int32_type.sign = 1;
+
+ src_vec_type   = lp_build_vec_type(src_type);
+ dst_vec_type   = lp_build_vec_type(dst_type);
+ int16_vec_type = lp_build_vec_type(int16_type);
+ int32_vec_type = lp_build_vec_type(int32_type);
+
+ const_255f = lp_build_const_vec(src_type, 255.0);
+
+ src_int0 = LLVMBuildFPToSI(builder,
+LLVMBuildFMul(builder, src[0], const_255f, 
),
+int32_vec_type, );
+
+ src_int1 = LLVMBuildFPToSI(builder,
+LLVMBuildFMul(builder, src[1], const_255f, 
),
+int32_vec_type, );
+
+ src_int2 = LLVMBuildFPToSI(builder,
+LLVMBuildFMul(builder, src[2], const_255f, 
),
+int32_vec_type, );
+
+ src_int3 = LLVMBuildFPToSI(builder,
+LLVMBuildFMul(builder, src[3], const_255f, 
),
+int32_vec_type, );
+
+#if HAVE_LLVM = 0x0207
+ lo = lp_build_intrinsic_binary(builder, llvm.x86.sse2.packssdw.128,
+int16_vec_type, src_int0, src_int1);
+ hi = lp_build_intrinsic_binary(builder, llvm.x86.sse2.packssdw.128,
+int16_vec_type, src_int2, src_int3);
+ dst[i] = lp_build_intrinsic_binary(builder, 
llvm.x86.sse2.packuswb.128,
+dst_vec_type, lo, hi);
+#else
+ lo = lp_build_intrinsic_binary(builder, llvm.x86.sse2.packssdw.128,
+int32_vec_type, src_int0, src_int1);
+ hi = lp_build_intrinsic_binary(builder, llvm.x86.sse2.packssdw.128,
+int32_vec_type, src_int2, src_int3);
+ dst[i] = lp_build_intrinsic_binary(builder, 
llvm.x86.sse2.packuswb.128,
+int16_vec_type, lo, hi);
+#endif
+  }
+  return; 
+   }
+
/*
 * Clamp if necessary
 */

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): gallivm: round rather than truncate in new 4x4f- 1x16ub conversion path

2010-10-08 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: e191bf4a8591c8bbccda606a72ed5b90a9db8f72
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e191bf4a8591c8bbccda606a72ed5b90a9db8f72

Author: Keith Whitwell kei...@vmware.com
Date:   Wed Oct  6 11:48:10 2010 +0100

gallivm: round rather than truncate in new 4x4f-1x16ub conversion path

---

 src/gallium/auxiliary/gallivm/lp_bld_conv.c |   59 +++
 1 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c 
b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
index 40c6618..b5ed4c2 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
@@ -63,6 +63,7 @@
 
 #include util/u_debug.h
 #include util/u_math.h
+#include util/u_cpu_detect.h
 
 #include lp_bld_type.h
 #include lp_bld_const.h
@@ -274,6 +275,7 @@ lp_build_conv(LLVMBuilderRef builder,
  LLVMTypeRef src_vec_type;
  LLVMTypeRef dst_vec_type;
  LLVMValueRef const_255f;
+ LLVMValueRef a, b, c, d;
 
  int16_type.width *= 2;
  int16_type.length /= 2;
@@ -288,23 +290,46 @@ lp_build_conv(LLVMBuilderRef builder,
  int16_vec_type = lp_build_vec_type(int16_type);
  int32_vec_type = lp_build_vec_type(int32_type);
 
- const_255f = lp_build_const_vec(src_type, 255.0);
-
- src_int0 = LLVMBuildFPToSI(builder,
-LLVMBuildFMul(builder, src[0], const_255f, 
),
-int32_vec_type, );
-
- src_int1 = LLVMBuildFPToSI(builder,
-LLVMBuildFMul(builder, src[1], const_255f, 
),
-int32_vec_type, );
-
- src_int2 = LLVMBuildFPToSI(builder,
-LLVMBuildFMul(builder, src[2], const_255f, 
),
-int32_vec_type, );
-
- src_int3 = LLVMBuildFPToSI(builder,
-LLVMBuildFMul(builder, src[3], const_255f, 
),
-int32_vec_type, );
+ const_255f = lp_build_const_vec(src_type, 255.0f);
+
+ a = LLVMBuildFMul(builder, src[0], const_255f, );
+ b = LLVMBuildFMul(builder, src[1], const_255f, );
+ c = LLVMBuildFMul(builder, src[2], const_255f, );
+ d = LLVMBuildFMul(builder, src[3], const_255f, );
+
+ /* lp_build_round generates excessively general code without
+  * sse4, so do rounding manually.
+  */
+ if (!util_cpu_caps.has_sse4_1) {
+LLVMValueRef const_half = lp_build_const_vec(src_type, 0.5f);
+
+a = LLVMBuildFAdd(builder, a, const_half, );
+b = LLVMBuildFAdd(builder, b, const_half, );
+c = LLVMBuildFAdd(builder, c, const_half, );
+d = LLVMBuildFAdd(builder, d, const_half, );
+
+src_int0 = LLVMBuildFPToSI(builder, a, int32_vec_type, );
+src_int1 = LLVMBuildFPToSI(builder, b, int32_vec_type, );
+src_int2 = LLVMBuildFPToSI(builder, c, int32_vec_type, );
+src_int3 = LLVMBuildFPToSI(builder, d, int32_vec_type, );
+ }
+ else {
+struct lp_build_context bld;
+
+bld.builder = builder;
+bld.type = src_type;
+bld.vec_type = src_vec_type;
+bld.int_elem_type = lp_build_elem_type(int32_type);
+bld.int_vec_type = int32_vec_type;
+bld.undef = lp_build_undef(src_type);
+bld.zero = lp_build_zero(src_type);
+bld.one = lp_build_one(src_type);
+
+src_int0 = lp_build_iround(bld, a);
+src_int1 = lp_build_iround(bld, b);
+src_int2 = lp_build_iround(bld, c);
+src_int3 = lp_build_iround(bld, d);
+ }
 
  lo = lp_build_pack2(builder, int32_type, int16_type, src_int0, 
src_int1);
  hi = lp_build_pack2(builder, int32_type, int16_type, src_int2, 
src_int3);

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: clean up setup_tri a little

2010-10-08 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: eeb13e2352d7a44881b011cb3232bb80aee0c826
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=eeb13e2352d7a44881b011cb3232bb80aee0c826

Author: Keith Whitwell kei...@vmware.com
Date:   Thu Sep 23 19:56:48 2010 +0100

llvmpipe: clean up setup_tri a little

---

 src/gallium/drivers/llvmpipe/lp_setup_tri.c |   53 +--
 1 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c 
b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index 0d57f13..9f87101 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -473,33 +473,6 @@ lp_setup_bin_triangle( struct lp_setup_context *setup,
int sz = floor_pot((bbox-x1 - (bbox-x0  ~3)) |
  (bbox-y1 - (bbox-y0  ~3)));
 
-   if (nr_planes == 3) {
-  if (sz  4  dx  64)
-  {
-/* Triangle is contained in a single 4x4 stamp:
- */
-int mask = (bbox-x0  63  ~3) | ((bbox-y0  63  ~3)  8);
-
-return lp_scene_bin_command( scene,
- bbox-x0/64, bbox-y0/64,
- LP_RAST_OP_TRIANGLE_3_4,
- lp_rast_arg_triangle(tri, mask) );
-  }
-
-  if (sz  16  dx  64)
-  {
-int mask = (bbox-x0  63  ~3) | ((bbox-y0  63  ~3)  8);
-
-/* Triangle is contained in a single 16x16 block:
- */
-return lp_scene_bin_command( scene,
- bbox-x0/64, bbox-y0/64,
-  LP_RAST_OP_TRIANGLE_3_16,
-  lp_rast_arg_triangle(tri, mask) );
-  }
-   }
-
-
/* Determine which tile(s) intersect the triangle's bounding box
 */
if (dx  TILE_SIZE)
@@ -510,6 +483,32 @@ lp_setup_bin_triangle( struct lp_setup_context *setup,
   assert(iy0 == bbox-y1 / TILE_SIZE 
 ix0 == bbox-x1 / TILE_SIZE);
 
+  if (nr_planes == 3) {
+ int px = bbox-x0  63  ~3;
+ int py = bbox-y0  63  ~3;
+int mask = px | (py  8);
+
+ if (sz  4)
+ {
+/* Triangle is contained in a single 4x4 stamp:
+ */
+
+return lp_scene_bin_command( scene, ix0, iy0,
+ LP_RAST_OP_TRIANGLE_3_4,
+ lp_rast_arg_triangle(tri, mask) );
+ }
+
+ if (sz  16)
+ {
+/* Triangle is contained in a single 16x16 block:
+ */
+return lp_scene_bin_command( scene, ix0, iy0,
+ LP_RAST_OP_TRIANGLE_3_16,
+ lp_rast_arg_triangle(tri, mask) );
+ }
+  }
+
+
   /* Triangle is contained in a single tile:
*/
   return lp_scene_bin_command( scene, ix0, iy0,

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): gallivm: Use the wrappers for SSE pack intrinsics.

2010-10-08 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: f91b4266c6ca950b267bc8968091c85de8cae032
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f91b4266c6ca950b267bc8968091c85de8cae032

Author: José Fonseca jfons...@vmware.com
Date:   Mon Oct  4 17:42:18 2010 +0100

gallivm: Use the wrappers for SSE pack intrinsics.

Fixes assertion failures on LLVM 2.6.

---

 src/gallium/auxiliary/gallivm/lp_bld_conv.c |   18 +++---
 1 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c 
b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
index 605eb04..40c6618 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
@@ -306,21 +306,9 @@ lp_build_conv(LLVMBuilderRef builder,
 LLVMBuildFMul(builder, src[3], const_255f, 
),
 int32_vec_type, );
 
-#if HAVE_LLVM = 0x0207
- lo = lp_build_intrinsic_binary(builder, llvm.x86.sse2.packssdw.128,
-int16_vec_type, src_int0, src_int1);
- hi = lp_build_intrinsic_binary(builder, llvm.x86.sse2.packssdw.128,
-int16_vec_type, src_int2, src_int3);
- dst[i] = lp_build_intrinsic_binary(builder, 
llvm.x86.sse2.packuswb.128,
-dst_vec_type, lo, hi);
-#else
- lo = lp_build_intrinsic_binary(builder, llvm.x86.sse2.packssdw.128,
-int32_vec_type, src_int0, src_int1);
- hi = lp_build_intrinsic_binary(builder, llvm.x86.sse2.packssdw.128,
-int32_vec_type, src_int2, src_int3);
- dst[i] = lp_build_intrinsic_binary(builder, 
llvm.x86.sse2.packuswb.128,
-int16_vec_type, lo, hi);
-#endif
+ lo = lp_build_pack2(builder, int32_type, int16_type, src_int0, 
src_int1);
+ hi = lp_build_pack2(builder, int32_type, int16_type, src_int2, 
src_int3);
+ dst[i] = lp_build_pack2(builder, int16_type, dst_type, lo, hi);
   }
   return; 
}

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): llvmpipe: add rast_tri_4_16 for small lines and points

2010-10-08 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: 0ff132e5a633170afaed0aea54d01438c895b8ab
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ff132e5a633170afaed0aea54d01438c895b8ab

Author: Keith Whitwell kei...@vmware.com
Date:   Fri Oct  8 17:21:03 2010 +0100

llvmpipe: add rast_tri_4_16 for small lines and points

---

 src/gallium/drivers/llvmpipe/lp_rast.c |1 +
 src/gallium/drivers/llvmpipe/lp_rast.h |   11 +-
 src/gallium/drivers/llvmpipe/lp_rast_debug.c   |1 +
 src/gallium/drivers/llvmpipe/lp_rast_priv.h|4 +
 src/gallium/drivers/llvmpipe/lp_rast_tri.c |  152 ++--
 src/gallium/drivers/llvmpipe/lp_rast_tri_tmp.h |  127 
 src/gallium/drivers/llvmpipe/lp_setup_tri.c|   13 ++-
 7 files changed, 161 insertions(+), 148 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c 
b/src/gallium/drivers/llvmpipe/lp_rast.c
index 790d88a..db9b2f9 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -597,6 +597,7 @@ static lp_rast_cmd_func dispatch[LP_RAST_OP_MAX] =
lp_rast_triangle_8,
lp_rast_triangle_3_4,
lp_rast_triangle_3_16,
+   lp_rast_triangle_4_16,
lp_rast_shade_tile,
lp_rast_shade_tile_opaque,
lp_rast_begin_query,
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h 
b/src/gallium/drivers/llvmpipe/lp_rast.h
index 0f62377..df0bea0 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast.h
@@ -238,12 +238,13 @@ lp_rast_arg_null( void )
 #define LP_RAST_OP_TRIANGLE_80x9
 #define LP_RAST_OP_TRIANGLE_3_4  0xa
 #define LP_RAST_OP_TRIANGLE_3_16 0xb
-#define LP_RAST_OP_SHADE_TILE0xc
-#define LP_RAST_OP_SHADE_TILE_OPAQUE 0xd
-#define LP_RAST_OP_BEGIN_QUERY   0xe
-#define LP_RAST_OP_END_QUERY 0xf
+#define LP_RAST_OP_TRIANGLE_4_16 0xc
+#define LP_RAST_OP_SHADE_TILE0xd
+#define LP_RAST_OP_SHADE_TILE_OPAQUE 0xe
+#define LP_RAST_OP_BEGIN_QUERY   0xf
+#define LP_RAST_OP_END_QUERY 0x10
 
-#define LP_RAST_OP_MAX   0x10
+#define LP_RAST_OP_MAX   0x11
 #define LP_RAST_OP_MASK  0xff
 
 void
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_debug.c 
b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
index 9fc7864..6f4ba1c 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_debug.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
@@ -42,6 +42,7 @@ static const char *cmd_names[LP_RAST_OP_MAX] =
triangle_8,
triangle_3_4,
triangle_3_16,
+   triangle_4_16,
shade_tile,
shade_tile_opaque,
begin_query,
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h 
b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
index 7370119..104000a 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
@@ -293,6 +293,10 @@ void lp_rast_triangle_3_4(struct lp_rasterizer_task *,
 
 void lp_rast_triangle_3_16( struct lp_rasterizer_task *, 
 const union lp_rast_cmd_arg );
+
+void lp_rast_triangle_4_16( struct lp_rasterizer_task *, 
+const union lp_rast_cmd_arg );
+
 void
 lp_debug_bin( const struct cmd_bin *bin );
 
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c 
b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
index a1f309d..f870a18 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
@@ -123,6 +123,16 @@ lp_rast_triangle_3_16(struct lp_rasterizer_task *task,
 }
 
 void
+lp_rast_triangle_4_16(struct lp_rasterizer_task *task,
+  const union lp_rast_cmd_arg arg)
+{
+   union lp_rast_cmd_arg arg2;
+   arg2.triangle.tri = arg.triangle.tri;
+   arg2.triangle.plane_mask = (14)-1;
+   lp_rast_triangle_3(task, arg2);
+}
+
+void
 lp_rast_triangle_3_4(struct lp_rasterizer_task *task,
   const union lp_rast_cmd_arg arg)
 {
@@ -229,145 +239,6 @@ sign_bits4(const __m128i *cstep, int cdiff)
return _mm_movemask_epi8(result);
 }
 
-
-/* Special case for 3 plane triangle which is contained entirely
- * within a 16x16 block.
- */
-void
-lp_rast_triangle_3_16(struct lp_rasterizer_task *task,
-  const union lp_rast_cmd_arg arg)
-{
-   const struct lp_rast_triangle *tri = arg.triangle.tri;
-   const struct lp_rast_plane *plane = tri-plane;
-   unsigned mask = arg.triangle.plane_mask;
-   const int x = task-x + (mask  0xff);
-   const int y = task-y + (mask  8);
-   unsigned outmask, inmask, partmask, partial_mask;
-   unsigned j;
-   __m128i cstep4[3][4];
-
-   outmask = 0; /* outside one or more trivial reject planes */
-   partmask = 0;/* outside one or more trivial accept planes */
-
-   for (j = 0; j  3; j++) {
-  const int dcdx = -plane[j].dcdx * 4;
-  const int dcdy = plane[j].dcdy * 4;
-  __m128i xdcdy = _mm_set1_epi32(dcdy);
-
-  cstep4[j][0] = _mm_setr_epi32(0, dcdx, dcdx*2, dcdx*3

Mesa (master): llvmpipe: fix off-by-one in tri_16

2010-10-08 Thread Keith Whitwell
Module: Mesa
Branch: master
Commit: ef3407672ed4c2c6d070384ea763e73b3da2240a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef3407672ed4c2c6d070384ea763e73b3da2240a

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Oct  5 16:50:22 2010 +0100

llvmpipe: fix off-by-one in tri_16

---

 src/gallium/drivers/llvmpipe/lp_rast_tri_tmp.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri_tmp.h 
b/src/gallium/drivers/llvmpipe/lp_rast_tri_tmp.h
index c8f9956..2f03229 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_tri_tmp.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_tri_tmp.h
@@ -309,7 +309,7 @@ TRI_16(struct lp_rasterizer_task *task,
   partial_mask = ~(1  i);
 
   for (j = 0; j  NR_PLANES; j++) {
- const int cx = (plane[j].c 
+ const int cx = (plane[j].c - 1
 - plane[j].dcdx * px
 + plane[j].dcdy * py) * 4;
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Demos (master): trivial: add drawelements-large

2010-10-05 Thread Keith Whitwell
Module: Demos
Branch: master
Commit: 09fb3da886168ab3aa635acac09fba45db1c3610
URL:
http://cgit.freedesktop.org/mesa/demos/commit/?id=09fb3da886168ab3aa635acac09fba45db1c3610

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Oct  5 09:53:56 2010 +0100

trivial: add drawelements-large

---

 src/trivial/SConscript   |1 +
 src/trivial/drawelements-large.c |  121 ++
 2 files changed, 122 insertions(+), 0 deletions(-)

diff --git a/src/trivial/SConscript b/src/trivial/SConscript
index 24b4f91..84270a4 100644
--- a/src/trivial/SConscript
+++ b/src/trivial/SConscript
@@ -15,6 +15,7 @@ progs = [
'drawarrays',
'draw2arrays',
'drawelements',
+   'drawelements-large',
'drawrange',
'flat-clip',
'fs-tri',
diff --git a/src/trivial/drawelements-large.c b/src/trivial/drawelements-large.c
new file mode 100644
index 000..fc23985
--- /dev/null
+++ b/src/trivial/drawelements-large.c
@@ -0,0 +1,121 @@
+/* Test rebasing */
+
+#include assert.h
+#include string.h
+#include stdio.h
+#include stdlib.h
+#include math.h
+#include GL/glew.h
+#include GL/glut.h
+
+#define NR_VERTS 2
+GLfloat verts[NR_VERTS][4];
+GLushort indices[NR_VERTS*2];
+
+
+
+static void Init( void )
+{
+   GLint errno;
+   GLuint prognum;
+   GLint i;
+
+   static const char *prog1 =
+  !!ARBvp1.0\n
+  MOV  result.color, {1.0}.;\n
+  MOV  result.position, vertex.position;\n
+  END\n;
+
+   glGenProgramsARB(1, prognum);
+   glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+   glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(prog1), (const GLubyte *) prog1);
+
+   assert(glIsProgramARB(prognum));
+   errno = glGetError();
+   printf(glGetError = %d\n, errno);
+   if (errno != GL_NO_ERROR)
+   {
+  GLint errorpos;
+
+  glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, errorpos);
+  printf(errorpos: %d\n, errorpos);
+  printf(%s\n, (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+   }
+
+
+   glEnableClientState( GL_VERTEX_ARRAY );
+   glEnableClientState( GL_COLOR_ARRAY );
+   glVertexPointer( 3, GL_FLOAT, sizeof(verts[0]), verts );
+
+
+   for (i = 0; i  NR_VERTS; i++) {
+  verts[i][0] = cos(i / (float)NR_VERTS * 2.0 * 3.141592);
+  verts[i][1] = sin(i / (float)NR_VERTS * 2.0 * 3.141592);
+  verts[i][2] = 0.0;
+  verts[i][3] = 1.0;
+
+  indices[2*i+0] = i;
+  indices[2*i+1] = (i+1 == NR_VERTS) ? 0 : i+1;
+   }
+}
+
+
+
+static void Display( void )
+{
+   glClearColor(0.3, 0.3, 0.3, 1);
+   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+   glEnable(GL_VERTEX_PROGRAM_NV);
+
+   /* Should have min_index == 1, maybe force a rebase:
+*/
+   glDrawElements( GL_LINES, NR_VERTS*2, GL_UNSIGNED_SHORT, indices );
+
+   glFlush(); 
+}
+
+
+static void Reshape( int width, int height )
+{
+   glViewport( 0, 0, width, height );
+   glMatrixMode( GL_PROJECTION );
+   glLoadIdentity();
+   glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+   glMatrixMode( GL_MODELVIEW );
+   glLoadIdentity();
+   /*glTranslatef( 0.0, 0.0, -15.0 );*/
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+   (void) x;
+   (void) y;
+   switch (key) {
+  case 27:
+ exit(0);
+ break;
+   }
+   glutPostRedisplay();
+}
+
+
+
+
+int main( int argc, char *argv[] )
+{
+   glutInit( argc, argv );
+   glutInitWindowPosition( 0, 0 );
+   glutInitWindowSize( 250, 250 );
+   glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH );
+   glutCreateWindow(argv[0]);
+   glewInit();
+   glutReshapeFunc( Reshape );
+   glutKeyboardFunc( Key );
+   glutDisplayFunc( Display );
+   Init();
+   glutMainLoop();
+   return 0;
+}

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Demos (master): demos: print framerates to stdout

2010-10-05 Thread Keith Whitwell
Module: Demos
Branch: master
Commit: 21e7e5f4823c5e4b20a13fd2b9bbc154a9004e1d
URL:
http://cgit.freedesktop.org/mesa/demos/commit/?id=21e7e5f4823c5e4b20a13fd2b9bbc154a9004e1d

Author: Keith Whitwell kei...@vmware.com
Date:   Tue Oct  5 09:55:39 2010 +0100

demos: print framerates to stdout

Useful if you want to capture this information automatically, or if
you're doing experiments like disabling texturing or swapbuffers which
mean you can't read the onscreen display.

---

 src/demos/fbo_firecube.c |1 +
 src/demos/fire.c |1 +
 src/demos/ipers.c|1 +
 src/demos/ray.c  |1 +
 src/demos/teapot.c   |1 +
 src/demos/terrain.c  |1 +
 src/demos/tunnel.c   |1 +
 src/demos/tunnel2.c  |1 +
 8 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/demos/fbo_firecube.c b/src/demos/fbo_firecube.c
index afda1d7..3fd7413 100644
--- a/src/demos/fbo_firecube.c
+++ b/src/demos/fbo_firecube.c
@@ -584,6 +584,7 @@ drawfire(void)
 GLfloat seconds = (t - T0) / 1000.0;
 GLfloat fps = Frames / seconds;
 sprintf(frbuf, Frame rate: %f, fps);
+ printf(%s\n, frbuf);
 T0 = t;
 Frames = 0;
   }
diff --git a/src/demos/fire.c b/src/demos/fire.c
index bb912fb..2e15985 100644
--- a/src/demos/fire.c
+++ b/src/demos/fire.c
@@ -528,6 +528,7 @@ drawfire(void)
  GLfloat seconds = (t - T0) / 1000.0;
  GLfloat fps = Frames / seconds;
  sprintf(frbuf, Frame rate: %f, fps);
+ printf(%s\n, frbuf);
  T0 = t;
  Frames = 0;
   }
diff --git a/src/demos/ipers.c b/src/demos/ipers.c
index 265378b..4b57d78 100644
--- a/src/demos/ipers.c
+++ b/src/demos/ipers.c
@@ -668,6 +668,7 @@ draw(void)
   if (t - T0 = 2000) {
  GLfloat seconds = (t - T0) / 1000.0;
  fr = Frames / seconds;
+ printf(Frame rate: %f\n, fr);
  T0 = t;
  Frames = 0;
   }
diff --git a/src/demos/ray.c b/src/demos/ray.c
index 9cc464d..bcb6355 100644
--- a/src/demos/ray.c
+++ b/src/demos/ray.c
@@ -739,6 +739,7 @@ draw(void)
  GLfloat seconds = (t - T0) / 1000.0;
  GLfloat fps = Frames / seconds;
  sprintf(frbuf, Frame rate: %f, fps);
+ printf(%s\n, frbuf);
  T0 = t;
  Frames = 0;
   }
diff --git a/src/demos/teapot.c b/src/demos/teapot.c
index 04a675f..fb79708 100644
--- a/src/demos/teapot.c
+++ b/src/demos/teapot.c
@@ -490,6 +490,7 @@ static void draw(void)
  GLfloat seconds = (t - T0) / 1000.0;
  GLfloat fps = Frames / seconds;
  sprintf(frbuf, Frame rate: %f, fps);
+ printf(%s\n, frbuf);
  T0 = t;
  Frames = 0;
   }
diff --git a/src/demos/terrain.c b/src/demos/terrain.c
index a72c8d3..97c4656 100644
--- a/src/demos/terrain.c
+++ b/src/demos/terrain.c
@@ -425,6 +425,7 @@ drawscene(void)
  GLfloat seconds = (t - T0) / 1000.0;
  GLfloat fps = Frames / seconds;
  sprintf(frbuf, Frame rate: %f, fps);
+ printf(%s\n, frbuf);
  T0 = t;
  Frames = 0;
   }
diff --git a/src/demos/tunnel.c b/src/demos/tunnel.c
index efc007c..6fe0f67 100644
--- a/src/demos/tunnel.c
+++ b/src/demos/tunnel.c
@@ -469,6 +469,7 @@ draw(void)
  GLfloat seconds = (t - T0) / 1000.0;
  GLfloat fps = Frames / seconds;
  sprintf(frbuf, Frame rate: %f, fps);
+ printf(%s\n, frbuf);
  T0 = t;
  Frames = 0;
   }
diff --git a/src/demos/tunnel2.c b/src/demos/tunnel2.c
index f15da95..90a9ef3 100644
--- a/src/demos/tunnel2.c
+++ b/src/demos/tunnel2.c
@@ -490,6 +490,7 @@ draw(void)
  GLfloat seconds = (t - T0) / 1000.0;
  GLfloat fps = Frames / seconds;
  sprintf(frbuf, Frame rate: %f, fps);
+ printf(%s\n, frbuf);
  T0 = t;
  Frames = 0;
   }

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (llvm-cliptest-viewport): draw: added userclip planes and updated variant_key

2010-10-04 Thread Keith Whitwell
Module: Mesa
Branch: llvm-cliptest-viewport
Commit: 25bb05fef075a87ec6e5f2a989049faff2afedd2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=25bb05fef075a87ec6e5f2a989049faff2afedd2

Author: delphi tayhuiqi...@gmail.com
Date:   Mon Oct  4 17:08:33 2010 +0100

draw: added userclip planes and updated variant_key

---

 src/gallium/auxiliary/draw/draw_llvm.c |  138 ++--
 src/gallium/auxiliary/draw/draw_llvm.h |8 +-
 2 files changed, 99 insertions(+), 47 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 940b2d7..9c17e77 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -823,13 +823,21 @@ generate_viewport(struct draw_llvm *llvm,
 static LLVMValueRef 
 generate_clipmask(LLVMBuilderRef builder,
   LLVMValueRef (*outputs)[NUM_CHANNELS],
-  boolean disable_zclipping,
-  boolean enable_d3dclipping)
+  boolean clip_xy,
+  boolean clip_z,
+  boolean clip_user,
+  boolean enable_d3dclipping,
+  struct draw_llvm *llvm)
 {
LLVMValueRef mask; /* stores the 4xi32 clipmasks */ 
LLVMValueRef test, temp; 
LLVMValueRef zero, shift;
LLVMValueRef pos_x, pos_y, pos_z, pos_w;
+   LLVMValueRef planes, sum;
+
+   unsigned nr;
+   unsigned i;
+   float (*plane)[4];
 
struct lp_type f32_type = lp_type_float_vec(32); 
 
@@ -843,33 +851,35 @@ generate_clipmask(LLVMBuilderRef builder,
pos_w = LLVMBuildLoad(builder, outputs[0][3], ); /*w0 w1 w2 w3*/   
 
/* Cliptest, for hardwired planes */
-   /* plane 1 */
-   test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, pos_x , 
pos_w);
-   temp = shift;
-   test = LLVMBuildAnd(builder, test, temp, ); 
-   mask = test;
+   if (clip_xy){
+  /* plane 1 */
+  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, pos_x , 
pos_w);
+  temp = shift;
+  test = LLVMBuildAnd(builder, test, temp, ); 
+  mask = test;

-   /* plane 2 */
-   test = LLVMBuildFAdd(builder, pos_x, pos_w, );
-   test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, test);
-   temp = LLVMBuildShl(builder, temp, shift, );
-   test = LLVMBuildAnd(builder, test, temp, ); 
-   mask = LLVMBuildOr(builder, mask, test, );
+  /* plane 2 */
+  test = LLVMBuildFAdd(builder, pos_x, pos_w, );
+  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, 
test);
+  temp = LLVMBuildShl(builder, temp, shift, );
+  test = LLVMBuildAnd(builder, test, temp, ); 
+  mask = LLVMBuildOr(builder, mask, test, );

-   /* plane 3 */
-   test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, pos_y, pos_w);
-   temp = LLVMBuildShl(builder, temp, shift, );
-   test = LLVMBuildAnd(builder, test, temp, ); 
-   mask = LLVMBuildOr(builder, mask, test, );
-
-   /* plane 4 */
-   test = LLVMBuildFAdd(builder, pos_y, pos_w, );
-   test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, test);
-   temp = LLVMBuildShl(builder, temp, shift, );
-   test = LLVMBuildAnd(builder, test, temp, ); 
-   mask = LLVMBuildOr(builder, mask, test, );
-
-   if (!disable_zclipping){
+  /* plane 3 */
+  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, pos_y, 
pos_w);
+  temp = LLVMBuildShl(builder, temp, shift, );
+  test = LLVMBuildAnd(builder, test, temp, ); 
+  mask = LLVMBuildOr(builder, mask, test, );
+
+  /* plane 4 */
+  test = LLVMBuildFAdd(builder, pos_y, pos_w, );
+  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, 
test);
+  temp = LLVMBuildShl(builder, temp, shift, );
+  test = LLVMBuildAnd(builder, test, temp, ); 
+  mask = LLVMBuildOr(builder, mask, test, );
+   }
+
+   if (clip_z){
   if (enable_d3dclipping){
  /* plane 5 */
  test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, 
pos_z);
@@ -892,6 +902,32 @@ generate_clipmask(LLVMBuilderRef builder,
   mask = LLVMBuildOr(builder, mask, test, );
}   
 
+   if (clip_user){
+  /* userclip planes */
+  nr = llvm-draw-nr_planes;
+  plane = llvm-draw-plane;
+  for (i = 6; i  nr; i++) {
+ planes = lp_build_const_vec(f32_type, plane[i][0]);
+ sum = LLVMBuildMul(builder, planes, pos_x, );
+
+ planes = lp_build_const_vec(f32_type, plane[i][1]);
+ test = LLVMBuildMul(builder, planes, pos_y, );
+ sum = LLVMBuildFAdd(builder, sum, test, );
+
+ planes = lp_build_const_vec(f32_type, plane[i][2]);
+ test = LLVMBuildMul(builder, planes, pos_z, );
+ sum = LLVMBuildFAdd(builder, sum, test, );
+
+ planes = lp_build_const_vec(f32_type, plane[i][3]);
+ test = LLVMBuildMul(builder, planes, pos_w, );
+ sum = LLVMBuildFAdd(builder, sum, test, );
+
+ test = lp_build_compare(builder, f32_type, 

Mesa (llvm-cliptest-viewport): draw: added viewport and cliptest flags

2010-09-29 Thread Keith Whitwell
Module: Mesa
Branch: llvm-cliptest-viewport
Commit: 3744d1c7d30543520cede8a6c580f26985978953
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3744d1c7d30543520cede8a6c580f26985978953

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Tue Sep 28 17:52:14 2010 +0100

draw: added viewport and cliptest flags

Corrections in store_clip to store clip coordinates in AoS form.
Viewport  cliptest flag options based on variant key.
Put back draw_pt_post_vs and now 2 paths based on whether clipping
occurs or not.

---

 src/gallium/auxiliary/draw/draw_llvm.c |  130 +---
 src/gallium/auxiliary/draw/draw_llvm.h |6 +-
 .../draw/draw_pt_fetch_shade_pipeline_llvm.c   |   12 ++-
 3 files changed, 98 insertions(+), 50 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 36254d3..940b2d7 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -736,10 +736,10 @@ store_clip(LLVMBuilderRef builder,
indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0);
indices[1] = LLVMConstInt(LLVMInt32Type(), 0, 0);

-   out[0] = LLVMBuildLoad(builder, outputs[0][0], ); /*x0 y0 z0 w0*/
-   out[1] = LLVMBuildLoad(builder, outputs[0][1], ); /*x1 y1 z1 w1*/
-   out[2] = LLVMBuildLoad(builder, outputs[0][2], ); /*x2 y2 z2 w2*/
-   out[3] = LLVMBuildLoad(builder, outputs[0][3], ); /*x3 y3 z3 w3*/  
+   out[0] = LLVMBuildLoad(builder, outputs[0][0], ); /*x0 x1 x2 x3*/
+   out[1] = LLVMBuildLoad(builder, outputs[0][1], ); /*y0 y1 y2 y3*/
+   out[2] = LLVMBuildLoad(builder, outputs[0][2], ); /*z0 z1 z2 z3*/
+   out[3] = LLVMBuildLoad(builder, outputs[0][3], ); /*w0 w1 w2 w3*/  
 
io0_ptr = LLVMBuildGEP(builder, io_ptr, ind0, 1, );
io1_ptr = LLVMBuildGEP(builder, io_ptr, ind1, 1, );
@@ -753,22 +753,22 @@ store_clip(LLVMBuilderRef builder,
 
for (int i = 0; i4; i++){
   clip0_ptr = LLVMBuildGEP(builder, clip_ptr0,
-   indices, 2, ); //x1
+   indices, 2, ); //x0
   clip1_ptr = LLVMBuildGEP(builder, clip_ptr1,
-   indices, 2, ); //y1
+   indices, 2, ); //x1
   clip2_ptr = LLVMBuildGEP(builder, clip_ptr2,
-   indices, 2, ); //z1
+   indices, 2, ); //x2
   clip3_ptr = LLVMBuildGEP(builder, clip_ptr3,
-   indices, 2, ); //w1
-
-  out0elem = LLVMBuildExtractElement(builder, out[0],
- indices[1], ); //x1
-  out1elem = LLVMBuildExtractElement(builder, out[1],
- indices[1], ); //y1
-  out2elem = LLVMBuildExtractElement(builder, out[2],
- indices[1], ); //z1
-  out3elem = LLVMBuildExtractElement(builder, out[3],
- indices[1], ); //w1
+   indices, 2, ); //x3
+
+  out0elem = LLVMBuildExtractElement(builder, out[i],
+ ind0, ); //x0
+  out1elem = LLVMBuildExtractElement(builder, out[i],
+ ind1, ); //x1
+  out2elem = LLVMBuildExtractElement(builder, out[i],
+ ind2, ); //x2
+  out3elem = LLVMBuildExtractElement(builder, out[i],
+ ind3, ); //x3
   
   LLVMBuildStore(builder, out0elem, clip0_ptr);
   LLVMBuildStore(builder, out1elem, clip1_ptr);
@@ -822,7 +822,9 @@ generate_viewport(struct draw_llvm *llvm,
  */
 static LLVMValueRef 
 generate_clipmask(LLVMBuilderRef builder,
-  LLVMValueRef (*outputs)[NUM_CHANNELS])
+  LLVMValueRef (*outputs)[NUM_CHANNELS],
+  boolean disable_zclipping,
+  boolean enable_d3dclipping)
 {
LLVMValueRef mask; /* stores the 4xi32 clipmasks */ 
LLVMValueRef test, temp; 
@@ -866,22 +868,31 @@ generate_clipmask(LLVMBuilderRef builder,
temp = LLVMBuildShl(builder, temp, shift, );
test = LLVMBuildAnd(builder, test, temp, ); 
mask = LLVMBuildOr(builder, mask, test, );
-   
-   /* plane 5 */
-   test = LLVMBuildFAdd(builder, pos_z, pos_w, );
-   test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, test);
-   temp = LLVMBuildShl(builder, temp, shift, );
-   test = LLVMBuildAnd(builder, test, temp, ); 
-   mask = LLVMBuildOr(builder, mask, test, );
-   
-   /* plane 6 */
-   test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, pos_z, pos_w);
-   temp = LLVMBuildShl(builder, temp, shift, );
-   test = LLVMBuildAnd(builder, test, temp, ); 
-   mask = LLVMBuildOr(builder, mask, test, ); 
-
+
+   if (!disable_zclipping){
+  if (enable_d3dclipping){
+ /* plane 5 */
+ test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, 

Mesa (lp-setup-llvm): llvmpipe: minor changes in llvm coefficient calcs

2010-09-27 Thread Keith Whitwell
Module: Mesa
Branch: lp-setup-llvm
Commit: 75d22e71a812bbe78414d3f9519f4c7a7157c748
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=75d22e71a812bbe78414d3f9519f4c7a7157c748

Author: Hui Qi Tay tayhuiqi...@gmail.com
Date:   Sun Sep 26 16:01:59 2010 +0800

llvmpipe: minor changes in llvm coefficient calcs

---

 src/gallium/drivers/llvmpipe/lp_setup_debug.c |1 +
 src/gallium/drivers/llvmpipe/lp_state_setup.c |5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup_debug.c 
b/src/gallium/drivers/llvmpipe/lp_setup_debug.c
new file mode 100644
index 000..a71a471
--- /dev/null
+++ b/src/gallium/drivers/llvmpipe/lp_setup_debug.c
@@ -0,0 +1 @@
+/* Some debugging stuff */
diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c 
b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index aa9147a..3261c53 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -173,8 +173,9 @@ emit_facing_coef( LLVMBuilderRef builder,
  unsigned slot )
 {
LLVMValueRef a0_0 = args-facing;
+   LLVMValueRef a0_0f = LLVMBuildSIToFP(builder, a0_0, LLVMFloatType(), );
LLVMValueRef zero = LLVMConstReal(LLVMFloatType(), 0.0);
-   LLVMValueRef a0  = vec4f(builder, a0_0, zero, zero, zero, facing);
+   LLVMValueRef a0  = vec4f(builder, a0_0f, zero, zero, zero, facing);
LLVMValueRef zerovec = vec4f_from_scalar(builder, zero, zero);
 
store_coef(builder, args, slot, a0, zerovec, zerovec);
@@ -520,7 +521,7 @@ generate_setup_variant(struct llvmpipe_screen *screen,
arg_types[4] = LLVMPointerType(vec4f_type, 0);  /* a0, aligned */
arg_types[5] = LLVMPointerType(vec4f_type, 0);  /* dadx, aligned */
arg_types[6] = LLVMPointerType(vec4f_type, 0);  /* dady, aligned */
-   arg_types[7] = LLVMPointerType(LLVMVoidType(), 0);  /* key, unused */
+   arg_types[7] = LLVMPointerType(vec4f_type, 0);   /* key, unused */
 
func_type = LLVMFunctionType(LLVMVoidType(), arg_types, 
Elements(arg_types), 0);
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


  1   2   3   4   5   6   7   8   9   10   >