From 8b8c160a90a3ac539903f41ff5ba6339f20b8900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 3 Sep 2014 13:58:57 +0200 Subject: [PATCH] r600g,radeonsi: make sure there's enough CS space before resuming queries Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83432 Cc: mesa-stable@lists.freedesktop.org --- src/gallium/drivers/radeon/r600_query.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c index 503737c..eea7ba9 100644 --- a/src/gallium/drivers/radeon/r600_query.c +++ b/src/gallium/drivers/radeon/r600_query.c @@ -807,12 +807,32 @@ void r600_suspend_nontimer_queries(struct r600_common_context *ctx) assert(ctx->num_cs_dw_nontimer_queries_suspend == 0); } +static unsigned r600_queries_num_cs_dw_for_resuming(struct r600_common_context *ctx) +{ + struct r600_query *query; + unsigned num_dw = 0; + + LIST_FOR_EACH_ENTRY(query, &ctx->active_nontimer_queries, list) { + num_dw += query->num_cs_dw * 2; + } + /* primitives generated query */ + num_dw += ctx->streamout.enable_atom.num_dw; + /* guess for ZPASS enable or PERFECT_ZPASS_COUNT enable updates */ + num_dw += 13; + + return num_dw; +} + void r600_resume_nontimer_queries(struct r600_common_context *ctx) { struct r600_query *query; assert(ctx->num_cs_dw_nontimer_queries_suspend == 0); + /* Check CS space here. Resuming must not be interrupted by flushes. */ + ctx->need_gfx_cs_space(&ctx->b, + r600_queries_num_cs_dw_for_resuming(ctx), TRUE); + LIST_FOR_EACH_ENTRY(query, &ctx->active_nontimer_queries, list) { r600_emit_query_begin(ctx, query); } -- 1.9.1