summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno/freedreno_query.c
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2018-07-18 09:40:04 -0400
committerRob Clark <[email protected]>2018-07-18 10:19:03 -0400
commit33af91dc07efcc2ca52200570a297de33c18a5f7 (patch)
treeacd474092cb4b7e2f2f9945390502db42a38813d /src/gallium/drivers/freedreno/freedreno_query.c
parent9e30e7490da0a89a1760fc23d150e21310066d0c (diff)
freedreno: batch query support (perfcounters)
Core infrastructure for performance counters, using gallium's batch query interface (to support AMD_performance_monitor). Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/freedreno_query.c')
-rw-r--r--src/gallium/drivers/freedreno/freedreno_query.c69
1 files changed, 66 insertions, 3 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_query.c b/src/gallium/drivers/freedreno/freedreno_query.c
index 9d4637a03a4..2b100a3d336 100644
--- a/src/gallium/drivers/freedreno/freedreno_query.c
+++ b/src/gallium/drivers/freedreno/freedreno_query.c
@@ -150,25 +150,88 @@ static int
fd_get_driver_query_info(struct pipe_screen *pscreen,
unsigned index, struct pipe_driver_query_info *info)
{
+ struct fd_screen *screen = fd_screen(pscreen);
+
if (!info)
- return ARRAY_SIZE(sw_query_list);
+ return ARRAY_SIZE(sw_query_list) + screen->num_perfcntr_queries;
- if (index >= ARRAY_SIZE(sw_query_list))
- return 0;
+ if (index >= ARRAY_SIZE(sw_query_list)) {
+ index -= ARRAY_SIZE(sw_query_list);
+ if (index >= screen->num_perfcntr_queries)
+ return 0;
+ *info = screen->perfcntr_queries[index];
+ return 1;
+ }
*info = sw_query_list[index];
return 1;
}
+static int
+fd_get_driver_query_group_info(struct pipe_screen *pscreen, unsigned index,
+ struct pipe_driver_query_group_info *info)
+{
+ struct fd_screen *screen = fd_screen(pscreen);
+
+ if (!info)
+ return screen->num_perfcntr_groups;
+
+ if (index >= screen->num_perfcntr_groups)
+ return 0;
+
+ const struct fd_perfcntr_group *g = &screen->perfcntr_groups[index];
+
+ info->name = g->name;
+ info->max_active_queries = g->num_counters;
+ info->num_queries = g->num_countables;
+
+ return 1;
+}
+
static void
fd_set_active_query_state(struct pipe_context *pipe, boolean enable)
{
}
+static void
+setup_perfcntr_query_info(struct fd_screen *screen)
+{
+ unsigned num_queries = 0;
+
+ for (unsigned i = 0; i < screen->num_perfcntr_groups; i++)
+ num_queries += screen->perfcntr_groups[i].num_countables;
+
+ screen->perfcntr_queries =
+ calloc(num_queries, sizeof(screen->perfcntr_queries[0]));
+ screen->num_perfcntr_queries = num_queries;
+
+ unsigned idx = 0;
+ for (unsigned i = 0; i < screen->num_perfcntr_groups; i++) {
+ const struct fd_perfcntr_group *g = &screen->perfcntr_groups[i];
+ for (unsigned j = 0; j < g->num_countables; j++) {
+ struct pipe_driver_query_info *info =
+ &screen->perfcntr_queries[idx];
+ const struct fd_perfcntr_countable *c =
+ &g->countables[j];
+
+ info->name = c->name;
+ info->query_type = FD_QUERY_FIRST_PERFCNTR + idx;
+ info->type = c->query_type;
+ info->result_type = c->result_type;
+ info->group_id = i;
+ info->flags = PIPE_DRIVER_QUERY_FLAG_BATCH;
+
+ idx++;
+ }
+ }
+}
+
void
fd_query_screen_init(struct pipe_screen *pscreen)
{
pscreen->get_driver_query_info = fd_get_driver_query_info;
+ pscreen->get_driver_query_group_info = fd_get_driver_query_group_info;
+ setup_perfcntr_query_info(fd_screen(pscreen));
}
void