--- src/compiler/nir/nir.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index fab2110f619..e52a1006896 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -351,6 +351,37 @@ typedef struct nir_variable { #define nir_foreach_variable_safe(var, var_list) \ foreach_list_typed_safe(nir_variable, var, node, var_list) +/** + * Returns the bits in the inputs_read, outputs_written, or + * system_values_read bitfield corresponding to this variable. + */ +static inline uint64_t +nir_variable_get_io_mask(nir_variable *var, gl_shader_stage stage) +{ + /* TODO: add support for tess patches */ + if (var->data.patch || var->data.location < 0) + return 0; + + assert(var->data.mode == nir_var_shader_in || + var->data.mode == nir_var_shader_out || + var->data.mode == nir_var_system_value); + assert(var->data.location >= 0); + + const struct glsl_type *var_type = var->type; + if ((var->data.mode == nir_var_shader_in && + (stage == MESA_SHADER_GEOMETRY || + stage == MESA_SHADER_TESS_CTRL || + stage == MESA_SHADER_TESS_EVAL)) || + (var->data.mode == nir_var_shader_out && + stage == MESA_SHADER_TESS_CTRL)) { + if (glsl_type_is_array(var_type)) + var_type = glsl_get_array_element(var_type); + } + + unsigned slots = glsl_count_attribute_slots(var_type, false); + return ((1ull << slots) - 1) << var->data.location; +} + static inline bool nir_variable_is_global(const nir_variable *var) { -- 2.13.5 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev