radeonsi: Use param export count from si_llvm_export_vs in si_shader_vs
authorMichel Dänzer <michel.daenzer@amd.com>
Mon, 6 Jul 2015 08:23:07 +0000 (17:23 +0900)
committerMichel Dänzer <michel@daenzer.net>
Tue, 7 Jul 2015 03:35:35 +0000 (12:35 +0900)
This eliminates the error prone logic in si_shader_vs recalculating this
value.

It also fixes TGSI_SEMANTIC_CLIPDIST outputs incorrectly not being
counted for VS exports. They need to be counted because they are passed
to the pixel shader as parameters as well.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91193
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index 4d97b58aec80612e0014167b324b858e0a3ecdf6..753b238e2c0f38098c02ec5b7a79717b4fc058a1 100644 (file)
@@ -1218,6 +1218,8 @@ handle_semantic:
                }
        }
 
+       shader->nr_param_exports = param_count;
+
        /* We need to add the position output manually if it's missing. */
        if (!pos_args[0][0]) {
                pos_args[0][0] = lp_build_const_int32(base->gallivm, 0xf); /* writemask */
index b4339ae2b360ed81b0b32e495eeb170a56e4bff2..8d309b4eb37708b5b864525420e7d2a8ce73720f 100644 (file)
@@ -165,6 +165,7 @@ struct si_shader {
 
        bool                    uses_instanceid;
        unsigned                nr_pos_exports;
+       unsigned                nr_param_exports;
        bool                    is_gs_copy_shader;
        bool                    dx10_clamp_mode; /* convert NaNs to 0 */
 };
index eef3baad1640e5de6af94979f3ce1a989103958d..a842d9db798202802d58d5b036992cf61cebebb9 100644 (file)
@@ -148,10 +148,9 @@ static void si_shader_gs(struct si_shader *shader)
 
 static void si_shader_vs(struct si_shader *shader)
 {
-       struct tgsi_shader_info *info = &shader->selector->info;
        struct si_pm4_state *pm4;
        unsigned num_sgprs, num_user_sgprs;
-       unsigned nparams, i, vgpr_comp_cnt;
+       unsigned nparams, vgpr_comp_cnt;
        uint64_t va;
        unsigned window_space =
           shader->selector->info.properties[TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION];
@@ -180,26 +179,8 @@ static void si_shader_vs(struct si_shader *shader)
        }
        assert(num_sgprs <= 104);
 
-       /* Certain attributes (position, psize, etc.) don't count as params.
-        * VS is required to export at least one param and r600_shader_from_tgsi()
-        * takes care of adding a dummy export.
-        */
-       for (nparams = 0, i = 0 ; i < info->num_outputs; i++) {
-               switch (info->output_semantic_name[i]) {
-               case TGSI_SEMANTIC_CLIPVERTEX:
-               case TGSI_SEMANTIC_CLIPDIST:
-               case TGSI_SEMANTIC_CULLDIST:
-               case TGSI_SEMANTIC_POSITION:
-               case TGSI_SEMANTIC_PSIZE:
-               case TGSI_SEMANTIC_EDGEFLAG:
-                       break;
-               default:
-                       nparams++;
-               }
-       }
-       if (nparams < 1)
-               nparams = 1;
-
+       /* VS is required to export at least one param. */
+       nparams = MAX2(shader->nr_param_exports, 1);
        si_pm4_set_reg(pm4, R_0286C4_SPI_VS_OUT_CONFIG,
                       S_0286C4_VS_EXPORT_COUNT(nparams - 1));