[Mesa-dev] [PATCH 16/16] glsl: Allow arrays of arrays in GLSL ES 3.10 and GLSL 4.30

Timothy Arceri t_arceri at yahoo.com.au
Fri Jul 17 18:25:43 PDT 2015


V2: add missing 's' to the extension name in error messages
 and add decimal place in version string
---
 src/glsl/ast_to_hir.cpp       | 13 ++++++++-----
 src/glsl/glsl_parser.yy       | 22 ++++++++++++++--------
 src/glsl/glsl_parser_extras.h |  5 +++++
 3 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 8154c1e..fe169b3 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1939,12 +1939,15 @@ process_array_type(YYLTYPE *loc, const glsl_type *base,
           *
           * "Only one-dimensional arrays may be declared."
           */
-         if (!state->ARB_arrays_of_arrays_enable) {
+         if (!state->has_arrays_of_arrays()) {
+            const char *const requirement = state->es_shader
+               ? "GLSL ES 3.10"
+               : "GL_ARB_arrays_of_arrays or GLSL 4.30";
             _mesa_glsl_error(loc, state,
-                             "invalid array of `%s'"
-                             "GL_ARB_arrays_of_arrays "
-                             "required for defining arrays of arrays",
-                             base->name);
+                             "invalid array of `%s' "
+                             "%s required for defining arrays of arrays",
+                             base->name, requirement);
+
             return glsl_type::error_type;
          }
       }
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 1f08893..c480689 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1856,10 +1856,13 @@ array_specifier:
       void *ctx = state;
       $$ = $1;
 
-      if (!state->ARB_arrays_of_arrays_enable) {
-         _mesa_glsl_error(& @1, state,
-                          "GL_ARB_arrays_of_arrays "
-                          "required for defining arrays of arrays");
+      if (!state->has_arrays_of_arrays()) {
+         const char *const requirement = state->es_shader
+            ? "GLSL ES 3.10"
+            : "GL_ARB_arrays_of_arrays or GLSL 4.30";
+         _mesa_glsl_error(& @1, state,                     
+                          "%s required for defining arrays of arrays.",
+                          requirement);
       }
       $$->add_dimension(new(ctx) ast_expression(ast_unsized_array_dim, NULL,
                                                 NULL, NULL));
@@ -1868,10 +1871,13 @@ array_specifier:
    {
       $$ = $1;
 
-      if (!state->ARB_arrays_of_arrays_enable) {
-         _mesa_glsl_error(& @1, state,
-                          "GL_ARB_arrays_of_arrays "
-                          "required for defining arrays of arrays");
+      if (!state->has_arrays_of_arrays()) {
+         const char *const requirement = state->es_shader
+            ? "GLSL ES 3.10"
+            : "GL_ARB_arrays_of_arrays or GLSL 4.30";
+         _mesa_glsl_error(& @1, state,                     
+                          "%s required for defining arrays of arrays.",
+                          requirement);
       }
 
       $$->add_dimension($3);
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 02ddbbd..ba760fe 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -190,6 +190,11 @@ struct _mesa_glsl_parse_state {
       return true;
    }
 
+   bool has_arrays_of_arrays() const
+   {
+      return ARB_arrays_of_arrays_enable || is_version(430, 310);
+   }
+
    bool has_atomic_counters() const
    {
       return ARB_shader_atomic_counters_enable || is_version(420, 310);
-- 
2.4.3



More information about the mesa-dev mailing list