ac/nir: add radv_export_param() helper
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 8 Feb 2018 13:56:45 +0000 (14:56 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 8 Feb 2018 21:14:26 +0000 (22:14 +0100)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_nir_to_llvm.c

index aa7503136ce5346eb5be09a25bdea0f7f6cb88d8..f1f846caeb5c9583af1965b555bbc7a12df0214a 100644 (file)
@@ -5863,6 +5863,17 @@ si_llvm_init_export_args(struct nir_to_llvm_context *ctx,
                args->out[i] = ac_to_float(&ctx->ac, args->out[i]);
 }
 
+static void
+radv_export_param(struct nir_to_llvm_context *ctx, unsigned index,
+                 LLVMValueRef *values)
+{
+       struct ac_export_args args;
+
+       si_llvm_init_export_args(ctx, values,
+                                V_008DFC_SQ_EXP_PARAM + index, &args);
+       ac_build_export(&ctx->ac, &args);
+}
+
 static void
 handle_vs_outputs_post(struct nir_to_llvm_context *ctx,
                       bool export_prim_id,
@@ -6006,42 +6017,32 @@ handle_vs_outputs_post(struct nir_to_llvm_context *ctx,
                if (!(ctx->output_mask & (1ull << i)))
                        continue;
 
+               if (i != VARYING_SLOT_LAYER &&
+                   i != VARYING_SLOT_PRIMITIVE_ID &&
+                   i < VARYING_SLOT_VAR0)
+                       continue;
+
                for (unsigned j = 0; j < 4; j++)
                        values[j] = ac_to_float(&ctx->ac, LLVMBuildLoad(ctx->builder,
                                                ctx->nir->outputs[radeon_llvm_reg_index_soa(i, j)], ""));
 
-               if (i == VARYING_SLOT_LAYER) {
-                       target = V_008DFC_SQ_EXP_PARAM + param_count;
-                       outinfo->vs_output_param_offset[VARYING_SLOT_LAYER] = param_count;
-                       param_count++;
-               } else if (i == VARYING_SLOT_PRIMITIVE_ID) {
-                       target = V_008DFC_SQ_EXP_PARAM + param_count;
-                       outinfo->vs_output_param_offset[VARYING_SLOT_PRIMITIVE_ID] = param_count;
-                       param_count++;
-               } else if (i >= VARYING_SLOT_VAR0) {
-                       target = V_008DFC_SQ_EXP_PARAM + param_count;
-                       outinfo->vs_output_param_offset[i] = param_count;
-                       param_count++;
-               } else
-                       continue;
+               radv_export_param(ctx, param_count, values);
 
-               si_llvm_init_export_args(ctx, values, target, &args);
-               ac_build_export(&ctx->ac, &args);
+               outinfo->vs_output_param_offset[i] = param_count++;
        }
 
        if (export_prim_id) {
                LLVMValueRef values[4];
-               target = V_008DFC_SQ_EXP_PARAM + param_count;
-               outinfo->vs_output_param_offset[VARYING_SLOT_PRIMITIVE_ID] = param_count;
-               param_count++;
 
                values[0] = ctx->vs_prim_id;
                ctx->shader_info->vs.vgpr_comp_cnt = MAX2(2,
                                                          ctx->shader_info->vs.vgpr_comp_cnt);
                for (unsigned j = 1; j < 4; j++)
                        values[j] = ctx->ac.f32_0;
-               si_llvm_init_export_args(ctx, values, target, &args);
-               ac_build_export(&ctx->ac, &args);
+
+               radv_export_param(ctx, param_count, values);
+
+               outinfo->vs_output_param_offset[VARYING_SLOT_PRIMITIVE_ID] = param_count++;
                outinfo->export_prim_id = true;
        }