[Mesa-dev] [PATCH 05/10] r600g: Add pkt_flag parameter to r600_context_block_emit_dirty()

Tom Stellard tstellar at gmail.com
Wed Jun 27 08:37:29 PDT 2012


This allows the shader type bit to be set in the pm4 header when
emitting registers for compute shaders.
---
 src/gallium/drivers/r600/r600.h              |    2 +-
 src/gallium/drivers/r600/r600_hw_context.c   |   14 +++++++++++++-
 src/gallium/drivers/r600/r600_state_common.c |    2 +-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h
index d95eada..d4e01d9 100644
--- a/src/gallium/drivers/r600/r600.h
+++ b/src/gallium/drivers/r600/r600.h
@@ -215,7 +215,7 @@ void r600_context_streamout_begin(struct r600_context *ctx);
 void r600_context_streamout_end(struct r600_context *ctx);
 void r600_context_draw_opaque_count(struct r600_context *ctx, struct r600_so_target *t);
 void r600_need_cs_space(struct r600_context *ctx, unsigned num_dw, boolean count_draw_in);
-void r600_context_block_emit_dirty(struct r600_context *ctx, struct r600_block *block);
+void r600_context_block_emit_dirty(struct r600_context *ctx, struct r600_block *block, unsigned pkt_flags);
 void r600_context_block_resource_emit_dirty(struct r600_context *ctx, struct r600_block *block);
 
 int evergreen_context_init(struct r600_context *ctx);
diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c
index 9303d09..77c3553 100644
--- a/src/gallium/drivers/r600/r600_hw_context.c
+++ b/src/gallium/drivers/r600/r600_hw_context.c
@@ -1025,7 +1025,12 @@ void r600_context_pipe_state_set_vs_sampler(struct r600_context *ctx, struct r60
 	r600_context_pipe_state_set_sampler_border(ctx, state, offset);
 }
 
-void r600_context_block_emit_dirty(struct r600_context *ctx, struct r600_block *block)
+/**
+ * @param pkt_flags should be set to RADEON_CP_PACKET3_COMPUTE_MODE if this
+ * block will be used for compute shaders.
+ */
+void r600_context_block_emit_dirty(struct r600_context *ctx, struct r600_block *block,
+	unsigned pkt_flags)
 {
 	struct radeon_winsys_cs *cs = ctx->cs;
 	int optional = block->nbo == 0 && !(block->flags & REG_FLAG_DIRTY_ALWAYS);
@@ -1063,6 +1068,13 @@ void r600_context_block_emit_dirty(struct r600_context *ctx, struct r600_block *
 		cp_dwords = new_dwords + 2;
 	}
 	memcpy(&cs->buf[cs->cdw], block->pm4, cp_dwords * 4);
+
+	/* We are applying the pkt_flags after copying the register block to
+	 * the the command stream, because it is possible this block will be
+	 * emitted with a different pkt_flags, and we don't want to store the
+	 * pkt_flags in the block.
+	 */
+	cs->buf[cs->cdw] |= pkt_flags;
 	cs->cdw += cp_dwords;
 
 	if (optional) {
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index b5241a7..2cf0171 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -957,7 +957,7 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo)
 		r600_emit_atom(rctx, state);
 	}
 	LIST_FOR_EACH_ENTRY_SAFE(dirty_block, next_block, &rctx->dirty,list) {
-		r600_context_block_emit_dirty(rctx, dirty_block);
+		r600_context_block_emit_dirty(rctx, dirty_block, 0 /* pkt_flags */);
 	}
 	LIST_FOR_EACH_ENTRY_SAFE(dirty_block, next_block, &rctx->resource_dirty,list) {
 		r600_context_block_resource_emit_dirty(rctx, dirty_block);
-- 
1.7.7.6



More information about the mesa-dev mailing list