llvmpipe: support nested/overlapping queries for all query types
authorRoland Scheidegger <sroland@vmware.com>
Fri, 23 Aug 2013 19:25:01 +0000 (21:25 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 27 Aug 2013 14:59:01 +0000 (16:59 +0200)
There's just no way resetting the counters is working with nested/overlapping
queries.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/llvmpipe/lp_query.c
src/gallium/drivers/llvmpipe/lp_query.h
src/gallium/drivers/llvmpipe/lp_setup_vbuf.c

index cea2d07394e7f7e856e4693a31c724d4e01f3d8b..4fb707b023399a442cc5cd93ff1beae36f58cbc4 100644 (file)
@@ -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 =
index 62ad5fde188b48cf0326889153d2db1cd7b8a647..cd47fb0f4cf2fa4ee75d025d2dcf413c4f8aa27a 100644 (file)
@@ -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;
 };
index 1ea6bcf5b005adcbb869655d2cbd5ccd7dbac1ae..9e69591116aebd18d3cfc729e3bbcab45127011c 100644 (file)
@@ -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;
 }