gallium: change comments to remove 'state tracker'
[mesa.git] / src / gallium / auxiliary / hud / hud_context.c
index e7e99944993ad8ffaf32960a4d7f01f419c02ab8..0cd3307a1a5f7cd01d25ddd9e98fdc85bf508198 100644 (file)
@@ -27,7 +27,7 @@
 
 /* This head-up display module can draw transparent graphs on top of what
  * the app is rendering, visualizing various data like framerate, cpu load,
- * performance counters, etc. It can be hook up into any state tracker.
+ * performance counters, etc. It can be hook up into any gallium frontend.
  *
  * The HUD is controlled with the GALLIUM_HUD environment variable.
  * Set GALLIUM_HUD=help for more info.
@@ -42,7 +42,7 @@
 
 #include "cso_cache/cso_context.h"
 #include "util/u_draw_quad.h"
-#include "util/u_format.h"
+#include "util/format/u_format.h"
 #include "util/u_inlines.h"
 #include "util/u_memory.h"
 #include "util/u_math.h"
@@ -55,6 +55,7 @@
 
 /* Control the visibility of all HUD contexts */
 static boolean huds_visible = TRUE;
+static int hud_scale = 1;
 
 
 #ifdef PIPE_OS_UNIX
@@ -84,10 +85,10 @@ hud_draw_colored_prims(struct hud_context *hud, unsigned prim,
    hud->constants.color[1] = g;
    hud->constants.color[2] = b;
    hud->constants.color[3] = a;
-   hud->constants.translate[0] = (float) xoffset;
-   hud->constants.translate[1] = (float) yoffset;
-   hud->constants.scale[0] = 1;
-   hud->constants.scale[1] = yscale;
+   hud->constants.translate[0] = (float) (xoffset * hud_scale);
+   hud->constants.translate[1] = (float) (yoffset * hud_scale);
+   hud->constants.scale[0] = hud_scale;
+   hud->constants.scale[1] = yscale * hud_scale;
    cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
 
    cso_set_vertex_buffers(cso, 0, 1, &hud->color_prims.vbuf);
@@ -149,7 +150,7 @@ hud_draw_string(struct hud_context *hud, unsigned x, unsigned y,
 
    va_list ap;
    va_start(ap, str);
-   util_vsnprintf(buf, sizeof(buf), str, ap);
+   vsnprintf(buf, sizeof(buf), str, ap);
    va_end(ap);
 
    if (!*s)
@@ -538,7 +539,7 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
    cso_set_tesseval_shader_handle(cso, NULL);
    cso_set_geometry_shader_handle(cso, NULL);
    cso_set_vertex_shader_handle(cso, hud->vs);
-   cso_set_vertex_elements(cso, 2, hud->velems);
+   cso_set_vertex_elements(cso, &hud->velems);
    cso_set_render_condition(cso, NULL, FALSE, 0);
    cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, 1,
                          &hud->font_sampler_view);
@@ -556,10 +557,11 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
       hud->constants.color[3] = 0.666f;
       hud->constants.translate[0] = 0;
       hud->constants.translate[1] = 0;
-      hud->constants.scale[0] = 1;
-      hud->constants.scale[1] = 1;
+      hud->constants.scale[0] = hud_scale;
+      hud->constants.scale[1] = hud_scale;
 
       cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
+
       cso_set_vertex_buffers(cso, 0, 1, &hud->bg.vbuf);
       cso_draw_arrays(cso, PIPE_PRIM_QUADS, 0, hud->bg.num_vertices);
    }
@@ -590,8 +592,8 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
    hud->constants.color[3] = 1;
    hud->constants.translate[0] = 0;
    hud->constants.translate[1] = 0;
-   hud->constants.scale[0] = 1;
-   hud->constants.scale[1] = 1;
+   hud->constants.scale[0] = hud_scale;
+   hud->constants.scale[1] = hud_scale;
    cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
 
    if (hud->whitelines.num_vertices) {
@@ -696,8 +698,8 @@ hud_stop_queries(struct hud_context *hud, struct pipe_context *pipe)
              */
             if (gr->current_value <
                 LIST_ENTRY(struct hud_graph, next, head)->current_value) {
-               LIST_DEL(&gr->head);
-               LIST_ADD(&gr->head, &next->head);
+               list_del(&gr->head);
+               list_add(&gr->head, &next->head);
             }
          }
       }
@@ -898,7 +900,7 @@ hud_pane_create(struct hud_context *hud,
    pane->sort_items = sort_items;
    pane->initial_max_value = max_value;
    hud_pane_set_max_value(pane, max_value);
-   LIST_INITHEAD(&pane->graph_list);
+   list_inithead(&pane->graph_list);
    return pane;
 }
 
@@ -946,7 +948,7 @@ hud_pane_add_graph(struct hud_pane *pane, struct hud_graph *gr)
    gr->color[1] = colors[color][1];
    gr->color[2] = colors[color][2];
    gr->pane = pane;
-   LIST_ADDTAIL(&gr->head, &pane->graph_list);
+   list_addtail(&gr->head, &pane->graph_list);
    pane->num_graphs++;
    pane->next_color++;
 }
@@ -1431,7 +1433,7 @@ hud_parse_env_var(struct hud_context *hud, struct pipe_screen *screen,
          env += num;
 
          strip_hyphens(s);
-         if (added && !LIST_IS_EMPTY(&pane->graph_list)) {
+         if (added && !list_is_empty(&pane->graph_list)) {
             struct hud_graph *graph;
             graph = LIST_ENTRY(struct hud_graph, pane->graph_list.prev, head);
             strncpy(graph->name, s, sizeof(graph->name)-1);
@@ -1458,7 +1460,7 @@ hud_parse_env_var(struct hud_context *hud, struct pipe_screen *screen,
          height = 100;
 
          if (pane && pane->num_graphs) {
-            LIST_ADDTAIL(&pane->head, &hud->pane_list);
+            list_addtail(&pane->head, &hud->pane_list);
             pane = NULL;
          }
          break;
@@ -1471,7 +1473,7 @@ hud_parse_env_var(struct hud_context *hud, struct pipe_screen *screen,
          height = 100;
 
          if (pane && pane->num_graphs) {
-            LIST_ADDTAIL(&pane->head, &hud->pane_list);
+            list_addtail(&pane->head, &hud->pane_list);
             pane = NULL;
          }
 
@@ -1494,7 +1496,7 @@ hud_parse_env_var(struct hud_context *hud, struct pipe_screen *screen,
 
    if (pane) {
       if (pane->num_graphs) {
-         LIST_ADDTAIL(&pane->head, &hud->pane_list);
+         list_addtail(&pane->head, &hud->pane_list);
       }
       else {
          FREE(pane);
@@ -1752,10 +1754,10 @@ hud_unset_record_context(struct hud_context *hud)
 
    LIST_FOR_EACH_ENTRY_SAFE(pane, pane_tmp, &hud->pane_list, head) {
       LIST_FOR_EACH_ENTRY_SAFE(graph, graph_tmp, &pane->graph_list, head) {
-         LIST_DEL(&graph->head);
+         list_del(&graph->head);
          hud_graph_destroy(graph, pipe);
       }
-      LIST_DEL(&pane->head);
+      list_del(&pane->head);
       FREE(pane);
    }
 
@@ -1816,9 +1818,12 @@ hud_create(struct cso_context *cso, struct hud_context *share)
 #ifdef PIPE_OS_UNIX
    unsigned signo = debug_get_num_option("GALLIUM_HUD_TOGGLE_SIGNAL", 0);
    static boolean sig_handled = FALSE;
-   struct sigaction action = {};
+   struct sigaction action;
+
+   memset(&action, 0, sizeof(action));
 #endif
    huds_visible = debug_get_bool_option("GALLIUM_HUD_VISIBLE", TRUE);
+   hud_scale = debug_get_num_option("GALLIUM_HUD_SCALE", 1);
 
    if (!env || !*env)
       return NULL;
@@ -1869,10 +1874,11 @@ hud_create(struct cso_context *cso, struct hud_context *share)
    hud->rasterizer_aa_lines.line_smooth = 1;
 
    /* vertex elements */
+   hud->velems.count = 2;
    for (i = 0; i < 2; i++) {
-      hud->velems[i].src_offset = i * 2 * sizeof(float);
-      hud->velems[i].src_format = PIPE_FORMAT_R32G32_FLOAT;
-      hud->velems[i].vertex_buffer_index = 0;
+      hud->velems.velems[i].src_offset = i * 2 * sizeof(float);
+      hud->velems.velems[i].src_format = PIPE_FORMAT_R32G32_FLOAT;
+      hud->velems.velems[i].vertex_buffer_index = 0;
    }
 
    /* sampler state (for font drawing) */
@@ -1885,7 +1891,7 @@ hud_create(struct cso_context *cso, struct hud_context *share)
    hud->constbuf.buffer_size = sizeof(hud->constants);
    hud->constbuf.user_buffer = &hud->constants;
 
-   LIST_INITHEAD(&hud->pane_list);
+   list_inithead(&hud->pane_list);
 
    /* setup sig handler once for all hud contexts */
 #ifdef PIPE_OS_UNIX