[Mesa-dev] [PATCH 0/5] deal with multiple appearances of the same layout-qualifier-name in a single declaration

Andres Gomez agomez at igalia.com
Thu Oct 6 22:52:03 UTC 2016


In the case of layout-qualifier-names that can appear multiple times
in different declarations of the same shader or, even, the same
program, we are using the ast_layout_expression class which holds a
list to store all the appearances to be able to check later which is
the overriding value and whether it matches (or not) previous
appearances of the same layout-qualifier-name.

Until now, we were also holding inside the ast_layout_expression
values of the same layout-qualifier-name that could appear inside a
single layout-qualifier or across multiple layout-qualifiers in a
single declaration.

This was a problem since, inside a declaration, only the last
appearance should be taken into account. As we were not doing this,
the compilation or linking was failing due to different values of the
same layout-qualifier-name in a single declaration when such
layout-qualifier-name had as a constraint to hold the same value
across the same shader or program.

Now, we only hold the last appearanace of a repeated
layout-qualifier-name inside a single declaration.

These following 2 example will help to illustrate the problem:

- " #version 150
    #extension GL_ARB_shading_language_420pack: enable
    #extension GL_ARB_enhanced_layouts: enable

    layout(max_vertices=2, max_vertices=3) out;
    layout(max_vertices=3) out;"

- " #version 150
    #extension GL_ARB_shading_language_420pack: enable
    #extension GL_ARB_enhanced_layouts: enable

    layout(max_vertices=2) layout(max_vertices=3) out;
    layout(max_vertices=3) out;"

Although different values for the "max_vertices" layout-qualifier-name
should end in a compilation failure, since only the last occurrence is
taken into account, these two small pieces of code from a shader are
valid.

Fixes:
- GL44-CTS.shading_language_420pack.qualifier_override_layout
- GL44-CTS.enhanced_layouts.xfb_duplicated_stride

Andres Gomez (5):
  glsl: last duplicated layout-qualifier-name in a layout-qualifier
    overrides the former
  glsl: last duplicated layout-qualifier-name in multiple
    layout-qualifiers overrides the former
  glsl: push layout-qualifier-name values from variable declarations to
    global
  glsl: by default, any ast_layout_expression variable value must match
    its previous appearances
  glsl: simplified ast_type_qualifier::merge_[in|out]_qualifier API

 src/compiler/glsl/ast.h                  |  17 +++-
 src/compiler/glsl/ast_type.cpp           |  95 +++++++++++--------
 src/compiler/glsl/glsl_parser.yy         | 156 +++++++++++++++----------------
 src/compiler/glsl/glsl_parser_extras.cpp |   2 +-
 4 files changed, 144 insertions(+), 126 deletions(-)

-- 
2.9.3



More information about the mesa-dev mailing list