radeonsi: move POSITION and FACE fragment shader inputs to system values
authorMarek Olšák <marek.olsak@amd.com>
Sat, 2 Jan 2016 22:09:58 +0000 (23:09 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 13 Jan 2016 11:27:28 +0000 (12:27 +0100)
And FACE becomes integer instead of float.

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_state_shaders.c

index c2ca94339ac708071d8ee89b63776edd0a9d1d15..4e23cb19da81fa661484321c043fbf7c72615324 100644 (file)
@@ -301,6 +301,8 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_TGSI_TXQS:
        case PIPE_CAP_FORCE_PERSAMPLE_INTERP:
        case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS:
+       case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
+       case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
                return 1;
 
        case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
@@ -344,8 +346,6 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_TGSI_PACK_HALF_FLOAT:
        case PIPE_CAP_MULTI_DRAW_INDIRECT:
        case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS:
-       case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
-       case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
        case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
                return 0;
 
index 1db3e4849157a95c9e58cbf6304ba0495bd74c06..cc9718e42d3460c8d6f6365d23dd7b6d632fda49 100644 (file)
@@ -911,36 +911,6 @@ static void declare_input_fs(
 
        unsigned chan;
 
-       if (decl->Semantic.Name == TGSI_SEMANTIC_POSITION) {
-               for (chan = 0; chan < TGSI_NUM_CHANNELS; chan++) {
-                       unsigned soa_index =
-                               radeon_llvm_reg_index_soa(input_index, chan);
-                       radeon_bld->inputs[soa_index] =
-                               LLVMGetParam(main_fn, SI_PARAM_POS_X_FLOAT + chan);
-
-                       if (chan == 3)
-                               /* RCP for fragcoord.w */
-                               radeon_bld->inputs[soa_index] =
-                                       LLVMBuildFDiv(gallivm->builder,
-                                                     lp_build_const_float(gallivm, 1.0f),
-                                                     radeon_bld->inputs[soa_index],
-                                                     "");
-               }
-               return;
-       }
-
-       if (decl->Semantic.Name == TGSI_SEMANTIC_FACE) {
-               radeon_bld->inputs[radeon_llvm_reg_index_soa(input_index, 0)] =
-                       LLVMGetParam(main_fn, SI_PARAM_FRONT_FACE);
-               radeon_bld->inputs[radeon_llvm_reg_index_soa(input_index, 1)] =
-               radeon_bld->inputs[radeon_llvm_reg_index_soa(input_index, 2)] =
-                       lp_build_const_float(gallivm, 0.0f);
-               radeon_bld->inputs[radeon_llvm_reg_index_soa(input_index, 3)] =
-                       lp_build_const_float(gallivm, 1.0f);
-
-               return;
-       }
-
        shader->ps_input_param_offset[input_index] = shader->nparam++;
        attr_number = lp_build_const_int32(gallivm,
                                           shader->ps_input_param_offset[input_index]);
@@ -975,10 +945,8 @@ static void declare_input_fs(
 
                face = LLVMGetParam(main_fn, SI_PARAM_FRONT_FACE);
 
-               is_face_positive = LLVMBuildFCmp(gallivm->builder,
-                                                LLVMRealOGT, face,
-                                                lp_build_const_float(gallivm, 0.0f),
-                                                "");
+               is_face_positive = LLVMBuildICmp(gallivm->builder, LLVMIntNE,
+                                                face, uint->zero, "");
 
                args[2] = params;
                args[3] = interp_param;
@@ -1129,6 +1097,24 @@ static void declare_system_value(
                        assert(!"INVOCATIONID not implemented");
                break;
 
+       case TGSI_SEMANTIC_POSITION:
+       {
+               LLVMValueRef pos[4] = {
+                       LLVMGetParam(radeon_bld->main_fn, SI_PARAM_POS_X_FLOAT),
+                       LLVMGetParam(radeon_bld->main_fn, SI_PARAM_POS_Y_FLOAT),
+                       LLVMGetParam(radeon_bld->main_fn, SI_PARAM_POS_Z_FLOAT),
+                       lp_build_emit_llvm_unary(&radeon_bld->soa.bld_base, TGSI_OPCODE_RCP,
+                                                LLVMGetParam(radeon_bld->main_fn,
+                                                             SI_PARAM_POS_W_FLOAT)),
+               };
+               value = lp_build_gather_values(gallivm, pos, 4);
+               break;
+       }
+
+       case TGSI_SEMANTIC_FACE:
+               value = LLVMGetParam(radeon_bld->main_fn, SI_PARAM_FRONT_FACE);
+               break;
+
        case TGSI_SEMANTIC_SAMPLEID:
                value = get_sample_id(radeon_bld);
                break;
@@ -3506,7 +3492,7 @@ static void create_function(struct si_shader_context *si_shader_ctx)
                params[SI_PARAM_POS_Y_FLOAT] = f32;
                params[SI_PARAM_POS_Z_FLOAT] = f32;
                params[SI_PARAM_POS_W_FLOAT] = f32;
-               params[SI_PARAM_FRONT_FACE] = f32;
+               params[SI_PARAM_FRONT_FACE] = i32;
                params[SI_PARAM_ANCILLARY] = i32;
                params[SI_PARAM_SAMPLE_COVERAGE] = f32;
                params[SI_PARAM_POS_FIXED_PT] = f32;
@@ -4067,7 +4053,7 @@ int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
        if (poly_stipple) {
                tokens = util_pstipple_create_fragment_shader(tokens, NULL,
                                                SI_POLY_STIPPLE_SAMPLER,
-                                               TGSI_FILE_INPUT);
+                                               TGSI_FILE_SYSTEM_VALUE);
                tgsi_scan_shader(tokens, &stipple_shader_info);
        }
 
index 460dda51b97a2c15548ab036dccf4296f88bd81e..35b226f015778677a8dead1e35be669a076e635d 100644 (file)
@@ -390,7 +390,7 @@ static void si_shader_ps(struct si_shader *shader)
        unsigned spi_shader_col_format = 0, cb_shader_mask = 0;
        unsigned colors_written, export_16bpc;
        unsigned num_sgprs, num_user_sgprs;
-       unsigned spi_baryc_cntl = 0;
+       unsigned spi_baryc_cntl = S_0286E0_FRONT_FACE_ALL_BITS(1);
        uint64_t va;
        bool has_centroid;
 
@@ -979,12 +979,6 @@ static void si_emit_spi_map(struct si_context *sctx, struct r600_atom *atom)
                unsigned index = psinfo->input_semantic_index[i];
                unsigned interpolate = psinfo->input_interpolate[i];
                unsigned param_offset = ps->ps_input_param_offset[i];
-
-               if (name == TGSI_SEMANTIC_POSITION ||
-                   name == TGSI_SEMANTIC_FACE)
-                       /* Read from preloaded VGPRs, not parameters */
-                       continue;
-
 bcolor:
                tmp = 0;