Mesa (master): r600g: fix alphatest without a colorbuffer on r6xx-r7xx

Marek Olšák mareko at kemper.freedesktop.org
Wed Jul 18 03:03:40 UTC 2012


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

Author: Marek Olšák <maraeo at gmail.com>
Date:   Wed Jul 18 04:31:56 2012 +0200

r600g: fix alphatest without a colorbuffer on r6xx-r7xx

---

 src/gallium/drivers/r600/r600_state.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 269198b..ab4a3cf 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -1595,7 +1595,7 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
 {
 	struct r600_context *rctx = (struct r600_context *)ctx;
 	struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
-	uint32_t tl, br, shader_control;
+	uint32_t tl, br;
 
 	if (rstate == NULL)
 		return;
@@ -1618,10 +1618,6 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
 		r600_db(rctx, rstate, state);
 	}
 
-	shader_control = 0;
-	for (int i = 0; i < state->nr_cbufs; i++) {
-		shader_control |= 1 << i;
-	}
 	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);
 
@@ -1630,8 +1626,16 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
 	r600_pipe_state_add_reg(rstate,
 				R_028208_PA_SC_WINDOW_SCISSOR_BR, br);
 
+	/* Always enable the first colorbuffer in CB_SHADER_CONTROL. This
+	 * will assure that the alpha-test will work even if there is
+	 * no colorbuffer bound. */
 	r600_pipe_state_add_reg(rstate, R_0287A0_CB_SHADER_CONTROL,
-				shader_control);
+				(1ull << MAX2(state->nr_cbufs, 1)) - 1);
+
+	if (state->nr_cbufs == 0 && rctx->alphatest_state.bypass) {
+		rctx->alphatest_state.bypass = false;
+		r600_atom_dirty(rctx, &rctx->alphatest_state.atom);
+	}
 
 	free(rctx->states[R600_PIPE_STATE_FRAMEBUFFER]);
 	rctx->states[R600_PIPE_STATE_FRAMEBUFFER] = rstate;




More information about the mesa-commit mailing list