From fb45a816eb9de88b2862c51ca107676b9eaade8d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 21 Dec 2012 16:29:19 +0100 Subject: [PATCH] r600g: don't suspend TIME_ELAPSED queries during flushing According to the GL spec, the result should be equivalent to comparing two timestamps. --- src/gallium/drivers/r600/r600_hw_context.c | 9 ------ src/gallium/drivers/r600/r600_pipe.c | 1 - src/gallium/drivers/r600/r600_pipe.h | 16 +++------- src/gallium/drivers/r600/r600_query.c | 36 +++------------------- 4 files changed, 8 insertions(+), 54 deletions(-) diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c index 6c8cb9d6c98..486bc7acf76 100644 --- a/src/gallium/drivers/r600/r600_hw_context.c +++ b/src/gallium/drivers/r600/r600_hw_context.c @@ -391,7 +391,6 @@ void r600_need_cs_space(struct r600_context *ctx, unsigned num_dw, /* Count in queries_suspend. */ num_dw += ctx->num_cs_dw_nontimer_queries_suspend; - num_dw += ctx->num_cs_dw_timer_queries_suspend; /* Count in streamout_end at the end of CS. */ num_dw += ctx->num_cs_dw_streamout_end; @@ -691,15 +690,10 @@ void r600_context_flush(struct r600_context *ctx, unsigned flags) if (cs->cdw == ctx->start_cs_cmd.num_dw) return; - ctx->timer_queries_suspended = false; ctx->nontimer_queries_suspended = false; ctx->streamout_suspended = false; /* suspend queries */ - if (ctx->num_cs_dw_timer_queries_suspend) { - r600_suspend_timer_queries(ctx); - ctx->timer_queries_suspended = true; - } if (ctx->num_cs_dw_nontimer_queries_suspend) { r600_suspend_nontimer_queries(ctx); ctx->nontimer_queries_suspended = true; @@ -827,9 +821,6 @@ void r600_begin_new_cs(struct r600_context *ctx) } /* resume queries */ - if (ctx->timer_queries_suspended) { - r600_resume_timer_queries(ctx); - } if (ctx->nontimer_queries_suspended) { r600_resume_nontimer_queries(ctx); } diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index b02f875c25b..65dcbf8a5e9 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -227,7 +227,6 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void rctx->chip_class = rscreen->chip_class; rctx->keep_tiling_flags = rscreen->info.drm_minor >= 12; - LIST_INITHEAD(&rctx->active_timer_queries); LIST_INITHEAD(&rctx->active_nontimer_queries); LIST_INITHEAD(&rctx->dirty); LIST_INITHEAD(&rctx->enable_list); diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index 84187378995..6b7c0537604 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -496,18 +496,12 @@ struct r600_context { /* Queries. */ /* The list of active queries. Only one query of each type can be active. */ int num_occlusion_queries; - /* Manage queries in two separate groups: - * The timer ones and the others (streamout, occlusion). - * - * We do this because we should only suspend non-timer queries for u_blitter, - * and later if the non-timer queries are suspended, the context flush should - * only suspend and resume the timer queries. */ - struct list_head active_timer_queries; - unsigned num_cs_dw_timer_queries_suspend; + /* Keep track of non-timer queries, because they should be suspended + * during context flushing. + * The timer queries (TIME_ELAPSED) shouldn't be suspended. */ struct list_head active_nontimer_queries; unsigned num_cs_dw_nontimer_queries_suspend; - /* Flags if queries have been suspended. */ - bool timer_queries_suspended; + /* If queries have been suspended. */ bool nontimer_queries_suspended; /* Render condition. */ @@ -636,8 +630,6 @@ void r600_flush(struct pipe_context *ctx, struct pipe_fence_handle **fence, void r600_init_query_functions(struct r600_context *rctx); void r600_suspend_nontimer_queries(struct r600_context *ctx); void r600_resume_nontimer_queries(struct r600_context *ctx); -void r600_suspend_timer_queries(struct r600_context *ctx); -void r600_resume_timer_queries(struct r600_context *ctx); /* r600_resource.c */ void r600_init_context_resource_functions(struct r600_context *r600); diff --git a/src/gallium/drivers/r600/r600_query.c b/src/gallium/drivers/r600/r600_query.c index d35d3fbd0bd..083d510677a 100644 --- a/src/gallium/drivers/r600/r600_query.c +++ b/src/gallium/drivers/r600/r600_query.c @@ -156,9 +156,7 @@ static void r600_emit_query_begin(struct r600_context *ctx, struct r600_query *q cs->buf[cs->cdw++] = PKT3(PKT3_NOP, 0, 0); cs->buf[cs->cdw++] = r600_context_bo_reloc(ctx, query->buffer.buf, RADEON_USAGE_WRITE); - if (r600_is_timer_query(query->type)) { - ctx->num_cs_dw_timer_queries_suspend += query->num_cs_dw; - } else { + if (!r600_is_timer_query(query->type)) { ctx->num_cs_dw_nontimer_queries_suspend += query->num_cs_dw; } } @@ -213,9 +211,7 @@ static void r600_emit_query_end(struct r600_context *ctx, struct r600_query *que query->buffer.results_end += query->result_size; if (r600_query_needs_begin(query->type)) { - if (r600_is_timer_query(query->type)) { - ctx->num_cs_dw_timer_queries_suspend -= query->num_cs_dw; - } else { + if (!r600_is_timer_query(query->type)) { ctx->num_cs_dw_nontimer_queries_suspend -= query->num_cs_dw; } } @@ -366,9 +362,7 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query) r600_emit_query_begin(rctx, rquery); - if (r600_is_timer_query(rquery->type)) { - LIST_ADDTAIL(&rquery->list, &rctx->active_timer_queries); - } else { + if (!r600_is_timer_query(rquery->type)) { LIST_ADDTAIL(&rquery->list, &rctx->active_nontimer_queries); } } @@ -380,7 +374,7 @@ static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query) r600_emit_query_end(rctx, rquery); - if (r600_query_needs_begin(rquery->type)) { + if (r600_query_needs_begin(rquery->type) && !r600_is_timer_query(rquery->type)) { LIST_DELINIT(&rquery->list); } } @@ -581,28 +575,6 @@ void r600_resume_nontimer_queries(struct r600_context *ctx) } } -void r600_suspend_timer_queries(struct r600_context *ctx) -{ - struct r600_query *query; - - LIST_FOR_EACH_ENTRY(query, &ctx->active_timer_queries, list) { - r600_emit_query_end(ctx, query); - } - - assert(ctx->num_cs_dw_timer_queries_suspend == 0); -} - -void r600_resume_timer_queries(struct r600_context *ctx) -{ - struct r600_query *query; - - assert(ctx->num_cs_dw_timer_queries_suspend == 0); - - LIST_FOR_EACH_ENTRY(query, &ctx->active_timer_queries, list) { - r600_emit_query_begin(ctx, query); - } -} - void r600_init_query_functions(struct r600_context *rctx) { rctx->context.create_query = r600_create_query; -- 2.30.2