diff options
author | Nicolai Hähnle <[email protected]> | 2015-11-18 11:40:00 +0100 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2015-11-18 12:27:12 +0100 |
commit | 829a9808a98f5b53576c6c8bc5da53182d58e1e8 (patch) | |
tree | e9f535cdca470c3a49de43c206230d144dff4d95 | |
parent | 50cab4788d664769ffc8547d8e759e92d14cf5e6 (diff) |
radeon: add query handler function pointers
The goal here is to be able to move the implementation details of hardware-
specific queries (in particular, performance counters) out of the common code.
Reviewed-by: Marek Olšák <[email protected]>
[Fixed a rebase conflict and re-tested before pushing.]
-rw-r--r-- | src/gallium/drivers/radeon/r600_query.c | 57 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/r600_query.h | 12 |
2 files changed, 62 insertions, 7 deletions
diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c index 3b58e00bd27..409d7803562 100644 --- a/src/gallium/drivers/radeon/r600_query.c +++ b/src/gallium/drivers/radeon/r600_query.c @@ -26,7 +26,6 @@ #include "r600_cs.h" #include "util/u_memory.h" - struct r600_query_buffer { /* The buffer where query results are stored. */ struct r600_resource *buf; @@ -39,6 +38,8 @@ struct r600_query_buffer { }; struct r600_query { + struct r600_query_ops *ops; + /* The query buffer and how many results are in it. */ struct r600_query_buffer buffer; /* The type of query */ @@ -59,6 +60,19 @@ struct r600_query { unsigned stream; }; +static void r600_do_destroy_query(struct r600_common_context *, struct r600_query *); +static boolean r600_do_begin_query(struct r600_common_context *, struct r600_query *); +static void r600_do_end_query(struct r600_common_context *, struct r600_query *); +static boolean r600_do_get_query_result(struct r600_common_context *, + struct r600_query *, boolean wait, + union pipe_query_result *result); + +static struct r600_query_ops legacy_query_ops = { + .destroy = r600_do_destroy_query, + .begin = r600_do_begin_query, + .end = r600_do_end_query, + .get_result = r600_do_get_query_result, +}; static bool r600_is_timer_query(unsigned type) { @@ -373,6 +387,7 @@ static struct pipe_query *r600_create_query(struct pipe_context *ctx, unsigned q return NULL; query->type = query_type; + query->ops = &legacy_query_ops; switch (query_type) { case PIPE_QUERY_OCCLUSION_COUNTER: @@ -380,7 +395,6 @@ static struct pipe_query *r600_create_query(struct pipe_context *ctx, unsigned q query->result_size = 16 * rctx->max_db; query->num_cs_dw = 6; break; - break; case PIPE_QUERY_TIME_ELAPSED: query->result_size = 16; query->num_cs_dw = 8; @@ -440,7 +454,15 @@ static struct pipe_query *r600_create_query(struct pipe_context *ctx, unsigned q static void r600_destroy_query(struct pipe_context *ctx, struct pipe_query *query) { - struct r600_query *rquery = (struct r600_query*)query; + struct r600_common_context *rctx = (struct r600_common_context *)ctx; + struct r600_query *rquery = (struct r600_query *)query; + + rquery->ops->destroy(rctx, rquery); +} + +static void r600_do_destroy_query(struct r600_common_context *rctx, + struct r600_query *rquery) +{ struct r600_query_buffer *prev = rquery->buffer.previous; /* Release all query buffers. */ @@ -452,7 +474,7 @@ static void r600_destroy_query(struct pipe_context *ctx, struct pipe_query *quer } pipe_resource_reference((struct pipe_resource**)&rquery->buffer.buf, NULL); - FREE(query); + FREE(rquery); } static boolean r600_begin_query(struct pipe_context *ctx, @@ -460,6 +482,13 @@ static boolean r600_begin_query(struct pipe_context *ctx, { struct r600_common_context *rctx = (struct r600_common_context *)ctx; struct r600_query *rquery = (struct r600_query *)query; + + return rquery->ops->begin(rctx, rquery); +} + +static boolean r600_do_begin_query(struct r600_common_context *rctx, + struct r600_query *rquery) +{ struct r600_query_buffer *prev = rquery->buffer.previous; if (!r600_query_needs_begin(rquery->type)) { @@ -535,12 +564,18 @@ static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query) struct r600_common_context *rctx = (struct r600_common_context *)ctx; struct r600_query *rquery = (struct r600_query *)query; + rquery->ops->end(rctx, rquery); +} + +static void r600_do_end_query(struct r600_common_context *rctx, + struct r600_query *rquery) +{ /* Non-GPU queries. */ switch (rquery->type) { case PIPE_QUERY_TIMESTAMP_DISJOINT: return; case PIPE_QUERY_GPU_FINISHED: - ctx->flush(ctx, &rquery->fence, 0); + rctx->b.flush(&rctx->b, &rquery->fence, 0); return; case R600_QUERY_DRAW_CALLS: rquery->end_result = rctx->num_draw_calls; @@ -799,11 +834,19 @@ static boolean r600_get_query_buffer_result(struct r600_common_context *ctx, } static boolean r600_get_query_result(struct pipe_context *ctx, - struct pipe_query *query, - boolean wait, union pipe_query_result *result) + struct pipe_query *query, boolean wait, + union pipe_query_result *result) { struct r600_common_context *rctx = (struct r600_common_context *)ctx; struct r600_query *rquery = (struct r600_query *)query; + + return rquery->ops->get_result(rctx, rquery, wait, result); +} + +static boolean r600_do_get_query_result(struct r600_common_context *rctx, + struct r600_query *rquery, + boolean wait, union pipe_query_result *result) +{ struct r600_query_buffer *qbuf; util_query_clear_result(result, rquery->type); diff --git a/src/gallium/drivers/radeon/r600_query.h b/src/gallium/drivers/radeon/r600_query.h index fc8b47b19af..6d568d6fd3b 100644 --- a/src/gallium/drivers/radeon/r600_query.h +++ b/src/gallium/drivers/radeon/r600_query.h @@ -30,6 +30,9 @@ #include "pipe/p_defines.h" +struct r600_common_context; +struct r600_query; + #define R600_QUERY_DRAW_CALLS (PIPE_QUERY_DRIVER_SPECIFIC + 0) #define R600_QUERY_REQUESTED_VRAM (PIPE_QUERY_DRIVER_SPECIFIC + 1) #define R600_QUERY_REQUESTED_GTT (PIPE_QUERY_DRIVER_SPECIFIC + 2) @@ -46,4 +49,13 @@ #define R600_QUERY_NUM_SHADERS_CREATED (PIPE_QUERY_DRIVER_SPECIFIC + 13) #define R600_QUERY_FIRST_PERFCOUNTER (PIPE_QUERY_DRIVER_SPECIFIC + 100) +struct r600_query_ops { + void (*destroy)(struct r600_common_context *, struct r600_query *); + boolean (*begin)(struct r600_common_context *, struct r600_query *); + void (*end)(struct r600_common_context *, struct r600_query *); + boolean (*get_result)(struct r600_common_context *, + struct r600_query *, boolean wait, + union pipe_query_result *result); +}; + #endif /* R600_QUERY_H */ |