[Mesa-dev] [PATCH 6/9] glsl: Implement ARB_arrays_of_arrays support for constructors

Matt Turner mattst88 at gmail.com
Thu Jan 16 16:45:38 PST 2014


On Wed, Jan 15, 2014 at 10:27 PM, Timothy Arceri <t_arceri at yahoo.com.au> wrote:
> Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
> ---
>  src/glsl/ast_function.cpp | 54 ++++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 46 insertions(+), 8 deletions(-)
>
> diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
> index 2d05d07..57aa45f 100644
> --- a/src/glsl/ast_function.cpp
> +++ b/src/glsl/ast_function.cpp
> @@ -734,6 +734,7 @@ process_array_constructor(exec_list *instructions,
>      *    Section 4.1.10 "Implicit Conversions.""
>      */
>     exec_list actual_parameters;
> +
>     const unsigned parameter_count =
>        process_parameters(instructions, &actual_parameters, parameters, state);
>     bool is_unsized_array = constructor_type->is_unsized_array();
> @@ -752,8 +753,10 @@ process_array_constructor(exec_list *instructions,
>
>     if (is_unsized_array) {
>        constructor_type =
> -        glsl_type::get_array_instance(constructor_type->element_type(),
> -                                      parameter_count);
> +         glsl_type::get_array_instance(constructor_type->element_type(),
> +                                       parameter_count,
> +                                       constructor_type->dimension_count);
> +
>        assert(constructor_type != NULL);
>        assert(constructor_type->length == parameter_count);
>     }
> @@ -782,14 +785,49 @@ process_array_constructor(exec_list *instructions,
>          }
>        }
>
> -      if (result->type != constructor_type->element_type()) {
> -        _mesa_glsl_error(loc, state, "type error in array constructor: "
> -                         "expected: %s, found %s",
> -                         constructor_type->element_type()->name,
> -                         result->type->name);
> +      if (constructor_type->dimension_count == 1 &&
> +          result->type != constructor_type->element_type()) {
> +         _mesa_glsl_error(loc, state, "type error in array constructor: "
> +                          "expected: %s, found %s",
> +                          constructor_type->element_type()->name,
> +                          result->type->name);
>           return ir_rvalue::error_value(ctx);
>        }
>
> +      /* compare arrays of arrays dimensions, element type, and sizes*/
> +      if (result->type->is_array()) {
> +
> +         if (result->type->dimension_count != (constructor_type->dimension_count-1)) {
> +             _mesa_glsl_error(loc, state, "type error in array constructor: "
> +                             "expected array with: %u dimension(s),"
> +                              " found %u dimension(s)",
> +                              constructor_type->dimension_count-1,
> +                              result->type->dimension_count);
> +             return ir_rvalue::error_value(ctx);
> +         }
> +
> +         const glsl_type *expected_type = constructor_type->element_type();
> +         const glsl_type *result_type = result->type;
> +         for (unsigned i=0; i<result->type->dimension_count; i++) {
> +            if (result_type->length != expected_type->length) {
> +               _mesa_glsl_error(loc, state, "type error in array constructor: "
> +                                "expected array with size: %u,"
> +                                " found size %u",
> +                                expected_type->length,
> +                                result_type->length);
> +               return ir_rvalue::error_value(ctx);
> +            }
> +            expected_type = expected_type->element_type();
> +            result_type = result_type->element_type();
> +         }
> +
> +         if (expected_type != result_type) {
> +            _mesa_glsl_error(loc, state, "type error in array constructor: "
> +                            "expected: %s",
> +                             expected_type->name);
> +         }
> +      }
> +
>        /* Attempt to convert the parameter to a constant valued expression.
>         * After doing so, track whether or not all the parameters to the
>         * constructor are trivially constant valued expressions.
> @@ -808,7 +846,7 @@ process_array_constructor(exec_list *instructions,
>        return new(ctx) ir_constant(constructor_type, &actual_parameters);
>
>     ir_variable *var = new(ctx) ir_variable(constructor_type, "array_ctor",
> -                                          ir_var_temporary);
> +                                           ir_var_temporary);
>     instructions->push_tail(var);
>
>     int i = 0;
> --
> 1.8.3.1

There are just generally a bunch of unrelated whitespace changes in
this patch. I see some of them are replacing tabs with spaces, but
this just makes finding the functional differences in the patch
harder. If you're already modifying a line, feel free to fix up its
whitespace, but not on otherwise untouched lines. Actually, there are
some added lines with tabs too..


More information about the mesa-dev mailing list