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

Keith Whitwell keithw at kemper.freedesktop.org
Fri Oct 15 12:28:35 UTC 2010


Module: Mesa
Branch: master
Commit: 0a1c9001037a13b69b157994e7983aa3dee158d3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a1c9001037a13b69b157994e7983aa3dee158d3

Author: Keith Whitwell <keithw at 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( struct lp_rasterizer_task *task,
    BEGIN_JIT_CALL(state);
    variant->jit_function[RAST_WHOLE]( &state->jit_context,
                                       x, y,
-                                      inputs->facing,
+                                      inputs->frontfacing,
                                       inputs->a0,
                                       inputs->dadx,
                                       inputs->dady,
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_line.c b/src/gallium/drivers/llvmpipe/lp_setup_line.c
index e4cff9a..efc48ee 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_line.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_line.c
@@ -596,7 +596,7 @@ try_setup_line( struct lp_setup_context *setup,
     */
    setup_line_coefficients( setup, line, &info); 
 
-   line->inputs.facing = 1.0F;
+   line->inputs.frontfacing = TRUE;
    line->inputs.disable = FALSE;
    line->inputs.opaque = FALSE;
 
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_point.c b/src/gallium/drivers/llvmpipe/lp_setup_point.c
index 93c3efe..108c831 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_point.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_point.c
@@ -373,7 +373,7 @@ try_setup_point( struct lp_setup_context *setup,
     */
    setup_point_coefficients(setup, point, &info);
 
-   point->inputs.facing = 1.0F;
+   point->inputs.frontfacing = TRUE;
    point->inputs.disable = FALSE;
    point->inputs.opaque = FALSE;
 
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index bc48eb8..3bf0b2d 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -319,7 +319,7 @@ do_triangle_ccw(struct lp_setup_context *setup,
     */
    lp_setup_tri_coef( setup, &tri->inputs, v0, v1, v2, frontfacing );
 
-   tri->inputs.facing = frontfacing ? 1.0F : -1.0F;
+   tri->inputs.frontfacing = frontfacing;
    tri->inputs.disable = FALSE;
    tri->inputs.opaque = setup->fs.current.variant->opaque;
 
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index d2fbe27..8df807c 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -579,7 +579,7 @@ generate_fragment(struct llvmpipe_context *lp,
    arg_types[0] = screen->context_ptr_type;            /* context */
    arg_types[1] = LLVMInt32Type();                     /* x */
    arg_types[2] = LLVMInt32Type();                     /* y */
-   arg_types[3] = LLVMFloatType();                     /* facing */
+   arg_types[3] = LLVMInt32Type();                     /* facing */
    arg_types[4] = LLVMPointerType(fs_elem_type, 0);    /* a0 */
    arg_types[5] = LLVMPointerType(fs_elem_type, 0);    /* dadx */
    arg_types[6] = LLVMPointerType(fs_elem_type, 0);    /* dady */




More information about the mesa-commit mailing list