softpipe: support nested/overlapping queries for all query types
authorRoland Scheidegger <sroland@vmware.com>
Fri, 23 Aug 2013 19:23:07 +0000 (21:23 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 27 Aug 2013 14:58:20 +0000 (16:58 +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/softpipe/sp_prim_vbuf.c
src/gallium/drivers/softpipe/sp_query.c

index 5d0b5e1c5883f0f225b35de8e342d06357a4378f..80c6450bb6b4c2f099017168afc11cf63c2bf080 100644 (file)
@@ -595,7 +595,7 @@ sp_vbuf_so_info(struct vbuf_render *vbr, uint primitives, uint vertices,
    struct softpipe_context *softpipe = cvbr->softpipe;
 
    softpipe->so_stats.num_primitives_written += primitives;
-   softpipe->so_stats.primitives_storage_needed =
+   softpipe->so_stats.primitives_storage_needed +=
       vertices * 4 /*sizeof(float|int32)*/ * 4 /*x,y,z,w*/;
    softpipe->num_primitives_generated += prim_generated;
 }
index daeef53b86fd0d1b70932f61d57b17dd6ddade3b..ca15f03464d4499d8d94cf968cd371f82ca1da61 100644 (file)
@@ -99,22 +99,17 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
       sq->start = os_time_get_nano();
       break;
    case PIPE_QUERY_SO_STATISTICS:
-      sq->so.primitives_storage_needed = 0;
-      sq->num_primitives_generated = 0;
-      softpipe->num_primitives_generated = 0;
-      sq->so.num_primitives_written = 0;
-      softpipe->so_stats.num_primitives_written = 0;
+      sq->so.num_primitives_written = softpipe->so_stats.num_primitives_written;
+      sq->so.primitives_storage_needed = softpipe->num_primitives_generated;
       break;
    case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
       sq->end = FALSE;
       break;
    case PIPE_QUERY_PRIMITIVES_EMITTED:
-      sq->so.num_primitives_written = 0;
-      softpipe->so_stats.num_primitives_written = 0;
+      sq->so.num_primitives_written = softpipe->so_stats.num_primitives_written;
       break;
    case PIPE_QUERY_PRIMITIVES_GENERATED:
-      sq->num_primitives_generated = 0;
-      softpipe->num_primitives_generated = 0;
+      sq->num_primitives_generated = softpipe->num_primitives_generated;
       break;
    case PIPE_QUERY_TIMESTAMP:
    case PIPE_QUERY_GPU_FINISHED:
@@ -158,21 +153,25 @@ softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q)
       sq->end = os_time_get_nano();
       break;
    case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
-      sq->end = (softpipe->num_primitives_generated >
-                 softpipe->so_stats.num_primitives_written);
+      sq->so.num_primitives_written =
+         softpipe->so_stats.num_primitives_written - sq->so.num_primitives_written;
+      sq->num_primitives_generated =
+         softpipe->num_primitives_generated - sq->num_primitives_generated;
+      sq->end = sq->num_primitives_generated > sq->so.num_primitives_written;
       break;
    case PIPE_QUERY_SO_STATISTICS:
-      sq->num_primitives_generated =
-         softpipe->num_primitives_generated;
       sq->so.num_primitives_written =
-         softpipe->so_stats.num_primitives_written;
+         softpipe->so_stats.num_primitives_written - sq->so.num_primitives_written;
+      sq->so.primitives_storage_needed =
+         softpipe->num_primitives_generated - sq->so.primitives_storage_needed;
       break;
    case PIPE_QUERY_PRIMITIVES_EMITTED:
       sq->so.num_primitives_written =
-         softpipe->so_stats.num_primitives_written;
+         softpipe->so_stats.num_primitives_written - sq->so.num_primitives_written;
       break;
    case PIPE_QUERY_PRIMITIVES_GENERATED:
-      sq->num_primitives_generated = softpipe->num_primitives_generated;
+      sq->num_primitives_generated =
+         softpipe->num_primitives_generated - sq->num_primitives_generated;
       break;
    case PIPE_QUERY_GPU_FINISHED:
    case PIPE_QUERY_TIMESTAMP_DISJOINT:
@@ -219,7 +218,7 @@ softpipe_get_query_result(struct pipe_context *pipe,
       struct pipe_query_data_so_statistics *stats =
          (struct pipe_query_data_so_statistics *)vresult;
       stats->num_primitives_written = sq->so.num_primitives_written;
-      stats->primitives_storage_needed = sq->num_primitives_generated;
+      stats->primitives_storage_needed = sq->so.primitives_storage_needed;
    }
       break;
    case PIPE_QUERY_PIPELINE_STATISTICS: