glsl: replace index layout min boundary check
authorTimothy Arceri <timothy.arceri@collabora.com>
Sat, 14 Nov 2015 02:09:46 +0000 (13:09 +1100)
committerTimothy Arceri <t_arceri@yahoo.com.au>
Fri, 20 Nov 2015 20:27:09 +0000 (07:27 +1100)
Use new helper that will in a later patch allow for
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 f0f2d52d811fb807e5c054a10ea9c46bf74f38e7..fde3df5d9b6cef9f0a94f91595d9c76dc17b9924 100644 (file)
@@ -2804,7 +2804,10 @@ apply_explicit_location(const struct ast_type_qualifier *qual,
          break;
       }
 
-      if (qual->flags.q.explicit_index) {
+      unsigned qual_index;
+      if (qual->flags.q.explicit_index &&
+          process_qualifier_constant(state, loc, "index", qual->index,
+                                     &qual_index)) {
          /* From the GLSL 4.30 specification, section 4.4.2 (Output
           * Layout Qualifiers):
           *
@@ -2814,12 +2817,12 @@ apply_explicit_location(const struct ast_type_qualifier *qual,
           * Older specifications don't mandate a behavior; we take
           * this as a clarification and always generate the error.
           */
-         if (qual->index < 0 || qual->index > 1) {
+         if (qual_index > 1) {
             _mesa_glsl_error(loc, state,
                              "explicit index may only be 0 or 1");
          } else {
             var->data.explicit_index = true;
-            var->data.index = qual->index;
+            var->data.index = qual_index;
          }
       }
    }