[Mesa-dev] [PATCH 0/3] Expand inter-shader compatibility check of built-in blocks

Eduardo Lima Mitev elima at igalia.com
Sun Mar 5 19:28:40 UTC 2017


Few weeks ago I submitted this same series, that essentially expands the existing validation of inter-shader build-in interfaces blocks, to also consider blocks that have unused members and thus were optimized out at compile time.

The original concern about this series was that forcing a link error on blocks that have no used members was not a spec requirement, and thus would make the linker behavior more restrictive than expected/necessary. Apparently, this is not the case.

After filing a bug against the spec to clarify this, the position seems firm that built-in block interfaces must match across shaders within a program, regardless of usage of its members. These are the relevant spec quotations, from OpenGL Shading Language 4.5:

Section 4.3.9 Interface Blocks:

    "The block name (block-name) is used to match within shader interfaces: an output block of one pipeline stage will be matched to an input block with the same name in the subsequent pipeline stage."

Followed in the next paragraph by:

    "Matched block names within a shader interface (as defined above) must match in terms of having the same number of declarations with the same sequence of types and the same sequence of member names, as well as having the same member-wise layout qualification (see next section)."

Section 7.1 Built-In Language Variables:

    "If multiple shaders using members of a built-in block belonging to the same interface are linked together in the same program, they must all redeclare the built-in block in the same way, as described in section 4.3.9 “Interface Blocks” for interface-block matching, or a link-time error will result. If a built-in block interface is formed across shaders in different programs, the shaders must all redeclare the built-in block in the same way (as described for a single program), or the values passed along the interface are undefined."

There is no explicit language for blocks with unused members, hence we must assume all re-declared blocks are subject to the restrictions above.

Honestly, I think it is unfortunate that we need to carry otherwise unused symbols from compile-time to link-time, just to perform this validation. However, the code is pretty simple and we get to factorize a couple of routines too. Also, I see value in catching a potential shader error early.

Eduardo

Eduardo Lima Mitev (3):
  glsl_parser_extra: Add utility to copy symbols between symbol tables
  glsl: Use the utility function to copy symbols between symbol tables
  glsl/linker: Check that re-declared, inter-shader built-in blocks
    match

 src/compiler/glsl/glsl_parser_extras.cpp    | 53 ++++++++++++++++++++---------
 src/compiler/glsl/glsl_parser_extras.h      |  5 +++
 src/compiler/glsl/link_interface_blocks.cpp | 33 +++++++++++++++++-
 src/compiler/glsl/linker.cpp                | 16 ++-------
 4 files changed, 77 insertions(+), 30 deletions(-)

-- 
2.11.0



More information about the mesa-dev mailing list