diff options
author | Marek Olšák <[email protected]> | 2011-10-28 18:27:00 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2011-10-28 19:29:05 +0200 |
commit | e9b6f21a5054b2639a1dfc6401e4e9053dce5394 (patch) | |
tree | cff3171b99578309123c17fc0bdd40eac39931cc /src/gallium | |
parent | b70a51318a43f489611f4fc2f93887a362f5c99f (diff) |
r600g: only maintain the list of active queries
And not all existing queries. The only reason we have that list is to be able
to suspend and resume the active ones.
This reduces looping over queries when suspending and resuming.
The queries no longer have to track some of their states.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/r600/evergreen_hw_context.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600.h | 11 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_hw_context.c | 33 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_query.c | 5 |
4 files changed, 19 insertions, 32 deletions
diff --git a/src/gallium/drivers/r600/evergreen_hw_context.c b/src/gallium/drivers/r600/evergreen_hw_context.c index 3779dd480f8..72ec5630b9a 100644 --- a/src/gallium/drivers/r600/evergreen_hw_context.c +++ b/src/gallium/drivers/r600/evergreen_hw_context.c @@ -905,7 +905,7 @@ int evergreen_context_init(struct r600_context *ctx, struct r600_screen *screen) memset(ctx, 0, sizeof(struct r600_context)); ctx->screen = screen; - LIST_INITHEAD(&ctx->query_list); + LIST_INITHEAD(&ctx->active_query_list); /* init dirty list */ LIST_INITHEAD(&ctx->dirty); diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h index ea9a2d658c2..f58549afb4d 100644 --- a/src/gallium/drivers/r600/r600.h +++ b/src/gallium/drivers/r600/r600.h @@ -179,7 +179,7 @@ struct r600_query { /* Count of new queries started in one stream without flushing */ unsigned queries_emitted; /* State flags */ - unsigned state; + boolean flushed; /* The buffer where query results are stored. It's used as a ring, * data blocks for current query are stored sequentially from * results_start to results_end, with wrapping on the buffer end */ @@ -188,11 +188,6 @@ struct r600_query { 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) -#define R600_QUERY_STATE_FLUSHED (1 << 3) - #define R600_CONTEXT_DRAW_PENDING (1 << 0) #define R600_CONTEXT_DST_CACHES_DIRTY (1 << 1) #define R600_CONTEXT_CHECK_EVENT_FLUSH (1 << 2) @@ -218,7 +213,9 @@ struct r600_context { u32 *pm4; unsigned pm4_cdwords; - struct list_head query_list; + /* The list of active queries. Only one query of each type can be active. */ + struct list_head active_query_list; + unsigned num_query_running; unsigned backend_mask; unsigned max_db; /* for OQ */ diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c index aec537f82da..e9c61875429 100644 --- a/src/gallium/drivers/r600/r600_hw_context.c +++ b/src/gallium/drivers/r600/r600_hw_context.c @@ -832,7 +832,7 @@ int r600_context_init(struct r600_context *ctx, struct r600_screen *screen) memset(ctx, 0, sizeof(struct r600_context)); ctx->screen = screen; - LIST_INITHEAD(&ctx->query_list); + LIST_INITHEAD(&ctx->active_query_list); /* init dirty list */ LIST_INITHEAD(&ctx->dirty); @@ -1623,7 +1623,7 @@ void r600_query_begin(struct r600_context *ctx, struct r600_query *query) /* Count queries emitted without flushes, and flush if more than * half of buffer used, to avoid overwriting results which may be * still in use. */ - if (query->state & R600_QUERY_STATE_FLUSHED) { + if (query->flushed) { query->queries_emitted = 1; } else { if (++query->queries_emitted > query->buffer->b.b.b.width0 / query->result_size / 2) @@ -1637,7 +1637,7 @@ void r600_query_begin(struct r600_context *ctx, struct r600_query *query) /* collect current results if query buffer is full */ if (new_results_end == query->results_start) { - if (!(query->state & R600_QUERY_STATE_FLUSHED)) + if (!query->flushed) r600_context_flush(ctx, 0); r600_query_result(ctx, query, TRUE); } @@ -1684,8 +1684,6 @@ void r600_query_begin(struct r600_context *ctx, struct r600_query *query) ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NOP, 0, 0); ctx->pm4[ctx->pm4_cdwords++] = r600_context_bo_reloc(ctx, query->buffer, RADEON_USAGE_WRITE); - query->state |= R600_QUERY_STATE_STARTED; - query->state ^= R600_QUERY_STATE_ENDED; ctx->num_query_running++; } @@ -1717,9 +1715,7 @@ void r600_query_end(struct r600_context *ctx, struct r600_query *query) if (query->results_end >= query->buffer->b.b.b.width0) query->results_end = 0; - query->state ^= R600_QUERY_STATE_STARTED; - query->state |= R600_QUERY_STATE_ENDED; - query->state &= ~R600_QUERY_STATE_FLUSHED; + query->flushed = FALSE; ctx->num_query_running--; } @@ -1806,15 +1802,12 @@ struct r600_query *r600_context_query_create(struct r600_context *ctx, unsigned FREE(query); return NULL; } - - LIST_ADDTAIL(&query->list, &ctx->query_list); return query; } void r600_context_query_destroy(struct r600_context *ctx, struct r600_query *query) { pipe_resource_reference((struct pipe_resource**)&query->buffer, NULL); - LIST_DELINIT(&query->list); free(query); } @@ -1824,7 +1817,7 @@ boolean r600_context_query_result(struct r600_context *ctx, { uint64_t *result = (uint64_t*)vresult; - if (!(query->state & R600_QUERY_STATE_FLUSHED)) { + if (!query->flushed) { r600_context_flush(ctx, 0); } if (!r600_query_result(ctx, query, wait)) @@ -1849,11 +1842,8 @@ void r600_context_queries_suspend(struct r600_context *ctx) { struct r600_query *query; - LIST_FOR_EACH_ENTRY(query, &ctx->query_list, list) { - if (query->state & R600_QUERY_STATE_STARTED) { - r600_query_end(ctx, query); - query->state |= R600_QUERY_STATE_SUSPENDED; - } + LIST_FOR_EACH_ENTRY(query, &ctx->active_query_list, list) { + r600_query_end(ctx, query); } } @@ -1861,13 +1851,10 @@ void r600_context_queries_resume(struct r600_context *ctx, boolean flushed) { struct r600_query *query; - LIST_FOR_EACH_ENTRY(query, &ctx->query_list, list) { + LIST_FOR_EACH_ENTRY(query, &ctx->active_query_list, list) { if (flushed) - query->state |= R600_QUERY_STATE_FLUSHED; + query->flushed = TRUE; - if (query->state & R600_QUERY_STATE_SUSPENDED) { - r600_query_begin(ctx, query); - query->state ^= R600_QUERY_STATE_SUSPENDED; - } + r600_query_begin(ctx, query); } } diff --git a/src/gallium/drivers/r600/r600_query.c b/src/gallium/drivers/r600/r600_query.c index e3512f7b1a6..a632ef4615b 100644 --- a/src/gallium/drivers/r600/r600_query.c +++ b/src/gallium/drivers/r600/r600_query.c @@ -45,13 +45,16 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query) rquery->result = 0; rquery->results_start = rquery->results_end; r600_query_begin(&rctx->ctx, (struct r600_query *)query); + LIST_ADDTAIL(&rquery->list, &rctx->ctx.active_query_list); } static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query) { struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx; + struct r600_query *rquery = (struct r600_query *)query; - r600_query_end(&rctx->ctx, (struct r600_query *)query); + r600_query_end(&rctx->ctx, rquery); + LIST_DELINIT(&rquery->list); } static boolean r600_get_query_result(struct pipe_context *ctx, |