[Mesa-dev] [PATCH v3] compiler/glsl: invalidate float suffixes for glsl 1.10

Kenneth Graunke kenneth at whitecape.org
Wed Mar 30 04:31:27 UTC 2016


On Monday, March 28, 2016 8:42:14 PM PDT Lars Hamre wrote:
> NOTE: someone with access will need to commit this patch after the
>       review process
> 
> v2: modify error message
> v3: parse the float instead of returning an ERROR_TOK
> 
> Invalidates float suffixes for glsl 1.10
> 
> Fixes the following piglit tests:
> tests/spec/glsl-1.10/compiler/literals/invalid-float-suffix-capital-f.vert
> tests/spec/glsl-1.10/compiler/literals/invalid-float-suffix-f.vert`
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81585
> 
> Signed-off-by: Lars Hamre <chemecse at gmail.com>
> Reviewed-by: Timothy Arceri <timothy.arceri at collabora.com>
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
> 
> ---
>  src/compiler/glsl/glsl_lexer.ll | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/
glsl_lexer.ll
> index 1f12265..6084d71 100644
> --- a/src/compiler/glsl/glsl_lexer.ll
> +++ b/src/compiler/glsl/glsl_lexer.ll
> @@ -472,6 +472,13 @@ layout		{
>  \.[0-9]+([eE][+-]?[0-9]+)?[fF]?		|
>  [0-9]+\.([eE][+-]?[0-9]+)?[fF]?		|
>  [0-9]+[eE][+-]?[0-9]+[fF]?		{
> +			    struct _mesa_glsl_parse_state *state = yyextra;
> +			    char suffix = yytext[strlen(yytext) - 1];
> +			    if (!state->is_version(120, 0) &&
> +			        (suffix == 'f' || suffix == 'F')) {
> +			        _mesa_glsl_error(yylloc, state,
> +			                         "Float suffixes are invalid in GLSL 
1.10");
> +			    }
>  			    yylval->real = _mesa_strtof(yytext, NULL);
>  			    return FLOATCONSTANT;
>  			}
> --
> 2.5.5

Hi Lars,

I ran this through our test suite and found that it broke most GLSL ES
3.00 tests.  It turns out this isn't allowed in GLSL ES 1.00, but is
allowed in GLSL ES 3.00.

I changed it to is_version(120, 300), and everything worked.  I went
ahead and made that change to save you the trouble of resending a v4,
and pushed the patch.

Thanks for fixing this longstanding bug :)

--Ken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160329/cd3fbcd5/attachment.sig>


More information about the mesa-dev mailing list