- unsigned soa_index = radeon_llvm_reg_index_soa(input_index,
- chan);
-
- switch (decl->Semantic.Name) {
- case TGSI_SEMANTIC_FACE:
- ctx->inputs[soa_index] = llvm_load_input_helper(ctx,
- "llvm.R600.load.input",
- 4 * ctx->face_input);
- break;
- case TGSI_SEMANTIC_POSITION:
- if (ctx->type != TGSI_PROCESSOR_FRAGMENT || chan != 3) {
- ctx->inputs[soa_index] = llvm_load_input_helper(ctx,
- "llvm.R600.load.input",
- soa_index + (ctx->reserved_reg_count * 4));
- } else {
- LLVMValueRef w_coord = llvm_load_input_helper(ctx,
- "llvm.R600.load.input",
- soa_index + (ctx->reserved_reg_count * 4));
- ctx->inputs[soa_index] = LLVMBuildFDiv(ctx->gallivm.builder,
- lp_build_const_float(&(ctx->gallivm), 1.0f), w_coord, "");
- }
- break;
- case TGSI_SEMANTIC_COLOR:
- if (ctx->two_side) {
- unsigned front_location, back_location;
- unsigned back_reg = ctx->r600_inputs[input_index]
- .potential_back_facing_reg;
- if (ctx->chip_class >= EVERGREEN) {
- front_location = 4 * ctx->r600_inputs[input_index].lds_pos + chan;
- back_location = 4 * ctx->r600_inputs[back_reg].lds_pos + chan;
- } else {
- front_location = soa_index + 4 * ctx->reserved_reg_count;
- back_location = radeon_llvm_reg_index_soa(
- ctx->r600_inputs[back_reg].gpr,
- chan);
- }
- ctx->inputs[soa_index] = llvm_face_select_helper(ctx,
- intrinsics,
- 4 * ctx->face_input, front_location, back_location);
- break;
- }
- default:
- {
- unsigned location;
- if (ctx->chip_class >= EVERGREEN) {
- location = 4 * ctx->r600_inputs[input_index].lds_pos + chan;
- } else {
- location = soa_index + 4 * ctx->reserved_reg_count;
- }
- /* The * 4 is assuming that we are in soa mode. */
- ctx->inputs[soa_index] = llvm_load_input_helper(ctx,
- intrinsics, location);
-
- break;
- }
+ unsigned soa_index = radeon_llvm_reg_index_soa(input_index, chan);
+ int loc;
+
+ if (interp) {
+ loc = 4 * input->lds_pos + chan;
+ } else {
+ if (input->name == TGSI_SEMANTIC_FACE)
+ loc = 4 * ctx->face_gpr;
+ else
+ loc = 4 * input->gpr + chan;
+ }
+
+ v = llvm_load_input_helper(ctx, loc, interp, ij_index);
+
+ if (two_side) {
+ struct r600_shader_io * back_input =
+ &ctx->r600_inputs[input->back_color_input];
+ int back_loc = interp ? back_input->lds_pos : back_input->gpr;
+ LLVMValueRef v2;
+
+ back_loc = 4 * back_loc + chan;
+ v2 = llvm_load_input_helper(ctx, back_loc, interp, ij_index);
+ v = llvm_face_select_helper(ctx, 4 * ctx->face_gpr, v, v2);
+ } else if (input->name == TGSI_SEMANTIC_POSITION &&
+ ctx->type == TGSI_PROCESSOR_FRAGMENT && chan == 3) {
+ /* RCP for fragcoord.w */
+ v = LLVMBuildFDiv(ctx->gallivm.builder,
+ lp_build_const_float(&(ctx->gallivm), 1.0f),
+ v, "");