From de8f0c9ab99ac6140f6560e776a42a22eeff6721 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Sat, 14 Nov 2015 12:22:49 +1100 Subject: [PATCH] glsl: add process_qualifier_constant() helper MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Emil Velikov --- src/glsl/ast_to_hir.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index a9b1c0ed34b..334561d4eb6 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2504,6 +2504,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, -- 2.30.2