Skip to content
  • Andres Gomez's avatar
    glsl: UBOs and SSBOs must match the binding qualifier too · 40b09ed1
    Andres Gomez authored
    
    
    From page 140 (page 147 of the PDF) of the GLSL ES 3.10 v.4 spec:
    
      " 9.2 Matching of Qualifiers
    
        The following tables summarize the requirements for matching of
        qualifiers.  It applies whenever there are two or more matching
        variables in a shader interface.
    
        Notes:
    
        1. Yes means the qualifiers must match.
    
        ...
    
        9.2.1 Linked Shaders
    
        | Qualifier | Qualifier | in/out | Default  | uniform | buffer|
        |   Class   |           |        | Uniforms |  Block  | Block |
    
        ...
    
        |  Layout   |  binding  |  N/A   |   Yes    |   Yes   |  Yes  |"
    
    From page 93 (page 110 of the PDF) of the GL 4.2 (Core Profile) spec:
    
      " 2.11.7 Uniform Variables
    
        ...
    
        Uniform Blocks
    
        ...
    
        When a named uniform block is declared by multiple shaders in a
        program, it must be declared identically in each shader. The
        uniforms within the block must be declared with the same names and
        types, and in the same order. If a program contains multiple
        shaders with different declarations for the same named uniform
        block differs between shader, the program will fail to link."
    
    From page 129 (page 150 of the PDF) of the GL 4.3 (Core Profile) spec:
    
      " 7.8 Shader Buffer Variables and Shader Storage Blocks
    
        ...
    
        When a named shader storage block is declared by multiple shaders
        in a program, it must be declared identically in each shader. The
        buffer variables within the block must be declared with the same
        names, types, qualification, and declaration order. If a program
        contains multiple shaders with different declarations for the same
        named shader storage block, the program will fail to link."
    
    Therefore, if the binding qualifier differs between two linked Uniform
    or Shader Storage Blocks of the same name, a link error should happen.
    
    This patch will make that a link error will be reported on a program
    like this:
    
        "# VS
    
        layout(binding = 1) Block {
          vec4 color;
        } uni_block1;
    
        ...
    
        # FS
    
        layout(binding = 2) Block {
          vec4 color;
        } uni_block2;
    
        ..."
    
    Signed-off-by: default avatarAndres Gomez <agomez@igalia.com>
    Cc: Ian Romanick <ian.d.romanick@intel.com>
    Reviewed-by: default avatarTimothy Arceri <tarceri@itsqueeze.com>
    40b09ed1