Mesa (master): r600g: work out range/block etc at state build time.

Dave Airlie airlied at kemper.freedesktop.org
Thu Jun 2 05:17:50 UTC 2011


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

Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Jun  2 14:57:13 2011 +1000

r600g: work out range/block etc at state build time.

This moves the overhead of working out the range/block to state build time,
it also allows the compiler to use constants for a lot of things instead
of working them out each time.

Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/gallium/drivers/r600/r600.h               |   11 ++++++-----
 src/gallium/drivers/r600/r600_state_common.c  |   10 +++++++++-
 src/gallium/winsys/r600/drm/r600_hw_context.c |    6 ++----
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h
index 2495aab..df02787 100644
--- a/src/gallium/drivers/r600/r600.h
+++ b/src/gallium/drivers/r600/r600.h
@@ -157,10 +157,11 @@ static INLINE unsigned r600_bo_offset(struct r600_bo *bo)
 #define CTX_BLOCK_ID(offset) (((offset - RANGE_OFFSET_START) >> 2) & ((1 << HASH_SHIFT) - 1))
 
 struct r600_pipe_reg {
-	u32				offset;
-	u32				mask;
 	u32				value;
-	struct r600_bo		*bo;
+	u32				mask;
+	struct r600_block 		*block;
+	struct r600_bo			*bo;
+	u32				id;
 };
 
 struct r600_pipe_state {
@@ -313,9 +314,9 @@ struct radeon *radeon_decref(struct radeon *radeon);
 void _r600_pipe_state_add_reg(struct r600_context *ctx,
 			      struct r600_pipe_state *state,
 			      u32 offset, u32 value, u32 mask,
+			      u32 range_id, u32 block_id,
 			      struct r600_bo *bo);
 
-#define r600_pipe_state_add_reg(state, offset, value, mask, bo) _r600_pipe_state_add_reg(&rctx->ctx, state, offset, value, mask, bo)
-
+#define r600_pipe_state_add_reg(state, offset, value, mask, bo) _r600_pipe_state_add_reg(&rctx->ctx, state, offset, value, mask, CTX_RANGE_ID(offset), CTX_BLOCK_ID(offset), bo)
 
 #endif
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index e1d637a..db9451f 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -634,12 +634,20 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
 void _r600_pipe_state_add_reg(struct r600_context *ctx,
 			      struct r600_pipe_state *state,
 			      u32 offset, u32 value, u32 mask,
+			      u32 range_id, u32 block_id,
 			      struct r600_bo *bo)
 {
-	state->regs[state->nregs].offset = offset;
+	struct r600_range *range;
+	struct r600_block *block;
+
+	range = &ctx->range[range_id];
+	block = range->blocks[block_id];
+
 	state->regs[state->nregs].value = value;
 	state->regs[state->nregs].mask = mask;
 	state->regs[state->nregs].bo = bo;
+	state->regs[state->nregs].block = block;
+	state->regs[state->nregs].id = (offset - block->start_offset) >> 2;
 	state->nregs++;
 	assert(state->nregs < R600_BLOCK_MAX_REG);
 }
diff --git a/src/gallium/winsys/r600/drm/r600_hw_context.c b/src/gallium/winsys/r600/drm/r600_hw_context.c
index 6415268..a3c8945 100644
--- a/src/gallium/winsys/r600/drm/r600_hw_context.c
+++ b/src/gallium/winsys/r600/drm/r600_hw_context.c
@@ -940,7 +940,6 @@ void r600_context_dirty_block(struct r600_context *ctx, struct r600_block *block
 
 void r600_context_pipe_state_set(struct r600_context *ctx, struct r600_pipe_state *state)
 {
-	struct r600_range *range;
 	struct r600_block *block;
 	unsigned new_val;
 	int dirty;
@@ -948,9 +947,8 @@ void r600_context_pipe_state_set(struct r600_context *ctx, struct r600_pipe_stat
 		unsigned id, reloc_id;
 		struct r600_pipe_reg *reg = &state->regs[i];
 
-		range = &ctx->range[CTX_RANGE_ID(reg->offset)];
-		block = range->blocks[CTX_BLOCK_ID(reg->offset)];
-		id = (reg->offset - block->start_offset) >> 2;
+		block = reg->block;
+		id = reg->id;
 
 		dirty = block->status & R600_BLOCK_STATUS_DIRTY;
 




More information about the mesa-commit mailing list