Home | History | Annotate | Download | only in hud

Lines Matching defs:hud

32  * The HUD is controlled with the GALLIUM_HUD environment variable.
40 #include "hud/hud_context.h"
41 #include "hud/hud_private.h"
42 #include "hud/font.h"
57 /* Control the visibility of all HUD contexts */
115 hud_draw_colored_prims(struct hud_context *hud, unsigned prim,
120 struct cso_context *cso = hud->cso;
123 hud->constants.color[0] = r;
124 hud->constants.color[1] = g;
125 hud->constants.color[2] = b;
126 hud->constants.color[3] = a;
127 hud->constants.translate[0] = (float) xoffset;
128 hud->constants.translate[1] = (float) yoffset;
129 hud->constants.scale[0] = 1;
130 hud->constants.scale[1] = yscale;
131 cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
138 cso_set_fragment_shader_handle(hud->cso, hud->fs_color);
143 hud_draw_colored_quad(struct hud_context *hud, unsigned prim,
154 hud_draw_colored_prims(hud, prim, buffer, 4, r, g, b, a, 0, 0, 1);
158 hud_draw_background_quad(struct hud_context *hud,
161 float *vertices = hud->bg.vertices + hud->bg.num_vertices*2;
164 assert(hud->bg.num_vertices + 4 <= hud->bg.max_num_vertices);
178 hud->bg.num_vertices += num/2;
182 hud_draw_string(struct hud_context *hud, unsigned x, unsigned y,
187 float *vertices = hud->text.vertices + hud->text.num_vertices*4;
198 hud_draw_background_quad(hud,
200 x + strlen(buf)*hud->font.glyph_width,
201 y + hud->font.glyph_height);
206 unsigned x2 = x + hud->font.glyph_width;
207 unsigned y2 = y + hud->font.glyph_height;
208 unsigned tx1 = (*s % 16) * hud->font.glyph_width;
209 unsigned ty1 = (*s / 16) * hud->font.glyph_height;
210 unsigned tx2 = tx1 + hud->font.glyph_width;
211 unsigned ty2 = ty1 + hud->font.glyph_height;
214 x += hud->font.glyph_width;
219 assert(hud->text.num_vertices + num/4 + 4 <= hud->text.max_num_vertices);
241 x += hud->font.glyph_width;
245 hud->text.num_vertices += num/4;
336 hud_draw_graph_line_strip(struct hud_context *hud, const struct hud_graph *gr,
344 hud_draw_colored_prims(hud, PIPE_PRIM_LINE_STRIP,
353 hud_draw_colored_prims(hud, PIPE_PRIM_LINE_STRIP,
361 hud_pane_accumulate_vertices(struct hud_context *hud,
365 float *line_verts = hud->whitelines.vertices + hud->whitelines.num_vertices*2;
371 hud_draw_background_quad(hud,
380 hud->font.glyph_height / 2;
384 hud_draw_string(hud, x, y, "%s", str);
391 unsigned y = pane->y2 + 2 + i*hud->font.glyph_height;
394 hud_draw_string(hud, x, y, " %s: %s", gr->name, str);
399 assert(hud->whitelines.num_vertices + num/2 + 8 <= hud->whitelines.max_num_vertices);
425 assert(hud->whitelines.num_vertices + num/2 + 2 <= hud->whitelines.max_num_vertices);
432 hud->whitelines.num_vertices += num/2;
436 hud_pane_draw_colored_objects(struct hud_context *hud,
446 unsigned y = pane->y2 + 2 + i*hud->font.glyph_height;
448 hud_draw_colored_quad(hud, PIPE_PRIM_QUADS, x + 1, y + 1, x + 12, y + 13,
455 hud_draw_graph_line_strip(hud, gr, pane->inner_x1, pane->inner_y2, pane->yscale);
460 hud_alloc_vertices(struct hud_context *hud, struct vertex_queue *v,
466 u_upload_alloc(hud->uploader, 0, v->vbuf.stride * v->max_num_vertices,
472 * Draw the HUD to the texture \p tex.
476 hud_draw(struct hud_context *hud, struct pipe_resource *tex)
478 struct cso_context *cso = hud->cso;
479 struct pipe_context *pipe = hud->pipe;
484 { &hud->font_sampler_state };
491 hud->fb_width = tex->width0;
492 hud->fb_height = tex->height0;
493 hud->constants.two_div_fb_width = 2.0f / hud->fb_width;
494 hud->constants.two_div_fb_height = 2.0f / hud->fb_height;
526 if (hud->has_srgb) {
538 fb.width = hud->fb_width;
539 fb.height = hud->fb_height;
541 viewport.scale[0] = 0.5f * hud->fb_width;
542 viewport.scale[1] = 0.5f * hud->fb_height;
544 viewport.translate[0] = 0.5f * hud->fb_width;
545 viewport.translate[1] = 0.5f * hud->fb_height;
551 cso_set_depth_stencil_alpha(cso, &hud->dsa);
552 cso_set_rasterizer(cso, &hud->rasterizer);
558 cso_set_vertex_shader_handle(cso, hud->vs);
559 cso_set_vertex_elements(cso, 2, hud->velems);
562 &hud->font_sampler_view);
564 cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
567 hud_alloc_vertices(hud, &hud->bg, 16 * 256, 2 * sizeof(float));
568 hud_alloc_vertices(hud, &hud->whitelines, 4 * 256, 2 * sizeof(float));
569 hud_alloc_vertices(hud, &hud->text, 16 * 1024, 4 * sizeof(float));
572 hud_batch_query_update(hud->batch_query);
574 LIST_FOR_EACH_ENTRY(pane, &hud->pane_list, head) {
596 hud_pane_accumulate_vertices(hud, pane);
600 u_upload_unmap(hud->uploader);
603 cso_set_blend(cso, &hud->alpha_blend);
604 cso_set_fragment_shader_handle(hud->cso, hud->fs_color);
606 if (hud->bg.num_vertices) {
607 hud->constants.color[0] = 0;
608 hud->constants.color[1] = 0;
609 hud->constants.color[2] = 0;
610 hud->constants.color[3] = 0.666f;
611 hud->constants.translate[0] = 0;
612 hud->constants.translate[1] = 0;
613 hud->constants.scale[0] = 1;
614 hud->constants.scale[1] = 1;
616 cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
618 &hud->bg.vbuf);
619 cso_draw_arrays(cso, PIPE_PRIM_QUADS, 0, hud->bg.num_vertices);
621 pipe_resource_reference(&hud->bg.vbuf.buffer, NULL);
624 cso_set_blend(cso, &hud->no_blend);
626 hud->constants.color[0] = 1;
627 hud->constants.color[1] = 1;
628 hud->constants.color[2] = 1;
629 hud->constants.color[3] = 1;
630 hud->constants.translate[0] = 0;
631 hud->constants.translate[1] = 0;
632 hud->constants.scale[0] = 1;
633 hud->constants.scale[1] = 1;
634 cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
636 if (hud->whitelines.num_vertices) {
638 &hud->whitelines.vbuf);
639 cso_set_fragment_shader_handle(hud->cso, hud->fs_color);
640 cso_draw_arrays(cso, PIPE_PRIM_LINES, 0, hud->whitelines.num_vertices);
642 pipe_resource_reference(&hud->whitelines.vbuf.buffer, NULL);
645 cso_set_blend(cso, &hud->alpha_blend);
646 if (hud->text.num_vertices) {
648 &hud->text.vbuf);
649 cso_set_fragment_shader_handle(hud->cso, hud->fs_text);
650 cso_draw_arrays(cso, PIPE_PRIM_QUADS, 0, hud->text.num_vertices);
652 pipe_resource_reference(&hud->text.vbuf.buffer, NULL);
655 cso_set_rasterizer(cso, &hud->rasterizer_aa_lines);
656 LIST_FOR_EACH_ENTRY(pane, &hud->pane_list, head) {
658 hud_pane_draw_colored_objects(hud, pane);
667 hud_batch_query_begin(hud->batch_query);
669 LIST_FOR_EACH_ENTRY(pane, &hud->pane_list, head) {
1051 hud_parse_env_var(struct hud_context *hud, const char *env)
1180 has_occlusion_query(hud->pipe->screen)) {
1181 hud_pipe_query_install(&hud->batch_query, pane, hud->pipe,
1189 has_streamout(hud->pipe->screen)) {
1190 hud_pipe_query_install(&hud->batch_query, pane, hud->pipe,
1201 if (has_pipeline_stats_query(hud->pipe->screen)) {
1220 hud_pipe_query_install(&hud->batch_query, pane, hud->pipe, name,
1231 if (!hud_driver_query_install(&hud->batch_query, pane, hud->pipe,
1299 y += height + hud->font.glyph_height * (pane->num_graphs + 2);
1303 LIST_ADDTAIL(&pane->head, &hud->pane_list);
1311 x += column_width + hud->font.glyph_width * 9;
1315 LIST_ADDTAIL(&pane->head, &hud->pane_list);
1338 LIST_ADDTAIL(&pane->head, &hud->pane_list);
1454 struct hud_context *hud;
1473 hud = CALLOC_STRUCT(hud_context);
1474 if (!hud)
1477 hud->pipe = pipe;
1478 hud->cso = cso;
1479 hud->uploader = u_upload_create(pipe, 256 * 1024,
1483 if (!util_font_create(pipe, UTIL_FONT_FIXED_8X13, &hud->font)) {
1484 u_upload_destroy(hud->uploader);
1485 FREE(hud);
1489 hud->has_srgb = screen->is_format_supported(screen,
1495 hud->no_blend.rt[0].colormask = PIPE_MASK_RGBA;
1497 hud->alpha_blend.rt[0].colormask = PIPE_MASK_RGBA;
1498 hud->alpha_blend.rt[0].blend_enable = 1;
1499 hud->alpha_blend.rt[0].rgb_func = PIPE_BLEND_ADD;
1500 hud->alpha_blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_SRC_ALPHA;
1501 hud->alpha_blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA;
1502 hud->alpha_blend.rt[0].alpha_func = PIPE_BLEND_ADD;
1503 hud->alpha_blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ZERO;
1504 hud->alpha_blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
1507 hud->fs_color =
1533 pipe_resource_reference(&hud->font.texture, NULL);
1534 u_upload_destroy(hud->uploader);
1535 FREE(hud);
1539 hud->fs_text = pipe->create_fs_state(pipe, &state);
1543 hud->rasterizer.half_pixel_center = 1;
1544 hud->rasterizer.bottom_edge_rule = 1;
1545 hud->rasterizer.depth_clip = 1;
1546 hud->rasterizer.line_width = 1;
1547 hud->rasterizer.line_last_pixel = 1;
1549 hud->rasterizer_aa_lines = hud->rasterizer;
1550 hud->rasterizer_aa_lines.line_smooth = 1;
1582 pipe_resource_reference(&hud->font.texture, NULL);
1583 u_upload_destroy(hud->uploader);
1584 FREE(hud);
1588 hud->vs = pipe->create_vs_state(pipe, &state);
1593 hud->velems[i].src_offset = i * 2 * sizeof(float);
1594 hud->velems[i].src_format = PIPE_FORMAT_R32G32_FLOAT;
1595 hud->velems[i].vertex_buffer_index = cso_get_aux_vertex_buffer_slot(cso);
1600 &view_templ, hud->font.texture, hud->font.texture->format);
1601 hud->font_sampler_view = pipe->create_sampler_view(pipe, hud->font.texture,
1605 hud->font_sampler_state.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
1606 hud->font_sampler_state.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
1607 hud->font_sampler_state.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
1608 hud->font_sampler_state.normalized_coords = 0;
1611 hud->constbuf.buffer_size = sizeof(hud->constants);
1612 hud->constbuf.user_buffer = &hud->constants;
1614 LIST_INITHEAD(&hud->pane_list);
1616 /* setup sig handler once for all hud contexts */
1632 hud_parse_env_var(hud, env);
1633 return hud;
1637 hud_destroy(struct hud_context *hud)
1639 struct pipe_context *pipe = hud->pipe;
1643 LIST_FOR_EACH_ENTRY_SAFE(pane, pane_tmp, &hud->pane_list, head) {
1652 hud_batch_query_cleanup(&hud->batch_query);
1653 pipe->delete_fs_state(pipe, hud->fs_color);
1654 pipe->delete_fs_state(pipe, hud->fs_text);
1655 pipe->delete_vs_state(pipe, hud->vs);
1656 pipe_sampler_view_reference(&hud->font_sampler_view, NULL);
1657 pipe_resource_reference(&hud->font.texture, NULL);
1658 u_upload_destroy(hud->uploader);
1659 FREE(hud);