[Mesa-dev] [PATCH 04/11] radeonsi: initialize the first CS like any other

Marek Olšák maraeo at gmail.com
Tue Sep 3 06:22:56 PDT 2013


So that the "init" state is always emitted first and not later in draw_vbo.

This fixes streamout where the "init" state, which disables streamout,
was emitted in draw_vbo after streamout was enabled.
---
 src/gallium/drivers/radeonsi/r600.h            |  1 +
 src/gallium/drivers/radeonsi/r600_hw_context.c | 11 ++++++++---
 src/gallium/drivers/radeonsi/radeonsi_pipe.c   |  5 +++--
 src/gallium/drivers/radeonsi/radeonsi_pipe.h   |  2 ++
 src/gallium/drivers/radeonsi/radeonsi_pm4.c    |  1 +
 5 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/r600.h b/src/gallium/drivers/radeonsi/r600.h
index a914ce2..4b43169 100644
--- a/src/gallium/drivers/radeonsi/r600.h
+++ b/src/gallium/drivers/radeonsi/r600.h
@@ -74,6 +74,7 @@ struct r600_screen;
 
 void si_get_backend_mask(struct r600_context *ctx);
 void si_context_flush(struct r600_context *ctx, unsigned flags);
+void si_begin_new_cs(struct r600_context *ctx);
 
 struct r600_query *r600_context_query_create(struct r600_context *ctx, unsigned query_type);
 void r600_context_query_destroy(struct r600_context *ctx, struct r600_query *query);
diff --git a/src/gallium/drivers/radeonsi/r600_hw_context.c b/src/gallium/drivers/radeonsi/r600_hw_context.c
index 1a2128e..c8fa66c 100644
--- a/src/gallium/drivers/radeonsi/r600_hw_context.c
+++ b/src/gallium/drivers/radeonsi/r600_hw_context.c
@@ -179,15 +179,15 @@ void si_need_cs_space(struct r600_context *ctx, unsigned num_dw,
 void si_context_flush(struct r600_context *ctx, unsigned flags)
 {
 	struct radeon_winsys_cs *cs = ctx->b.rings.gfx.cs;
-	bool queries_suspended = false;
 
 	if (!cs->cdw)
 		return;
 
 	/* suspend queries */
+	ctx->nontimer_queries_suspended = false;
 	if (ctx->num_cs_dw_nontimer_queries_suspend) {
 		r600_context_queries_suspend(ctx);
-		queries_suspended = true;
+		ctx->nontimer_queries_suspended = true;
 	}
 
 	ctx->b.streamout.suspended = false;
@@ -245,6 +245,11 @@ void si_context_flush(struct r600_context *ctx, unsigned flags)
 	}
 #endif
 
+	si_begin_new_cs(ctx);
+}
+
+void si_begin_new_cs(struct r600_context *ctx)
+{
 	ctx->pm4_dirty_cdwords = 0;
 
 	/* Flush read caches at the beginning of CS. */
@@ -267,7 +272,7 @@ void si_context_flush(struct r600_context *ctx, unsigned flags)
 	}
 
 	/* resume queries */
-	if (queries_suspended) {
+	if (ctx->nontimer_queries_suspended) {
 		r600_context_queries_resume(ctx);
 	}
 
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.c b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
index 993f30a..e219e36 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
@@ -279,14 +279,15 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
 	if (rctx->blitter == NULL)
 		goto fail;
 
-	si_get_backend_mask(rctx); /* this emits commands and must be last */
-
 	rctx->dummy_pixel_shader =
 		util_make_fragment_cloneinput_shader(&rctx->b.b, 0,
 						     TGSI_SEMANTIC_GENERIC,
 						     TGSI_INTERPOLATE_CONSTANT);
 	rctx->b.b.bind_fs_state(&rctx->b.b, rctx->dummy_pixel_shader);
 
+	/* these must be last */
+	si_begin_new_cs(rctx);
+	si_get_backend_mask(rctx);
 	return &rctx->b.b;
 fail:
 	r600_destroy_context(&rctx->b.b);
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index ed17f2c..c5059e8 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -180,6 +180,8 @@ struct r600_context {
 	/* The list of active queries. Only one query of each type can be active. */
 	struct list_head	active_nontimer_query_list;
 	unsigned		num_cs_dw_nontimer_queries_suspend;
+	/* If queries have been suspended. */
+	bool			nontimer_queries_suspended;
 
 	unsigned		backend_mask;
 	unsigned                max_db; /* for OQ */
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pm4.c b/src/gallium/drivers/radeonsi/radeonsi_pm4.c
index 37a199d..eed0c47 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pm4.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_pm4.c
@@ -242,6 +242,7 @@ void si_pm4_emit_dirty(struct r600_context *rctx)
 		if (!state || rctx->emitted.array[i] == state)
 			continue;
 
+		assert(state != rctx->queued.named.init);
 		si_pm4_emit(rctx, state);
 		rctx->emitted.array[i] = state;
 	}
-- 
1.8.1.2



More information about the mesa-dev mailing list