Bug 25771

Summary: Implicit converting "int" to "float" should be allowed in GLSL
Product: piglit Reporter: Gordon Jin <gordon.jin>
Component: testsAssignee: Eric Anholt <eric>
Status: VERIFIED NOTABUG QA Contact: Eric Anholt <eric>
Severity: normal    
Priority: medium CC: idr
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Gordon Jin 2009-12-22 23:42:53 UTC
piglit/tests/glslparsertest/shaders/dataType5.frag expects it to fail:
void main()
{
    float f = 1; // int cannot be converted to float, use constructor to do the conversion explicitly
}

But section 4.1.10 "Implicit Conversions" of GLSL spec (v1.20 or 1.50) says this is allowed.
Comment 1 Ian Romanick 2009-12-23 11:59:45 UTC
This conversion is allowed, but only if the shader specifies '#version 120" or later.  If no #version is specified, the default version 110 is used.  In GLSL version 1.10 these automatic conversions are not allowed.

These GLSL tests were written by the authors of original the GLSL spec.  We should assume that any test failures are problems in our drivers, not in the tests.
Comment 2 Gordon Jin 2009-12-23 17:23:28 UTC
Thanks for the explanation. I was checking spec v1.20 and the latest v1.50, but didn't look into v1.10.

>> If no #version is specified, the default version 110 is used.
This default version is defined by mesa, right? Isn't mesa already supporting OpenGL 2.1 hence GLSL 1.2?
Comment 3 Ian Romanick 2009-12-25 00:39:33 UTC
The default is defined by the GLSL spec.  If no #version statement exists in the shader source, it is treated as if shader contained '#version 110'.  For example, see this language from page 10 of the GLSL 1.50 spec:

"Version 1.10 of the language does not require shaders to include this directive, and shaders that do not include a #version directive will be treated as targeting version 1.10."
Comment 4 Gordon Jin 2010-01-05 00:52:32 UTC
Agree this is not test case bug, but a driver bug.
I'm filing mesa bug#25877 to follow it up.

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.