return nir_variable_is_in_ubo(var) || nir_variable_is_in_ssbo(var);
}
+static inline unsigned
+nir_variable_count_slots(const nir_variable *var, const struct glsl_type *type)
+{
+ return var->data.compact ?
+ DIV_ROUND_UP(var->data.location_frac + glsl_get_length(type), 4) :
+ glsl_count_attribute_slots(type, false);
+}
+
/* See default_ub_config in nir_range_analysis.c for documentation. */
typedef struct nir_unsigned_upper_bound_config {
unsigned min_subgroup_size;
type = glsl_get_array_element(type);
}
- const unsigned slots =
- var->data.compact ? DIV_ROUND_UP(var->data.location_frac + glsl_get_length(type), 4)
- : glsl_count_attribute_slots(type, false);
-
+ const unsigned slots = nir_variable_count_slots(var, type);
set_io_mask(shader, var, 0, slots, deref, is_output_read);
}
if (offset == -1)
return false;
- const unsigned slots =
- var->data.compact ? DIV_ROUND_UP(var->data.location_frac + glsl_get_length(type), 4)
- : glsl_count_attribute_slots(type, false);
-
+ const unsigned slots = nir_variable_count_slots(var, type);
if (offset >= slots) {
/* Constant index outside the bounds of the matrix/array. This could
* arise as a result of constant folding of a legal GLSL program.
memset(output_map, 0, sizeof(output_map));
nir_foreach_shader_out_variable(var, nir) {
- unsigned slots =
- var->data.compact ? DIV_ROUND_UP(var->data.location_frac + glsl_get_length(var->type), 4)
- : glsl_count_attribute_slots(var->type, false);
+ unsigned slots = nir_variable_count_slots(var, var->type);
for (unsigned i = 0; i < slots; i++)
output_map[var->data.location + i] = var->data.driver_location + i;
}
type = glsl_get_array_element(type);
}
- unsigned attrib_count = variable->data.compact ? DIV_ROUND_UP(variable->data.location_frac + glsl_get_length(type), 4) :
- glsl_count_attribute_slots(type, nir->info.stage == MESA_SHADER_VERTEX);
+ unsigned attrib_count = nir_variable_count_slots(variable, type);
i = variable->data.driver_location;
type = glsl_get_array_element(type);
}
- unsigned attrib_count = variable->data.compact ? DIV_ROUND_UP(variable->data.location_frac + glsl_get_length(type), 4) :
- glsl_count_attribute_slots(type, false);
+ unsigned attrib_count = nir_variable_count_slots(variable, type);
for (unsigned k = 0; k < attrib_count; k++, i++) {
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
memset(output_mapping, 0, sizeof(output_mapping));
nir_foreach_shader_out_variable(var, shader->pipeline_nir->nir) {
- unsigned slots = var->data.compact ? DIV_ROUND_UP(var->data.location_frac + glsl_get_length(var->type), 4)
- : glsl_count_attribute_slots(var->type, false);
+ unsigned slots = nir_variable_count_slots(var, var->type);
for (unsigned i = 0; i < slots; i++)
output_mapping[var->data.location + i] = var->data.driver_location + i;
}
*/
nir_foreach_shader_out_variable(var, nir) {
const int loc = var->data.driver_location;
- const unsigned var_vec4s =
- var->data.compact ? DIV_ROUND_UP(var->data.location_frac + glsl_get_length(var->type), 4)
- : type_size_vec4(var->type, true);
+ const unsigned var_vec4s = nir_variable_count_slots(var, var->type);
vec4s[loc] = MAX2(vec4s[loc], var_vec4s);
}