llvmpipe: move more coef setup into lp_setup_coef.c
authorKeith Whitwell <keithw@vmware.com>
Wed, 1 Sep 2010 17:43:46 +0000 (18:43 +0100)
committerKeith Whitwell <keithw@vmware.com>
Tue, 7 Sep 2010 13:02:29 +0000 (14:02 +0100)
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_tri.c

index 95e3e8fffe82b4a42384d25ad7551086f4684f94..8dc2688ddb604f56f8110983b526ca9a483525ac 100644 (file)
@@ -187,11 +187,32 @@ static void setup_facing_coef( struct lp_rast_shader_inputs *inputs,
  */
 void lp_setup_tri_coef( struct lp_setup_context *setup,
                        struct lp_rast_shader_inputs *inputs,
-                       const struct lp_tri_info *info)
+                        const float (*v0)[4],
+                        const float (*v1)[4],
+                        const float (*v2)[4],
+                        boolean frontfacing)
 {
    unsigned fragcoord_usage_mask = TGSI_WRITEMASK_XYZ;
    unsigned slot;
    unsigned i;
+   struct lp_tri_info info;
+   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];
+   float oneoverarea = 1.0f / (dx01 * dy20 - dx20 * dy01);
+
+   info.v0 = v0;
+   info.v1 = v1;
+   info.v2 = v2;
+   info.frontfacing = frontfacing;
+   info.x0_center = v0[0][0] - setup->pixel_offset;
+   info.y0_center = v0[0][1] - setup->pixel_offset;
+   info.dx01_ooa  = dx01 * oneoverarea;
+   info.dx20_ooa  = dx20 * oneoverarea;
+   info.dy01_ooa  = dy01 * oneoverarea;
+   info.dy20_ooa  = dy20 * oneoverarea;
+
 
    /* setup interpolation for all the remaining attributes:
     */
@@ -204,25 +225,25 @@ void lp_setup_tri_coef( struct lp_setup_context *setup,
          if (setup->flatshade_first) {
             for (i = 0; i < NUM_CHANNELS; i++)
                if (usage_mask & (1 << i))
-                  constant_coef(inputs, slot+1, info->v0[vert_attr][i], i);
+                  constant_coef(inputs, slot+1, info.v0[vert_attr][i], i);
          }
          else {
             for (i = 0; i < NUM_CHANNELS; i++)
                if (usage_mask & (1 << i))
-                  constant_coef(inputs, slot+1, info->v2[vert_attr][i], i);
+                  constant_coef(inputs, slot+1, info.v2[vert_attr][i], i);
          }
          break;
 
       case LP_INTERP_LINEAR:
          for (i = 0; i < NUM_CHANNELS; i++)
             if (usage_mask & (1 << i))
-               linear_coef(inputs, info, slot+1, vert_attr, i);
+               linear_coef(inputs, &info, slot+1, vert_attr, i);
          break;
 
       case LP_INTERP_PERSPECTIVE:
          for (i = 0; i < NUM_CHANNELS; i++)
             if (usage_mask & (1 << i))
-               perspective_coef(inputs, info, slot+1, vert_attr, i);
+               perspective_coef(inputs, &info, slot+1, vert_attr, i);
          fragcoord_usage_mask |= TGSI_WRITEMASK_W;
          break;
 
@@ -236,7 +257,7 @@ void lp_setup_tri_coef( struct lp_setup_context *setup,
          break;
 
       case LP_INTERP_FACING:
-         setup_facing_coef(inputs, slot+1, info->frontfacing, usage_mask);
+         setup_facing_coef(inputs, slot+1, info.frontfacing, usage_mask);
          break;
 
       default:
@@ -246,7 +267,7 @@ void lp_setup_tri_coef( struct lp_setup_context *setup,
 
    /* The internal position input is in slot zero:
     */
-   setup_fragcoord_coef(inputs, info, 0, fragcoord_usage_mask);
+   setup_fragcoord_coef(inputs, &info, 0, fragcoord_usage_mask);
 }
 
 #else
index d68b39c603f71326ca9636ac37ba97b389b722c7..87a3255ccc698fd80638a983ab61d34a911856dd 100644 (file)
@@ -56,6 +56,9 @@ struct lp_tri_info {
 
 void lp_setup_tri_coef( struct lp_setup_context *setup,
                        struct lp_rast_shader_inputs *inputs,
-                       const struct lp_tri_info *info);
+                        const float (*v0)[4],
+                        const float (*v1)[4],
+                        const float (*v2)[4],
+                        boolean frontfacing);
 
 #endif
index 73fb70599c968a9fe7ffb7327a698c1bd7a63b4d..3742fd672b2d74c3e41568a074afce2e807e2c8d 100644 (file)
@@ -151,13 +151,34 @@ static void perspective_coef( struct lp_rast_shader_inputs *inputs,
  */
 void lp_setup_tri_coef( struct lp_setup_context *setup,
                        struct lp_rast_shader_inputs *inputs,
-                       const struct lp_tri_info *info)
+                        const float (*v0)[4],
+                        const float (*v1)[4],
+                        const float (*v2)[4],
+                        boolean frontfacing)
 {
    unsigned slot;
+   struct lp_tri_info info;
+   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];
+   float oneoverarea = 1.0f / (dx01 * dy20 - dx20 * dy01);
+
+   info.v0 = v0;
+   info.v1 = v1;
+   info.v2 = v2;
+   info.frontfacing = frontfacing;
+   info.x0_center = v0[0][0] - setup->pixel_offset;
+   info.y0_center = v0[0][1] - setup->pixel_offset;
+   info.dx01_ooa  = dx01 * oneoverarea;
+   info.dx20_ooa  = dx20 * oneoverarea;
+   info.dy01_ooa  = dy01 * oneoverarea;
+   info.dy20_ooa  = dy20 * oneoverarea;
+
 
    /* The internal position input is in slot zero:
     */
-   linear_coef(inputs, info, 0, 0);
+   linear_coef(inputs, &info, 0, 0);
 
    /* setup interpolation for all the remaining attributes:
     */
@@ -167,19 +188,19 @@ void lp_setup_tri_coef( struct lp_setup_context *setup,
       switch (setup->fs.input[slot].interp) {
       case LP_INTERP_CONSTANT:
          if (setup->flatshade_first) {
-           constant_coef4(inputs, info, slot+1, info->v0[vert_attr]);
+           constant_coef4(inputs, &info, slot+1, info.v0[vert_attr]);
          }
          else {
-           constant_coef4(inputs, info, slot+1, info->v2[vert_attr]);
+           constant_coef4(inputs, &info, slot+1, info.v2[vert_attr]);
          }
          break;
 
       case LP_INTERP_LINEAR:
-        linear_coef(inputs, info, slot+1, vert_attr);
+        linear_coef(inputs, &info, slot+1, vert_attr);
          break;
 
       case LP_INTERP_PERSPECTIVE:
-        perspective_coef(inputs, info, slot+1, vert_attr);
+        perspective_coef(inputs, &info, slot+1, vert_attr);
          break;
 
       case LP_INTERP_POSITION:
@@ -190,7 +211,7 @@ void lp_setup_tri_coef( struct lp_setup_context *setup,
          break;
 
       case LP_INTERP_FACING:
-         setup_facing_coef(inputs, info, slot+1);
+         setup_facing_coef(inputs, &info, slot+1);
          break;
 
       default:
index e3cc3f494c051fc85a2d4d944541660cb11b4377..72c0a9cb0b0c94b3c0f32e86f8262c8bbf0f4cec 100644 (file)
@@ -227,10 +227,6 @@ do_triangle_ccw(struct lp_setup_context *setup,
    struct lp_rast_triangle *tri;
    int x[3];
    int y[3];
-   float dy01, dy20;
-   float dx01, dx20;
-   float oneoverarea;
-   struct lp_tri_info info;
    int area;
    struct u_rect bbox;
    unsigned tri_bytes;
@@ -330,29 +326,9 @@ do_triangle_ccw(struct lp_setup_context *setup,
       return TRUE;
    }
 
-
-   /* 
-    */
-   dx01 = v0[0][0] - v1[0][0];
-   dy01 = v0[0][1] - v1[0][1];
-   dx20 = v2[0][0] - v0[0][0];
-   dy20 = v2[0][1] - v0[0][1];
-   oneoverarea = 1.0f / (dx01 * dy20 - dx20 * dy01);
-
-   info.v0 = v0;
-   info.v1 = v1;
-   info.v2 = v2;
-   info.frontfacing = frontfacing;
-   info.x0_center = v0[0][0] - setup->pixel_offset;
-   info.y0_center = v0[0][1] - setup->pixel_offset;
-   info.dx01_ooa  = dx01 * oneoverarea;
-   info.dx20_ooa  = dx20 * oneoverarea;
-   info.dy01_ooa  = dy01 * oneoverarea;
-   info.dy20_ooa  = dy20 * oneoverarea;
-
    /* Setup parameter interpolants:
     */
-   lp_setup_tri_coef( setup, &tri->inputs, &info );
+   lp_setup_tri_coef( setup, &tri->inputs, v0, v1, v2, frontfacing );
 
    tri->inputs.facing = frontfacing ? 1.0F : -1.0F;
    tri->inputs.disable = FALSE;