ac/shader: be a little smarter when scanning vertex buffers
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 14 Feb 2018 11:03:55 +0000 (12:03 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 15 Feb 2018 13:53:30 +0000 (14:53 +0100)
Although meta shaders don't use any vertex buffers, there is no
behaviour change but I think it's better to do this. Though,
this saves two user SGPRs for push constants inlining or
something else.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_shader_info.c

index 3b0887995d301ab4a3b37f205d60899bd09312f2..f6cdd3470352398d6190a6469d87bddf89ca65cc 100644 (file)
@@ -179,6 +179,16 @@ gather_info_block(const nir_shader *nir, const nir_block *block,
        }
 }
 
+static void
+gather_info_input_decl_vs(const nir_shader *nir, const nir_variable *var,
+                         struct ac_shader_info *info)
+{
+       int idx = var->data.location;
+
+       if (idx >= VERT_ATTRIB_GENERIC0 && idx <= VERT_ATTRIB_GENERIC15)
+               info->vs.has_vertex_buffers = true;
+}
+
 static void
 gather_info_input_decl_ps(const nir_shader *nir, const nir_variable *var,
                          struct ac_shader_info *info)
@@ -197,7 +207,7 @@ gather_info_input_decl(const nir_shader *nir, const nir_variable *var,
 {
        switch (nir->info.stage) {
        case MESA_SHADER_VERTEX:
-               info->vs.has_vertex_buffers = true;
+               gather_info_input_decl_vs(nir, var, info);
                break;
        case MESA_SHADER_FRAGMENT:
                gather_info_input_decl_ps(nir, var, info);