[Mesa-dev] [PATCH] radeonsi: Do not suspend timer queries

Marek Olšák maraeo at gmail.com
Wed Aug 28 10:21:43 PDT 2013


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Wed, Aug 28, 2013 at 6:42 PM, Niels Ole Salscheider
<niels_ole at salscheider-online.de> wrote:
> Signed-off-by: Niels Ole Salscheider <niels_ole at salscheider-online.de>
> ---
>  src/gallium/drivers/radeonsi/r600.h            |  1 +
>  src/gallium/drivers/radeonsi/r600_hw_context.c | 28 ++++++++++++++++++--------
>  src/gallium/drivers/radeonsi/r600_query.c      |  7 +++++--
>  src/gallium/drivers/radeonsi/radeonsi_pipe.c   |  2 +-
>  src/gallium/drivers/radeonsi/radeonsi_pipe.h   |  4 ++--
>  src/gallium/drivers/radeonsi/si_state_draw.c   |  2 +-
>  6 files changed, 30 insertions(+), 14 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/r600.h b/src/gallium/drivers/radeonsi/r600.h
> index ce0468d..ac3b2f1 100644
> --- a/src/gallium/drivers/radeonsi/r600.h
> +++ b/src/gallium/drivers/radeonsi/r600.h
> @@ -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);
>
> diff --git a/src/gallium/drivers/radeonsi/r600_hw_context.c b/src/gallium/drivers/radeonsi/r600_hw_context.c
> index 59b2d70..f050b3b 100644
> --- a/src/gallium/drivers/radeonsi/r600_hw_context.c
> +++ b/src/gallium/drivers/radeonsi/r600_hw_context.c
> @@ -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);
>         }
>  }
> diff --git a/src/gallium/drivers/radeonsi/r600_query.c b/src/gallium/drivers/radeonsi/r600_query.c
> index 927577c..aa51e74 100644
> --- a/src/gallium/drivers/radeonsi/r600_query.c
> +++ b/src/gallium/drivers/radeonsi/r600_query.c
> @@ -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);
>         }
>  }
> diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.c b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
> index 91c41e7..8a5d701 100644
> --- a/src/gallium/drivers/radeonsi/radeonsi_pipe.c
> +++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
> @@ -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;
> diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
> index f9e4999..faad8e1 100644
> --- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
> +++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
> @@ -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;
> diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c
> index 15cb87f..44ec735 100644
> --- a/src/gallium/drivers/radeonsi/si_state_draw.c
> +++ b/src/gallium/drivers/radeonsi/si_state_draw.c
> @@ -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,
> --
> 1.8.3.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list