From: Mark Janes Date: Wed, 3 Jul 2019 23:27:22 +0000 (-0700) Subject: iris/query: enable amd performance monitors X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9c597514d42716e2948b6cacbd3a6c95eec2e124;p=mesa.git iris/query: enable amd performance monitors Reviewed-by: Kenneth Graunke --- diff --git a/src/gallium/drivers/iris/iris_query.c b/src/gallium/drivers/iris/iris_query.c index a50b47418df..c5ebf6b59bd 100644 --- a/src/gallium/drivers/iris/iris_query.c +++ b/src/gallium/drivers/iris/iris_query.c @@ -43,6 +43,7 @@ #include "iris_context.h" #include "iris_defines.h" #include "iris_fence.h" +#include "iris_monitor.h" #include "iris_resource.h" #include "iris_screen.h" @@ -439,6 +440,7 @@ iris_create_query(struct pipe_context *ctx, q->type = query_type; q->index = index; + q->monitor = NULL; if (q->type == PIPE_QUERY_PIPELINE_STATISTICS_SINGLE && q->index == PIPE_STAT_QUERY_CS_INVOCATIONS) @@ -448,12 +450,35 @@ iris_create_query(struct pipe_context *ctx, return (struct pipe_query *) q; } +static struct pipe_query * +iris_create_batch_query(struct pipe_context *ctx, + unsigned num_queries, + unsigned *query_types) +{ + struct iris_context *ice = (void *) ctx; + struct iris_query *q = calloc(1, sizeof(struct iris_query)); + if (unlikely(!q)) + return NULL; + q->type = PIPE_QUERY_DRIVER_SPECIFIC; + q->index = -1; + q->monitor = iris_create_monitor_object(ice, num_queries, query_types); + if (unlikely(!q->monitor)) + return NULL; + + return (struct pipe_query *) q; +} + static void iris_destroy_query(struct pipe_context *ctx, struct pipe_query *p_query) { struct iris_query *query = (void *) p_query; struct iris_screen *screen = (void *) ctx->screen; - iris_syncpt_reference(screen, &query->syncpt, NULL); + if (query->monitor) { + iris_destroy_monitor_object(ctx, query->monitor); + query->monitor = NULL; + } else { + iris_syncpt_reference(screen, &query->syncpt, NULL); + } free(query); } @@ -463,6 +488,10 @@ iris_begin_query(struct pipe_context *ctx, struct pipe_query *query) { struct iris_context *ice = (void *) ctx; struct iris_query *q = (void *) query; + + if (q->monitor) + return iris_begin_monitor(ctx, q->monitor); + void *ptr = NULL; uint32_t size; @@ -508,6 +537,10 @@ iris_end_query(struct pipe_context *ctx, struct pipe_query *query) { struct iris_context *ice = (void *) ctx; struct iris_query *q = (void *) query; + + if (q->monitor) + return iris_end_monitor(ctx, q->monitor); + struct iris_batch *batch = &ice->batches[q->batch_idx]; if (q->type == PIPE_QUERY_TIMESTAMP) { @@ -559,6 +592,10 @@ iris_get_query_result(struct pipe_context *ctx, { struct iris_context *ice = (void *) ctx; struct iris_query *q = (void *) query; + + if (q->monitor) + return iris_get_monitor_result(ctx, q->monitor, wait, result->batch); + struct iris_screen *screen = (void *) ctx->screen; const struct gen_device_info *devinfo = &screen->devinfo; @@ -812,6 +849,7 @@ genX(init_query)(struct iris_context *ice) struct pipe_context *ctx = &ice->ctx; ctx->create_query = iris_create_query; + ctx->create_batch_query = iris_create_batch_query; ctx->destroy_query = iris_destroy_query; ctx->begin_query = iris_begin_query; ctx->end_query = iris_end_query;