svga: minor cleanups, comments in svga_tgsi_insn.c
[mesa.git] / src / gallium / drivers / llvmpipe / lp_setup_tri.c
index c1ba52e8ca66229eb28b9517b78c73411fef6de4..bedd16beee1e1f80eb2665057d1e24f18c080064 100644 (file)
@@ -38,6 +38,7 @@
 #include "lp_rast.h"
 #include "lp_state_fs.h"
 #include "lp_state_setup.h"
+#include "lp_context.h"
 
 #define NUM_CHANNELS 4
 
@@ -203,7 +204,14 @@ lp_setup_whole_tile(struct lp_setup_context *setup,
    LP_COUNT(nr_fully_covered_64);
 
    /* if variant is opaque and scissor doesn't effect the tile */
-   if (inputs->opaque) {
+   /*
+    * Need to disable this optimization for layered rendering and cannot use
+    * setup->layer_slot here to determine it, because it could incorrectly
+    * reset the tile if a previous shader used layer_slot but not this one
+    * (or maybe even "undo" clears). So determine this from presence of layers
+    * instead (in which case layer_slot will have no effect).
+    */
+   if (inputs->opaque && scene->fb_max_layer == 0) {
       if (!scene->fb.zsbuf) {
          /*
           * All previous rendering will be overwritten so reset the bin.
@@ -247,6 +255,7 @@ do_triangle_ccw(struct lp_setup_context *setup,
    unsigned tri_bytes;
    int nr_planes = 3;
    unsigned scissor_index = 0;
+   unsigned layer = 0;
 
    /* Area should always be positive here */
    assert(position->area > 0);
@@ -258,12 +267,16 @@ do_triangle_ccw(struct lp_setup_context *setup,
       nr_planes = 7;
       if (setup->viewport_index_slot > 0) {
          unsigned *udata = (unsigned*)v0[setup->viewport_index_slot];
-         scissor_index = *udata;
+         scissor_index = lp_clamp_scissor_idx(*udata);
       }
    }
    else {
       nr_planes = 3;
    }
+   if (setup->layer_slot > 0) {
+      layer = *(unsigned*)v1[setup->layer_slot];
+      layer = MIN2(layer, scene->fb_max_layer);
+   }
 
    /* Bounding rectangle (in pixels) */
    {
@@ -321,6 +334,11 @@ do_triangle_ccw(struct lp_setup_context *setup,
 
    LP_COUNT(nr_tris);
 
+   if (setup->active_query[PIPE_QUERY_PIPELINE_STATISTICS]) {
+      struct llvmpipe_context *lp_context = (struct llvmpipe_context *)setup->pipe;
+      lp_context->pipeline_statistics.c_primitives++;
+   }
+
    /* Setup parameter interpolants:
     */
    setup->setup.variant->jit_function( v0,
@@ -334,6 +352,7 @@ do_triangle_ccw(struct lp_setup_context *setup,
    tri->inputs.frontfacing = frontfacing;
    tri->inputs.disable = FALSE;
    tri->inputs.opaque = setup->fs.current.variant->opaque;
+   tri->inputs.layer = layer;
 
    if (0)
       lp_dump_setup_coef(&setup->setup.variant->key,
@@ -519,7 +538,7 @@ do_triangle_ccw(struct lp_setup_context *setup,
       plane[6].eo = 0;
    }
 
-   return lp_setup_bin_triangle( setup, tri, &bbox, nr_planes, scissor_index );
+   return lp_setup_bin_triangle(setup, tri, &bbox, nr_planes, scissor_index);
 }
 
 /*
@@ -870,6 +889,8 @@ typedef void (*triangle_func_t)(struct lp_setup_context *setup,
 /**
  * Subdivide this triangle by bisecting edge (v0, v1).
  * \param pv  the provoking vertex (must = v0 or v1 or v2)
+ * TODO: should probably think about non-overflowing arithmetic elsewhere.
+ * This will definitely screw with pipeline counters for instance.
  */
 static void
 subdiv_tri(struct lp_setup_context *setup,