llvmpipe: remove misleading debug string
[mesa.git] / src / gallium / drivers / llvmpipe / lp_setup_tri.c
index 15c414d8c3b654860a82ed6990340c3c4b3713a7..bfb6bf277bd93f85fc432cafa292c516f8124809 100644 (file)
@@ -35,9 +35,9 @@
 #include "util/u_sse.h"
 #include "lp_perf.h"
 #include "lp_setup_context.h"
-#include "lp_setup_coef.h"
 #include "lp_rast.h"
 #include "lp_state_fs.h"
+#include "lp_state_setup.h"
 
 #define NUM_CHANNELS 4
 
@@ -68,7 +68,7 @@ fixed_to_float(int a)
  * immediately after it.
  * The memory is allocated from the per-scene pool, not per-tile.
  * \param tri_size  returns number of bytes allocated
- * \param nr_inputs  number of fragment shader inputs
+ * \param num_inputs  number of fragment shader inputs
  * \return pointer to triangle space
  */
 struct lp_rast_triangle *
@@ -105,25 +105,26 @@ lp_setup_print_vertex(struct lp_setup_context *setup,
                       const char *name,
                       const float (*v)[4])
 {
+   const struct lp_setup_variant_key *key = &setup->setup.variant->key;
    int i, j;
 
    debug_printf("   wpos (%s[0]) xyzw %f %f %f %f\n",
                 name,
                 v[0][0], v[0][1], v[0][2], v[0][3]);
 
-   for (i = 0; i < setup->fs.nr_inputs; i++) {
-      const float *in = v[setup->fs.input[i].src_index];
+   for (i = 0; i < key->num_inputs; i++) {
+      const float *in = v[key->inputs[i].src_index];
 
       debug_printf("  in[%d] (%s[%d]) %s%s%s%s ",
                    i, 
-                   name, setup->fs.input[i].src_index,
-                   (setup->fs.input[i].usage_mask & 0x1) ? "x" : " ",
-                   (setup->fs.input[i].usage_mask & 0x2) ? "y" : " ",
-                   (setup->fs.input[i].usage_mask & 0x4) ? "z" : " ",
-                   (setup->fs.input[i].usage_mask & 0x8) ? "w" : " ");
+                   name, key->inputs[i].src_index,
+                   (key->inputs[i].usage_mask & 0x1) ? "x" : " ",
+                   (key->inputs[i].usage_mask & 0x2) ? "y" : " ",
+                   (key->inputs[i].usage_mask & 0x4) ? "z" : " ",
+                   (key->inputs[i].usage_mask & 0x8) ? "w" : " ");
 
       for (j = 0; j < 4; j++)
-         if (setup->fs.input[i].usage_mask & (1<<j))
+         if (key->inputs[i].usage_mask & (1<<j))
             debug_printf("%.5f ", in[j]);
 
       debug_printf("\n");
@@ -231,6 +232,7 @@ do_triangle_ccw(struct lp_setup_context *setup,
                boolean frontfacing )
 {
    struct lp_scene *scene = setup->scene;
+   const struct lp_setup_variant_key *key = &setup->setup.variant->key;
    struct lp_rast_triangle *tri;
    struct lp_rast_plane *plane;
    int x[4];
@@ -293,10 +295,15 @@ 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,
-                                 setup->fs.nr_inputs,
+                                 key->num_inputs,
                                  nr_planes,
                                  &tri_bytes);
    if (!tri)
@@ -315,12 +322,24 @@ do_triangle_ccw(struct lp_setup_context *setup,
 
    /* Setup parameter interpolants:
     */
-   lp_setup_tri_coef( setup, &tri->inputs, v0, v1, v2, frontfacing );
+   setup->setup.variant->jit_function( v0,
+                                      v1,
+                                      v2,
+                                      frontfacing,
+                                      GET_A0(&tri->inputs),
+                                      GET_DADX(&tri->inputs),
+                                      GET_DADY(&tri->inputs) );
 
    tri->inputs.frontfacing = frontfacing;
    tri->inputs.disable = FALSE;
    tri->inputs.opaque = setup->fs.current.variant->opaque;
 
+   if (0)
+      lp_dump_setup_coef(&setup->setup.variant->key,
+                        (const float (*)[4])GET_A0(&tri->inputs),
+                        (const float (*)[4])GET_DADX(&tri->inputs),
+                        (const float (*)[4])GET_DADY(&tri->inputs));
+
    plane = GET_PLANES(tri);
 
 #if defined(PIPE_ARCH_SSE)
@@ -487,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;
    }
 
@@ -545,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:
@@ -558,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)
@@ -612,15 +641,16 @@ lp_setup_bin_triangle( struct lp_setup_context *setup,
       struct lp_rast_plane *plane = GET_PLANES(tri);
       int c[MAX_PLANES];
       int ei[MAX_PLANES];
+
       int eo[MAX_PLANES];
       int xstep[MAX_PLANES];
       int ystep[MAX_PLANES];
       int x, y;
 
-      int ix0 = bbox->x0 / TILE_SIZE;
-      int iy0 = bbox->y0 / TILE_SIZE;
-      int ix1 = bbox->x1 / TILE_SIZE;
-      int iy1 = bbox->y1 / TILE_SIZE;
+      int ix0 = trimmed_box.x0 / TILE_SIZE;
+      int iy0 = trimmed_box.y0 / TILE_SIZE;
+      int ix1 = trimmed_box.x1 / TILE_SIZE;
+      int iy1 = trimmed_box.y1 / TILE_SIZE;
       
       for (i = 0; i < nr_planes; i++) {
          c[i] = (plane[i].c + 
@@ -785,6 +815,16 @@ static void triangle_both( struct lp_setup_context *setup,
 {
    float area = calc_area(v0, v1, v2);
 
+   if (0) {
+      assert(!util_is_inf_or_nan(v0[0][0]));
+      assert(!util_is_inf_or_nan(v0[0][1]));
+      assert(!util_is_inf_or_nan(v1[0][0]));
+      assert(!util_is_inf_or_nan(v1[0][1]));
+      assert(!util_is_inf_or_nan(v2[0][0]));
+      assert(!util_is_inf_or_nan(v2[0][1]));
+      assert(!util_is_inf_or_nan(area));
+   }
+
    if (area > 0.0f) 
       retry_triangle_ccw( setup, v0, v1, v2, setup->ccw_is_frontface );
    else if (area < 0.0f)