From 670f847776c02eb2b44d0d353e1ce6cf1b06d06b Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Sat, 2 Jul 2011 09:26:17 +0200 Subject: [PATCH 2/2] r600g: add logic to avoid infinite loop flush->begin_query->flush r600_begin_query() is now given a flag allowing it to skip the call to r600_context_flush(). This flag is TRUE when called from r600_cibtext_queries_resume(), which is called at the end of r600_context_flush() --- src/gallium/drivers/r600/r600.h | 2 +- src/gallium/drivers/r600/r600_query.c | 2 +- src/gallium/winsys/r600/drm/r600_hw_context.c | 13 ++++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h index 225c17c..0f45c9e 100644 --- a/src/gallium/drivers/r600/r600.h +++ b/src/gallium/drivers/r600/r600.h @@ -290,7 +290,7 @@ void r600_context_query_destroy(struct r600_context *ctx, struct r600_query *que 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_begin(struct r600_context *ctx, struct r600_query *query, bool context_flush_just_done); void r600_query_end(struct r600_context *ctx, struct r600_query *query); void r600_context_queries_suspend(struct r600_context *ctx); void r600_context_queries_resume(struct r600_context *ctx); diff --git a/src/gallium/drivers/r600/r600_query.c b/src/gallium/drivers/r600/r600_query.c index bedb48b..691a42c 100644 --- a/src/gallium/drivers/r600/r600_query.c +++ b/src/gallium/drivers/r600/r600_query.c @@ -44,7 +44,7 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query) rquery->result = 0; rquery->num_results = 0; - r600_query_begin(&rctx->ctx, (struct r600_query *)query); + r600_query_begin(&rctx->ctx, (struct r600_query *)query, FALSE); } static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query) diff --git a/src/gallium/winsys/r600/drm/r600_hw_context.c b/src/gallium/winsys/r600/drm/r600_hw_context.c index f89f24c..b743a34 100644 --- a/src/gallium/winsys/r600/drm/r600_hw_context.c +++ b/src/gallium/winsys/r600/drm/r600_hw_context.c @@ -1721,7 +1721,7 @@ static boolean r600_query_result(struct r600_context *ctx, struct r600_query *qu return TRUE; } -void r600_query_begin(struct r600_context *ctx, struct r600_query *query) +void r600_query_begin(struct r600_context *ctx, struct r600_query *query, bool context_flush_just_done) { unsigned required_space; int num_backends = r600_get_num_backends(ctx->radeon); @@ -1733,13 +1733,17 @@ void r600_query_begin(struct r600_context *ctx, struct r600_query *query) required_space = 12; if ((required_space + ctx->pm4_cdwords) > ctx->pm4_ndwords) { + assert(!context_flush_just_done); /* need to flush */ r600_context_flush(ctx); + context_flush_just_done = TRUE; } /* if query buffer is full force a flush */ if (query->num_results*4 >= query->buffer_size - 16) { - r600_context_flush(ctx); + if (!context_flush_just_done) { + r600_context_flush(ctx); + } r600_query_result(ctx, query, TRUE); } @@ -1906,7 +1910,10 @@ void r600_context_queries_resume(struct r600_context *ctx) LIST_FOR_EACH_ENTRY(query, &ctx->query_list, list) { if (query->state & R600_QUERY_STATE_SUSPENDED) { - r600_query_begin(ctx, query); + /* r600_context_queries_resume is always called from r600_context_flush, + hence we inform r600_query_begin that it does need to perform + a flush */ + r600_query_begin(ctx, query, TRUE); query->state ^= R600_QUERY_STATE_SUSPENDED; } } -- 1.7.5.4