summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-04-26 18:50:15 +0200
committerSamuel Pitoiset <[email protected]>2017-04-28 10:43:13 +0200
commitedb4a1ab2d3fbbbe0ec88f3fbb0654620b4b094c (patch)
tree425dd466a006c5d78ebc77d4fb5b2f69cb68c829 /src
parent80738425e4d3240c43cac1b4cfde91650379cf5c (diff)
glsl: introduce validate_image_qualifier_for_type() helper
Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/glsl/ast_to_hir.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 425da639c71..1159b2cdfbf 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -3291,15 +3291,13 @@ apply_explicit_location(const struct ast_type_qualifier *qual,
}
}
-static void
-apply_image_qualifier_to_variable(const struct ast_type_qualifier *qual,
- ir_variable *var,
- struct _mesa_glsl_parse_state *state,
- YYLTYPE *loc)
+static bool
+validate_image_qualifier_for_type(struct _mesa_glsl_parse_state *state,
+ YYLTYPE *loc,
+ const struct ast_type_qualifier *qual,
+ const glsl_type *type)
{
- const glsl_type *base_type = var->type->without_array();
-
- if (!base_type->is_image()) {
+ if (!type->is_image()) {
if (qual->flags.q.read_only ||
qual->flags.q.write_only ||
qual->flags.q.coherent ||
@@ -3313,8 +3311,21 @@ apply_image_qualifier_to_variable(const struct ast_type_qualifier *qual,
_mesa_glsl_error(loc, state, "format layout qualifiers may only be "
"applied to images");
}
- return;
+ return false;
}
+ return true;
+}
+
+static void
+apply_image_qualifier_to_variable(const struct ast_type_qualifier *qual,
+ ir_variable *var,
+ struct _mesa_glsl_parse_state *state,
+ YYLTYPE *loc)
+{
+ const glsl_type *base_type = var->type->without_array();
+
+ if (!validate_image_qualifier_for_type(state, loc, qual, base_type))
+ return;
if (var->data.mode != ir_var_uniform &&
var->data.mode != ir_var_function_in) {