<div dir="ltr"><div>The series looks good. Another way to distinguish between return one and return all is to use "index". index <= 11 returns one. index == ~0 returns all. This is the least intrusive.</div><div><br></div><div>st/mesa and gallium/hud always want to get one.</div><div>st/nine and util/u_helpers always want to get all.<br></div><div><br></div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 15, 2018 at 4:45 AM Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Gallium handles pipeline statistics queries as a single query<br>
(PIPE_QUERY_PIPELINE_STATISTICS) which returns a struct with 11 values.<br>
Sometimes it's useful to refer to each of those values individually,<br>
rather than as a group.  To avoid hardcoding numbers, we define a new<br>
enum for each value.  Here, the name and enum value correspond to the<br>
index in the struct pipe_query_data_pipeline_statistics result.<br>
<br>
Cc: Roland Scheidegger <<a href="mailto:sroland@vmware.com" target="_blank">sroland@vmware.com</a>><br>
---<br>
 src/gallium/include/pipe/p_defines.h    | 17 +++++++++++++++++<br>
 src/mesa/state_tracker/st_cb_queryobj.c | 22 +++++++++++-----------<br>
 2 files changed, 28 insertions(+), 11 deletions(-)<br>
<br>
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h<br>
index 6d96f1ccb5b..21005955a36 100644<br>
--- a/src/gallium/include/pipe/p_defines.h<br>
+++ b/src/gallium/include/pipe/p_defines.h<br>
@@ -568,6 +568,23 @@ enum pipe_query_type {<br>
    PIPE_QUERY_DRIVER_SPECIFIC = 256,<br>
 };<br>
<br>
+/**<br>
+ * Index for PIPE_QUERY_PIPELINE_STATISTICS subqueries.<br>
+ */<br>
+enum pipe_statistics_query_index {<br>
+   PIPE_STAT_QUERY_IA_VERTICES,<br>
+   PIPE_STAT_QUERY_IA_PRIMITIVES,<br>
+   PIPE_STAT_QUERY_VS_INVOCATIONS,<br>
+   PIPE_STAT_QUERY_GS_INVOCATIONS,<br>
+   PIPE_STAT_QUERY_GS_PRIMITIVES,<br>
+   PIPE_STAT_QUERY_C_INVOCATIONS,<br>
+   PIPE_STAT_QUERY_C_PRIMITIVES,<br>
+   PIPE_STAT_QUERY_PS_INVOCATIONS,<br>
+   PIPE_STAT_QUERY_HS_INVOCATIONS,<br>
+   PIPE_STAT_QUERY_DS_INVOCATIONS,<br>
+   PIPE_STAT_QUERY_CS_INVOCATIONS,<br>
+};<br>
+<br>
 /**<br>
  * Conditional rendering modes<br>
  */<br>
diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c<br>
index 69e6004c3f1..82f53243336 100644<br>
--- a/src/mesa/state_tracker/st_cb_queryobj.c<br>
+++ b/src/mesa/state_tracker/st_cb_queryobj.c<br>
@@ -386,37 +386,37 @@ st_StoreQueryResult(struct gl_context *ctx, struct gl_query_object *q,<br>
    } else if (stq->type == PIPE_QUERY_PIPELINE_STATISTICS) {<br>
       switch (q->Target) {<br>
       case GL_VERTICES_SUBMITTED_ARB:<br>
-         index = 0;<br>
+         index = PIPE_STAT_QUERY_IA_VERTICES;<br>
          break;<br>
       case GL_PRIMITIVES_SUBMITTED_ARB:<br>
-         index = 1;<br>
+         index = PIPE_STAT_QUERY_IA_PRIMITIVES;<br>
          break;<br>
       case GL_VERTEX_SHADER_INVOCATIONS_ARB:<br>
-         index = 2;<br>
+         index = PIPE_STAT_QUERY_VS_INVOCATIONS;<br>
          break;<br>
       case GL_GEOMETRY_SHADER_INVOCATIONS:<br>
-         index = 3;<br>
+         index = PIPE_STAT_QUERY_GS_INVOCATIONS;<br>
          break;<br>
       case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB:<br>
-         index = 4;<br>
+         index = PIPE_STAT_QUERY_GS_PRIMITIVES;<br>
          break;<br>
       case GL_CLIPPING_INPUT_PRIMITIVES_ARB:<br>
-         index = 5;<br>
+         index = PIPE_STAT_QUERY_C_INVOCATIONS;<br>
          break;<br>
       case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:<br>
-         index = 6;<br>
+         index = PIPE_STAT_QUERY_C_PRIMITIVES;<br>
          break;<br>
       case GL_FRAGMENT_SHADER_INVOCATIONS_ARB:<br>
-         index = 7;<br>
+         index = PIPE_STAT_QUERY_PS_INVOCATIONS;<br>
          break;<br>
       case GL_TESS_CONTROL_SHADER_PATCHES_ARB:<br>
-         index = 8;<br>
+         index = PIPE_STAT_QUERY_HS_INVOCATIONS;<br>
          break;<br>
       case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:<br>
-         index = 9;<br>
+         index = PIPE_STAT_QUERY_DS_INVOCATIONS;<br>
          break;<br>
       case GL_COMPUTE_SHADER_INVOCATIONS_ARB:<br>
-         index = 10;<br>
+         index = PIPE_STAT_QUERY_CS_INVOCATIONS;<br>
          break;<br>
       default:<br>
          unreachable("Unexpected target");<br>
-- <br>
2.19.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>