radeonsi: use tgsi_shader_info in si_llvm_emit_vs_epilogue
authorMarek Olšák <marek.olsak@amd.com>
Sat, 4 Oct 2014 20:33:36 +0000 (22:33 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Sun, 12 Oct 2014 21:53:57 +0000 (23:53 +0200)
That code was really ugly.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeonsi/si_shader.c

index 63b77be73e79995955428720481921960119ea08..2a1217946c1aceb97f72064d5e22d17f8e8a9565 100644 (file)
@@ -1308,38 +1308,25 @@ static void si_llvm_emit_vs_epilogue(struct lp_build_tgsi_context * bld_base)
 {
        struct si_shader_context *si_shader_ctx = si_shader_context(bld_base);
        struct gallivm_state *gallivm = bld_base->base.gallivm;
-       struct tgsi_parse_context *parse = &si_shader_ctx->parse;
+       struct tgsi_shader_info *info = &si_shader_ctx->shader->selector->info;
        struct si_shader_output_values *outputs = NULL;
-       unsigned noutput = 0;
-       int i;
-
-       while (!tgsi_parse_end_of_tokens(parse)) {
-               struct tgsi_full_declaration *d =
-                                       &parse->FullToken.FullDeclaration;
-               unsigned index;
+       int i,j;
 
-               tgsi_parse_token(parse);
+       outputs = MALLOC(info->num_outputs * sizeof(outputs[0]));
 
-               if (parse->FullToken.Token.Type != TGSI_TOKEN_TYPE_DECLARATION)
-                       continue;
+       for (i = 0; i < info->num_outputs; i++) {
+               outputs[i].name = info->output_semantic_name[i];
+               outputs[i].sid = info->output_semantic_index[i];
+               outputs[i].index = i;
 
-               outputs = REALLOC(outputs, noutput * sizeof(outputs[0]),
-                                 (noutput + 1) * sizeof(outputs[0]));
-               for (index = d->Range.First; index <= d->Range.Last; index++) {
-                       outputs[noutput].index = index;
-                       outputs[noutput].name = d->Semantic.Name;
-                       outputs[noutput].sid = d->Semantic.Index;
-
-                       for (i = 0; i < 4; i++)
-                               outputs[noutput].values[i] =
-                                       LLVMBuildLoad(gallivm->builder,
-                                                     si_shader_ctx->radeon_bld.soa.outputs[index][i],
-                                                     "");
-               }
-               noutput++;
+               for (j = 0; j < 4; j++)
+                       outputs[i].values[j] =
+                               LLVMBuildLoad(gallivm->builder,
+                                             si_shader_ctx->radeon_bld.soa.outputs[i][j],
+                                             "");
        }
 
-       si_llvm_export_vs(bld_base, outputs, noutput);
+       si_llvm_export_vs(bld_base, outputs, info->num_outputs);
        FREE(outputs);
 }