[Mesa-dev] [PATCH] r600g: Tweaked calculation of CB_SHADER_MASK and CB_TARGET_MASK.

Tilman Sauerbeck tilman at code-monkey.de
Mon Oct 4 13:10:42 PDT 2010


Signed-off-by: Tilman Sauerbeck <tilman at code-monkey.de>
---

Any reason why we shouldn't do it like this?

 src/gallium/drivers/r600/evergreen_state.c |   15 ++++-----------
 src/gallium/drivers/r600/r600_state.c      |   18 +++++-------------
 2 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index 70799f6..8d84fd2 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -859,13 +859,9 @@ static void evergreen_set_framebuffer_state(struct pipe_context *ctx,
 		evergreen_db(rctx, rstate, state);
 	}
 
-	target_mask = 0x00000000;
-	target_mask = 0xFFFFFFFF;
-	shader_mask = 0;
-	for (int i = 0; i < state->nr_cbufs; i++) {
-		target_mask ^= 0xf << (i * 4);
-		shader_mask |= 0xf << (i * 4);
-	}
+	shader_mask = (1 << (state->nr_cbufs * 4)) - 1;
+	target_mask = ~shader_mask;
+
 	tl = S_028240_TL_X(0) | S_028240_TL_Y(0);
 	br = S_028244_BR_X(state->width) | S_028244_BR_Y(state->height);
 
@@ -1431,10 +1427,7 @@ void evergreen_draw(struct pipe_context *ctx, const struct pipe_draw_info *info)
 		evergreen_vs_resource_set(&rctx->ctx, rstate, i);
 	}
 
-	mask = 0;
-	for (int i = 0; i < rctx->framebuffer.nr_cbufs; i++) {
-		mask |= (0xF << (i * 4));
-	}
+	mask = (1 << (rctx->framebuffer.nr_cbufs * 4)) - 1;
 
 	vgt.id = R600_PIPE_STATE_VGT;
 	vgt.nregs = 0;
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 2814ecc..2ed83d5 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -110,10 +110,7 @@ static void r600_draw_common(struct r600_drawl *draw)
 		r600_context_pipe_state_set_vs_resource(&rctx->ctx, rstate, i);
 	}
 
-	mask = 0;
-	for (int i = 0; i < rctx->framebuffer.nr_cbufs; i++) {
-		mask |= (0xF << (i * 4));
-	}
+	mask = (1 << (rctx->framebuffer.nr_cbufs * 4)) - 1;
 
 	vgt.id = R600_PIPE_STATE_VGT;
 	vgt.nregs = 0;
@@ -1055,15 +1052,10 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
 		r600_db(rctx, rstate, state);
 	}
 
-	target_mask = 0x00000000;
-	target_mask = 0xFFFFFFFF;
-	shader_mask = 0;
-	shader_control = 0;
-	for (int i = 0; i < state->nr_cbufs; i++) {
-		target_mask ^= 0xf << (i * 4);
-		shader_mask |= 0xf << (i * 4);
-		shader_control |= 1 << i;
-	}
+	shader_mask = (1 << (state->nr_cbufs * 4)) - 1;
+	target_mask = ~shader_mask;
+	shader_control = (1 << state->nr_cbufs) - 1;
+
 	tl = S_028240_TL_X(0) | S_028240_TL_Y(0) | S_028240_WINDOW_OFFSET_DISABLE(1);
 	br = S_028244_BR_X(state->width) | S_028244_BR_Y(state->height);
 
-- 
1.7.3



More information about the mesa-dev mailing list