[Mesa-dev] [PATCH v2 03/15] glsl: parse in/out types for interface blocks

Jordan Justen jljusten at gmail.com
Sun Mar 24 18:02:05 PDT 2013


On Wed, Mar 20, 2013 at 5:19 PM, Eric Anholt <eric at anholt.net> wrote:
> Jordan Justen <jordan.l.justen at intel.com> writes:
>
>> Previously only 'uniform' was allowed for uniform blocks.
>>
>> Now, in/out can be parsed, but it will only be allowed for
>> GLSL >= 150.
>
>
>>  basic_interface_block:
>> -     UNIFORM NEW_IDENTIFIER '{' member_list '}' instance_name_opt ';'
>> +     interface_qualifier NEW_IDENTIFIER '{' member_list '}' instance_name_opt ';'
>>       {
>>          ast_interface_block *const block = $6;
>>
>>          block->block_name = $2;
>>          block->declarations.push_degenerate_list_at_head(& $4->link);
>>
>> -        if (!state->ARB_uniform_buffer_object_enable) {
>> -           _mesa_glsl_error(& @1, state,
>> -                            "#version 140 / GL_ARB_uniform_buffer_object "
>> -                            "required for defining uniform blocks\n");
>> -        } else if (state->ARB_uniform_buffer_object_warn) {
>> -           _mesa_glsl_warning(& @1, state,
>> -                              "#version 140 / GL_ARB_uniform_buffer_object "
>> -                              "required for defining uniform blocks\n");
>> +        if ($1.flags.q.uniform) {
>> +           if (!state->ARB_uniform_buffer_object_enable) {
>> +              _mesa_glsl_error(& @1, state,
>> +                               "#version 140 / GL_ARB_uniform_buffer_object "
>> +                               "required for defining uniform blocks\n");
>> +           } else if (state->ARB_uniform_buffer_object_warn) {
>> +              _mesa_glsl_warning(& @1, state,
>> +                                 "#version 140 / GL_ARB_uniform_buffer_object "
>> +                                 "required for defining uniform blocks\n");
>> +           }
>> +        } else {
>> +           if (state->es_shader || state->language_version < 150) {
>> +              _mesa_glsl_error(& @1, state,
>> +                              "#version 150 required for using "
>> +                              "interface blocks.\n");
>> +           }
>>          }
>>
>>          /* Since block arrays require names, and both features are added in
>> @@ -1937,10 +1946,39 @@ basic_interface_block:
>>                              "blocks with an instance name\n");
>>          }
>>
>> +        unsigned interface_type_mask, interface_type_flags;
>> +        struct ast_type_qualifier temp_type_qualifier;
>> +
>> +        temp_type_qualifier.flags.i = 0;
>> +        temp_type_qualifier.flags.q.uniform = true;
>> +        temp_type_qualifier.flags.q.in = true;
>> +        temp_type_qualifier.flags.q.out = true;
>> +        interface_type_mask = temp_type_qualifier.flags.i;
>> +        interface_type_flags = $1.flags.i & interface_type_mask;
>> +        block->layout.flags.i |= interface_type_flags;
>
> Given that an interface_qualifier ($1) only has either uniform, in, or
> out set, I don't see why this masking is needed.

You're right. I don't need the mask here. I'll change this to use $1.

But, I need the mask in
[07/15] glsl parser: handle interface block member qualifier
to verify/copy the interface type to the members. I'll move the mask there.

-Jordan


More information about the mesa-dev mailing list