[Mesa-dev] [PATCH 3/3] st/mesa: Support an array for pipeline statistics query results.

Kenneth Graunke kenneth at whitecape.org
Sat Dec 15 09:44:56 UTC 2018


We can now simply index into an array of uint64_t values to read or
write the result, based on the query's index.  The structure is still
available and is interchangeable.

Cc: Roland Scheidegger <sroland at vmware.com>
---
 src/gallium/include/pipe/p_defines.h    |  3 ++
 src/mesa/state_tracker/st_cb_queryobj.c | 55 ++++++-------------------
 2 files changed, 15 insertions(+), 43 deletions(-)

This also lets me replace a 35 line switch statement in iris with

   result->pipeline_statistics_array[q->index] = q->result;

which is a bit nicer.

diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 21005955a36..817d4787f06 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -1082,6 +1082,9 @@ union pipe_query_result
    /* PIPE_QUERY_PIPELINE_STATISTICS */
    struct pipe_query_data_pipeline_statistics pipeline_statistics;
 
+   /* PIPE_QUERY_PIPELINE_STATISTICS, but as an array of values */
+   uint64_t pipeline_statistics_array[11];
+
    /* batch queries (variable length) */
    union pipe_numeric_type_union batch[1];
 };
diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c
index a0ed309c2b3..81d63bb0401 100644
--- a/src/mesa/state_tracker/st_cb_queryobj.c
+++ b/src/mesa/state_tracker/st_cb_queryobj.c
@@ -259,52 +259,21 @@ get_query_result(struct pipe_context *pipe,
    if (!pipe->get_query_result(pipe, stq->pq, wait, &data))
       return FALSE;
 
-   switch (stq->base.Target) {
-   case GL_VERTICES_SUBMITTED_ARB:
-      stq->base.Result = data.pipeline_statistics.ia_vertices;
-      break;
-   case GL_PRIMITIVES_SUBMITTED_ARB:
-      stq->base.Result = data.pipeline_statistics.ia_primitives;
-      break;
-   case GL_VERTEX_SHADER_INVOCATIONS_ARB:
-      stq->base.Result = data.pipeline_statistics.vs_invocations;
-      break;
-   case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
-      stq->base.Result = data.pipeline_statistics.hs_invocations;
-      break;
-   case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
-      stq->base.Result = data.pipeline_statistics.ds_invocations;
-      break;
-   case GL_GEOMETRY_SHADER_INVOCATIONS:
-      stq->base.Result = data.pipeline_statistics.gs_invocations;
+   switch (stq->type) {
+   case PIPE_QUERY_PIPELINE_STATISTICS: {
+      unsigned index = target_to_index(&stq->base);
+      assert(index < 11);
+      stq->base.Result = data.pipeline_statistics_array[index];
       break;
-   case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB:
-      stq->base.Result = data.pipeline_statistics.gs_primitives;
-      break;
-   case GL_FRAGMENT_SHADER_INVOCATIONS_ARB:
-      stq->base.Result = data.pipeline_statistics.ps_invocations;
-      break;
-   case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
-      stq->base.Result = data.pipeline_statistics.cs_invocations;
-      break;
-   case GL_CLIPPING_INPUT_PRIMITIVES_ARB:
-      stq->base.Result = data.pipeline_statistics.c_invocations;
-      break;
-   case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:
-      stq->base.Result = data.pipeline_statistics.c_primitives;
+   }
+   case PIPE_QUERY_OCCLUSION_PREDICATE:
+   case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
+   case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
+   case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
+      stq->base.Result = !!data.b;
       break;
    default:
-      switch (stq->type) {
-      case PIPE_QUERY_OCCLUSION_PREDICATE:
-      case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
-      case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
-      case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
-         stq->base.Result = !!data.b;
-         break;
-      default:
-         stq->base.Result = data.u64;
-         break;
-      }
+      stq->base.Result = data.u64;
       break;
    }
 
-- 
2.19.1



More information about the mesa-dev mailing list