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

Lofstedt, Marta marta.lofstedt at intel.com
Thu Sep 17 03:20:17 PDT 2015


Reviewed-by: Marta Lofstedt <marta.lofstedt at intel.com>

> -----Original Message-----
> From: mesa-dev [mailto:mesa-dev-bounces at lists.freedesktop.org] On
> Behalf Of Timothy Arceri
> Sent: Thursday, September 17, 2015 9:03 AM
> To: mesa-dev at lists.freedesktop.org
> Subject: [Mesa-dev] [PATCH 22/24] glsl: Allow arrays of arrays in GLSL ES 3.10
> and GLSL 4.30
> 
> V3: use a check_*_allowed style function for requirements checking rather
> than has_* which doesn't encapsulate the error message
> 
> V2: add missing 's' to the extension name in error messages  and add decimal
> place in version string
> ---
>  src/glsl/ast_to_hir.cpp       |  7 +------
>  src/glsl/glsl_parser.yy       | 17 +++++------------
>  src/glsl/glsl_parser_extras.h | 14 ++++++++++++++
>  3 files changed, 20 insertions(+), 18 deletions(-)
> 
> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index
> 167824d..3620d1d 100644
> --- a/src/glsl/ast_to_hir.cpp
> +++ b/src/glsl/ast_to_hir.cpp
> @@ -1996,12 +1996,7 @@ process_array_type(YYLTYPE *loc, const glsl_type
> *base,
>            *
>            * "Only one-dimensional arrays may be declared."
>            */
> -         if (!state->ARB_arrays_of_arrays_enable) {
> -            _mesa_glsl_error(loc, state,
> -                             "invalid array of `%s'"
> -                             "GL_ARB_arrays_of_arrays "
> -                             "required for defining arrays of arrays",
> -                             base->name);
> +         if (!state->check_arrays_of_arrays_allowed(loc)) {
>              return glsl_type::error_type;
>           }
>        }
> diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index
> bdd4dea..096baf1 100644
> --- a/src/glsl/glsl_parser.yy
> +++ b/src/glsl/glsl_parser.yy
> @@ -1974,25 +1974,18 @@ 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->check_arrays_of_arrays_allowed(& @1)) {
> +         $$->add_dimension(new(ctx) ast_expression(ast_unsized_array_dim,
> NULL,
> +                                                   NULL, NULL));
>        }
> -      $$->add_dimension(new(ctx) ast_expression(ast_unsized_array_dim,
> NULL,
> -                                                NULL, NULL));
>     }
>     | array_specifier '[' constant_expression ']'
>     {
>        $$ = $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->check_arrays_of_arrays_allowed(& @1)) {
> +         $$->add_dimension($3);
>        }
> -
> -      $$->add_dimension($3);
>     }
>     ;
> 
> diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index
> d3b091d..bd0cac2 100644
> --- a/src/glsl/glsl_parser_extras.h
> +++ b/src/glsl/glsl_parser_extras.h
> @@ -115,6 +115,20 @@ struct _mesa_glsl_parse_state {
>                        unsigned required_glsl_es_version,
>                        YYLTYPE *locp, const char *fmt, ...) PRINTFLIKE(5, 6);
> 
> +   bool check_arrays_of_arrays_allowed(YYLTYPE *locp)
> +   {
> +      if (!(ARB_arrays_of_arrays_enable || is_version(430, 310))) {
> +         const char *const requirement = this->es_shader
> +            ? "GLSL ES 3.10"
> +            : "GL_ARB_arrays_of_arrays or GLSL 4.30";
> +         _mesa_glsl_error(locp, this,
> +                          "%s required for defining arrays of arrays.",
> +                          requirement);
> +         return false;
> +      }
> +      return true;
> +   }
> +
>     bool check_precision_qualifiers_allowed(YYLTYPE *locp)
>     {
>        return check_version(130, 100, locp,
> --
> 2.4.3
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list