[Mesa-dev] [PATCH v2 13/31] glsl: allow image qualifiers inside structures

Samuel Pitoiset samuel.pitoiset at gmail.com
Wed Apr 26 19:22:27 UTC 2017



On 04/26/2017 09:30 AM, Nicolai Hähnle wrote:
> On 24.04.2017 12:35, Samuel Pitoiset wrote:
>> The GL_ARB_bindless_texture allows to declare images inside
>> structures which means that qualifiers like writeonly should
>> be allowed.
>>
>> I have a got a confirmation from Jeff Bolz (one author of the spec),
>> because the spec doesn't clearly explain this.
> 
> Is there a check somewhere that forbids those qualifiers to be applied 
> to other struct members? Seems like this merits some more compiler tests.

You were right.

I have sent a piglit test and here's the patch which fixes the issue:

https://lists.freedesktop.org/archives/mesa-dev/2017-April/153219.html

It disallows using image qualifiers with non-image types for both plain 
GLSL and ARB_bindless_texture.

> 
> Cheers,
> Nicolai
> 
>>
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>> Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
>> ---
>>  src/compiler/glsl/glsl_parser.yy | 28 ++++++++++++++++++++++++----
>>  1 file changed, 24 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/compiler/glsl/glsl_parser.yy 
>> b/src/compiler/glsl/glsl_parser.yy
>> index 9cdc37eb9a..05171e53a3 100644
>> --- a/src/compiler/glsl/glsl_parser.yy
>> +++ b/src/compiler/glsl/glsl_parser.yy
>> @@ -2409,10 +2409,30 @@ struct_declaration:
>>        ast_fully_specified_type *const type = $1;
>>        type->set_location(@1);
>>
>> -      if (type->qualifier.flags.i != 0)
>> -         _mesa_glsl_error(&@1, state,
>> -              "only precision qualifiers may be applied to "
>> -              "structure members");
>> +      if (state->has_bindless()) {
>> +         ast_type_qualifier input_layout_mask;
>> +
>> +         /* Allow to declare qualifiers for images as specified by
>> +          * GL_ARB_bindless_texture. */
>> +         input_layout_mask.flags.i = 0;
>> +         input_layout_mask.flags.q.coherent = 1;
>> +         input_layout_mask.flags.q._volatile = 1;
>> +         input_layout_mask.flags.q.restrict_flag = 1;
>> +         input_layout_mask.flags.q.read_only = 1;
>> +         input_layout_mask.flags.q.write_only = 1;
>> +         input_layout_mask.flags.q.explicit_image_format = 1;
>> +
>> +         if ((type->qualifier.flags.i & ~input_layout_mask.flags.i) 
>> != 0) {
>> +            _mesa_glsl_error(&@1, state,
>> +                             "only precision and image qualifiers may 
>> be "
>> +                             "applied to structure members");
>> +         }
>> +      } else {
>> +         if (type->qualifier.flags.i != 0)
>> +            _mesa_glsl_error(&@1, state,
>> +                             "only precision qualifiers may be 
>> applied to "
>> +                             "structure members");
>> +      }
>>
>>        $$ = new(ctx) ast_declarator_list(type);
>>        $$->set_location(@2);
>>
> 
> 


More information about the mesa-dev mailing list