[Mesa-dev] [PATCH 4/4] glsl: Give a warning, not an error, for UBO qualifiers on struct fields.

Ian Romanick idr at freedesktop.org
Wed Aug 21 21:02:12 PDT 2013


On 08/15/2013 11:27 AM, Matt Turner wrote:
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59648
> ---
>   src/glsl/ast_to_hir.cpp | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
> index c2fdbd5..f35c11f 100644
> --- a/src/glsl/ast_to_hir.cpp
> +++ b/src/glsl/ast_to_hir.cpp
> @@ -1830,10 +1830,11 @@ validate_matrix_layout_for_type(struct _mesa_glsl_parse_state *state,
>   				const glsl_type *type)
>   {
>      if (!type->is_matrix() && !type->is_record()) {
> -      _mesa_glsl_error(loc, state,
> -                       "uniform block layout qualifiers row_major and "
> -                       "column_major can only be applied to matrix and "
> -                       "structure types");
> +      _mesa_glsl_warning(loc, state,
> +                         "uniform block layout qualifiers row_major and "
> +                         "column_major applied to structure fields is not "
> +                         "strictly conformant and my be rejected by other "
> +                         "compilers");

This is now strictly conformant.  However, ES3 compilers that have 
already shipped will reject this usage.  I would change this message to:

/**
  * Matrix layout qualifiers are only allowed on certain types
  */
static void
validate_matrix_layout_for_type(struct _mesa_glsl_parse_state *state,
                                 YYLTYPE *loc,
                                 const glsl_type *type)
{
    if (!type->is_matrix()) {
       /* The OpenGL ES 3.0 conformance tests did not originally allow
        * matrix layout qualifiers on non-matrices.  However, the OpenGL
        * 4.4 and OpenGL ES 3.0 (revision TBD) specifications were
        * amended to specifically allow these layouts on all types.  Emit
        * a warning so that people know their code may not be portable.
        */
       _mesa_glsl_warning(loc, state,
                          "uniform block layout qualifiers row_major and "
                          "column_major applied to non-matrix types may "
                          "be rejected by older compilers");
    }
}

>      } else if (type->is_record()) {
>         /* We allow 'layout(row_major)' on structure types because it's the only
>          * way to get row-major layouts on matrices contained in structures.
>



More information about the mesa-dev mailing list