[Mesa-dev] [PATCH] Revert "gallium/hud: automatically print % if max_value == 100"

Marek Olšák maraeo at gmail.com
Fri Sep 30 18:17:53 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

This reverts commit dbfeb0ec12d6550e68de1bcd164e422e79bccf2d.

With max_value being rounded to 100, it's often wrong.
---
 src/gallium/auxiliary/hud/hud_context.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index 3445488..31e81f0 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -238,22 +238,22 @@ hud_draw_string(struct hud_context *hud, unsigned x, unsigned y,
       vertices[num++] = (float) ty1;
 
       x += hud->font.glyph_width;
       s++;
    }
 
    hud->text.num_vertices += num/4;
 }
 
 static void
-number_to_human_readable(uint64_t num, uint64_t max_value,
-                         enum pipe_driver_query_type type, char *out)
+number_to_human_readable(uint64_t num, enum pipe_driver_query_type type,
+                         char *out)
 {
    static const char *byte_units[] =
       {" B", " KB", " MB", " GB", " TB", " PB", " EB"};
    static const char *metric_units[] =
       {"", " k", " M", " G", " T", " P", " E"};
    static const char *time_units[] =
       {" us", " ms", " s"};  /* based on microseconds */
    static const char *hz_units[] =
       {" Hz", " KHz", " MHz", " GHz"};
    static const char *percent_units[] = {"%"};
@@ -300,27 +300,22 @@ number_to_human_readable(uint64_t num, uint64_t max_value,
       break;
    case PIPE_DRIVER_QUERY_TYPE_HZ:
       max_unit = ARRAY_SIZE(hz_units)-1;
       units = hz_units;
       break;
    case PIPE_DRIVER_QUERY_TYPE_WATTS:
       max_unit = ARRAY_SIZE(watt_units)-1;
       units = watt_units;
       break;
    default:
-      if (max_value == 100) {
-         max_unit = ARRAY_SIZE(percent_units)-1;
-         units = percent_units;
-      } else {
-         max_unit = ARRAY_SIZE(metric_units)-1;
-         units = metric_units;
-      }
+      max_unit = ARRAY_SIZE(metric_units)-1;
+      units = metric_units;
    }
 
    while (d > divisor && unit < max_unit) {
       d /= divisor;
       unit++;
    }
 
    /* Round to 3 decimal places so as not to print trailing zeros. */
    if (d*1000 != (int)(d*1000))
       d = round(d * 1000) / 1000;
@@ -376,33 +371,32 @@ hud_pane_accumulate_vertices(struct hud_context *hud,
                             pane->x1, pane->y1,
                             pane->x2, pane->y2);
 
    /* draw numbers on the right-hand side */
    for (i = 0; i <= last_line; i++) {
       unsigned x = pane->x2 + 2;
       unsigned y = pane->inner_y1 +
                    pane->inner_height * (last_line - i) / last_line -
                    hud->font.glyph_height / 2;
 
-      number_to_human_readable(pane->max_value * i / last_line, pane->max_value,
+      number_to_human_readable(pane->max_value * i / last_line,
                                pane->type, str);
       hud_draw_string(hud, x, y, "%s", str);
    }
 
    /* draw info below the pane */
    i = 0;
    LIST_FOR_EACH_ENTRY(gr, &pane->graph_list, head) {
       unsigned x = pane->x1 + 2;
       unsigned y = pane->y2 + 2 + i*hud->font.glyph_height;
 
-      number_to_human_readable(gr->current_value, pane->max_value,
-                               pane->type, str);
+      number_to_human_readable(gr->current_value, pane->type, str);
       hud_draw_string(hud, x, y, "  %s: %s", gr->name, str);
       i++;
    }
 
    /* draw border */
    assert(hud->whitelines.num_vertices + num/2 + 8 <= hud->whitelines.max_num_vertices);
    line_verts[num++] = (float) pane->x1;
    line_verts[num++] = (float) pane->y1;
    line_verts[num++] = (float) pane->x2;
    line_verts[num++] = (float) pane->y1;
-- 
2.7.4



More information about the mesa-dev mailing list