Bug 81585 - piglit spec_glsl-1.10_compiler_literals_invalid-float-suffix-capital-f.vert fails
Summary: piglit spec_glsl-1.10_compiler_literals_invalid-float-suffix-capital-f.vert f...
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: medium normal
Assignee: Lars Hamre
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-21 06:06 UTC by lu hua
Modified: 2016-03-30 04:32 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description lu hua 2014-07-21 06:06:30 UTC
System Environment:
--------------------------
Platform: SNB
Libdrm:		(master)libdrm-2.4.54-19-gc0b34dca2632a774249cfa3b969c3f7ce9df33e1
Mesa:		(10.2)e7310313725142cf536179d4d918db2c20438765
Xserver:	(server-1.15-branch)xorg-server-1.15.2
Xf86_video_intel:(master)2.99.912-233-gf33d44f41ef0f287375b7a6b1c117abff5a23b19
Libva:		(master)c61d8c6ce9ffc27320e9e177c1e1123d5f1b5014
Libva_intel_driver:(master)c5cb17ea86f0065a939d3636dd26651c93d497c8
kernel: drm-intel-fixes/c6930992948adf0f8fc1f6ff1da51c5002a2cf95

Bug detailed description:
---------------------------
New case spec_glsl-1.10_compiler_literals_invalid-float-suffix-capital-f.vert fails on all platforms with mesa 10.2 and master branch.

output:
Successfully compiled vertex shader tests/spec/glsl-1.10/compiler/literals/invalid-float-suffix-capital-f.vert:
Shader source:
// [config]
// expect_result: fail
// glsl_version: 1.10
// [end config]

void main() {
        // Float-suffixes are not in GLSL 1.10
        float f = 1.0F;
        gl_Position = vec4(1.0);
}

PIGLIT: {"result": "fail" }

Reproduce steps:
---------------------------- 
1. xinit
2. bin/glslparsertest tests/spec/glsl-1.10/compiler/literals/invalid-float-suffix-capital-f.vert fail 1.10
Comment 1 Ian Romanick 2014-12-17 19:37:27 UTC
The "f" suffix on floats was added in 1.20.

Before accepting a change in behavior, I'd like to know what other implementations do.  If this test also fails on NVIDIA and AMD, I'd rather remove the test.  That would imply there's a good chance that applications may rely on the behavior.

It's also not clear whether this was intended to be new feature of GLSL 1.20 or just a correction.  It is called out in the changes section along with other new features, so I guess it's a new feature?

    "Changes from revision 60 of version 1.10

    • Accept "f" as part of a floating-point constant. E.g. "float g = 3.5f"."
Comment 2 Neil Roberts 2014-12-18 13:30:24 UTC
Using the f suffix on NVidia's proprietary driver version 340.46 with #version 110 gives the following error:

error C7502: OpenGL does not allow type suffix 'f' on constant literals in versions below 120

However, if I leave out the #version line entirely then the error becomes a warning and it successfully compiles. The Piglit test doesn't specify the #version line so I guess it would fail on NVidia's driver too.
Comment 3 Matt Turner 2014-12-18 15:50:03 UTC
(In reply to Neil Roberts from comment #2)
> Using the f suffix on NVidia's proprietary driver version 340.46 with
> #version 110 gives the following error:
> 
> error C7502: OpenGL does not allow type suffix 'f' on constant literals in
> versions below 120
> 
> However, if I leave out the #version line entirely then the error becomes a
> warning and it successfully compiles. The Piglit test doesn't specify the
> #version line so I guess it would fail on NVidia's driver too.

The GLSL spec says "shaders that do not include a #version directive will be
treated as targeting version 110". I think NVidia operates in some relaxed mode when #version is missing.
Comment 4 Ian Romanick 2014-12-19 15:51:45 UTC
(In reply to Matt Turner from comment #3)
> (In reply to Neil Roberts from comment #2)
> > Using the f suffix on NVidia's proprietary driver version 340.46 with
> > #version 110 gives the following error:
> > 
> > error C7502: OpenGL does not allow type suffix 'f' on constant literals in
> > versions below 120
> > 
> > However, if I leave out the #version line entirely then the error becomes a
> > warning and it successfully compiles. The Piglit test doesn't specify the
> > #version line so I guess it would fail on NVidia's driver too.
> 
> The GLSL spec says "shaders that do not include a #version directive will be
> treated as targeting version 110". I think NVidia operates in some relaxed
> mode when #version is missing.

That's correct.  Without a #version, NVIDIA treats the shader as if it specified the highest supported version, but offers some warnings for post-1.10 functionality.

Based on this information, I think it's probably okay to strictly follow the spec by rejecting the F suffix in 1.10 shaders.
Comment 5 Kenneth Graunke 2016-03-30 04:32:05 UTC
Fixed by:

commit 6773128bbf8703663ed1a4d6c1c3308b3c002a35
Author: Lars Hamre <chemecse@gmail.com>
Date:   Mon Mar 28 20:42:14 2016 -0400

    glsl: invalidate float suffixes for GLSL 1.10 and GLSL ES 1.00
    
    Float suffixes are not allowed in GLSL 1.10 nor GLSL ES 1.00.
    
    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`
    
    v2: modify error message
    v3: parse the float instead of returning an ERROR_TOK
    v4: (by Ken) Change to is_version(120, 300) to avoid breaking ES3
        shaders; update commit message accordingly.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81585
    Signed-off-by: Lars Hamre <chemecse@gmail.com>
    Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
    Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.