gallium: replace pipe_driver_query_info::max_value by a union
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 7 Jul 2014 21:49:14 +0000 (23:49 +0200)
committerMartin Peres <martin.peres@linux.intel.com>
Tue, 5 May 2015 21:03:35 +0000 (00:03 +0300)
This allows queries to return different numeric types.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Martin Peres <martin.peres@free.fr>
src/gallium/auxiliary/hud/hud_driver_query.c
src/gallium/drivers/freedreno/freedreno_query.c
src/gallium/drivers/nouveau/nvc0/nvc0_query.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/svga/svga_screen.c
src/gallium/include/pipe/p_defines.h

index 1c8c485bb2ff52d0260dd19fbf1223d040d84578..603aba7e8cd4cb7c6d60f7a2f32c868915f6bb17 100644 (file)
@@ -208,6 +208,7 @@ hud_driver_query_install(struct hud_pane *pane, struct pipe_context *pipe,
 
    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, uses_byte_units);
+                          query.max_value.u64, uses_byte_units);
+
    return TRUE;
 }
index cb3b49a5f5831ba6783277651cc77b7eacbe9302..6f01e0313c12a53ade4fbd73da77cc4415b5d84d 100644 (file)
@@ -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, {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}},
        };
 
        if (!info)
index 5be150ea11c6163eed5b9bcc59e7275db1254353..477ca8027ca1765170263a63d488e74763a70a41 100644 (file)
@@ -1418,7 +1418,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen,
    if (id < NVC0_QUERY_DRV_STAT_COUNT) {
       info->name = nvc0_drv_stat_names[id];
       info->query_type = NVC0_QUERY_DRV_STAT(id);
-      info->max_value = 0;
+      info->max_value.u64 = 0;
       if (strstr(info->name, "bytes"))
          info->type = PIPE_DRIVER_QUERY_TYPE_BYTES;
       return 1;
@@ -1428,20 +1428,21 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen,
       if (screen->base.class_3d >= NVE4_3D_CLASS) {
          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->max_value.u64 =
+            (id < NVE4_PM_QUERY_METRIC_MP_OCCUPANCY) ? 0 : 100;
          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->max_value.u64 = 0;
          return 1;
       }
    }
    /* user asked for info about non-existing query */
    info->name = "this_is_not_the_query_you_are_looking_for";
    info->query_type = 0xdeadd01d;
-   info->max_value = 0;
+   info->max_value.u64 = 0;
    return 0;
 }
 
index a9b04d8ccf912e9dcb39927005113299fdb9b24c..42e681dc7d218ec9b11fd463ccc72ee530b5413c 100644 (file)
@@ -657,18 +657,18 @@ 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, PIPE_DRIVER_QUERY_TYPE_BYTES},
-               {"requested-GTT", R600_QUERY_REQUESTED_GTT, rscreen->info.gart_size, PIPE_DRIVER_QUERY_TYPE_BYTES},
-               {"buffer-wait-time", R600_QUERY_BUFFER_WAIT_TIME, 0},
-               {"num-cs-flushes", R600_QUERY_NUM_CS_FLUSHES, 0},
-               {"num-bytes-moved", R600_QUERY_NUM_BYTES_MOVED, 0, PIPE_DRIVER_QUERY_TYPE_BYTES},
-               {"VRAM-usage", R600_QUERY_VRAM_USAGE, rscreen->info.vram_size, PIPE_DRIVER_QUERY_TYPE_BYTES},
-               {"GTT-usage", R600_QUERY_GTT_USAGE, rscreen->info.gart_size, PIPE_DRIVER_QUERY_TYPE_BYTES},
-               {"temperature", R600_QUERY_GPU_TEMPERATURE, 100},
-               {"shader-clock", R600_QUERY_CURRENT_GPU_SCLK, 0},
-               {"memory-clock", R600_QUERY_CURRENT_GPU_MCLK, 0},
-               {"GPU-load", R600_QUERY_GPU_LOAD, 100}
+               {"draw-calls", R600_QUERY_DRAW_CALLS, {0}},
+               {"requested-VRAM", R600_QUERY_REQUESTED_VRAM, {rscreen->info.vram_size}, PIPE_DRIVER_QUERY_TYPE_BYTES},
+               {"requested-GTT", R600_QUERY_REQUESTED_GTT, {rscreen->info.gart_size}, PIPE_DRIVER_QUERY_TYPE_BYTES},
+               {"buffer-wait-time", R600_QUERY_BUFFER_WAIT_TIME, {0}},
+               {"num-cs-flushes", R600_QUERY_NUM_CS_FLUSHES, {0}},
+               {"num-bytes-moved", R600_QUERY_NUM_BYTES_MOVED, {0}, PIPE_DRIVER_QUERY_TYPE_BYTES},
+               {"VRAM-usage", R600_QUERY_VRAM_USAGE, {rscreen->info.vram_size}, PIPE_DRIVER_QUERY_TYPE_BYTES},
+               {"GTT-usage", R600_QUERY_GTT_USAGE, {rscreen->info.gart_size}, PIPE_DRIVER_QUERY_TYPE_BYTES},
+               {"temperature", R600_QUERY_GPU_TEMPERATURE, {100}},
+               {"shader-clock", R600_QUERY_CURRENT_GPU_SCLK, {0}},
+               {"memory-clock", R600_QUERY_CURRENT_GPU_MCLK, {0}},
+               {"GPU-load", R600_QUERY_GPU_LOAD, {100}}
        };
        unsigned num_queries;
 
index 35e5a114b04527110ec1bc6cedfaa6f43a6b85c6..b75f0386449e5646fe1f1bc78e80a0ac7b30a7e0 100644 (file)
@@ -568,9 +568,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},
-      {"fallbacks", SVGA_QUERY_FALLBACKS, 0},
-      {"memory-used", SVGA_QUERY_MEMORY_USED, 0, PIPE_DRIVER_QUERY_TYPE_BYTES}
+      {"draw-calls", SVGA_QUERY_DRAW_CALLS, {0}},
+      {"fallbacks", SVGA_QUERY_FALLBACKS, {0}},
+      {"memory-used", SVGA_QUERY_MEMORY_USED, {0}, PIPE_DRIVER_QUERY_TYPE_BYTES}
    };
 
    if (!info)
index b1df8366997b4c1b67e9b43619b69b1cf7c761e7..8a16fde22e7d9b8038b2a894f8f756c06260eab1 100644 (file)
@@ -775,11 +775,18 @@ enum pipe_driver_query_group_type
    PIPE_DRIVER_QUERY_GROUP_TYPE_GPU = 1,
 };
 
+union pipe_numeric_type_union
+{
+   uint64_t u64;
+   uint32_t u32;
+   float f;
+};
+
 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 */
    enum pipe_driver_query_type type;
    unsigned group_id;
 };