summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>2013-03-29 13:56:35 +0100
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>2013-04-03 12:54:43 +0200
commit3d2790cead7eb744341e8b1708b7a6d03524768d (patch)
tree3e078dfc33a1d8b744d820d6b4b4420ed5bc10c6
parentc620aad71c2fe147dd2435c27053b435801a5237 (diff)
gallium/hud: add support for PIPE_QUERY_PIPELINE_STATISTICS
Also, renamed "pixels-rendered" to "samples-passed" because the occlusion counter increments even if colour and depth writes are disabled, or (on some implementations) for killed fragments that passed the depth test when PS early_fragment_tests is set.
-rw-r--r--src/gallium/auxiliary/hud/hud_context.c45
-rw-r--r--src/gallium/auxiliary/hud/hud_cpu.c6
-rw-r--r--src/gallium/auxiliary/hud/hud_driver_query.c9
-rw-r--r--src/gallium/auxiliary/hud/hud_private.h1
4 files changed, 52 insertions, 9 deletions
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index 9b7b63f91ba..5511f8e1011 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -90,6 +90,10 @@ struct hud_context {
90 unsigned max_num_vertices; 90 unsigned max_num_vertices;
91 unsigned num_vertices; 91 unsigned num_vertices;
92 } text, bg, whitelines; 92 } text, bg, whitelines;
93
94 struct {
95 boolean query_pipeline_statistics;
96 } cap;
93}; 97};
94 98
95 99
@@ -719,15 +723,45 @@ hud_parse_env_var(struct hud_context *hud, const char *env)
719 else if (sscanf(name, "cpu%u%s", &i, s) == 1) { 723 else if (sscanf(name, "cpu%u%s", &i, s) == 1) {
720 hud_cpu_graph_install(pane, i); 724 hud_cpu_graph_install(pane, i);
721 } 725 }
722 else if (strcmp(name, "pixels-rendered") == 0 && 726 else if (strcmp(name, "samples-passed") == 0 &&
723 has_occlusion_query(hud->pipe->screen)) { 727 has_occlusion_query(hud->pipe->screen)) {
724 hud_pipe_query_install(pane, hud->pipe, "pixels-rendered", 728 hud_pipe_query_install(pane, hud->pipe, "samples-passed",
725 PIPE_QUERY_OCCLUSION_COUNTER, 0, FALSE); 729 PIPE_QUERY_OCCLUSION_COUNTER, 0, 0, FALSE);
726 } 730 }
727 else if (strcmp(name, "primitives-generated") == 0 && 731 else if (strcmp(name, "primitives-generated") == 0 &&
728 has_streamout(hud->pipe->screen)) { 732 has_streamout(hud->pipe->screen)) {
729 hud_pipe_query_install(pane, hud->pipe, "primitives-generated", 733 hud_pipe_query_install(pane, hud->pipe, "primitives-generated",
730 PIPE_QUERY_PRIMITIVES_GENERATED, 0, FALSE); 734 PIPE_QUERY_PRIMITIVES_GENERATED, 0, 0, FALSE);
735 }
736 else if (strncmp(name, "pipeline-statistics-", 20) == 0) {
737 if (hud->cap.query_pipeline_statistics) {
738 static const char *pipeline_statistics_names[] =
739 {
740 "ia-vertices",
741 "ia-primitives",
742 "vs-invocations",
743 "gs-invocations",
744 "gs-primitives",
745 "clipper-invocations",
746 "clipper-primitives-generated",
747 "ps-invocations",
748 "hs-invocations",
749 "ds-invocations",
750 "cs-invocations"
751 };
752 for (i = 0; i < Elements(pipeline_statistics_names); ++i)
753 if (strcmp(&name[20], pipeline_statistics_names[i]) == 0)
754 break;
755 if (i < Elements(pipeline_statistics_names))
756 hud_pipe_query_install(pane, hud->pipe, &name[20],
757 PIPE_QUERY_PIPELINE_STATISTICS, i,
758 0, FALSE);
759 else
760 fprintf(stderr, "gallium_hud: invalid pipeline-statistics-*\n");
761 } else {
762 fprintf(stderr, "gallium_hud: PIPE_QUERY_PIPELINE_STATISTICS "
763 "not supported by the driver\n");
764 }
731 } 765 }
732 else { 766 else {
733 if (!hud_driver_query_install(pane, hud->pipe, name)){ 767 if (!hud_driver_query_install(pane, hud->pipe, name)){
@@ -990,6 +1024,9 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso)
990 1024
991 LIST_INITHEAD(&hud->pane_list); 1025 LIST_INITHEAD(&hud->pane_list);
992 1026
1027 hud->cap.query_pipeline_statistics =
1028 pipe->screen->get_param(pipe->screen, PIPE_CAP_QUERY_PIPELINE_STATISTICS);
1029
993 hud_parse_env_var(hud, env); 1030 hud_parse_env_var(hud, env);
994 return hud; 1031 return hud;
995} 1032}
diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c
index dfd9f686920..ce98115d542 100644
--- a/src/gallium/auxiliary/hud/hud_cpu.c
+++ b/src/gallium/auxiliary/hud/hud_cpu.c
@@ -32,6 +32,7 @@
32#include "os/os_time.h" 32#include "os/os_time.h"
33#include "util/u_memory.h" 33#include "util/u_memory.h"
34#include <stdio.h> 34#include <stdio.h>
35#include <inttypes.h>
35 36
36static boolean 37static boolean
37get_cpu_stats(unsigned cpu_index, uint64_t *busy_time, uint64_t *total_time) 38get_cpu_stats(unsigned cpu_index, uint64_t *busy_time, uint64_t *total_time)
@@ -55,8 +56,9 @@ get_cpu_stats(unsigned cpu_index, uint64_t *busy_time, uint64_t *total_time)
55 int i, num; 56 int i, num;
56 57
57 num = sscanf(line, 58 num = sscanf(line,
58 "%s %llu %llu %llu %llu %llu %llu %llu %llu %llu " 59 "%s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64
59 "%llu %llu %llu", 60 " %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64
61 " %"PRIu64" %"PRIu64"",
60 cpuname, &v[0], &v[1], &v[2], &v[3], &v[4], &v[5], 62 cpuname, &v[0], &v[1], &v[2], &v[3], &v[4], &v[5],
61 &v[6], &v[7], &v[8], &v[9], &v[10], &v[11]); 63 &v[6], &v[7], &v[8], &v[9], &v[10], &v[11]);
62 if (num < 5) { 64 if (num < 5) {
diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c b/src/gallium/auxiliary/hud/hud_driver_query.c
index 798da50e57c..0f52e18cc2d 100644
--- a/src/gallium/auxiliary/hud/hud_driver_query.c
+++ b/src/gallium/auxiliary/hud/hud_driver_query.c
@@ -42,6 +42,7 @@
42struct query_info { 42struct query_info {
43 struct pipe_context *pipe; 43 struct pipe_context *pipe;
44 unsigned query_type; 44 unsigned query_type;
45 unsigned result_index; /* unit depends on query_type */
45 46
46 /* Ring of queries. If a query is busy, we use another slot. */ 47 /* Ring of queries. If a query is busy, we use another slot. */
47 struct pipe_query *query[NUM_QUERIES]; 48 struct pipe_query *query[NUM_QUERIES];
@@ -67,10 +68,10 @@ query_new_value(struct hud_graph *gr)
67 while (1) { 68 while (1) {
68 struct pipe_query *query = info->query[info->tail]; 69 struct pipe_query *query = info->query[info->tail];
69 union pipe_query_result result; 70 union pipe_query_result result;
70 result.u64 = 0; 71 uint64_t *res64 = (uint64_t *)&result;
71 72
72 if (pipe->get_query_result(pipe, query, FALSE, &result)) { 73 if (pipe->get_query_result(pipe, query, FALSE, &result)) {
73 info->results_cumulative += result.u64; 74 info->results_cumulative += res64[info->result_index];
74 info->num_results++; 75 info->num_results++;
75 76
76 if (info->tail == info->head) 77 if (info->tail == info->head)
@@ -146,6 +147,7 @@ free_query_info(void *ptr)
146void 147void
147hud_pipe_query_install(struct hud_pane *pane, struct pipe_context *pipe, 148hud_pipe_query_install(struct hud_pane *pane, struct pipe_context *pipe,
148 const char *name, unsigned query_type, 149 const char *name, unsigned query_type,
150 unsigned result_index,
149 uint64_t max_value, boolean uses_byte_units) 151 uint64_t max_value, boolean uses_byte_units)
150{ 152{
151 struct hud_graph *gr; 153 struct hud_graph *gr;
@@ -168,6 +170,7 @@ hud_pipe_query_install(struct hud_pane *pane, struct pipe_context *pipe,
168 info = gr->query_data; 170 info = gr->query_data;
169 info->pipe = pipe; 171 info->pipe = pipe;
170 info->query_type = query_type; 172 info->query_type = query_type;
173 info->result_index = result_index;
171 174
172 hud_pane_add_graph(pane, gr); 175 hud_pane_add_graph(pane, gr);
173 if (pane->max_value < max_value) 176 if (pane->max_value < max_value)
@@ -201,7 +204,7 @@ hud_driver_query_install(struct hud_pane *pane, struct pipe_context *pipe,
201 if (!found) 204 if (!found)
202 return FALSE; 205 return FALSE;
203 206
204 hud_pipe_query_install(pane, pipe, query.name, query.query_type, 207 hud_pipe_query_install(pane, pipe, query.name, query.query_type, 0,
205 query.max_value, query.uses_byte_units); 208 query.max_value, query.uses_byte_units);
206 return TRUE; 209 return TRUE;
207} 210}
diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h
index 4c97791c635..2b7d56bb1ad 100644
--- a/src/gallium/auxiliary/hud/hud_private.h
+++ b/src/gallium/auxiliary/hud/hud_private.h
@@ -84,6 +84,7 @@ void hud_fps_graph_install(struct hud_pane *pane);
84void hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index); 84void hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index);
85void hud_pipe_query_install(struct hud_pane *pane, struct pipe_context *pipe, 85void hud_pipe_query_install(struct hud_pane *pane, struct pipe_context *pipe,
86 const char *name, unsigned query_type, 86 const char *name, unsigned query_type,
87 unsigned result_index,
87 uint64_t max_value, boolean uses_byte_units); 88 uint64_t max_value, boolean uses_byte_units);
88boolean hud_driver_query_install(struct hud_pane *pane, 89boolean hud_driver_query_install(struct hud_pane *pane,
89 struct pipe_context *pipe, const char *name); 90 struct pipe_context *pipe, const char *name);