[Mesa-dev] [PATCH 05/14] glsl: Add support for parsing [iu]samplerBuffer in GLSL 1.40.

Kenneth Graunke kenneth at whitecape.org
Wed Mar 28 20:07:51 PDT 2012


On 03/28/2012 10:58 AM, Eric Anholt wrote:
> The type will be undefined in !glsl 1.40, and the keyword is marked as
> reserved.
> ---
>   src/glsl/ast.h          |    3 +++
>   src/glsl/ast_type.cpp   |    3 +++
>   src/glsl/glsl_parser.yy |    6 +++++-
>   src/glsl/glsl_types.cpp |    5 ++++-
>   4 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/src/glsl/ast.h b/src/glsl/ast.h
> index 1f78af8..ab4c210 100644
> --- a/src/glsl/ast.h
> +++ b/src/glsl/ast.h
> @@ -459,18 +459,21 @@ enum ast_types {
>      ast_sampler2darray,
>      ast_sampler1darrayshadow,
>      ast_sampler2darrayshadow,
> +   ast_samplerbuffer,
>      ast_isampler1d,
>      ast_isampler2d,
>      ast_isampler3d,
>      ast_isamplercube,
>      ast_isampler1darray,
>      ast_isampler2darray,
> +   ast_isamplerbuffer,
>      ast_usampler1d,
>      ast_usampler2d,
>      ast_usampler3d,
>      ast_usamplercube,
>      ast_usampler1darray,
>      ast_usampler2darray,
> +   ast_usamplerbuffer,
>
>      ast_struct,
>      ast_type_name
> diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
> index 79c43ee..f914f71 100644
> --- a/src/glsl/ast_type.cpp
> +++ b/src/glsl/ast_type.cpp
> @@ -92,18 +92,21 @@ ast_type_specifier::ast_type_specifier(int specifier)
>         "sampler2DArray",
>         "sampler1DArrayShadow",
>         "sampler2DArrayShadow",
> +      "samplerBuffer",
>         "isampler1D",
>         "isampler2D",
>         "isampler3D",
>         "isamplerCube",
>         "isampler1DArray",
>         "isampler2DArray",
> +      "isamplerBuffer",
>         "usampler1D",
>         "usampler2D",
>         "usampler3D",
>         "usamplerCube",
>         "usampler1DArray",
>         "usampler2DArray",
> +      "usamplerBuffer",
>
>         NULL, /* ast_struct */
>         NULL  /* ast_type_name */
> diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
> index 64506b6..c6b6238 100644
> --- a/src/glsl/glsl_parser.yy
> +++ b/src/glsl/glsl_parser.yy
> @@ -103,6 +103,7 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
>   %token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE
>   %token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D
>   %token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY
> +%token SAMPLERBUFFER ISAMPLERBUFFER USAMPLERBUFFER

You need to add these to the lexer.  It already has a rule for 
samplerBuffer, but is missing isamplerBuffer or usamplerBuffer.

With that fixed,
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

>   %token SAMPLEREXTERNALOES
>   %token STRUCT VOID_TOK WHILE
>   %token<identifier>  IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER
> @@ -135,7 +136,7 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
>
>   %token ERROR_TOK
>
> -%token COMMON PARTITION ACTIVE SAMPLERBUFFER FILTER
> +%token COMMON PARTITION ACTIVE FILTER
>   %token  IMAGE1D  IMAGE2D  IMAGE3D  IMAGECUBE  IMAGE1DARRAY  IMAGE2DARRAY
>   %token IIMAGE1D IIMAGE2D IIMAGE3D IIMAGECUBE IIMAGE1DARRAY IIMAGE2DARRAY
>   %token UIMAGE1D UIMAGE2D UIMAGE3D UIMAGECUBE UIMAGE1DARRAY UIMAGE2DARRAY
> @@ -1405,18 +1406,21 @@ basic_type_specifier_nonarray:
>   	| SAMPLER2DARRAY	{ $$ = ast_sampler2darray; }
>   	| SAMPLER1DARRAYSHADOW	{ $$ = ast_sampler1darrayshadow; }
>   	| SAMPLER2DARRAYSHADOW	{ $$ = ast_sampler2darrayshadow; }
> +	| SAMPLERBUFFER		{ $$ = ast_samplerbuffer; }
>   	| ISAMPLER1D		{ $$ = ast_isampler1d; }
>   	| ISAMPLER2D		{ $$ = ast_isampler2d; }
>   	| ISAMPLER3D		{ $$ = ast_isampler3d; }
>   	| ISAMPLERCUBE		{ $$ = ast_isamplercube; }
>   	| ISAMPLER1DARRAY	{ $$ = ast_isampler1darray; }
>   	| ISAMPLER2DARRAY	{ $$ = ast_isampler2darray; }
> +	| ISAMPLERBUFFER	{ $$ = ast_isamplerbuffer; }
>   	| USAMPLER1D		{ $$ = ast_usampler1d; }
>   	| USAMPLER2D		{ $$ = ast_usampler2d; }
>   	| USAMPLER3D		{ $$ = ast_usampler3d; }
>   	| USAMPLERCUBE		{ $$ = ast_usamplercube; }
>   	| USAMPLER1DARRAY	{ $$ = ast_usampler1darray; }
>   	| USAMPLER2DARRAY	{ $$ = ast_usampler2darray; }
> +	| USAMPLERBUFFER	{ $$ = ast_usamplerbuffer; }
>   	;
>
>   precision_qualifier:
> diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
> index 069ebd1..8a34b8e 100644
> --- a/src/glsl/glsl_types.cpp
> +++ b/src/glsl/glsl_types.cpp
> @@ -146,7 +146,6 @@ glsl_type::sampler_index() const
>      case GLSL_SAMPLER_DIM_RECT:
>         return TEXTURE_RECT_INDEX;
>      case GLSL_SAMPLER_DIM_BUF:
> -      assert(!"FINISHME: Implement ARB_texture_buffer_object");
>         return TEXTURE_BUFFER_INDEX;
>      case GLSL_SAMPLER_DIM_EXTERNAL:
>         return TEXTURE_EXTERNAL_INDEX;
> @@ -213,6 +212,10 @@ glsl_type::generate_140_types(glsl_symbol_table *symtab)
>
>      add_types_to_symbol_table(symtab, builtin_140_types,
>   			     Elements(builtin_140_types), false);
> +
> +   add_types_to_symbol_table(symtab, builtin_EXT_texture_buffer_object_types,
> +			     Elements(builtin_EXT_texture_buffer_object_types),
> +			     false);
>   }


More information about the mesa-dev mailing list