llvmpipe/query: add support for indexed queries
authorDave Airlie <airlied@redhat.com>
Thu, 23 Jan 2020 05:48:46 +0000 (15:48 +1000)
committerMarge Bot <eric+marge@anholt.net>
Fri, 7 Feb 2020 00:54:42 +0000 (00:54 +0000)
This adds support for the queries needed for gpu_shader5 vertex streams

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

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

index 0e029f591224b384cb5086be66c8ada04d02f263..b9bdfa1097836920070f00f409064bd369337e94 100644 (file)
@@ -96,7 +96,7 @@ struct llvmpipe_context {
 
    struct draw_so_target *so_targets[PIPE_MAX_SO_BUFFERS];
    int num_so_targets;
-   struct pipe_query_data_so_statistics so_stats;
+   struct pipe_query_data_so_statistics so_stats[PIPE_MAX_VERTEX_STREAMS];
 
    struct pipe_query_data_pipeline_statistics pipeline_statistics;
    unsigned active_statistics_queries;
index 276fd3bab7843d173061a5a982f46482a2ea03fd..75e3b47bfdbb5b25a65b62c9e2fd8cda35093652 100644 (file)
@@ -61,6 +61,7 @@ llvmpipe_create_query(struct pipe_context *pipe,
 
    if (pq) {
       pq->type = type;
+      pq->index = index;
    }
 
    return (struct pipe_query *) pq;
@@ -357,20 +358,20 @@ 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.num_primitives_written;
+      pq->num_primitives_written = llvmpipe->so_stats[pq->index].num_primitives_written;
       break;
    case PIPE_QUERY_PRIMITIVES_GENERATED:
-      pq->num_primitives_generated = llvmpipe->so_stats.primitives_storage_needed;
+      pq->num_primitives_generated = 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.num_primitives_written;
-      pq->num_primitives_generated = llvmpipe->so_stats.primitives_storage_needed;
+      pq->num_primitives_written = llvmpipe->so_stats[pq->index].num_primitives_written;
+      pq->num_primitives_generated = 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.num_primitives_written;
-      pq->num_primitives_generated = llvmpipe->so_stats.primitives_storage_needed;
+      pq->num_primitives_written = llvmpipe->so_stats[pq->index].num_primitives_written;
+      pq->num_primitives_generated = llvmpipe->so_stats[pq->index].primitives_storage_needed;
       break;
    case PIPE_QUERY_PIPELINE_STATISTICS:
       /* reset our cache */
@@ -406,26 +407,26 @@ llvmpipe_end_query(struct pipe_context *pipe, struct pipe_query *q)
 
    case PIPE_QUERY_PRIMITIVES_EMITTED:
       pq->num_primitives_written =
-         llvmpipe->so_stats.num_primitives_written - pq->num_primitives_written;
+         llvmpipe->so_stats[pq->index].num_primitives_written - pq->num_primitives_written;
       break;
    case PIPE_QUERY_PRIMITIVES_GENERATED:
       assert(llvmpipe->active_primgen_queries);
       llvmpipe->active_primgen_queries--;
       pq->num_primitives_generated =
-         llvmpipe->so_stats.primitives_storage_needed - pq->num_primitives_generated;
+         llvmpipe->so_stats[pq->index].primitives_storage_needed - pq->num_primitives_generated;
       break;
    case PIPE_QUERY_SO_STATISTICS:
       pq->num_primitives_written =
-         llvmpipe->so_stats.num_primitives_written - pq->num_primitives_written;
+         llvmpipe->so_stats[pq->index].num_primitives_written - pq->num_primitives_written;
       pq->num_primitives_generated =
-         llvmpipe->so_stats.primitives_storage_needed - pq->num_primitives_generated;
+         llvmpipe->so_stats[pq->index].primitives_storage_needed - pq->num_primitives_generated;
       break;
    case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
    case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
       pq->num_primitives_written =
-         llvmpipe->so_stats.num_primitives_written - pq->num_primitives_written;
+         llvmpipe->so_stats[pq->index].num_primitives_written - pq->num_primitives_written;
       pq->num_primitives_generated =
-         llvmpipe->so_stats.primitives_storage_needed - pq->num_primitives_generated;
+         llvmpipe->so_stats[pq->index].primitives_storage_needed - pq->num_primitives_generated;
       break;
    case PIPE_QUERY_PIPELINE_STATISTICS:
       pq->stats.ia_vertices =
index 797375c8843f82bc921037842a6891482df78978..aa6707ce661b341a40ecb3cfae82cbd370d38748 100644 (file)
@@ -46,6 +46,7 @@ struct llvmpipe_query {
    uint64_t end[LP_MAX_THREADS];    /* end count value for each thread */
    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;
 
index 5dd318329e0919b5407cd6dd5b753925562d4b19..a400d79fb87105b3dd1ff0428de1ff385838332e 100644 (file)
@@ -549,8 +549,8 @@ lp_setup_so_info(struct vbuf_render *vbr, uint stream, uint primitives, uint pri
    struct lp_setup_context *setup = lp_setup_context(vbr);
    struct llvmpipe_context *lp = llvmpipe_context(setup->pipe);
 
-   lp->so_stats.num_primitives_written += primitives;
-   lp->so_stats.primitives_storage_needed += prim_generated;
+   lp->so_stats[stream].num_primitives_written += primitives;
+   lp->so_stats[stream].primitives_storage_needed += prim_generated;
 }
 
 static void