From: Jason Ekstrand Date: Mon, 25 Jan 2016 23:50:31 +0000 (-0800) Subject: Merge remote-tracking branch 'mattst88/nir-lower-pack-unpack' into vulkan X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e462d4d81529ecf438cb75f8a74f5662adfd69ce;p=mesa.git Merge remote-tracking branch 'mattst88/nir-lower-pack-unpack' into vulkan --- e462d4d81529ecf438cb75f8a74f5662adfd69ce diff --cc src/glsl/nir/nir.h index 4e3533189e4,3b90b5129f1..ec6595b091d --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@@ -355,35 -349,7 +355,35 @@@ typedef struct nir_variable #define nir_foreach_variable(var, var_list) \ foreach_list_typed(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) +{ + 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 (stage == MESA_SHADER_GEOMETRY && var->data.mode == nir_var_shader_in) { + /* Most geometry shader inputs are per-vertex arrays */ + if (var->data.location >= VARYING_SLOT_VAR0) + assert(glsl_type_is_array(var_type)); + + if (glsl_type_is_array(var_type)) + var_type = glsl_get_array_element(var_type); + } + + bool is_vertex_input = (var->data.mode == nir_var_shader_in && + stage == MESA_SHADER_VERTEX); + unsigned slots = glsl_count_attribute_slots(var_type, is_vertex_input); + return ((1ull << slots) - 1) << var->data.location; +} + - typedef struct { + typedef struct nir_register { struct exec_node node; unsigned num_components; /** < number of vector components */