gallium/util: add easy profiling helpers using TIME_ELAPSED queries

There are no users and that's intentional.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10262>
This commit is contained in:
Marek Olšák
2021-04-02 11:27:31 -04:00
committed by Marge Bot
parent 1b5851fadb
commit 451089812a
2 changed files with 33 additions and 0 deletions

View File

@@ -218,6 +218,33 @@ util_end_pipestat_query(struct pipe_context *ctx, struct pipe_query *q,
stats.cs_invocations);
}
/* This is a helper for profiling. Don't remove. */
struct pipe_query *
util_begin_time_query(struct pipe_context *ctx)
{
struct pipe_query *q =
ctx->create_query(ctx, PIPE_QUERY_TIME_ELAPSED, 0);
if (!q)
return NULL;
ctx->begin_query(ctx, q);
return q;
}
/* This is a helper for profiling. Don't remove. */
void
util_end_time_query(struct pipe_context *ctx, struct pipe_query *q, FILE *f,
const char *name)
{
union pipe_query_result result;
ctx->end_query(ctx, q);
ctx->get_query_result(ctx, q, true, &result);
ctx->destroy_query(ctx, q);
fprintf(f, "Time elapsed: %s - %"PRIu64".%u us\n", name, result.u64 / 1000, (unsigned)(result.u64 % 1000) / 100);
}
/* This is a helper for hardware bring-up. Don't remove. */
void
util_wait_for_idle(struct pipe_context *ctx)

View File

@@ -87,6 +87,12 @@ void
util_end_pipestat_query(struct pipe_context *ctx, struct pipe_query *q,
FILE *f);
struct pipe_query *
util_begin_time_query(struct pipe_context *ctx);
void
util_end_time_query(struct pipe_context *ctx, struct pipe_query *q, FILE *f,
const char *name);
void
util_wait_for_idle(struct pipe_context *ctx);