[Mesa-dev] [PATCH 13/17] glsl: Add default precision qualifiers to the symbol table

Ian Romanick idr at freedesktop.org
Wed Jul 29 14:50:54 PDT 2015


On 07/29/2015 07:01 AM, Samuel Iglesias Gonsalvez wrote:
> From: Iago Toral Quiroga <itoral at igalia.com>
> 
> The GLSL ES spec specifies default precision qualifiers for certain types,
> so populate the symbol table with these.
> 
> Notice that the desktop GLSL spec also indicates defaults for some types
> but this is not really useful since precision qualifiers are completely
> ignored in desktop GLSL.
> ---
>  src/glsl/glsl_parser.yy | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
> index e66b80a..f55fd23 100644
> --- a/src/glsl/glsl_parser.yy
> +++ b/src/glsl/glsl_parser.yy
> @@ -310,6 +310,20 @@ translation_unit:
>     {
>        delete state->symbols;
>        state->symbols = new(ralloc_parent(state)) glsl_symbol_table;
> +      if (state->es_shader) {
> +         if (state->stage == MESA_SHADER_FRAGMENT) {
> +            state->symbols->add_default_precision_qualifier("int", ast_precision_medium);
> +            state->symbols->add_default_precision_qualifier("sampler2D", ast_precision_low);
> +            state->symbols->add_default_precision_qualifier("samplerCube", ast_precision_low);
> +            state->symbols->add_default_precision_qualifier("samplerExternalOES", ast_precision_low);
> +         } else {
> +            state->symbols->add_default_precision_qualifier("float", ast_precision_high);
> +            state->symbols->add_default_precision_qualifier("int", ast_precision_high);
> +            state->symbols->add_default_precision_qualifier("sampler2D", ast_precision_low);
> +            state->symbols->add_default_precision_qualifier("samplerCube", ast_precision_low);
> +            state->symbols->add_default_precision_qualifier("samplerExternalOES", ast_precision_low);
> +         }

What about sampler types added in ES 3.0 or by extensions (e.g., sampler3D)?

> +      }
>        _mesa_glsl_initialize_types(state);
>     }
>     ;
> 



More information about the mesa-dev mailing list