glsl: add process_qualifier_constant() helper
authorTimothy Arceri <timothy.arceri@collabora.com>
Sat, 14 Nov 2015 01:22:49 +0000 (12:22 +1100)
committerTimothy Arceri <t_arceri@yahoo.com.au>
Fri, 20 Nov 2015 20:26:55 +0000 (07:26 +1100)
For now this just validates that a qualifier is inside its
minimum boundary, in a later patch we will expand it to
evaluate compile time constants.

Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/glsl/ast_to_hir.cpp

index a9b1c0e..334561d 100644 (file)
@@ -2505,6 +2505,23 @@ validate_matrix_layout_for_type(struct _mesa_glsl_parse_state *state,
 }
 
 static bool
+process_qualifier_constant(struct _mesa_glsl_parse_state *state,
+                           YYLTYPE *loc,
+                           const char *qual_indentifier,
+                           int qual_value,
+                           unsigned *value)
+{
+   if (qual_value < 0) {
+      _mesa_glsl_error(loc, state, "%s layout qualifier is invalid (%d < 0)",
+                       qual_indentifier, qual_value);
+      return false;
+   }
+
+   *value = (unsigned) qual_value;
+   return true;
+}
+
+static bool
 validate_binding_qualifier(struct _mesa_glsl_parse_state *state,
                            YYLTYPE *loc,
                            const glsl_type *type,