ac/shader: scan vertex inputs usage mask
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 1 Feb 2018 10:32:32 +0000 (11:32 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 7 Feb 2018 11:42:07 +0000 (12:42 +0100)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_shader_info.c
src/amd/common/ac_shader_info.h

index d771cd250dc2ed39eda515e80d445ebd76b5009a..e7132638172719d024d7c3edb1d3f1592f597f48 100644 (file)
@@ -133,6 +133,19 @@ gather_intrinsic_info(const nir_shader *nir, const nir_intrinsic_instr *instr,
                if (nir->info.stage == MESA_SHADER_FRAGMENT)
                        info->ps.writes_memory = true;
                break;
+       case nir_intrinsic_load_var:
+               if (nir->info.stage == MESA_SHADER_VERTEX) {
+                       nir_deref_var *dvar = instr->variables[0];
+                       nir_variable *var = dvar->var;
+
+                       if (var->data.mode == nir_var_shader_in) {
+                               unsigned idx = var->data.location;
+                               uint8_t mask =
+                                       nir_ssa_def_components_read(&instr->dest.ssa);
+                               info->vs.input_usage_mask[idx] |= mask;
+                       }
+               }
+               break;
        default:
                break;
        }
index 59b749576aa8c88ced7cc6344533fad462b91d64..380c06a855140130e57e6952e24fe37d11d95466 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef AC_SHADER_INFO_H
 #define AC_SHADER_INFO_H
 
+#include "compiler/shader_enums.h"
+
 struct nir_shader;
 struct ac_nir_compiler_options;
 
@@ -34,6 +36,7 @@ struct ac_shader_info {
        bool uses_invocation_id;
        bool uses_prim_id;
        struct {
+               uint8_t input_usage_mask[VERT_ATTRIB_MAX];
                bool has_vertex_buffers; /* needs vertex buffers and base/start */
                bool needs_draw_id;
                bool needs_instance_id;