draw: fix clipper invocation statistics
authorZack Rusin <zackr@vmware.com>
Thu, 6 Jun 2013 12:49:09 +0000 (08:49 -0400)
committerZack Rusin <zackr@vmware.com>
Tue, 11 Jun 2013 02:04:28 +0000 (22:04 -0400)
We need to figure out the number of invocations of the clipper
before the emit, because in the emit we are after clipping
where the number of primitives will be equal to number of clipper
invocations minus the clipped primitives. So our computations
were always off by the number of clipped primitives.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pt_emit.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c

index e8480f6ba73a8fc43a075b72dcaaf77a173c5818..81b3068553d877b7653bcdf9d12e0bb01a48f8e8 100644 (file)
@@ -37,6 +37,7 @@
 #include "util/u_cpu_detect.h"
 #include "util/u_inlines.h"
 #include "util/u_helpers.h"
+#include "util/u_prim.h"
 #include "draw_context.h"
 #include "draw_vs.h"
 #include "draw_gs.h"
@@ -925,3 +926,27 @@ draw_collect_pipeline_statistics(struct draw_context *draw,
 {
    draw->collect_statistics = enable;
 }
+
+/**
+ * Computes clipper invocation statistics.
+ *
+ * Figures out how many primitives would have been
+ * sent to the clipper given the specified
+ * prim info data.
+ */
+void
+draw_stats_clipper_primitives(struct draw_context *draw,
+                              const struct draw_prim_info *prim_info)
+{
+   if (draw->collect_statistics) {
+      unsigned start, i;
+      for (start = i = 0;
+           i < prim_info->primitive_count;
+           start += prim_info->primitive_lengths[i], i++)
+      {
+         draw->statistics.c_invocations +=
+            u_decomposed_prims_for_vertices(prim_info->prim,
+                                            prim_info->primitive_lengths[i]);
+      }
+   }
+}
index 8777e8617f775efa1fd22bbb8a5af719229465ce..e08173580b7a660b5310b6b5e94258b4853dfd98 100644 (file)
@@ -461,6 +461,10 @@ draw_get_rasterizer_no_cull( struct draw_context *draw,
                              boolean scissor,
                              boolean flatshade );
 
+void
+draw_stats_clipper_primitives(struct draw_context *draw,
+                              const struct draw_prim_info *prim_info);
+
 
 /** 
  * Return index i from the index buffer.
index b3d3546402dde0f08c31bc31c4b9a34014a9b5d7..ea02554f83c76318c13826a77bdbe6ba18412cb9 100644 (file)
@@ -180,12 +180,6 @@ draw_pt_emit(struct pt_emit *emit,
         i < prim_info->primitive_count;
         start += prim_info->primitive_lengths[i], i++)
    {
-      if (draw->collect_statistics) {
-         draw->statistics.c_invocations +=
-            u_decomposed_prims_for_vertices(prim_info->prim,
-                                            prim_info->primitive_lengths[i]);
-      }
-         
       render->draw_elements(render,
                             elts + start,
                             prim_info->primitive_lengths[i]);
index 6d1bd116ba7d01c18b4c9d4cd85bdafb88183a83..84f86ae75ee6118e42a7f3dbd96d755d5e55a797 100644 (file)
@@ -317,6 +317,8 @@ static void fetch_pipeline_generic( struct draw_pt_middle_end *middle,
     */
    draw_pt_so_emit( fpme->so_emit, vert_info, prim_info );
 
+   draw_stats_clipper_primitives(draw, prim_info);
+
    /*
     * if there's no position, need to stop now, or the latter stages
     * will try to access non-existent position output.
index ecb7a6b8f759f75f49e5bc5c7e820ee1ef0881d7..2e47fad551a3a667e7204ac1f30c853e9141bfef 100644 (file)
@@ -411,6 +411,8 @@ llvm_pipeline_generic( struct draw_pt_middle_end *middle,
    /* stream output needs to be done before clipping */
    draw_pt_so_emit( fpme->so_emit, vert_info, prim_info );
 
+   draw_stats_clipper_primitives(draw, prim_info);
+
    /*
     * if there's no position, need to stop now, or the latter stages
     * will try to access non-existent position output.