According to the spec of GL_AMD_performance_monitor, valid type values
returned are UNSIGNED_INT, UNSIGNED_INT64_AMD, PERCENTAGE_AMD, FLOAT.
This also introduces the new field group_id in order to categorize
queries into groups.

v2: add PIPE_DRIVER_QUERY_TYPE_BYTES

Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>
---
 src/gallium/auxiliary/hud/hud_driver_query.c  |  4 +++-
 src/gallium/drivers/nouveau/nvc0/nvc0_query.c |  6 ++----
 src/gallium/include/pipe/p_defines.h          | 12 +++++++++++-
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c 
b/src/gallium/auxiliary/hud/hud_driver_query.c
index b48708c..f00318a 100644
--- a/src/gallium/auxiliary/hud/hud_driver_query.c
+++ b/src/gallium/auxiliary/hud/hud_driver_query.c
@@ -186,6 +186,7 @@ hud_driver_query_install(struct hud_pane *pane, struct 
pipe_context *pipe,
    struct pipe_screen *screen = pipe->screen;
    struct pipe_driver_query_info query;
    unsigned num_queries, i;
+   boolean uses_byte_units;
    boolean found = FALSE;
 
    if (!screen->get_driver_query_info)
@@ -204,7 +205,8 @@ hud_driver_query_install(struct hud_pane *pane, struct 
pipe_context *pipe,
    if (!found)
       return FALSE;
 
+   uses_byte_units = query.type == PIPE_DRIVER_QUERY_TYPE_BYTES;
    hud_pipe_query_install(pane, pipe, query.name, query.query_type, 0,
-                      query.max_value, query.uses_byte_units);
+                      query.max_value, uses_byte_units);
    return TRUE;
 }
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
index f21deea..5be150e 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
@@ -1419,7 +1419,8 @@ nvc0_screen_get_driver_query_info(struct pipe_screen 
*pscreen,
       info->name = nvc0_drv_stat_names[id];
       info->query_type = NVC0_QUERY_DRV_STAT(id);
       info->max_value = 0;
-      info->uses_byte_units = !!strstr(info->name, "bytes");
+      if (strstr(info->name, "bytes"))
+         info->type = PIPE_DRIVER_QUERY_TYPE_BYTES;
       return 1;
    } else
 #endif
@@ -1428,14 +1429,12 @@ nvc0_screen_get_driver_query_info(struct pipe_screen 
*pscreen,
          info->name = nve4_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT];
          info->query_type = NVE4_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT);
          info->max_value = (id < NVE4_PM_QUERY_METRIC_MP_OCCUPANCY) ? 0 : 100;
-         info->uses_byte_units = FALSE;
          return 1;
       } else
       if (screen->compute) {
          info->name = nvc0_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT];
          info->query_type = NVC0_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT);
          info->max_value = 0;
-         info->uses_byte_units = FALSE;
          return 1;
       }
    }
@@ -1443,7 +1442,6 @@ nvc0_screen_get_driver_query_info(struct pipe_screen 
*pscreen,
    info->name = "this_is_not_the_query_you_are_looking_for";
    info->query_type = 0xdeadd01d;
    info->max_value = 0;
-   info->uses_byte_units = FALSE;
    return 0;
 }
 
diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index b2e3f29..dcbb8fe 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -752,12 +752,22 @@ union pipe_color_union
    unsigned int ui[4];
 };
 
+enum pipe_driver_query_type
+{
+   PIPE_DRIVER_QUERY_TYPE_UINT64     = 0,
+   PIPE_DRIVER_QUERY_TYPE_UINT       = 1,
+   PIPE_DRIVER_QUERY_TYPE_FLOAT      = 2,
+   PIPE_DRIVER_QUERY_TYPE_PERCENTAGE = 3,
+   PIPE_DRIVER_QUERY_TYPE_BYTES      = 4,
+};
+
 struct pipe_driver_query_info
 {
    const char *name;
    unsigned query_type; /* PIPE_QUERY_DRIVER_SPECIFIC + i */
    uint64_t max_value; /* max value that can be returned */
-   boolean uses_byte_units; /* whether the result is in bytes */
+   enum pipe_driver_query_type type;
+   unsigned group_id;
 };
 
 struct pipe_driver_query_group_info
-- 
2.3.3

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to