[Mesa-dev] [PATCH] gallium/hud: add support for PIPE_QUERY_PIPELINE_STATISTICS
Christoph Bumiller
e0425955 at student.tuwien.ac.at
Fri Mar 29 06:13:13 PDT 2013
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 that passed the
depth test when early_fragment_tests has been set for the PS.
---
src/gallium/auxiliary/hud/hud_context.c | 45 +++++++++++++++++++++++--
src/gallium/auxiliary/hud/hud_cpu.c | 6 ++-
src/gallium/auxiliary/hud/hud_driver_query.c | 8 +++--
src/gallium/auxiliary/hud/hud_private.h | 1 +
4 files changed, 51 insertions(+), 9 deletions(-)
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index 60355ca..cfb58a8 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -90,6 +90,10 @@ struct hud_context {
unsigned max_num_vertices;
unsigned num_vertices;
} text, bg, whitelines;
+
+ struct {
+ boolean query_pipeline_statistics;
+ } cap;
};
@@ -716,15 +720,45 @@ hud_parse_env_var(struct hud_context *hud, const char *env)
else if (sscanf(name, "cpu%u%s", &i, s) == 1) {
hud_cpu_graph_install(pane, i);
}
- else if (strcmp(name, "pixels-rendered") == 0 &&
+ else if (strcmp(name, "samples-passed") == 0 &&
has_occlusion_query(hud->pipe->screen)) {
- hud_pipe_query_install(pane, hud->pipe, "pixels-rendered",
- PIPE_QUERY_OCCLUSION_COUNTER, 0, FALSE);
+ hud_pipe_query_install(pane, hud->pipe, "samples-passed",
+ PIPE_QUERY_OCCLUSION_COUNTER, 0, 0, FALSE);
}
else if (strcmp(name, "primitives-generated") == 0 &&
has_streamout(hud->pipe->screen)) {
hud_pipe_query_install(pane, hud->pipe, "primitives-generated",
- PIPE_QUERY_PRIMITIVES_GENERATED, 0, FALSE);
+ PIPE_QUERY_PRIMITIVES_GENERATED, 0, 0, FALSE);
+ }
+ else if (strncmp(name, "pipeline-statistics-", 20) == 0) {
+ if (hud->cap.query_pipeline_statistics) {
+ static const char *pipeline_statistics_names[] =
+ {
+ "ia_vertices",
+ "ia_primitives",
+ "vs_invocations",
+ "gs_invocations",
+ "gs_primitives",
+ "c_invocationd",
+ "c_primitives",
+ "ps_invocations",
+ "hs_invocations",
+ "ds_invocations",
+ "cs_invocations"
+ };
+ for (i = 0; i < Elements(pipeline_statistics_names); ++i)
+ if (strcmp(&name[20], pipeline_statistics_names[i]) == 0)
+ break;
+ if (i < Elements(pipeline_statistics_names))
+ hud_pipe_query_install(pane, hud->pipe, &name[20],
+ PIPE_QUERY_PIPELINE_STATISTICS, i,
+ 0, FALSE);
+ else
+ fprintf(stderr, "gallium_hud: invalid pipeline-statistics-*\n");
+ } else {
+ fprintf(stderr, "gallium_hud: PIPE_QUERY_PIPELINE_STATISTICS "
+ "not supported by the driver\n");
+ }
}
else {
if (!hud_driver_query_install(pane, hud->pipe, name)){
@@ -963,6 +997,9 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso)
LIST_INITHEAD(&hud->pane_list);
+ hud->cap.query_pipeline_statistics =
+ pipe->screen->get_param(pipe->screen, PIPE_CAP_QUERY_PIPELINE_STATISTICS);
+
hud_parse_env_var(hud, env);
return hud;
}
diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c
index dfd9f68..ce98115 100644
--- a/src/gallium/auxiliary/hud/hud_cpu.c
+++ b/src/gallium/auxiliary/hud/hud_cpu.c
@@ -32,6 +32,7 @@
#include "os/os_time.h"
#include "util/u_memory.h"
#include <stdio.h>
+#include <inttypes.h>
static boolean
get_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)
int i, num;
num = sscanf(line,
- "%s %llu %llu %llu %llu %llu %llu %llu %llu %llu "
- "%llu %llu %llu",
+ "%s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64
+ " %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64
+ " %"PRIu64" %"PRIu64"",
cpuname, &v[0], &v[1], &v[2], &v[3], &v[4], &v[5],
&v[6], &v[7], &v[8], &v[9], &v[10], &v[11]);
if (num < 5) {
diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c b/src/gallium/auxiliary/hud/hud_driver_query.c
index 798da50..413059c 100644
--- a/src/gallium/auxiliary/hud/hud_driver_query.c
+++ b/src/gallium/auxiliary/hud/hud_driver_query.c
@@ -42,6 +42,7 @@
struct query_info {
struct pipe_context *pipe;
unsigned query_type;
+ unsigned result_index; /* unit depends on query_type */
/* Ring of queries. If a query is busy, we use another slot. */
struct pipe_query *query[NUM_QUERIES];
@@ -67,10 +68,10 @@ query_new_value(struct hud_graph *gr)
while (1) {
struct pipe_query *query = info->query[info->tail];
union pipe_query_result result;
- result.u64 = 0;
+ uint64_t *res64 = (uint64_t *)&result;
if (pipe->get_query_result(pipe, query, FALSE, &result)) {
- info->results_cumulative += result.u64;
+ info->results_cumulative += res64[info->result_index];
info->num_results++;
if (info->tail == info->head)
@@ -146,6 +147,7 @@ free_query_info(void *ptr)
void
hud_pipe_query_install(struct hud_pane *pane, struct pipe_context *pipe,
const char *name, unsigned query_type,
+ unsigned result_index,
uint64_t max_value, boolean uses_byte_units)
{
struct hud_graph *gr;
@@ -201,7 +203,7 @@ hud_driver_query_install(struct hud_pane *pane, struct pipe_context *pipe,
if (!found)
return FALSE;
- hud_pipe_query_install(pane, pipe, query.name, query.query_type,
+ hud_pipe_query_install(pane, pipe, query.name, query.query_type, 0,
query.max_value, query.uses_byte_units);
return TRUE;
}
diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h
index 4c97791..2b7d56b 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);
void hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index);
void hud_pipe_query_install(struct hud_pane *pane, struct pipe_context *pipe,
const char *name, unsigned query_type,
+ unsigned result_index,
uint64_t max_value, boolean uses_byte_units);
boolean hud_driver_query_install(struct hud_pane *pane,
struct pipe_context *pipe, const char *name);
--
1.7.3.4
More information about the mesa-dev
mailing list