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

Eric Anholt eric at anholt.net
Wed Mar 20 17:19:36 PDT 2013


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130320/86616a19/attachment.pgp>


More information about the mesa-dev mailing list