st/mesa: Make an enum for pipeline statistics query result indices.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 15 Dec 2018 05:09:32 +0000 (21:09 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 15 Jan 2019 19:43:04 +0000 (11:43 -0800)
Gallium handles pipeline statistics queries as a single query
(PIPE_QUERY_PIPELINE_STATISTICS) which returns a struct with 11 values.
Sometimes it's useful to refer to each of those values individually,
rather than as a group.  To avoid hardcoding numbers, we define a new
enum for each value.  Here, the name and enum value correspond to the
index in the struct pipe_query_data_pipeline_statistics result.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/gallium/include/pipe/p_defines.h
src/mesa/state_tracker/st_cb_queryobj.c

index 82c49c801e5cfdfb1c7f2cf7f00e9d660b18a082..4480b54eb2fa186be3d4d01e84708b3560b23d24 100644 (file)
@@ -568,6 +568,23 @@ enum pipe_query_type {
    PIPE_QUERY_DRIVER_SPECIFIC = 256,
 };
 
+/**
+ * Index for PIPE_QUERY_PIPELINE_STATISTICS subqueries.
+ */
+enum pipe_statistics_query_index {
+   PIPE_STAT_QUERY_IA_VERTICES,
+   PIPE_STAT_QUERY_IA_PRIMITIVES,
+   PIPE_STAT_QUERY_VS_INVOCATIONS,
+   PIPE_STAT_QUERY_GS_INVOCATIONS,
+   PIPE_STAT_QUERY_GS_PRIMITIVES,
+   PIPE_STAT_QUERY_C_INVOCATIONS,
+   PIPE_STAT_QUERY_C_PRIMITIVES,
+   PIPE_STAT_QUERY_PS_INVOCATIONS,
+   PIPE_STAT_QUERY_HS_INVOCATIONS,
+   PIPE_STAT_QUERY_DS_INVOCATIONS,
+   PIPE_STAT_QUERY_CS_INVOCATIONS,
+};
+
 /**
  * Conditional rendering modes
  */
index 69e6004c3f1f26837128da1c823c40229b87fe37..82f5324333669697b1720a68d7c9e47b29709d4d 100644 (file)
@@ -386,37 +386,37 @@ st_StoreQueryResult(struct gl_context *ctx, struct gl_query_object *q,
    } else if (stq->type == PIPE_QUERY_PIPELINE_STATISTICS) {
       switch (q->Target) {
       case GL_VERTICES_SUBMITTED_ARB:
-         index = 0;
+         index = PIPE_STAT_QUERY_IA_VERTICES;
          break;
       case GL_PRIMITIVES_SUBMITTED_ARB:
-         index = 1;
+         index = PIPE_STAT_QUERY_IA_PRIMITIVES;
          break;
       case GL_VERTEX_SHADER_INVOCATIONS_ARB:
-         index = 2;
+         index = PIPE_STAT_QUERY_VS_INVOCATIONS;
          break;
       case GL_GEOMETRY_SHADER_INVOCATIONS:
-         index = 3;
+         index = PIPE_STAT_QUERY_GS_INVOCATIONS;
          break;
       case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB:
-         index = 4;
+         index = PIPE_STAT_QUERY_GS_PRIMITIVES;
          break;
       case GL_CLIPPING_INPUT_PRIMITIVES_ARB:
-         index = 5;
+         index = PIPE_STAT_QUERY_C_INVOCATIONS;
          break;
       case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:
-         index = 6;
+         index = PIPE_STAT_QUERY_C_PRIMITIVES;
          break;
       case GL_FRAGMENT_SHADER_INVOCATIONS_ARB:
-         index = 7;
+         index = PIPE_STAT_QUERY_PS_INVOCATIONS;
          break;
       case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
-         index = 8;
+         index = PIPE_STAT_QUERY_HS_INVOCATIONS;
          break;
       case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
-         index = 9;
+         index = PIPE_STAT_QUERY_DS_INVOCATIONS;
          break;
       case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
-         index = 10;
+         index = PIPE_STAT_QUERY_CS_INVOCATIONS;
          break;
       default:
          unreachable("Unexpected target");