glsl: parse align layout qualifier
authorTimothy Arceri <timothy.arceri@collabora.com>
Tue, 12 Jan 2016 01:41:32 +0000 (12:41 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Sat, 5 Mar 2016 08:39:01 +0000 (19:39 +1100)
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
src/compiler/glsl/ast.h
src/compiler/glsl/ast_type.cpp
src/compiler/glsl/glsl_parser.yy

index 4dc9674e424c69922d5e57f7de4e55939d87342b..727aa432631fbde93c7dde65c4ddc4b45dbe2148 100644 (file)
@@ -479,6 +479,12 @@ struct ast_type_qualifier {
         unsigned pixel_center_integer:1;
         /*@}*/
 
+         /**
+          * Flag set if GL_ARB_enhanced_layouts "align" layout qualifier is
+          * used.
+          */
+         unsigned explicit_align:1;
+
         /**
          * Flag set if GL_ARB_explicit_attrib_location "location" layout
          * qualifier is used.
@@ -577,6 +583,11 @@ struct ast_type_qualifier {
    /** Precision of the type (highp/medium/lowp). */
    unsigned precision:2;
 
+   /**
+    * Alignment specified via GL_ARB_enhanced_layouts "align" layout qualifier
+    */
+   ast_expression *align;
+
    /** Geometry shader invocations for GL_ARB_gpu_shader5. */
    ast_layout_expression *invocations;
 
index 6b446a1d272605c75b9cee24321e3521c46b51d2..07ed4f2356c17ab2105bdb43bcf69ceb8c07870b 100644 (file)
@@ -73,6 +73,7 @@ ast_type_qualifier::has_layout() const
           || this->flags.q.column_major
           || this->flags.q.row_major
           || this->flags.q.packed
+          || this->flags.q.explicit_align
           || this->flags.q.explicit_location
           || this->flags.q.explicit_image_format
           || this->flags.q.explicit_index
@@ -287,6 +288,9 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
       return false;
    }
 
+   if (q.flags.q.explicit_align)
+      this->align = q.align;
+
    if (q.flags.q.explicit_location)
       this->location = q.location;
 
index 2fb0da1f8c0972f141a5e52f8b78aa4d4dee9e13..3c4f0c728dc8a7a018eb575d0da2df8a8a6377e4 100644 (file)
@@ -1468,6 +1468,17 @@ layout_qualifier_id:
                           "GLSL 4.40 or ARB_enhanced_layouts");
       }
 
+      if (match_layout_qualifier("align", $1, state) == 0) {
+         if (!state->has_enhanced_layouts()) {
+            _mesa_glsl_error(& @1, state,
+                             "align qualifier requires "
+                             "GLSL 4.40 or ARB_enhanced_layouts");
+         } else {
+            $$.flags.q.explicit_align = 1;
+            $$.align = $3;
+         }
+      }
+
       if (match_layout_qualifier("location", $1, state) == 0) {
          $$.flags.q.explicit_location = 1;