llvmpipe: don't pass frontfacing as a float
authorKeith Whitwell <keithw@vmware.com>
Thu, 14 Oct 2010 23:12:19 +0000 (00:12 +0100)
committerKeith Whitwell <keithw@vmware.com>
Fri, 15 Oct 2010 12:27:47 +0000 (13:27 +0100)
src/gallium/drivers/llvmpipe/lp_bld_depth.c
src/gallium/drivers/llvmpipe/lp_jit.h
src/gallium/drivers/llvmpipe/lp_rast.c
src/gallium/drivers/llvmpipe/lp_rast.h
src/gallium/drivers/llvmpipe/lp_rast_priv.h
src/gallium/drivers/llvmpipe/lp_setup_line.c
src/gallium/drivers/llvmpipe/lp_setup_point.c
src/gallium/drivers/llvmpipe/lp_setup_tri.c
src/gallium/drivers/llvmpipe/lp_state_fs.c

index e4cfa97aa3fa0711546b686656c103c0e75ccf56..ddf7da0b14db17e431a0bff865edf43d8d7955ad 100644 (file)
@@ -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),
                                       "");
index 16e04fce0cdefdaebb0ba7e9422805b9681e3762..114f21f2d16fa4184a25364a49a807678b224ac3 100644 (file)
@@ -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,
index 35e2f731e89bd026465fb491c8be1cd4ef189dd2..8e9be755e074d37db30f9b41ade9781e563681e2 100644 (file)
@@ -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,
index f74b198a66c4d4e9100c47f974e042f3f78e03e4..c5fb15484c59308a27a016ee9f3ebc6808dcdb70 100644 (file)
@@ -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 */
 
index 7ffd735def2b9f15a72ae052b1553d941029a8d7..e5d04c65b00128b806ac91e4a573ee6808e2de42 100644 (file)
@@ -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,
index e4cff9aa42ce287b458ac8cee4b4270269a4d010..efc48eecfee679f9decde371f41349c73330fb8a 100644 (file)
@@ -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;
 
index 93c3efe347e642d458143768d3705794782978cc..108c831e66e5af3e4e19a13cacdf077e1230807e 100644 (file)
@@ -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;
 
index bc48eb8d1b54785287ed94a4a7f47f3f9448c2ee..3bf0b2d25224f79de0b748ec86a3c82dbbf412c0 100644 (file)
@@ -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;
 
index d2fbe27708347502f515fd1bbc20b3cf20e406bf..8df807cec883e189b226e110602874c60bcbdc54 100644 (file)
@@ -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 */