[Mesa-dev] Mesa (master): glsl: Add semantic checks for precision qualifiers

Ian Romanick idr at freedesktop.org
Mon Jan 17 12:36:16 PST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/17/2011 10:21 AM, Chad Versace wrote:
> Module: Mesa
> Branch: master
> Commit: 889e1a5b6c6602198d649ea5881e0010dec575e9
> URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=889e1a5b6c6602198d649ea5881e0010dec575e9
> 
> Author: Chad Versace <chad.versace at intel.com>
> Date:   Sun Jan 16 22:38:45 2011 -0800
> 
> glsl: Add semantic checks for precision qualifiers
> 
> * Check that precision qualifiers only appear in language versions 1.00,
>   1.30, and later.
> * Check that precision qualifiers do not apply to bools and structs.
> 
> Fixes the following Piglit tests:
> * spec/glsl-1.30/precision-qualifiers/precision-bool-01.frag
> * spec/glsl-1.30/precision-qualifiers/precision-struct-01.frag
> * spec/glsl-1.30/precision-qualifiers/precision-struct-02.frag
> 
> ---
> 
>  src/glsl/ast_to_hir.cpp |   33 +++++++++++++++++++++++++++++++++
>  1 files changed, 33 insertions(+), 0 deletions(-)
> 
> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
> index 51bc8ec..764c549 100644
> --- a/src/glsl/ast_to_hir.cpp
> +++ b/src/glsl/ast_to_hir.cpp
> @@ -2351,6 +2351,39 @@ ast_declarator_list::hir(exec_list *instructions,
>        }
>  
>  
> +      /* Precision qualifiers exists only in GLSL versions 1.00 and >= 1.30.
> +       */
> +      if (this->type->specifier->precision != ast_precision_none
> +          && state->language_version != 100
> +          && state->language_version < 130) {
> +
> +         _mesa_glsl_error(&loc, state,
> +                          "precision qualifiers are supported only in GLSL ES "
> +                          "1.00, and GLSL 1.30 and later");
> +      }
> +
> +
> +      /* Precision qualifiers do not apply to bools and structs.
> +       *
> +       * From section 4.5.2 of the GLSL 1.30 spec:
> +       *    "Any floating point or any integer declaration can have the type
> +       *    preceded by one of these precision qualifiers [...] Literal
> +       *    constants do not have precision qualifiers. Neither do Boolean
> +       *    variables.
> +       */
> +      if (this->type->specifier->precision != ast_precision_none
> +          && this->type->specifier->type_specifier == ast_bool) {

Does this catch these cases:

highp bvec2 a;
highp bvec3 b;
highp bvec4 c;

> +
> +         _mesa_glsl_error(&loc, state,
> +                          "preicion qualifiers do not apply to type bool");
                              ^^^^^^^^ precision :)

> +      }
> +      if (this->type->specifier->precision != ast_precision_none
> +          && this->type->specifier->structure != NULL) {
> +
> +         _mesa_glsl_error(&loc, state,
> +                          "precision qualifiers do not apply to structures");
> +      }
> +
>        /* Process the initializer and add its instructions to a temporary
>         * list.  This list will be added to the instruction stream (below) after
>         * the declaration is added.  This is done because in some cases (such as
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk00qEAACgkQX1gOwKyEAw9t9wCeIHpvp58PEf03NicOmD/oYFyg
t6cAniVDI5pOD0gMgyCsfWZnpHVP4+qx
=mgbP
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list