nir: add a deref slot counter that handles compact

Conor suggested this, so we can mark slots properly
in the io marking.

This fixes a problem seen when rewriting llvmpipe to use
nir info instead of tgsi info.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24803>
This commit is contained in:
Dave Airlie
2023-08-03 11:16:47 +10:00
committed by Marge Bot
parent b318b3d520
commit 51840bbdce
2 changed files with 17 additions and 1 deletions

View File

@@ -6133,6 +6133,22 @@ 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);
}
static inline unsigned
nir_deref_count_slots(nir_deref_instr *deref, nir_variable *var)
{
if (var->data.compact) {
switch (deref->deref_type) {
case nir_deref_type_array:
return 1;
case nir_deref_type_var:
return nir_variable_count_slots(var, deref->type);
default:
unreachable("illegal deref type");
}
}
return glsl_count_attribute_slots(deref->type, false);
}
/* See default_ub_config in nir_range_analysis.c for documentation. */
typedef struct nir_unsigned_upper_bound_config {
unsigned min_subgroup_size;

View File

@@ -291,7 +291,7 @@ try_mask_partial_io(nir_shader *shader, nir_variable *var,
return false;
}
unsigned len = glsl_count_attribute_slots(deref->type, false);
unsigned len = nir_deref_count_slots(deref, var);
set_io_mask(shader, var, offset, len, deref, is_output_read);
return true;
}