<p dir="ltr"></p>
<p dir="ltr">---- Matt Turner wrote ----</p>
<p dir="ltr">> On Wed, May 27, 2015 at 3:53 AM, Timothy Arceri <<a href="mailto:t_arceri@yahoo.com.au">t_arceri@yahoo.com.au</a>> wrote:
<br>
> > Cc: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>>
<br>
> > ---
<br>
> >
<br>
> > It looks like this may never have actually worked, at least there
<br>
> > is no way it could have for inteface block arrays :)
<br>
> >
<br>
> > No piglit regressions.
<br>
> >
<br>
> > src/glsl/ast_to_hir.cpp | 22 ++++++++++++++--------
<br>
> > 1 file changed, 14 insertions(+), 8 deletions(-)
<br>
> >
<br>
> > diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
<br>
> > index 0ab664e..861bbfe 100644
<br>
> > --- a/src/glsl/ast_to_hir.cpp
<br>
> > +++ b/src/glsl/ast_to_hir.cpp
<br>
> > @@ -2041,10 +2041,10 @@ validate_matrix_layout_for_type(struct _mesa_glsl_parse_state *state,
<br>
> > static bool
<br>
> > validate_binding_qualifier(struct _mesa_glsl_parse_state *state,
<br>
> > YYLTYPE *loc,
<br>
> > - ir_variable *var,
<br>
> > + const glsl_type *type,
<br>
> > const ast_type_qualifier *qual)
<br>
> > {
<br>
> > - if (var->data.mode != ir_var_uniform) {
<br>
> > + if (!qual->flags.q.uniform) {
<br>
> > _mesa_glsl_error(loc, state,
<br>
> > "the \"binding\" qualifier only applies to uniforms");
<br>
> > return false;
<br>
> > @@ -2056,10 +2056,11 @@ validate_binding_qualifier(struct _mesa_glsl_parse_state *state,
<br>
> > }
<br>
> >
<br>
> > const struct gl_context *const ctx = state->ctx;
<br>
> > - unsigned elements = var->type->is_array() ? var->type->length : 1;
<br>
> > + unsigned elements = type->is_array() ? type->length : 1;
<br>
> > unsigned max_index = qual->binding + elements - 1;
<br>
> > + const glsl_type *base_type = type->without_array();
<br>
> >
<br>
> > - if (var->type->is_interface()) {
<br>
> > + if (base_type->is_interface()) {
<br>
> > /* UBOs. From page 60 of the GLSL 4.20 specification:
<br>
> > * "If the binding point for any uniform block instance is less than zero,
<br>
> > * or greater than or equal to the implementation-dependent maximum
<br>
> > @@ -2077,8 +2078,7 @@ validate_binding_qualifier(struct _mesa_glsl_parse_state *state,
<br>
> > ctx->Const.MaxUniformBufferBindings);
<br>
> > return false;
<br>
> > }
<br>
> > - } else if (var->type->is_sampler() ||
<br>
> > - (var->type->is_array() && var->type->fields.array->is_sampler())) {
<br>
> > + } else if (base_type->is_sampler()) {
<br>
> > /* Samplers. From page 63 of the GLSL 4.20 specification:
<br>
> > * "If the binding is less than zero, or greater than or equal to the
<br>
> > * implementation-dependent maximum supported number of units, a
<br>
> > @@ -2095,7 +2095,7 @@ validate_binding_qualifier(struct _mesa_glsl_parse_state *state,
<br>
> >
<br>
> > return false;
<br>
> > }
<br>
> > - } else if (var->type->contains_atomic()) {
<br>
> > + } else if (base_type->contains_atomic()) {
<br>
> > assert(ctx->Const.MaxAtomicBufferBindings <= MAX_COMBINED_ATOMIC_BUFFERS);
<br>
> > if (unsigned(qual->binding) >= ctx->Const.MaxAtomicBufferBindings) {
<br>
> > _mesa_glsl_error(loc, state, "layout(binding = %d) exceeds the "
<br>
> > @@ -2651,7 +2651,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
<br>
> > }
<br>
> >
<br>
> > if (qual->flags.q.explicit_binding &&
<br>
> > - validate_binding_qualifier(state, loc, var, qual)) {
<br>
> > + validate_binding_qualifier(state, loc, var->type, qual)) {
<br>
> > var->data.explicit_binding = true;
<br>
> > var->data.binding = qual->binding;
<br>
> > }
<br>
> > @@ -5658,6 +5658,8 @@ ast_interface_block::hir(exec_list *instructions,
<br>
> > num_variables,
<br>
> > packing,
<br>
> > this->block_name);
<br>
> > + if (this->layout.flags.q.explicit_binding)
<br>
> > + validate_binding_qualifier(state, &loc, block_type, &this->layout);
<br>
> >
<br>
> > if (!state->symbols->add_interface(block_type->name, block_type, var_mode)) {
<br>
> > YYLTYPE loc = this->get_location();
<br>
> > @@ -5744,6 +5746,10 @@ ast_interface_block::hir(exec_list *instructions,
<br>
> > const glsl_type *block_array_type =
<br>
> > process_array_type(&loc, block_type, this->array_specifier, state);
<br>
> >
<br>
> > + if(this->layout.flags.q.explicit_binding)
<br>
>
<br>
> Space after if</p>
<p dir="ltr">The space was intentional to separate validation code from from code that creates the IR. If you still think it should go I can remove it but I think it helps with code readability.</p>