ac/nir: Remove now-unused interp_deref handling
authorConnor Abbott <cwabbott0@gmail.com>
Fri, 17 May 2019 14:31:17 +0000 (16:31 +0200)
committerConnor Abbott <cwabbott0@gmail.com>
Mon, 8 Jul 2019 12:18:52 +0000 (14:18 +0200)
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/amd/common/ac_nir_to_llvm.c

index d9332700105458e495d7e2ed96a2e2b8e624518d..1fbbe507eae1dabce491c968322c40e90e6e9cd9 100644 (file)
@@ -3087,150 +3087,6 @@ static LLVMValueRef load_flat_input(struct ac_nir_context *ctx,
        return result;
 }
 
-static LLVMValueRef visit_interp(struct ac_nir_context *ctx,
-                                const nir_intrinsic_instr *instr)
-{
-       LLVMValueRef result[4];
-       LLVMValueRef interp_param;
-       unsigned location;
-       unsigned chan;
-       LLVMValueRef src_c0 = NULL;
-       LLVMValueRef src_c1 = NULL;
-       LLVMValueRef src0 = NULL;
-
-       nir_deref_instr *deref_instr = nir_instr_as_deref(instr->src[0].ssa->parent_instr);
-       nir_variable *var = nir_deref_instr_get_variable(deref_instr);
-       int input_base = ctx->abi->fs_input_attr_indices[var->data.location - VARYING_SLOT_VAR0];
-       switch (instr->intrinsic) {
-       case nir_intrinsic_interp_deref_at_centroid:
-               location = INTERP_CENTROID;
-               break;
-       case nir_intrinsic_interp_deref_at_sample:
-       case nir_intrinsic_interp_deref_at_offset:
-               location = INTERP_CENTER;
-               src0 = get_src(ctx, instr->src[1]);
-               break;
-       default:
-               break;
-       }
-
-       if (instr->intrinsic == nir_intrinsic_interp_deref_at_offset) {
-               src_c0 = ac_to_float(&ctx->ac, LLVMBuildExtractElement(ctx->ac.builder, src0, ctx->ac.i32_0, ""));
-               src_c1 = ac_to_float(&ctx->ac, LLVMBuildExtractElement(ctx->ac.builder, src0, ctx->ac.i32_1, ""));
-       } else if (instr->intrinsic == nir_intrinsic_interp_deref_at_sample) {
-               LLVMValueRef sample_position;
-               LLVMValueRef halfval = LLVMConstReal(ctx->ac.f32, 0.5f);
-
-               /* fetch sample ID */
-               sample_position = ctx->abi->load_sample_position(ctx->abi, src0);
-
-               src_c0 = LLVMBuildExtractElement(ctx->ac.builder, sample_position, ctx->ac.i32_0, "");
-               src_c0 = LLVMBuildFSub(ctx->ac.builder, src_c0, halfval, "");
-               src_c1 = LLVMBuildExtractElement(ctx->ac.builder, sample_position, ctx->ac.i32_1, "");
-               src_c1 = LLVMBuildFSub(ctx->ac.builder, src_c1, halfval, "");
-       }
-       interp_param = ctx->abi->lookup_interp_param(ctx->abi, var->data.interpolation, location);
-
-       if (location == INTERP_CENTER) {
-               LLVMValueRef ij_out[2];
-               LLVMValueRef ddxy_out = ac_build_ddxy_interp(&ctx->ac, interp_param);
-
-               /*
-                * take the I then J parameters, and the DDX/Y for it, and
-                * calculate the IJ inputs for the interpolator.
-                * temp1 = ddx * offset/sample.x + I;
-                * interp_param.I = ddy * offset/sample.y + temp1;
-                * temp1 = ddx * offset/sample.x + J;
-                * interp_param.J = ddy * offset/sample.y + temp1;
-                */
-               for (unsigned i = 0; i < 2; i++) {
-                       LLVMValueRef ix_ll = LLVMConstInt(ctx->ac.i32, i, false);
-                       LLVMValueRef iy_ll = LLVMConstInt(ctx->ac.i32, i + 2, false);
-                       LLVMValueRef ddx_el = LLVMBuildExtractElement(ctx->ac.builder,
-                                                                     ddxy_out, ix_ll, "");
-                       LLVMValueRef ddy_el = LLVMBuildExtractElement(ctx->ac.builder,
-                                                                     ddxy_out, iy_ll, "");
-                       LLVMValueRef interp_el = LLVMBuildExtractElement(ctx->ac.builder,
-                                                                        interp_param, ix_ll, "");
-                       LLVMValueRef temp1, temp2;
-
-                       interp_el = LLVMBuildBitCast(ctx->ac.builder, interp_el,
-                                                    ctx->ac.f32, "");
-
-                       temp1 = ac_build_fmad(&ctx->ac, ddx_el, src_c0, interp_el);
-                       temp2 = ac_build_fmad(&ctx->ac, ddy_el, src_c1, temp1);
-
-                       ij_out[i] = LLVMBuildBitCast(ctx->ac.builder,
-                                                    temp2, ctx->ac.i32, "");
-               }
-               interp_param = ac_build_gather_values(&ctx->ac, ij_out, 2);
-
-       }
-
-       LLVMValueRef attrib_idx = ctx->ac.i32_0;
-       while(deref_instr->deref_type != nir_deref_type_var) {
-               if (deref_instr->deref_type == nir_deref_type_array) {
-                       unsigned array_size = glsl_count_attribute_slots(deref_instr->type, false);
-
-                       LLVMValueRef offset;
-                       if (nir_src_is_const(deref_instr->arr.index)) {
-                               offset = LLVMConstInt(ctx->ac.i32, array_size * nir_src_as_uint(deref_instr->arr.index), false);
-                       } else {
-                               LLVMValueRef indirect = get_src(ctx, deref_instr->arr.index);
-
-                               offset = LLVMBuildMul(ctx->ac.builder, indirect,
-                                                     LLVMConstInt(ctx->ac.i32, array_size, false), "");
-                       }
-
-                       attrib_idx = LLVMBuildAdd(ctx->ac.builder, attrib_idx, offset, "");
-                       deref_instr = nir_src_as_deref(deref_instr->parent);
-               } else if (deref_instr->deref_type == nir_deref_type_struct) {
-                       LLVMValueRef offset;
-                       unsigned sidx = deref_instr->strct.index;
-                       deref_instr = nir_src_as_deref(deref_instr->parent);
-                       offset = LLVMConstInt(ctx->ac.i32, glsl_get_struct_location_offset(deref_instr->type, sidx), false);
-                       attrib_idx = LLVMBuildAdd(ctx->ac.builder, attrib_idx, offset, "");
-               } else {
-                       unreachable("Unsupported deref type");
-               }
-
-       }
-
-       unsigned attrib_size = glsl_count_attribute_slots(var->type, false);
-       for (chan = 0; chan < 4; chan++) {
-               LLVMValueRef gather = LLVMGetUndef(LLVMVectorType(ctx->ac.f32, attrib_size));
-               LLVMValueRef llvm_chan = LLVMConstInt(ctx->ac.i32, chan, false);
-
-               for (unsigned idx = 0; idx < attrib_size; ++idx) {
-                       LLVMValueRef v, attr_number;
-
-                       attr_number = LLVMConstInt(ctx->ac.i32, input_base + idx, false);
-                       if (interp_param) {
-                               interp_param = LLVMBuildBitCast(ctx->ac.builder,
-                                                       interp_param, ctx->ac.v2f32, "");
-                               LLVMValueRef i = LLVMBuildExtractElement(
-                                       ctx->ac.builder, interp_param, ctx->ac.i32_0, "");
-                               LLVMValueRef j = LLVMBuildExtractElement(
-                                       ctx->ac.builder, interp_param, ctx->ac.i32_1, "");
-
-                               v = ac_build_fs_interp(&ctx->ac, llvm_chan, attr_number,
-                                                      ctx->abi->prim_mask, i, j);
-                       } else {
-                               v = ac_build_fs_interp_mov(&ctx->ac, LLVMConstInt(ctx->ac.i32, 2, false),
-                                                          llvm_chan, attr_number, ctx->abi->prim_mask);
-                       }
-
-                       gather = LLVMBuildInsertElement(ctx->ac.builder, gather, v,
-                                                       LLVMConstInt(ctx->ac.i32, idx, false), "");
-               }
-
-               result[chan] = LLVMBuildExtractElement(ctx->ac.builder, gather, attrib_idx, "");
-
-       }
-       return ac_build_varying_gather_values(&ctx->ac, result, instr->num_components,
-                                             var->data.location_frac);
-}
-
 static void visit_intrinsic(struct ac_nir_context *ctx,
                             nir_intrinsic_instr *instr)
 {
@@ -3506,11 +3362,6 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
                result = visit_var_atomic(ctx, instr, ptr, 1);
                break;
        }
-       case nir_intrinsic_interp_deref_at_centroid:
-       case nir_intrinsic_interp_deref_at_sample:
-       case nir_intrinsic_interp_deref_at_offset:
-               result = visit_interp(ctx, instr);
-               break;
        case nir_intrinsic_load_barycentric_pixel:
                result = barycentric_center(ctx, nir_intrinsic_interp_mode(instr));
                break;