static const char *hz_units[] =
{" Hz", " KHz", " MHz", " GHz"};
static const char *percent_units[] = {"%"};
+ static const char *dbm_units[] = {" (-dBm)"};
+ static const char *temperature_units[] = {" C"};
+ static const char *volt_units[] = {" mV", " V"};
+ static const char *amp_units[] = {" mA", " A"};
const char **units;
unsigned max_unit;
max_unit = ARRAY_SIZE(time_units)-1;
units = time_units;
break;
+ case PIPE_DRIVER_QUERY_TYPE_VOLTS:
+ max_unit = ARRAY_SIZE(volt_units)-1;
+ units = volt_units;
+ break;
+ case PIPE_DRIVER_QUERY_TYPE_AMPS:
+ max_unit = ARRAY_SIZE(amp_units)-1;
+ units = amp_units;
+ break;
+ case PIPE_DRIVER_QUERY_TYPE_DBM:
+ max_unit = ARRAY_SIZE(dbm_units)-1;
+ units = dbm_units;
+ break;
+ case PIPE_DRIVER_QUERY_TYPE_TEMPERATURE:
+ max_unit = ARRAY_SIZE(temperature_units)-1;
+ units = temperature_units;
+ break;
case PIPE_DRIVER_QUERY_TYPE_PERCENTAGE:
max_unit = ARRAY_SIZE(percent_units)-1;
units = percent_units;
float *line_verts = hud->whitelines.vertices + hud->whitelines.num_vertices*2;
unsigned i, num = 0;
char str[32];
- const unsigned last_line = 5;
+ const unsigned last_line = pane->last_line;
/* draw background */
hud_draw_background_quad(hud,
cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
/* prepare vertex buffers */
- hud_alloc_vertices(hud, &hud->bg, 4 * 128, 2 * sizeof(float));
+ hud_alloc_vertices(hud, &hud->bg, 4 * 256, 2 * sizeof(float));
hud_alloc_vertices(hud, &hud->whitelines, 4 * 256, 2 * sizeof(float));
hud_alloc_vertices(hud, &hud->text, 4 * 1024, 4 * sizeof(float));
pipe_surface_reference(&surf, NULL);
}
+static void
+fixup_bytes(enum pipe_driver_query_type type, int position, uint64_t *exp10)
+{
+ if (type == PIPE_DRIVER_QUERY_TYPE_BYTES && position % 3 == 0)
+ *exp10 = (*exp10 / 1000) * 1024;
+}
+
/**
* Set the maximum value for the Y axis of the graph.
* This scales the graph accordingly.
void
hud_pane_set_max_value(struct hud_pane *pane, uint64_t value)
{
- pane->max_value = value;
+ double leftmost_digit;
+ uint64_t exp10;
+ int i;
+
+ /* The following code determines the max_value in the graph as well as
+ * how many describing lines are drawn. The max_value is rounded up,
+ * so that all drawn numbers are rounded for readability.
+ * We want to print multiples of a simple number instead of multiples of
+ * hard-to-read numbers like 1.753.
+ */
+
+ /* Find the left-most digit. */
+ exp10 = 1;
+ for (i = 0; value > 9 * exp10; i++) {
+ exp10 *= 10;
+ fixup_bytes(pane->type, i + 1, &exp10);
+ }
+
+ leftmost_digit = DIV_ROUND_UP(value, exp10);
+
+ /* Round 9 to 10. */
+ if (leftmost_digit == 9) {
+ leftmost_digit = 1;
+ exp10 *= 10;
+ fixup_bytes(pane->type, i + 1, &exp10);
+ }
+
+ switch ((unsigned)leftmost_digit) {
+ case 1:
+ pane->last_line = 5; /* lines in +1/5 increments */
+ break;
+ case 2:
+ pane->last_line = 8; /* lines in +1/4 increments. */
+ break;
+ case 3:
+ case 4:
+ pane->last_line = leftmost_digit * 2; /* lines in +1/2 increments */
+ break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ pane->last_line = leftmost_digit; /* lines in +1 increments */
+ break;
+ default:
+ assert(0);
+ }
+
+ /* Truncate {3,4} to {2.5, 3.5} if possible. */
+ for (i = 3; i <= 4; i++) {
+ if (leftmost_digit == i && value <= (i - 0.5) * exp10) {
+ leftmost_digit = i - 0.5;
+ pane->last_line = leftmost_digit * 2; /* lines in +1/2 increments. */
+ }
+ }
+
+ /* Truncate 2 to a multiple of 0.2 in (1, 1.6] if possible. */
+ if (leftmost_digit == 2) {
+ for (i = 1; i <= 3; i++) {
+ if (value <= (1 + i*0.2) * exp10) {
+ leftmost_digit = 1 + i*0.2;
+ pane->last_line = 5 + i; /* lines in +1/5 increments. */
+ break;
+ }
+ }
+ }
+
+ pane->max_value = leftmost_digit * exp10;
pane->yscale = -(int)pane->inner_height / (float)pane->max_value;
}
}
/* Add a graph. */
+#if HAVE_GALLIUM_EXTRA_HUD || HAVE_LIBSENSORS
+ char arg_name[64];
+#endif
/* IF YOU CHANGE THIS, UPDATE print_help! */
if (strcmp(name, "fps") == 0) {
hud_fps_graph_install(pane);
else if (sscanf(name, "cpu%u%s", &i, s) == 1) {
hud_cpu_graph_install(pane, i);
}
+#if HAVE_GALLIUM_EXTRA_HUD
+ else if (sscanf(name, "nic-rx-%s", arg_name) == 1) {
+ hud_nic_graph_install(pane, arg_name, NIC_DIRECTION_RX);
+ }
+ else if (sscanf(name, "nic-tx-%s", arg_name) == 1) {
+ hud_nic_graph_install(pane, arg_name, NIC_DIRECTION_TX);
+ }
+ else if (sscanf(name, "nic-rssi-%s", arg_name) == 1) {
+ hud_nic_graph_install(pane, arg_name, NIC_RSSI_DBM);
+ pane->type = PIPE_DRIVER_QUERY_TYPE_DBM;
+ }
+ else if (sscanf(name, "diskstat-rd-%s", arg_name) == 1) {
+ hud_diskstat_graph_install(pane, arg_name, DISKSTAT_RD);
+ pane->type = PIPE_DRIVER_QUERY_TYPE_BYTES;
+ }
+ else if (sscanf(name, "diskstat-wr-%s", arg_name) == 1) {
+ hud_diskstat_graph_install(pane, arg_name, DISKSTAT_WR);
+ pane->type = PIPE_DRIVER_QUERY_TYPE_BYTES;
+ }
+#endif
+#if HAVE_LIBSENSORS
+ else if (sscanf(name, "sensors_temp_cu-%s", arg_name) == 1) {
+ hud_sensors_temp_graph_install(pane, arg_name,
+ SENSORS_TEMP_CURRENT);
+ pane->type = PIPE_DRIVER_QUERY_TYPE_TEMPERATURE;
+ }
+ else if (sscanf(name, "sensors_temp_cr-%s", arg_name) == 1) {
+ hud_sensors_temp_graph_install(pane, arg_name,
+ SENSORS_TEMP_CRITICAL);
+ pane->type = PIPE_DRIVER_QUERY_TYPE_TEMPERATURE;
+ }
+ else if (sscanf(name, "sensors_volt_cu-%s", arg_name) == 1) {
+ hud_sensors_temp_graph_install(pane, arg_name,
+ SENSORS_VOLTAGE_CURRENT);
+ pane->type = PIPE_DRIVER_QUERY_TYPE_VOLTS;
+ }
+ else if (sscanf(name, "sensors_curr_cu-%s", arg_name) == 1) {
+ hud_sensors_temp_graph_install(pane, arg_name,
+ SENSORS_CURRENT_CURRENT);
+ pane->type = PIPE_DRIVER_QUERY_TYPE_AMPS;
+ }
+#endif
else if (strcmp(name, "samples-passed") == 0 &&
has_occlusion_query(hud->pipe->screen)) {
hud_pipe_query_install(&hud->batch_query, pane, hud->pipe,
puts(" cs-invocations");
}
+#if HAVE_GALLIUM_EXTRA_HUD
+ hud_get_num_disks(1);
+ hud_get_num_nics(1);
+#endif
+#if HAVE_LIBSENSORS
+ hud_get_num_sensors(1);
+#endif
+
if (screen->get_driver_query_info){
boolean skipping = false;
struct pipe_driver_query_info info;
struct pipe_sampler_view view_templ;
unsigned i;
const char *env = debug_get_option("GALLIUM_HUD", NULL);
- unsigned signo = debug_get_num_option("GALLIUM_HUD_TOGGLE_SIGNAL", 0);
#ifdef PIPE_OS_UNIX
+ unsigned signo = debug_get_num_option("GALLIUM_HUD_TOGGLE_SIGNAL", 0);
static boolean sig_handled = FALSE;
struct sigaction action = {};
#endif