[Mesa-dev] [PATCH 1/2] etnaviv: move sw get_driver_query_info(..)

Christian Gmeiner christian.gmeiner at gmail.com
Tue Sep 19 16:16:04 UTC 2017


This change makes etna_get_driver_query_info(..) more generic
and puts the knowledge of supported queries directly besides
the implementation.

Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_query.c    | 15 +++------------
 src/gallium/drivers/etnaviv/etnaviv_query_sw.c | 21 +++++++++++++++++++++
 src/gallium/drivers/etnaviv/etnaviv_query_sw.h |  4 ++++
 3 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query.c b/src/gallium/drivers/etnaviv/etnaviv_query.c
index 617e47562d..16adb8c21f 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query.c
@@ -81,21 +81,12 @@ static int
 etna_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
                            struct pipe_driver_query_info *info)
 {
-   struct pipe_driver_query_info list[] = {
-      {"prims-emitted", PIPE_QUERY_PRIMITIVES_EMITTED, { 0 }},
-      {"draw-calls", ETNA_QUERY_DRAW_CALLS, { 0 }},
-      {"rs-operations", ETNA_QUERY_RS_OPERATIONS, { 0 }},
-   };
+   int nr_sw_queries = etna_sw_get_driver_query_info(pscreen, 0, NULL);
 
    if (!info)
-      return ARRAY_SIZE(list);
+      return nr_sw_queries;
 
-   if (index >= ARRAY_SIZE(list))
-      return 0;
-
-   *info = list[index];
-
-   return 1;
+   return etna_sw_get_driver_query_info(pscreen, index, info);
 }
 
 static void
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_sw.c b/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
index 213c61f38b..90f4a65826 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_sw.c
@@ -124,3 +124,24 @@ etna_sw_create_query(struct etna_context *ctx, unsigned query_type)
 
    return q;
 }
+
+int
+etna_sw_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
+                              struct pipe_driver_query_info *info)
+{
+   static const struct pipe_driver_query_info list[] = {
+      {"prims-emitted", PIPE_QUERY_PRIMITIVES_EMITTED, { 0 }},
+      {"draw-calls", ETNA_QUERY_DRAW_CALLS, { 0 }},
+      {"rs-operations", ETNA_QUERY_RS_OPERATIONS, { 0 }},
+   };
+
+   if (!info)
+      return ARRAY_SIZE(list);
+
+   if (index >= ARRAY_SIZE(list))
+      return 0;
+
+   *info = list[index];
+
+   return 1;
+}
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_sw.h b/src/gallium/drivers/etnaviv/etnaviv_query_sw.h
index 9de2bc60f9..f07d0f5915 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_sw.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_sw.h
@@ -44,4 +44,8 @@ etna_sw_query(struct etna_query *q)
 struct etna_query *
 etna_sw_create_query(struct etna_context *ctx, unsigned query_type);
 
+int
+etna_sw_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
+                              struct pipe_driver_query_info *info);
+
 #endif
-- 
2.13.5



More information about the mesa-dev mailing list