[Mesa-dev] [PATCH] llvmpipe: fix pipeline statistics with a null ps

Zack Rusin zackr at vmware.com
Mon Aug 12 22:45:04 PDT 2013


If the fragment shader is null then pixel shader invocations have
to be equal to zero. And if we're running a null ps then clipper
invocations and primitives should be equal to zero but only
if both stancil and depth testing are disabled.

Signed-off-by: Zack Rusin <zackr at vmware.com>
---
 src/gallium/drivers/llvmpipe/lp_query.c |   30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_query.c b/src/gallium/drivers/llvmpipe/lp_query.c
index cea2d07..fb24c36 100644
--- a/src/gallium/drivers/llvmpipe/lp_query.c
+++ b/src/gallium/drivers/llvmpipe/lp_query.c
@@ -32,6 +32,7 @@
 
 #include "draw/draw_context.h"
 #include "pipe/p_defines.h"
+#include "tgsi/tgsi_scan.h"
 #include "util/u_memory.h"
 #include "os/os_time.h"
 #include "lp_context.h"
@@ -95,6 +96,7 @@ llvmpipe_get_query_result(struct pipe_context *pipe,
                           union pipe_query_result *vresult)
 {
    struct llvmpipe_screen *screen = llvmpipe_screen(pipe->screen);
+   struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
    unsigned num_threads = MAX2(1, screen->num_threads);
    struct llvmpipe_query *pq = llvmpipe_query(q);
    uint64_t *result = (uint64_t *)vresult;
@@ -166,11 +168,31 @@ llvmpipe_get_query_result(struct pipe_context *pipe,
    case PIPE_QUERY_PIPELINE_STATISTICS: {
       struct pipe_query_data_pipeline_statistics *stats =
          (struct pipe_query_data_pipeline_statistics *)vresult;
-      /* only ps_invocations come from binned query */
-      for (i = 0; i < num_threads; i++) {
-         pq->stats.ps_invocations += pq->end[i];
+      /* If we're running on what's considrered a null fragment
+       * shader, i.e. fragment shader consisting of a single
+       * END opcode or if the fragment shader is null then
+       * the number of ps_invocations should be zero */
+      if (llvmpipe->fs && llvmpipe->fs->info.base.num_tokens > 1) {
+         /* only ps_invocations come from binned query */
+         for (i = 0; i < num_threads; i++) {
+            pq->stats.ps_invocations += pq->end[i];
+         }
+         pq->stats.ps_invocations *=
+            LP_RASTER_BLOCK_SIZE * LP_RASTER_BLOCK_SIZE;
+      } else {
+         /* 
+          * Clipper primitives and invocations are equal to zero
+          * if we're running a null fragment shader but only
+          * if both stencil and depth testing are disabled.
+          */
+         if (!llvmpipe->depth_stencil->depth.enabled &&
+             !llvmpipe->depth_stencil->stencil[0].enabled &&
+             !llvmpipe->depth_stencil->stencil[1].enabled) {
+            pq->stats.c_primitives = 0;
+            pq->stats.c_invocations = 0;
+         }
+         pq->stats.ps_invocations = 0;
       }
-      pq->stats.ps_invocations *= LP_RASTER_BLOCK_SIZE * LP_RASTER_BLOCK_SIZE;
       *stats = pq->stats;
    }
       break;
-- 
1.7.10.4


More information about the mesa-dev mailing list