radv: gather clip/cull distances in the shader info pass
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 3 Sep 2019 15:55:02 +0000 (17:55 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 6 Sep 2019 13:52:07 +0000 (15:52 +0200)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_nir_to_llvm.c
src/amd/vulkan/radv_shader_info.c

index dd31b848961347b4cf61742335f57bf0fce174a1..9574330a4da129c923f3a38693c73703e45c65bc 100644 (file)
@@ -2277,27 +2277,6 @@ scan_shader_output_decl(struct radv_shader_context *ctx,
        }
 
        mask_attribs = ((1ull << attrib_count) - 1) << idx;
-       if (stage == MESA_SHADER_VERTEX ||
-           stage == MESA_SHADER_TESS_EVAL ||
-           stage == MESA_SHADER_GEOMETRY) {
-               if (idx == VARYING_SLOT_CLIP_DIST0) {
-                       if (stage == MESA_SHADER_VERTEX) {
-                               ctx->shader_info->vs.outinfo.clip_dist_mask = (1 << shader->info.clip_distance_array_size) - 1;
-                               ctx->shader_info->vs.outinfo.cull_dist_mask = (1 << shader->info.cull_distance_array_size) - 1;
-                               ctx->shader_info->vs.outinfo.cull_dist_mask <<= shader->info.clip_distance_array_size;
-                       }
-                       if (stage == MESA_SHADER_TESS_EVAL) {
-                               ctx->shader_info->tes.outinfo.clip_dist_mask = (1 << shader->info.clip_distance_array_size) - 1;
-                               ctx->shader_info->tes.outinfo.cull_dist_mask = (1 << shader->info.cull_distance_array_size) - 1;
-                               ctx->shader_info->tes.outinfo.cull_dist_mask <<= shader->info.clip_distance_array_size;
-                       }
-                       if (stage == MESA_SHADER_GEOMETRY) {
-                               ctx->shader_info->vs.outinfo.clip_dist_mask = (1 << shader->info.clip_distance_array_size) - 1;
-                               ctx->shader_info->vs.outinfo.cull_dist_mask = (1 << shader->info.cull_distance_array_size) - 1;
-                               ctx->shader_info->vs.outinfo.cull_dist_mask <<= shader->info.clip_distance_array_size;
-                       }
-               }
-       }
 
        ctx->output_mask |= mask_attribs;
 }
index 33ee072737362bde726393318c3e61b0b0333576..d639980e56a7782be134c935d6479f9021c4870a 100644 (file)
@@ -533,20 +533,45 @@ gather_info_output_decl(const nir_shader *nir, const nir_variable *var,
                        struct radv_shader_info *info,
                        const struct radv_nir_compiler_options *options)
 {
+       struct radv_vs_output_info *vs_info = NULL;
+
        switch (nir->info.stage) {
        case MESA_SHADER_FRAGMENT:
                gather_info_output_decl_ps(nir, var, info);
                break;
        case MESA_SHADER_VERTEX:
+               if (!options->key.vs_common_out.as_ls &&
+                   !options->key.vs_common_out.as_es)
+                       vs_info = &info->vs.outinfo;
+
                if (options->key.vs_common_out.as_ls)
                        gather_info_output_decl_ls(nir, var, info);
                break;
        case MESA_SHADER_GEOMETRY:
+               vs_info = &info->vs.outinfo;
                gather_info_output_decl_gs(nir, var, info);
                break;
+       case MESA_SHADER_TESS_EVAL:
+               if (!options->key.vs_common_out.as_es)
+                       vs_info = &info->tes.outinfo;
+               break;
        default:
                break;
        }
+
+       if (vs_info) {
+               switch (var->data.location) {
+               case VARYING_SLOT_CLIP_DIST0:
+                       vs_info->clip_dist_mask =
+                               (1 << nir->info.clip_distance_array_size) - 1;
+                       vs_info->cull_dist_mask =
+                               (1 << nir->info.cull_distance_array_size) - 1;
+                       vs_info->cull_dist_mask <<= nir->info.clip_distance_array_size;
+                       break;
+               default:
+                       break;
+               }
+       }
 }
 
 static void