From ca35292a4456fec1c584d40bf9b4197fe733f609 Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Tue, 21 Sep 2010 20:24:51 -0400 Subject: r600g: occlusion query for new design Signed-off-by: Jerome Glisse --- src/gallium/drivers/r600/r600.h | 38 ++++++++++++++++++++++++++- src/gallium/drivers/r600/r600_state2.c | 47 ++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h index 8879efca794..6d87220db2a 100644 --- a/src/gallium/drivers/r600/r600.h +++ b/src/gallium/drivers/r600/r600.h @@ -28,6 +28,8 @@ #include #include +#include +#include #define RADEON_CTX_MAX_PM4 (64 * 1024 / 4) @@ -183,6 +185,9 @@ struct r600_group { unsigned *offset_block_id; }; +/* + * relocation + */ #pragma pack(1) struct r600_reloc { uint32_t handle; @@ -192,7 +197,29 @@ struct r600_reloc { }; #pragma pack() -struct radeon_bo; +/* + * query + */ +struct r600_query { + u64 result; + /* The kind of query. Currently only OQ is supported. */ + unsigned type; + /* How many results have been written, in dwords. It's incremented + * after end_query and flush. */ + unsigned num_results; + /* if we've flushed the query */ + unsigned state; + /* The buffer where query results are stored. */ + struct radeon_ws_bo *buffer; + unsigned buffer_size; + /* linked list of queries */ + struct list_head list; +}; + +#define R600_QUERY_STATE_STARTED (1 << 0) +#define R600_QUERY_STATE_ENDED (1 << 1) +#define R600_QUERY_STATE_SUSPENDED (1 << 2) + struct r600_context { struct radeon *radeon; @@ -207,6 +234,7 @@ struct r600_context { struct r600_reloc *reloc; struct radeon_bo **bo; u32 *pm4; + struct list_head query_list; }; struct r600_draw { @@ -229,4 +257,12 @@ void r600_context_flush(struct r600_context *ctx); void r600_context_dump_bof(struct r600_context *ctx, const char *file); void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw); +struct r600_query *r600_context_query_create(struct r600_context *ctx, unsigned query_type); +void r600_context_query_destroy(struct r600_context *ctx, struct r600_query *query); +boolean r600_context_query_result(struct r600_context *ctx, + struct r600_query *query, + boolean wait, void *vresult); +void r600_query_begin(struct r600_context *ctx, struct r600_query *query); +void r600_query_end(struct r600_context *ctx, struct r600_query *query); + #endif diff --git a/src/gallium/drivers/r600/r600_state2.c b/src/gallium/drivers/r600/r600_state2.c index f29aa0fdeaf..0343704a90c 100644 --- a/src/gallium/drivers/r600/r600_state2.c +++ b/src/gallium/drivers/r600/r600_state2.c @@ -2089,6 +2089,52 @@ static void r600_init_config2(struct r600_pipe_context *rctx) r600_context_pipe_state_set(&rctx->ctx, rstate); } +static struct pipe_query *r600_create_query(struct pipe_context *ctx, unsigned query_type) +{ + struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; + + return (struct pipe_query*)r600_context_query_create(&rctx->ctx, query_type); +} + +static void r600_destroy_query(struct pipe_context *ctx, struct pipe_query *query) +{ + struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; + + r600_context_query_destroy(&rctx->ctx, (struct r600_query *)query); +} + +static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query) +{ + struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; + + r600_query_begin(&rctx->ctx, (struct r600_query *)query); +} + +static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query) +{ + struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; + + r600_query_end(&rctx->ctx, (struct r600_query *)query); +} + +static boolean r600_get_query_result(struct pipe_context *ctx, + struct pipe_query *query, + boolean wait, void *vresult) +{ + struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; + + return r600_context_query_result(&rctx->ctx, (struct r600_query *)query, wait, vresult); +} + +static void r600_init_query_functions2(struct r600_pipe_context *rctx) +{ + rctx->context.create_query = r600_create_query; + rctx->context.destroy_query = r600_destroy_query; + rctx->context.begin_query = r600_begin_query; + rctx->context.end_query = r600_end_query; + rctx->context.get_query_result = r600_get_query_result; +} + static struct pipe_context *r600_create_context2(struct pipe_screen *screen, void *priv) { struct r600_pipe_context *rctx = CALLOC_STRUCT(r600_pipe_context); @@ -2108,6 +2154,7 @@ static struct pipe_context *r600_create_context2(struct pipe_screen *screen, voi rctx->radeon = rscreen->radeon; r600_init_blit_functions2(rctx); + r600_init_query_functions2(rctx); r600_init_state_functions2(rctx); r600_init_context_resource_functions2(rctx); -- cgit v1.2.3