radeonsi: Do not suspend timer queries
authorNiels Ole Salscheider <niels_ole@salscheider-online.de>
Wed, 28 Aug 2013 16:42:40 +0000 (18:42 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 30 Aug 2013 21:30:00 +0000 (23:30 +0200)
Signed-off-by: Niels Ole Salscheider <niels_ole@salscheider-online.de>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/r600.h
src/gallium/drivers/radeonsi/r600_hw_context.c
src/gallium/drivers/radeonsi/r600_query.c
src/gallium/drivers/radeonsi/radeonsi_pipe.c
src/gallium/drivers/radeonsi/radeonsi_pipe.h
src/gallium/drivers/radeonsi/si_state_draw.c

index ce0468d41554cfa91eb90b8d14a5ec9ecc26d992..ac3b2f181eaca96adb49114fc51c4162e5a8cecb 100644 (file)
@@ -102,6 +102,7 @@ void si_context_emit_fence(struct r600_context *ctx, struct si_resource *fence,
                            unsigned offset, unsigned value);
 
 void r600_context_draw_opaque_count(struct r600_context *ctx, struct r600_so_target *t);
+bool si_is_timer_query(unsigned type);
 bool si_query_needs_begin(unsigned type);
 void si_need_cs_space(struct r600_context *ctx, unsigned num_dw, boolean count_draw_in);
 
index 59b2d70912784b59525477d258908f4ddd202f6b..f050b3b965e4bafbc312d9da5023fc3a3e7fd1c7 100644 (file)
@@ -110,6 +110,13 @@ err:
        return;
 }
 
+bool si_is_timer_query(unsigned type)
+{
+       return type == PIPE_QUERY_TIME_ELAPSED ||
+               type == PIPE_QUERY_TIMESTAMP ||
+               type == PIPE_QUERY_TIMESTAMP_DISJOINT;
+}
+
 bool si_query_needs_begin(unsigned type)
 {
        return type != PIPE_QUERY_TIMESTAMP;
@@ -139,7 +146,7 @@ void si_need_cs_space(struct r600_context *ctx, unsigned num_dw,
        }
 
        /* Count in queries_suspend. */
-       num_dw += ctx->num_cs_dw_queries_suspend;
+       num_dw += ctx->num_cs_dw_nontimer_queries_suspend;
 
        /* Count in streamout_end at the end of CS. */
        num_dw += ctx->num_cs_dw_streamout_end;
@@ -211,7 +218,7 @@ void si_context_flush(struct r600_context *ctx, unsigned flags)
                return;
 
        /* suspend queries */
-       if (ctx->num_cs_dw_queries_suspend) {
+       if (ctx->num_cs_dw_nontimer_queries_suspend) {
                r600_context_queries_suspend(ctx);
                queries_suspended = true;
        }
@@ -506,7 +513,9 @@ void r600_query_begin(struct r600_context *ctx, struct r600_query *query)
        cs->buf[cs->cdw++] = PKT3(PKT3_NOP, 0, 0);
        cs->buf[cs->cdw++] = r600_context_bo_reloc(ctx, query->buffer, RADEON_USAGE_WRITE);
 
-       ctx->num_cs_dw_queries_suspend += query->num_cs_dw;
+       if (!si_is_timer_query(query->type)) {
+               ctx->num_cs_dw_nontimer_queries_suspend += query->num_cs_dw;
+       }
 }
 
 void r600_query_end(struct r600_context *ctx, struct r600_query *query)
@@ -565,7 +574,10 @@ void r600_query_end(struct r600_context *ctx, struct r600_query *query)
        cs->buf[cs->cdw++] = r600_context_bo_reloc(ctx, query->buffer, RADEON_USAGE_WRITE);
 
        query->results_end = (query->results_end + query->result_size) % query->buffer->b.b.width0;
-       ctx->num_cs_dw_queries_suspend -= query->num_cs_dw;
+
+       if (si_query_needs_begin(query->type) && !si_is_timer_query(query->type)) {
+               ctx->num_cs_dw_nontimer_queries_suspend -= query->num_cs_dw;
+       }
 }
 
 void r600_query_predication(struct r600_context *ctx, struct r600_query *query, int operation,
@@ -712,19 +724,19 @@ void r600_context_queries_suspend(struct r600_context *ctx)
 {
        struct r600_query *query;
 
-       LIST_FOR_EACH_ENTRY(query, &ctx->active_query_list, list) {
+       LIST_FOR_EACH_ENTRY(query, &ctx->active_nontimer_query_list, list) {
                r600_query_end(ctx, query);
        }
-       assert(ctx->num_cs_dw_queries_suspend == 0);
+       assert(ctx->num_cs_dw_nontimer_queries_suspend == 0);
 }
 
 void r600_context_queries_resume(struct r600_context *ctx)
 {
        struct r600_query *query;
 
-       assert(ctx->num_cs_dw_queries_suspend == 0);
+       assert(ctx->num_cs_dw_nontimer_queries_suspend == 0);
 
-       LIST_FOR_EACH_ENTRY(query, &ctx->active_query_list, list) {
+       LIST_FOR_EACH_ENTRY(query, &ctx->active_nontimer_query_list, list) {
                r600_query_begin(ctx, query);
        }
 }
index 927577c220c2518a86cbce97264425f269122df6..aa51e741739db6cff7f369d6dbeb20315954af44 100644 (file)
@@ -50,7 +50,10 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query)
        memset(&rquery->result, 0, sizeof(rquery->result));
        rquery->results_start = rquery->results_end;
        r600_query_begin(rctx, (struct r600_query *)query);
-       LIST_ADDTAIL(&rquery->list, &rctx->active_query_list);
+
+       if (!si_is_timer_query(rquery->type)) {
+               LIST_ADDTAIL(&rquery->list, &rctx->active_nontimer_query_list);
+       }
 }
 
 static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query)
@@ -64,7 +67,7 @@ static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query)
 
        r600_query_end(rctx, rquery);
 
-       if (si_query_needs_begin(rquery->type)) {
+       if (si_query_needs_begin(rquery->type) && !si_is_timer_query(rquery->type)) {
                LIST_DELINIT(&rquery->list);
        }
 }
index 91c41e78a127fc0042d30197c94ca58057200158..8a5d7016d10b172304f4a35b251fa96a648d1afe 100644 (file)
@@ -245,7 +245,7 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
        case SI:
        case CIK:
                si_init_state_functions(rctx);
-               LIST_INITHEAD(&rctx->active_query_list);
+               LIST_INITHEAD(&rctx->active_nontimer_query_list);
                rctx->max_db = 8;
                si_init_config(rctx);
                break;
index f9e49996e2cd13c66f4eaf81d6134d463bcf366f..faad8e1b8c8c3710cb5bad0e80119566904dc9eb 100644 (file)
@@ -192,8 +192,8 @@ struct r600_context {
        unsigned                pm4_dirty_cdwords;
 
        /* The list of active queries. Only one query of each type can be active. */
-       struct list_head        active_query_list;
-       unsigned                num_cs_dw_queries_suspend;
+       struct list_head        active_nontimer_query_list;
+       unsigned                num_cs_dw_nontimer_queries_suspend;
        unsigned                num_cs_dw_streamout_end;
 
        unsigned                backend_mask;
index 15cb87f32ae5481115ff29b72a769664fa0f3b5b..44ec735d5675410341d836228ccc5ae1ef45d9e3 100644 (file)
@@ -594,7 +594,7 @@ static void si_state_draw(struct r600_context *rctx,
 
        /* queries need some special values
         * (this is non-zero if any query is active) */
-       if (rctx->num_cs_dw_queries_suspend) {
+       if (rctx->num_cs_dw_nontimer_queries_suspend) {
                struct si_state_dsa *dsa = rctx->queued.named.dsa;
 
                si_pm4_set_reg(pm4, R_028004_DB_COUNT_CONTROL,