Mesa (master): r600g: don't double count dirty block

Jerome Glisse glisse at kemper.freedesktop.org
Thu Sep 30 21:39:26 UTC 2010


Module: Mesa
Branch: master
Commit: dde1391cc95478f4dedccdf920ba0a6607472937
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=dde1391cc95478f4dedccdf920ba0a6607472937

Author: John Doe <glisse at barney.(none)>
Date:   Thu Sep 30 17:30:25 2010 -0400

r600g: don't double count dirty block

This avoid to overcount the number of dwords we need and
thus avoid maximazation of cs buffer use.

Signed-off-by: Jerome Glisse <jglisse at redhat.com

---

 src/gallium/winsys/r600/drm/evergreen_hw_context.c |   32 ++++++++++++-------
 src/gallium/winsys/r600/drm/r600_hw_context.c      |   32 ++++++++++++-------
 src/gallium/winsys/r600/drm/r600_priv.h            |    4 +-
 3 files changed, 42 insertions(+), 26 deletions(-)

diff --git a/src/gallium/winsys/r600/drm/evergreen_hw_context.c b/src/gallium/winsys/r600/drm/evergreen_hw_context.c
index 7d6bd50..e3390fd 100644
--- a/src/gallium/winsys/r600/drm/evergreen_hw_context.c
+++ b/src/gallium/winsys/r600/drm/evergreen_hw_context.c
@@ -625,9 +625,11 @@ static inline void evergreen_context_pipe_state_set_resource(struct r600_context
 		radeon_ws_bo_reference(ctx->radeon, &block->reloc[1].bo, state->regs[2].bo);
 		radeon_ws_bo_reference(ctx->radeon, &block->reloc[2].bo, state->regs[3].bo);
 	}
-	block->status |= R600_BLOCK_STATUS_ENABLED;
-	block->status |= R600_BLOCK_STATUS_DIRTY;
-	ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
+		block->status |= R600_BLOCK_STATUS_ENABLED;
+		block->status |= R600_BLOCK_STATUS_DIRTY;
+		ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	}
 }
 
 void evergreen_context_pipe_state_set_ps_resource(struct r600_context *ctx, struct r600_pipe_state *state, unsigned rid)
@@ -658,9 +660,11 @@ static inline void evergreen_context_pipe_state_set_sampler(struct r600_context
 	block->reg[0] = state->regs[0].value;
 	block->reg[1] = state->regs[1].value;
 	block->reg[2] = state->regs[2].value;
-	block->status |= R600_BLOCK_STATUS_ENABLED;
-	block->status |= R600_BLOCK_STATUS_DIRTY;
-	ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
+		block->status |= R600_BLOCK_STATUS_ENABLED;
+		block->status |= R600_BLOCK_STATUS_DIRTY;
+		ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	}
 }
 
 static inline void evergreen_context_pipe_state_set_sampler_border(struct r600_context *ctx, struct r600_pipe_state *state, unsigned offset, unsigned id)
@@ -683,9 +687,11 @@ static inline void evergreen_context_pipe_state_set_sampler_border(struct r600_c
 	block->reg[2] = state->regs[4].value;
 	block->reg[3] = state->regs[5].value;
 	block->reg[4] = state->regs[6].value;
-	block->status |= R600_BLOCK_STATUS_ENABLED;
-	block->status |= R600_BLOCK_STATUS_DIRTY;
-	ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
+		block->status |= R600_BLOCK_STATUS_ENABLED;
+		block->status |= R600_BLOCK_STATUS_DIRTY;
+		ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	}
 }
 
 void evergreen_context_pipe_state_set_ps_sampler(struct r600_context *ctx, struct r600_pipe_state *state, unsigned id)
@@ -837,9 +843,11 @@ static inline void evergreen_resource_set(struct r600_context *ctx, struct r600_
 		radeon_ws_bo_reference(ctx->radeon, &block->reloc[1].bo, state->regs[2].bo);
 		radeon_ws_bo_reference(ctx->radeon, &block->reloc[2].bo, state->regs[3].bo);
 	}
-	block->status |= R600_BLOCK_STATUS_ENABLED;
-	block->status |= R600_BLOCK_STATUS_DIRTY;
-	ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
+		block->status |= R600_BLOCK_STATUS_ENABLED;
+		block->status |= R600_BLOCK_STATUS_DIRTY;
+		ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	}
 }
 
 void evergreen_ps_resource_set(struct r600_context *ctx, struct r600_pipe_state *state, unsigned rid)
diff --git a/src/gallium/winsys/r600/drm/r600_hw_context.c b/src/gallium/winsys/r600/drm/r600_hw_context.c
index f363b69..6cb0b94 100644
--- a/src/gallium/winsys/r600/drm/r600_hw_context.c
+++ b/src/gallium/winsys/r600/drm/r600_hw_context.c
@@ -721,9 +721,11 @@ void r600_context_pipe_state_set(struct r600_context *ctx, struct r600_pipe_stat
 			id = block->pm4_bo_index[id];
 			radeon_ws_bo_reference(ctx->radeon, &block->reloc[id].bo, state->regs[i].bo);
 		}
-		block->status |= R600_BLOCK_STATUS_ENABLED;
-		block->status |= R600_BLOCK_STATUS_DIRTY;
-		ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+		if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
+			block->status |= R600_BLOCK_STATUS_ENABLED;
+			block->status |= R600_BLOCK_STATUS_DIRTY;
+			ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+		}
 	}
 }
 
@@ -760,9 +762,11 @@ static inline void r600_context_pipe_state_set_resource(struct r600_context *ctx
 		radeon_ws_bo_reference(ctx->radeon, &block->reloc[1].bo, state->regs[2].bo);
 		radeon_ws_bo_reference(ctx->radeon, &block->reloc[2].bo, state->regs[3].bo);
 	}
-	block->status |= R600_BLOCK_STATUS_ENABLED;
-	block->status |= R600_BLOCK_STATUS_DIRTY;
-	ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
+		block->status |= R600_BLOCK_STATUS_ENABLED;
+		block->status |= R600_BLOCK_STATUS_DIRTY;
+		ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	}
 }
 
 void r600_context_pipe_state_set_ps_resource(struct r600_context *ctx, struct r600_pipe_state *state, unsigned rid)
@@ -793,9 +797,11 @@ static inline void r600_context_pipe_state_set_sampler(struct r600_context *ctx,
 	block->reg[0] = state->regs[0].value;
 	block->reg[1] = state->regs[1].value;
 	block->reg[2] = state->regs[2].value;
-	block->status |= R600_BLOCK_STATUS_ENABLED;
-	block->status |= R600_BLOCK_STATUS_DIRTY;
-	ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
+		block->status |= R600_BLOCK_STATUS_ENABLED;
+		block->status |= R600_BLOCK_STATUS_DIRTY;
+		ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	}
 }
 
 static inline void r600_context_pipe_state_set_sampler_border(struct r600_context *ctx, struct r600_pipe_state *state, unsigned offset)
@@ -816,9 +822,11 @@ static inline void r600_context_pipe_state_set_sampler_border(struct r600_contex
 	block->reg[1] = state->regs[4].value;
 	block->reg[2] = state->regs[5].value;
 	block->reg[3] = state->regs[6].value;
-	block->status |= R600_BLOCK_STATUS_ENABLED;
-	block->status |= R600_BLOCK_STATUS_DIRTY;
-	ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
+		block->status |= R600_BLOCK_STATUS_ENABLED;
+		block->status |= R600_BLOCK_STATUS_DIRTY;
+		ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+	}
 }
 
 void r600_context_pipe_state_set_ps_sampler(struct r600_context *ctx, struct r600_pipe_state *state, unsigned id)
diff --git a/src/gallium/winsys/r600/drm/r600_priv.h b/src/gallium/winsys/r600/drm/r600_priv.h
index 7106bb6..125fb4f 100644
--- a/src/gallium/winsys/r600/drm/r600_priv.h
+++ b/src/gallium/winsys/r600/drm/r600_priv.h
@@ -118,9 +118,9 @@ static void inline r600_context_reg(struct r600_context *ctx,
 	block->reg[id] |= value;
 	if (!(block->status & R600_BLOCK_STATUS_DIRTY)) {
 		ctx->pm4_dirty_cdwords += block->pm4_ndwords;
+		block->status |= R600_BLOCK_STATUS_ENABLED;
+		block->status |= R600_BLOCK_STATUS_DIRTY;
 	}
-	block->status |= R600_BLOCK_STATUS_ENABLED;
-	block->status |= R600_BLOCK_STATUS_DIRTY;
 }
 
 static inline void r600_context_block_emit_dirty(struct r600_context *ctx, struct r600_block *block)




More information about the mesa-commit mailing list