llvmpipe/query: fix transform feedback overflow any queries.
authorDave Airlie <airlied@redhat.com>
Fri, 27 Mar 2020 03:29:59 +0000 (13:29 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 15 Apr 2020 04:26:03 +0000 (14:26 +1000)
The any queries need to signal if any stream has overflowed,
so we have to track all the streams.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4560>

src/gallium/drivers/llvmpipe/lp_query.c
src/gallium/drivers/llvmpipe/lp_query.h

index c922caa8490874836da4c1c0663f987eb2552def..6fac76b94fb89149c1fdbd5dde4328789a23bd5a 100644 (file)
@@ -151,20 +151,24 @@ llvmpipe_get_query_result(struct pipe_context *pipe,
       vresult->b = true;
       break;
    case PIPE_QUERY_PRIMITIVES_GENERATED:
-      *result = pq->num_primitives_generated;
+      *result = pq->num_primitives_generated[0];
       break;
    case PIPE_QUERY_PRIMITIVES_EMITTED:
-      *result = pq->num_primitives_written;
+      *result = pq->num_primitives_written[0];
       break;
-   case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
    case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
-      vresult->b = pq->num_primitives_generated > pq->num_primitives_written;
+      vresult->b = false;
+      for (unsigned s = 0; s < PIPE_MAX_VERTEX_STREAMS; s++)
+         vresult->b |= pq->num_primitives_generated[s] > pq->num_primitives_written[s];
+      break;
+   case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
+      vresult->b = pq->num_primitives_generated[0] > pq->num_primitives_written[0];
       break;
    case PIPE_QUERY_SO_STATISTICS: {
       struct pipe_query_data_so_statistics *stats =
          (struct pipe_query_data_so_statistics *)vresult;
-      stats->num_primitives_written = pq->num_primitives_written;
-      stats->primitives_storage_needed = pq->num_primitives_generated;
+      stats->num_primitives_written = pq->num_primitives_written[0];
+      stats->primitives_storage_needed = pq->num_primitives_generated[0];
    }
       break;
    case PIPE_QUERY_PIPELINE_STATISTICS: {
@@ -243,10 +247,10 @@ llvmpipe_get_query_result_resource(struct pipe_context *pipe,
          }
          break;
       case PIPE_QUERY_PRIMITIVES_GENERATED:
-         value = pq->num_primitives_generated;
+         value = pq->num_primitives_generated[0];
          break;
       case PIPE_QUERY_PRIMITIVES_EMITTED:
-         value = pq->num_primitives_written;
+         value = pq->num_primitives_written[0];
          break;
       case PIPE_QUERY_TIMESTAMP:
          for (i = 0; i < num_threads; i++) {
@@ -255,9 +259,13 @@ llvmpipe_get_query_result_resource(struct pipe_context *pipe,
             }
          }
          break;
-      case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
       case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
-         value = !!(pq->num_primitives_generated > pq->num_primitives_written);
+         value = 0;
+         for (unsigned s = 0; s < PIPE_MAX_VERTEX_STREAMS; s++)
+            value |= !!(pq->num_primitives_generated[s] > pq->num_primitives_written[s]);
+         break;
+      case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
+         value = !!(pq->num_primitives_generated[0] > pq->num_primitives_written[0]);
          break;
       case PIPE_QUERY_PIPELINE_STATISTICS:
          switch ((enum pipe_statistics_query_index)index) {
@@ -358,20 +366,25 @@ llvmpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
 
    switch (pq->type) {
    case PIPE_QUERY_PRIMITIVES_EMITTED:
-      pq->num_primitives_written = llvmpipe->so_stats[pq->index].num_primitives_written;
+      pq->num_primitives_written[0] = llvmpipe->so_stats[pq->index].num_primitives_written;
       break;
    case PIPE_QUERY_PRIMITIVES_GENERATED:
-      pq->num_primitives_generated = llvmpipe->so_stats[pq->index].primitives_storage_needed;
+      pq->num_primitives_generated[0] = llvmpipe->so_stats[pq->index].primitives_storage_needed;
       llvmpipe->active_primgen_queries++;
       break;
    case PIPE_QUERY_SO_STATISTICS:
-      pq->num_primitives_written = llvmpipe->so_stats[pq->index].num_primitives_written;
-      pq->num_primitives_generated = llvmpipe->so_stats[pq->index].primitives_storage_needed;
+      pq->num_primitives_written[0] = llvmpipe->so_stats[pq->index].num_primitives_written;
+      pq->num_primitives_generated[0] = llvmpipe->so_stats[pq->index].primitives_storage_needed;
       break;
-   case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
    case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
-      pq->num_primitives_written = llvmpipe->so_stats[pq->index].num_primitives_written;
-      pq->num_primitives_generated = llvmpipe->so_stats[pq->index].primitives_storage_needed;
+      for (unsigned s = 0; s < PIPE_MAX_VERTEX_STREAMS; s++) {
+         pq->num_primitives_written[s] = llvmpipe->so_stats[s].num_primitives_written;
+         pq->num_primitives_generated[s] = llvmpipe->so_stats[s].primitives_storage_needed;
+      }
+      break;
+   case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
+      pq->num_primitives_written[0] = llvmpipe->so_stats[pq->index].num_primitives_written;
+      pq->num_primitives_generated[0] = llvmpipe->so_stats[pq->index].primitives_storage_needed;
       break;
    case PIPE_QUERY_PIPELINE_STATISTICS:
       /* reset our cache */
@@ -406,27 +419,34 @@ 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[pq->index].num_primitives_written - pq->num_primitives_written;
+      pq->num_primitives_written[0] =
+         llvmpipe->so_stats[pq->index].num_primitives_written - pq->num_primitives_written[0];
       break;
    case PIPE_QUERY_PRIMITIVES_GENERATED:
       assert(llvmpipe->active_primgen_queries);
       llvmpipe->active_primgen_queries--;
-      pq->num_primitives_generated =
-         llvmpipe->so_stats[pq->index].primitives_storage_needed - pq->num_primitives_generated;
+      pq->num_primitives_generated[0] =
+         llvmpipe->so_stats[pq->index].primitives_storage_needed - pq->num_primitives_generated[0];
       break;
    case PIPE_QUERY_SO_STATISTICS:
-      pq->num_primitives_written =
-         llvmpipe->so_stats[pq->index].num_primitives_written - pq->num_primitives_written;
-      pq->num_primitives_generated =
-         llvmpipe->so_stats[pq->index].primitives_storage_needed - pq->num_primitives_generated;
+      pq->num_primitives_written[0] =
+         llvmpipe->so_stats[pq->index].num_primitives_written - pq->num_primitives_written[0];
+      pq->num_primitives_generated[0] =
+         llvmpipe->so_stats[pq->index].primitives_storage_needed - pq->num_primitives_generated[0];
       break;
-   case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
    case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
-      pq->num_primitives_written =
-         llvmpipe->so_stats[pq->index].num_primitives_written - pq->num_primitives_written;
-      pq->num_primitives_generated =
-         llvmpipe->so_stats[pq->index].primitives_storage_needed - pq->num_primitives_generated;
+      for (unsigned s = 0; s < PIPE_MAX_VERTEX_STREAMS; s++) {
+         pq->num_primitives_written[s] =
+            llvmpipe->so_stats[s].num_primitives_written - pq->num_primitives_written[s];
+         pq->num_primitives_generated[s] =
+            llvmpipe->so_stats[s].primitives_storage_needed - pq->num_primitives_generated[s];
+      }
+      break;
+   case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
+      pq->num_primitives_written[0] =
+         llvmpipe->so_stats[pq->index].num_primitives_written - pq->num_primitives_written[0];
+      pq->num_primitives_generated[0] =
+         llvmpipe->so_stats[pq->index].primitives_storage_needed - pq->num_primitives_generated[0];
       break;
    case PIPE_QUERY_PIPELINE_STATISTICS:
       pq->stats.ia_vertices =
index aa6707ce661b341a40ecb3cfae82cbd370d38748..d73640dd29c0353115c2b88191e2c8e3c6f555ef 100644 (file)
@@ -47,8 +47,8 @@ struct llvmpipe_query {
    struct lp_fence *fence;          /* fence from last scene this was binned in */
    unsigned type;                   /* PIPE_QUERY_* */
    unsigned index;
-   unsigned num_primitives_generated;
-   unsigned num_primitives_written;
+   unsigned num_primitives_generated[PIPE_MAX_VERTEX_STREAMS];
+   unsigned num_primitives_written[PIPE_MAX_VERTEX_STREAMS];
 
    struct pipe_query_data_pipeline_statistics stats;
 };