This allows to return different numeric types for queries.

Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>
---
 src/gallium/auxiliary/hud/hud_driver_query.c    |  2 +-
 src/gallium/drivers/freedreno/freedreno_query.c | 12 ++++++------
 src/gallium/drivers/nouveau/nvc0/nvc0_query.c   |  8 ++++----
 src/gallium/drivers/radeon/r600_pipe_common.c   | 16 ++++++++--------
 src/gallium/drivers/svga/svga_screen.c          |  6 +++---
 src/gallium/include/pipe/p_defines.h            |  9 ++++++++-
 6 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c 
b/src/gallium/auxiliary/hud/hud_driver_query.c
index b48708c..8d82208 100644
--- a/src/gallium/auxiliary/hud/hud_driver_query.c
+++ b/src/gallium/auxiliary/hud/hud_driver_query.c
@@ -205,6 +205,6 @@ hud_driver_query_install(struct hud_pane *pane, struct 
pipe_context *pipe,
       return FALSE;
 
    hud_pipe_query_install(pane, pipe, query.name, query.query_type, 0,
-                      query.max_value, query.uses_byte_units);
+                      query.max_value.ui, query.uses_byte_units);
    return TRUE;
 }
diff --git a/src/gallium/drivers/freedreno/freedreno_query.c 
b/src/gallium/drivers/freedreno/freedreno_query.c
index 5dbac94..d191c71 100644
--- a/src/gallium/drivers/freedreno/freedreno_query.c
+++ b/src/gallium/drivers/freedreno/freedreno_query.c
@@ -86,12 +86,12 @@ fd_get_driver_query_info(struct pipe_screen *pscreen,
                unsigned index, struct pipe_driver_query_info *info)
 {
        struct pipe_driver_query_info list[] = {
-                       {"draw-calls", FD_QUERY_DRAW_CALLS, 0},
-                       {"batches", FD_QUERY_BATCH_TOTAL, 0},
-                       {"batches-sysmem", FD_QUERY_BATCH_SYSMEM, 0},
-                       {"batches-gmem", FD_QUERY_BATCH_GMEM, 0},
-                       {"restores", FD_QUERY_BATCH_RESTORE, 0},
-                       {"prims-emitted", PIPE_QUERY_PRIMITIVES_EMITTED, 0},
+                       {"draw-calls", FD_QUERY_DRAW_CALLS, {.ui = 0}},
+                       {"batches", FD_QUERY_BATCH_TOTAL, {.ui = 0}},
+                       {"batches-sysmem", FD_QUERY_BATCH_SYSMEM, {.ui = 0}},
+                       {"batches-gmem", FD_QUERY_BATCH_GMEM, {.ui = 0}},
+                       {"restores", FD_QUERY_BATCH_RESTORE, {.ui = 0}},
+                       {"prims-emitted", PIPE_QUERY_PRIMITIVES_EMITTED, {.ui = 
0}},
        };
 
        if (!info)
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
index c0824c8..3e8c90b 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
@@ -1410,7 +1410,7 @@ 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->group_id = NVC0_QUERY_DRV_STAT_GROUP;
-      info->max_value = ~0ULL;
+      info->max_value.ui = ~0ULL;
       info->uses_byte_units = !!strstr(info->name, "bytes");
       return 1;
    } else
@@ -1420,7 +1420,7 @@ 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->group_id = NVC0_QUERY_PM_GROUP;
-         info->max_value = (id < NVE4_PM_QUERY_METRIC_MP_OCCUPANCY) ?
+         info->max_value.ui = (id < NVE4_PM_QUERY_METRIC_MP_OCCUPANCY) ?
             ~0ULL : 100;
          info->uses_byte_units = FALSE;
          return 1;
@@ -1429,7 +1429,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen 
*pscreen,
          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->group_id = NVC0_QUERY_PM_GROUP;
-         info->max_value = ~0ULL;
+         info->max_value.ui = ~0ULL;
          info->uses_byte_units = FALSE;
          return 1;
       }
@@ -1438,7 +1438,7 @@ 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->group_id = 0;
-   info->max_value = 0;
+   info->max_value.ui = 0;
    info->uses_byte_units = FALSE;
    return 0;
 }
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
b/src/gallium/drivers/radeon/r600_pipe_common.c
index 43d86a4..5153ef4 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -546,14 +546,14 @@ static int r600_get_driver_query_info(struct pipe_screen 
*screen,
 {
        struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
        struct pipe_driver_query_info list[] = {
-               {"draw-calls", R600_QUERY_DRAW_CALLS, 0},
-               {"requested-VRAM", R600_QUERY_REQUESTED_VRAM, 
rscreen->info.vram_size, TRUE},
-               {"requested-GTT", R600_QUERY_REQUESTED_GTT, 
rscreen->info.gart_size, TRUE},
-               {"buffer-wait-time", R600_QUERY_BUFFER_WAIT_TIME, 0, FALSE},
-               {"num-cs-flushes", R600_QUERY_NUM_CS_FLUSHES, 0, FALSE},
-               {"num-bytes-moved", R600_QUERY_NUM_BYTES_MOVED, 0, TRUE},
-               {"VRAM-usage", R600_QUERY_VRAM_USAGE, rscreen->info.vram_size, 
TRUE},
-               {"GTT-usage", R600_QUERY_GTT_USAGE, rscreen->info.gart_size, 
TRUE},
+               {"draw-calls", R600_QUERY_DRAW_CALLS, {.ui = 0}},
+               {"requested-VRAM", R600_QUERY_REQUESTED_VRAM, {.ui = 
rscreen->info.vram_size}, TRUE},
+               {"requested-GTT", R600_QUERY_REQUESTED_GTT, {.ui = 
rscreen->info.gart_size}, TRUE},
+               {"buffer-wait-time", R600_QUERY_BUFFER_WAIT_TIME, {.ui = 0}, 
FALSE},
+               {"num-cs-flushes", R600_QUERY_NUM_CS_FLUSHES, {.ui = 0}, FALSE},
+               {"num-bytes-moved", R600_QUERY_NUM_BYTES_MOVED, {.ui = 0}, 
TRUE},
+               {"VRAM-usage", R600_QUERY_VRAM_USAGE, {.ui = 
rscreen->info.vram_size}, TRUE},
+               {"GTT-usage", R600_QUERY_GTT_USAGE, {.ui = 
rscreen->info.gart_size}, TRUE},
        };
 
        if (!info)
diff --git a/src/gallium/drivers/svga/svga_screen.c 
b/src/gallium/drivers/svga/svga_screen.c
index 5621271..8c45bd0 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -539,9 +539,9 @@ svga_get_driver_query_info(struct pipe_screen *screen,
                            struct pipe_driver_query_info *info)
 {
    static const struct pipe_driver_query_info queries[] = {
-      {"draw-calls", SVGA_QUERY_DRAW_CALLS, 0, FALSE},
-      {"fallbacks", SVGA_QUERY_FALLBACKS, 0, FALSE},
-      {"memory-used", SVGA_QUERY_MEMORY_USED, 0, TRUE}
+      {"draw-calls", SVGA_QUERY_DRAW_CALLS, {.ui = 0}, FALSE},
+      {"fallbacks", SVGA_QUERY_FALLBACKS, {.ui = 0}, FALSE},
+      {"memory-used", SVGA_QUERY_MEMORY_USED, {.ui = 0}, TRUE}
    };
 
    if (!info)
diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index 065c8d9..501c1e2 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -727,11 +727,18 @@ union pipe_color_union
    unsigned int ui[4];
 };
 
+union pipe_numeric_type_union
+{
+   double f;
+   uint64_t ui;
+   int64_t i;
+};
+
 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 */
+   union pipe_numeric_type_union max_value; /* max value that can be returned 
*/
    boolean uses_byte_units; /* whether the result is in bytes */
    unsigned group_id;
 };
-- 
2.0.0

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

Reply via email to