gallium,hud: allow displaying cumulative values instead of average
authorMarek Olšák <marek.olsak@amd.com>
Sun, 2 Aug 2015 15:24:30 +0000 (17:24 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 6 Aug 2015 18:44:36 +0000 (20:44 +0200)
The cumulative value is useful for queries like the number of shader
compilations.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/auxiliary/hud/hud_context.c
src/gallium/auxiliary/hud/hud_driver_query.c
src/gallium/auxiliary/hud/hud_private.h
src/gallium/include/pipe/p_defines.h

index e0ca29da32966c43bbfdd6ef33c2200637c6ff25..decc055b21ae29f5477e31bdae0c043cbf774032 100644 (file)
@@ -896,13 +896,15 @@ hud_parse_env_var(struct hud_context *hud, const char *env)
                has_occlusion_query(hud->pipe->screen)) {
          hud_pipe_query_install(pane, hud->pipe, "samples-passed",
                                 PIPE_QUERY_OCCLUSION_COUNTER, 0, 0,
-                                PIPE_DRIVER_QUERY_TYPE_UINT64);
+                                PIPE_DRIVER_QUERY_TYPE_UINT64,
+                                PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE);
       }
       else if (strcmp(name, "primitives-generated") == 0 &&
                has_streamout(hud->pipe->screen)) {
          hud_pipe_query_install(pane, hud->pipe, "primitives-generated",
                                 PIPE_QUERY_PRIMITIVES_GENERATED, 0, 0,
-                                PIPE_DRIVER_QUERY_TYPE_UINT64);
+                                PIPE_DRIVER_QUERY_TYPE_UINT64,
+                                PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE);
       }
       else {
          boolean processed = FALSE;
@@ -929,7 +931,8 @@ hud_parse_env_var(struct hud_context *hud, const char *env)
             if (i < Elements(pipeline_statistics_names)) {
                hud_pipe_query_install(pane, hud->pipe, name,
                                       PIPE_QUERY_PIPELINE_STATISTICS, i,
-                                      0, PIPE_DRIVER_QUERY_TYPE_UINT64);
+                                      0, PIPE_DRIVER_QUERY_TYPE_UINT64,
+                                      PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE);
                processed = TRUE;
             }
          }
index c47d232842f6f2cd30080203b8b01cb46b378551..f14305ea8351e4431a92ee814406da6f92105afc 100644 (file)
@@ -43,6 +43,7 @@ struct query_info {
    struct pipe_context *pipe;
    unsigned query_type;
    unsigned result_index; /* unit depends on query_type */
+   enum pipe_driver_query_result_type result_type;
 
    /* Ring of queries. If a query is busy, we use another slot. */
    struct pipe_query *query[NUM_QUERIES];
@@ -108,8 +109,19 @@ query_new_value(struct hud_graph *gr)
       }
 
       if (info->num_results && info->last_time + gr->pane->period <= now) {
-         /* compute the average value across all frames */
-         hud_graph_add_value(gr, info->results_cumulative / info->num_results);
+         uint64_t value;
+
+         switch (info->result_type) {
+         default:
+         case PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE:
+            value = info->results_cumulative / info->num_results;
+            break;
+         case PIPE_DRIVER_QUERY_RESULT_TYPE_CUMULATIVE:
+            value = info->results_cumulative;
+            break;
+         }
+
+         hud_graph_add_value(gr, value);
 
          info->last_time = now;
          info->results_cumulative = 0;
@@ -150,7 +162,8 @@ void
 hud_pipe_query_install(struct hud_pane *pane, struct pipe_context *pipe,
                        const char *name, unsigned query_type,
                        unsigned result_index,
-                       uint64_t max_value, enum pipe_driver_query_type type)
+                       uint64_t max_value, enum pipe_driver_query_type type,
+                       enum pipe_driver_query_result_type result_type)
 {
    struct hud_graph *gr;
    struct query_info *info;
@@ -174,6 +187,7 @@ hud_pipe_query_install(struct hud_pane *pane, struct pipe_context *pipe,
    info->pipe = pipe;
    info->query_type = query_type;
    info->result_index = result_index;
+   info->result_type = result_type;
 
    hud_pane_add_graph(pane, gr);
    if (pane->max_value < max_value)
@@ -207,7 +221,7 @@ 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.u64, query.type);
+                          query.max_value.u64, query.type, query.result_type);
 
    return TRUE;
 }
index 033be534a75351f8ce479a32c78590a798010e17..01caf7b8b2ce671f93cd3cda9fc173296646a304 100644 (file)
@@ -90,7 +90,8 @@ void hud_pipe_query_install(struct hud_pane *pane, struct pipe_context *pipe,
                             const char *name, unsigned query_type,
                             unsigned result_index,
                             uint64_t max_value,
-                            enum pipe_driver_query_type type);
+                            enum pipe_driver_query_type type,
+                            enum pipe_driver_query_result_type result_type);
 boolean hud_driver_query_install(struct hud_pane *pane,
                                  struct pipe_context *pipe, const char *name);
 
index b124d8e4d13ca96b9f96a09dfff6c3a1e185ab12..85328264cc352b60eb2f3b4b380794a3ff260eb4 100644 (file)
@@ -806,6 +806,15 @@ enum pipe_driver_query_group_type
    PIPE_DRIVER_QUERY_GROUP_TYPE_GPU = 1,
 };
 
+/* Whether an average value per frame or a cumulative value should be
+ * displayed.
+ */
+enum pipe_driver_query_result_type
+{
+   PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE = 0,
+   PIPE_DRIVER_QUERY_RESULT_TYPE_CUMULATIVE = 1,
+};
+
 union pipe_numeric_type_union
 {
    uint64_t u64;
@@ -819,6 +828,7 @@ struct pipe_driver_query_info
    unsigned query_type; /* PIPE_QUERY_DRIVER_SPECIFIC + i */
    union pipe_numeric_type_union max_value; /* max value that can be returned */
    enum pipe_driver_query_type type;
+   enum pipe_driver_query_result_type result_type;
    unsigned group_id;
 };