}
+/**
+ * Matrix layout qualifiers are only allowed on certain types
+ */
+static void
+validate_matrix_layout_for_type(struct _mesa_glsl_parse_state *state,
+ YYLTYPE *loc,
+ const glsl_type *type)
+{
+ if (!type->is_matrix() && !type->is_record()) {
+ _mesa_glsl_error(loc, state,
+ "uniform block layout qualifiers row_major and "
+ "column_major can only be applied to matrix and "
+ "structure types");
+ } else if (type->is_record()) {
+ /* We allow 'layout(row_major)' on structure types because it's the only
+ * way to get row-major layouts on matrices contained in structures.
+ */
+ _mesa_glsl_warning(loc, state,
+ "uniform block layout qualifiers row_major and "
+ "column_major applied to structure types is not "
+ "strictly conformant and my be rejected by other "
+ "compilers");
+ }
+}
+
static void
apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
ir_variable *var,
"members");
}
- if (!ubo_qualifiers_valid &&
- (qual->flags.q.row_major || qual->flags.q.column_major)) {
- _mesa_glsl_error(loc, state,
- "uniform block layout qualifiers row_major and "
- "column_major can only be applied to uniform block "
- "members");
+ if (qual->flags.q.row_major || qual->flags.q.column_major) {
+ if (!ubo_qualifiers_valid) {
+ _mesa_glsl_error(loc, state,
+ "uniform block layout qualifiers row_major and "
+ "column_major can only be applied to uniform block "
+ "members");
+ } else
+ validate_matrix_layout_for_type(state, loc, var->type);
}
}