[Mesa-dev] [PATCH] r600g: Added support for TGSI_SEMANTIC_FACE.

Tilman Sauerbeck tilman at code-monkey.de
Sat Sep 18 08:21:48 PDT 2010


This makes the 'glsl1-gl_FrontFacing var (1)' piglit test pass.

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

Someone please test this on Evergreen. I only have r600 hardware.

 src/gallium/drivers/r600/eg_hw_states.c   |   11 ++++++++++-
 src/gallium/drivers/r600/r600_hw_states.c |   11 ++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r600/eg_hw_states.c b/src/gallium/drivers/r600/eg_hw_states.c
index d6f417e..6729508 100644
--- a/src/gallium/drivers/r600/eg_hw_states.c
+++ b/src/gallium/drivers/r600/eg_hw_states.c
@@ -930,7 +930,7 @@ static int eg_ps_shader(struct r600_context *rctx, struct r600_context_state *rp
 	const struct pipe_rasterizer_state *rasterizer;
 	struct r600_shader *rshader = &rpshader->shader;
 	unsigned i, tmp, exports_ps, num_cout;
-	boolean have_pos = FALSE;
+	boolean have_pos = FALSE, have_face = FALSE;
 
 	rasterizer = &rctx->rasterizer->state.rasterizer;
 
@@ -945,6 +945,10 @@ static int eg_ps_shader(struct r600_context *rctx, struct r600_context_state *rp
 		    rshader->input[i].name == TGSI_SEMANTIC_POSITION) {
 			tmp |= S_028644_FLAT_SHADE(rshader->flat_shade);
 		}
+
+		if (rshader->input[i].name == TGSI_SEMANTIC_FACE)
+			have_face = TRUE;
+
 		if (rasterizer->sprite_coord_enable & (1 << i)) {
 			tmp |= S_028644_PT_SPRITE_TEX(1);
 		}
@@ -971,7 +975,12 @@ static int eg_ps_shader(struct r600_context *rctx, struct r600_context_state *rp
 		state->states[EG_PS_SHADER__SPI_PS_IN_CONTROL_0] |=  S_0286CC_POSITION_ENA(1);
 		state->states[EG_PS_SHADER__SPI_INPUT_Z] |= 1;
 	}
+
 	state->states[EG_PS_SHADER__SPI_PS_IN_CONTROL_1] = 0x00000000;
+
+	if (have_face)
+		state->states[EG_PS_SHADER__SPI_PS_IN_CONTROL_1] |= S_0286D0_FRONT_FACE_ENA(1);
+
 	state->states[EG_PS_SHADER__SQ_PGM_RESOURCES_PS] = S_028844_NUM_GPRS(rshader->bc.ngpr) | S_028844_PRIME_CACHE_ON_DRAW(1) |
 		S_028844_STACK_SIZE(rshader->bc.nstack);
 	state->states[EG_PS_SHADER__SQ_PGM_EXPORTS_PS] = exports_ps;
diff --git a/src/gallium/drivers/r600/r600_hw_states.c b/src/gallium/drivers/r600/r600_hw_states.c
index bca78ee..6bb8c31 100644
--- a/src/gallium/drivers/r600/r600_hw_states.c
+++ b/src/gallium/drivers/r600/r600_hw_states.c
@@ -943,7 +943,7 @@ static int r600_ps_shader(struct r600_context *rctx, struct r600_context_state *
 	const struct pipe_rasterizer_state *rasterizer;
 	struct r600_shader *rshader = &rpshader->shader;
 	unsigned i, tmp, exports_ps, num_cout;
-	boolean have_pos = FALSE;
+	boolean have_pos = FALSE, have_face = FALSE;
 
 	rasterizer = &rctx->rasterizer->state.rasterizer;
 
@@ -958,6 +958,10 @@ static int r600_ps_shader(struct r600_context *rctx, struct r600_context_state *
 		    rshader->input[i].name == TGSI_SEMANTIC_POSITION) {
 			tmp |= S_028644_FLAT_SHADE(rshader->flat_shade);
 		}
+
+		if (rshader->input[i].name == TGSI_SEMANTIC_FACE)
+			have_face = TRUE;
+
 		if (rasterizer->sprite_coord_enable & (1 << i)) {
 			tmp |= S_028644_PT_SPRITE_TEX(1);
 		}
@@ -985,7 +989,12 @@ static int r600_ps_shader(struct r600_context *rctx, struct r600_context_state *
 		                                                       S_0286CC_BARYC_SAMPLE_CNTL(1);
 		state->states[R600_PS_SHADER__SPI_INPUT_Z] |= 1;
 	}
+
 	state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_1] = 0x00000000;
+
+	if (have_face)
+		state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_1] |= S_0286D0_FRONT_FACE_ENA(1);
+
 	state->states[R600_PS_SHADER__SQ_PGM_RESOURCES_PS] = S_028868_NUM_GPRS(rshader->bc.ngpr) |
 		S_028868_STACK_SIZE(rshader->bc.nstack);
 	state->states[R600_PS_SHADER__SQ_PGM_EXPORTS_PS] = exports_ps;
-- 
1.7.2.3



More information about the mesa-dev mailing list