[Mesa-dev] [PATCH 2/3] llvmpipe: support nested/overlapping queries for all query types

sroland at vmware.com sroland at vmware.com
Fri Aug 23 14:10:46 PDT 2013


From: Roland Scheidegger <sroland at vmware.com>

There's just no way resetting the counters is working with nested/overlapping
queries.
---
 src/gallium/drivers/llvmpipe/lp_query.c      |   35 ++++++++++++++------------
 src/gallium/drivers/llvmpipe/lp_query.h      |    1 -
 src/gallium/drivers/llvmpipe/lp_setup_vbuf.c |    2 +-
 3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_query.c b/src/gallium/drivers/llvmpipe/lp_query.c
index cea2d07..4fb707b 100644
--- a/src/gallium/drivers/llvmpipe/lp_query.c
+++ b/src/gallium/drivers/llvmpipe/lp_query.c
@@ -154,7 +154,7 @@ llvmpipe_get_query_result(struct pipe_context *pipe,
       *result = pq->num_primitives_written;
       break;
    case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
-      vresult->b = pq->so_has_overflown;
+      vresult->b = pq->num_primitives_generated > pq->num_primitives_written;
       break;
    case PIPE_QUERY_SO_STATISTICS: {
       struct pipe_query_data_so_statistics *stats =
@@ -204,21 +204,18 @@ llvmpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
 
    switch (pq->type) {
    case PIPE_QUERY_PRIMITIVES_EMITTED:
-      pq->num_primitives_written = 0;
-      llvmpipe->so_stats.num_primitives_written = 0;
+      pq->num_primitives_written = llvmpipe->so_stats.num_primitives_written;
       break;
    case PIPE_QUERY_PRIMITIVES_GENERATED:
-      pq->num_primitives_generated = 0;
-      llvmpipe->num_primitives_generated = 0;
+      pq->num_primitives_generated = llvmpipe->num_primitives_generated;
       break;
    case PIPE_QUERY_SO_STATISTICS:
-      pq->num_primitives_written = 0;
-      llvmpipe->so_stats.num_primitives_written = 0;
-      pq->num_primitives_generated = 0;
-      llvmpipe->num_primitives_generated = 0;
+      pq->num_primitives_written = llvmpipe->so_stats.num_primitives_written;
+      pq->num_primitives_generated = llvmpipe->num_primitives_generated;
       break;
    case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
-      pq->so_has_overflown = FALSE;
+      pq->num_primitives_written = llvmpipe->so_stats.num_primitives_written;
+      pq->num_primitives_generated = llvmpipe->num_primitives_generated;
       break;
    case PIPE_QUERY_PIPELINE_STATISTICS:
       /* reset our cache */
@@ -251,18 +248,24 @@ llvmpipe_end_query(struct pipe_context *pipe, struct pipe_query *q)
    switch (pq->type) {
 
    case PIPE_QUERY_PRIMITIVES_EMITTED:
-      pq->num_primitives_written = llvmpipe->so_stats.num_primitives_written;
+      pq->num_primitives_written =
+         llvmpipe->so_stats.num_primitives_written - pq->num_primitives_written;
       break;
    case PIPE_QUERY_PRIMITIVES_GENERATED:
-      pq->num_primitives_generated = llvmpipe->num_primitives_generated;
+      pq->num_primitives_generated =
+         llvmpipe->num_primitives_generated - pq->num_primitives_generated;
       break;
    case PIPE_QUERY_SO_STATISTICS:
-      pq->num_primitives_written = llvmpipe->so_stats.num_primitives_written;
-      pq->num_primitives_generated = llvmpipe->num_primitives_generated;
+      pq->num_primitives_written =
+         llvmpipe->so_stats.num_primitives_written - pq->num_primitives_written;
+      pq->num_primitives_generated =
+         llvmpipe->num_primitives_generated - pq->num_primitives_generated;
       break;
    case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
-      pq->so_has_overflown = (llvmpipe->num_primitives_generated >
-                              llvmpipe->so_stats.num_primitives_written);
+      pq->num_primitives_written =
+         llvmpipe->so_stats.num_primitives_written - pq->num_primitives_written;
+      pq->num_primitives_generated =
+         llvmpipe->num_primitives_generated - pq->num_primitives_generated;
       break;
    case PIPE_QUERY_PIPELINE_STATISTICS:
       pq->stats.ia_vertices =
diff --git a/src/gallium/drivers/llvmpipe/lp_query.h b/src/gallium/drivers/llvmpipe/lp_query.h
index 62ad5fd..cd47fb0 100644
--- a/src/gallium/drivers/llvmpipe/lp_query.h
+++ b/src/gallium/drivers/llvmpipe/lp_query.h
@@ -48,7 +48,6 @@ struct llvmpipe_query {
    unsigned type;                   /* PIPE_QUERY_* */
    unsigned num_primitives_generated;
    unsigned num_primitives_written;
-   boolean so_has_overflown;
 
    struct pipe_query_data_pipeline_statistics stats;
 };
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
index 1ea6bcf..9e69591 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
@@ -542,7 +542,7 @@ lp_setup_so_info(struct vbuf_render *vbr, uint primitives, uint vertices,
    struct llvmpipe_context *lp = llvmpipe_context(setup->pipe);
 
    lp->so_stats.num_primitives_written += primitives;
-   lp->so_stats.primitives_storage_needed =
+   lp->so_stats.primitives_storage_needed +=
       vertices * 4 /*sizeof(float|int32)*/ * 4 /*x,y,z,w*/;
    lp->num_primitives_generated += prim_generated;
 }
-- 
1.7.9.5


More information about the mesa-dev mailing list