[Mesa-dev] [PATCH v3 06/14] glsl: move stream layout qualifier validation

Emil Velikov emil.l.velikov at gmail.com
Tue Nov 17 10:30:13 PST 2015


On 14 November 2015 at 13:42, Timothy Arceri <t_arceri at yahoo.com.au> wrote:
> From: Timothy Arceri <timothy.arceri at collabora.com>
>
> We are moving this out of the parser in preparation for compile
> time constant support.
>
> The reason a validation function is used rather than an apply
> function like what is used with bindings is because glsl allows
> streams to be defined on members of blocks even though they must
> match the stream thats associated with the current block, this
> means we need access to the value after validation to do this
> comparision.
> ---
>  src/glsl/ast_to_hir.cpp | 44 +++++++++++++++++++++++++++++++++-----------
>  src/glsl/glsl_parser.yy | 11 ++---------
>  2 files changed, 35 insertions(+), 20 deletions(-)
>
> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
> index 8705f6e..53faacf 100644
> --- a/src/glsl/ast_to_hir.cpp
> +++ b/src/glsl/ast_to_hir.cpp
> @@ -3034,7 +3034,11 @@ apply_layout_qualifier_to_variable(const struct ast_type_qualifier *qual,
>
>     if (state->stage == MESA_SHADER_GEOMETRY &&
>         qual->flags.q.out && qual->flags.q.stream) {
> -      var->data.stream = qual->stream;
> +      unsigned qual_stream;
> +      if (process_qualifier_constant(state, loc, "stream", qual->stream,
> +                                     &qual_stream)) {
> +         var->data.stream = qual_stream;
> +      }
>     }
>
>     if (var->type->contains_atomic()) {
> @@ -6080,7 +6084,8 @@ ast_process_struct_or_iface_block_members(exec_list *instructions,
>                                            enum glsl_matrix_layout matrix_layout,
>                                            bool allow_reserved_names,
>                                            ir_variable_mode var_mode,
> -                                          ast_type_qualifier *layout)
> +                                          ast_type_qualifier *layout,
> +                                          unsigned block_stream)
>  {
>     unsigned decl_count = 0;
>
> @@ -6188,11 +6193,16 @@ ast_process_struct_or_iface_block_members(exec_list *instructions,
>         *   the specified stream must match the stream associated with the
>         *   containing block."
>         */
> -      if (qual->flags.q.explicit_stream &&
> -          qual->stream != layout->stream) {
> -         _mesa_glsl_error(&loc, state, "stream layout qualifier on interface "
> -                          "block member does not match the interface block "
> -                          "(%d vs %d)", qual->stream, layout->stream);
> +      if (qual->flags.q.explicit_stream) {
> +         unsigned qual_stream;
> +         if (process_qualifier_constant(state, &loc, "stream",
> +                                        qual->stream, &qual_stream) &&
> +             qual_stream != block_stream) {
> +            _mesa_glsl_error(&loc, state, "stream layout qualifier on "
> +                             "interface block member does not match "
> +                             "the interface block (%d vs %d)", qual->stream,
> +                             block_stream);
> +         }
>        }
>
>        if (qual->flags.q.uniform && qual->has_interpolation()) {
> @@ -6350,7 +6360,8 @@ ast_struct_specifier::hir(exec_list *instructions,
>                                                  GLSL_MATRIX_LAYOUT_INHERITED,
>                                                  false /* allow_reserved_names */,
>                                                  ir_var_auto,
> -                                                NULL);
> +                                                NULL,
> +                                                0 /* for interface only */);
>
>     validate_identifier(this->name, loc, state);
>
> @@ -6504,6 +6515,16 @@ ast_interface_block::hir(exec_list *instructions,
>                         "Interface block sets both readonly and writeonly");
>     }
>
> +   unsigned qual_stream;
> +   if (!process_qualifier_constant(state, &loc, "stream", this->layout.stream,
> +                                   &qual_stream)) {
> +      /* If the stream qualifier is invalid it doesn't make sense to continue
> +       * on and try to compare stream layouts on member variables agaist it so
typo "against".

-Emil


More information about the mesa-dev mailing list