}
static void
-validate_deref_chain(nir_deref *deref, validate_state *state)
+validate_deref_chain(nir_deref *deref, nir_variable_mode mode,
+ validate_state *state)
{
validate_assert(state, deref->child == NULL || ralloc_parent(deref->child) == deref);
while (deref != NULL) {
switch (deref->deref_type) {
case nir_deref_type_array:
+ if (mode == nir_var_shared) {
+ /* Shared variables have a bit more relaxed rules because we need
+ * to be able to handle array derefs on vectors. Fortunately,
+ * nir_lower_io handles these just fine.
+ */
+ validate_assert(state, glsl_type_is_array(parent->type) ||
+ glsl_type_is_matrix(parent->type) ||
+ glsl_type_is_vector(parent->type));
+ } else {
+ /* Most of NIR cannot handle array derefs on vectors */
+ validate_assert(state, glsl_type_is_array(parent->type) ||
+ glsl_type_is_matrix(parent->type));
+ }
validate_assert(state, deref->type == glsl_get_array_element(parent->type));
if (nir_deref_as_array(deref)->deref_array_type ==
nir_deref_array_type_indirect)
validate_var_use(deref->var, state);
- validate_deref_chain(&deref->deref, state);
+ validate_deref_chain(&deref->deref, deref->var->data.mode, state);
}
static void