radeonsi: Handle TGSI_SEMANTIC_FACE.
authorMichel Dänzer <michel.daenzer@amd.com>
Tue, 25 Sep 2012 10:41:31 +0000 (12:41 +0200)
committerMichel Dänzer <michel@daenzer.net>
Fri, 26 Oct 2012 13:51:18 +0000 (15:51 +0200)
Fixes two piglit tests using gl_FrontFacing.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
src/gallium/drivers/radeonsi/radeonsi_shader.c
src/gallium/drivers/radeonsi/si_state_draw.c

index aec5c2ea2227d811183c0eaf085d650bc4159dce..53e889c19de22d746b430d11a01630eb94c57224 100644 (file)
@@ -266,6 +266,33 @@ static void declare_input_fs(
                return;
        }
 
+       if (decl->Semantic.Name == TGSI_SEMANTIC_FACE) {
+               LLVMValueRef face, is_face_positive;
+
+               face = build_intrinsic(gallivm->builder,
+                                      "llvm.SI.fs.read.face",
+                                      input_type,
+                                      NULL, 0, LLVMReadNoneAttribute);
+               is_face_positive = LLVMBuildFCmp(gallivm->builder,
+                                                LLVMRealUGT, face,
+                                                lp_build_const_float(gallivm, 0.0f),
+                                                "");
+
+               si_shader_ctx->radeon_bld.inputs[radeon_llvm_reg_index_soa(input_index, 0)] =
+                       LLVMBuildSelect(gallivm->builder,
+                                       is_face_positive,
+                                       lp_build_const_float(gallivm, 1.0f),
+                                       lp_build_const_float(gallivm, 0.0f),
+                                       "");
+               si_shader_ctx->radeon_bld.inputs[radeon_llvm_reg_index_soa(input_index, 1)] =
+               si_shader_ctx->radeon_bld.inputs[radeon_llvm_reg_index_soa(input_index, 2)] =
+                       lp_build_const_float(gallivm, 0.0f);
+               si_shader_ctx->radeon_bld.inputs[radeon_llvm_reg_index_soa(input_index, 3)] =
+                       lp_build_const_float(gallivm, 1.0f);
+
+               return;
+       }
+
        shader->input[input_index].param_offset = shader->ninterp++;
        attr_number = lp_build_const_int32(gallivm,
                                           shader->input[input_index].param_offset);
index 3ac80b0a6e495134f375572c96b7aa40667a9544..d5587c78a33226efa6b1bcb0f144a1cec17a41de 100644 (file)
@@ -110,7 +110,8 @@ static void si_pipe_shader_ps(struct pipe_context *ctx, struct si_pipe_shader *s
 
        db_shader_control = S_02880C_Z_ORDER(V_02880C_EARLY_Z_THEN_LATE_Z);
        for (i = 0; i < shader->shader.ninput; i++) {
-               if (shader->shader.input[i].name == TGSI_SEMANTIC_POSITION) {
+               switch (shader->shader.input[i].name) {
+               case TGSI_SEMANTIC_POSITION:
                        if (shader->shader.input[i].centroid) {
                                /* fragcoord_interp_mode will be written to
                                 * SPI_BARYC_CNTL.POS_FLOAT_LOCATION
@@ -122,6 +123,8 @@ static void si_pipe_shader_ps(struct pipe_context *ctx, struct si_pipe_shader *s
                                 */
                                fragcoord_interp_mode = 1;
                        }
+                       /* Fall through */
+               case TGSI_SEMANTIC_FACE:
                        continue;
                }