Mesa (main): gallium: deduplicate target -> stats index code

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu May 12 07:45:03 UTC 2022


Module: Mesa
Branch: main
Commit: 7f4ee4afabd5fbeec74f895b6520ed7c6d19144f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f4ee4afabd5fbeec74f895b6520ed7c6d19144f

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Tue Apr 19 10:31:07 2022 +0200

gallium: deduplicate target -> stats index code

Now that target_to_index returns the correct index for
PIPE_QUERY_PIPELINE_STATISTICS we can use it in store_query_result instead
of duplicating the switch statement.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15861>

---

 src/mesa/main/queryobj.c | 42 +++---------------------------------------
 1 file changed, 3 insertions(+), 39 deletions(-)

diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
index 3080cdfbd7b..ccc4bcdb7b3 100644
--- a/src/mesa/main/queryobj.c
+++ b/src/mesa/main/queryobj.c
@@ -83,7 +83,7 @@ delete_query(struct gl_context *ctx, struct gl_query_object *q)
 }
 
 static int
-target_to_index(const struct st_context *st, const struct gl_query_object *q)
+target_to_index(const struct gl_query_object *q)
 {
    if (q->Target == GL_PRIMITIVES_GENERATED ||
        q->Target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN ||
@@ -199,7 +199,7 @@ begin_query(struct gl_context *ctx, struct gl_query_object *q)
          ret = pipe->end_query(pipe, q->pq_begin);
    } else {
       if (!q->pq) {
-         q->pq = pipe->create_query(pipe, type, target_to_index(st, q));
+         q->pq = pipe->create_query(pipe, type, target_to_index(q));
          q->type = type;
       }
       if (q->pq)
@@ -426,43 +426,7 @@ store_query_result(struct gl_context *ctx, struct gl_query_object *q,
    if (pname == GL_QUERY_RESULT_AVAILABLE) {
       index = -1;
    } else if (q->type == PIPE_QUERY_PIPELINE_STATISTICS) {
-      switch (q->Target) {
-      case GL_VERTICES_SUBMITTED_ARB:
-         index = PIPE_STAT_QUERY_IA_VERTICES;
-         break;
-      case GL_PRIMITIVES_SUBMITTED_ARB:
-         index = PIPE_STAT_QUERY_IA_PRIMITIVES;
-         break;
-      case GL_VERTEX_SHADER_INVOCATIONS_ARB:
-         index = PIPE_STAT_QUERY_VS_INVOCATIONS;
-         break;
-      case GL_GEOMETRY_SHADER_INVOCATIONS:
-         index = PIPE_STAT_QUERY_GS_INVOCATIONS;
-         break;
-      case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB:
-         index = PIPE_STAT_QUERY_GS_PRIMITIVES;
-         break;
-      case GL_CLIPPING_INPUT_PRIMITIVES_ARB:
-         index = PIPE_STAT_QUERY_C_INVOCATIONS;
-         break;
-      case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:
-         index = PIPE_STAT_QUERY_C_PRIMITIVES;
-         break;
-      case GL_FRAGMENT_SHADER_INVOCATIONS_ARB:
-         index = PIPE_STAT_QUERY_PS_INVOCATIONS;
-         break;
-      case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
-         index = PIPE_STAT_QUERY_HS_INVOCATIONS;
-         break;
-      case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
-         index = PIPE_STAT_QUERY_DS_INVOCATIONS;
-         break;
-      case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
-         index = PIPE_STAT_QUERY_CS_INVOCATIONS;
-         break;
-      default:
-         unreachable("Unexpected target");
-      }
+      index = target_to_index(q);
    } else {
       index = 0;
    }



More information about the mesa-commit mailing list