KroMignon / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 1 forks source link

Built-in function call whose arguments are all constant expressions is not treated as constant expression #913

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Built-in function call whose arguments are all constant expressions is not 
treated as constant expression.

What steps will reproduce the problem?

Following shader statements fails to compile in ANGLE:
const float val = abs(float (-42.0));
or
const float val2 = max(float(42.0), float(13.0));

with error:
ERROR: 0:3: '=' :  assigning non-constant to 'const highp float'
What is the expected output? What do you see instead?
Shader should compile successfully.

What version of the product are you using? On what operating system?
Tested it with ANGLE sample application on latest ANGLE code, using dEQP tests 
and also using chrome as mentioned below

As per spec:
"Initializers for const declarations must be constant expressions" and
"a built-in function call whose arguments are all constant expressions is a 
constant expression(with the exception of the texture lookup functions)".

It is also one of the reasons why below mentioned dEQP tests are failing:
- Tests in : 
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.*
- Some tests in : dEQP-GLES3.functional.shaders.operator.common_functions.*

Other simple way to reproduce the issue:
Open WebGL Shader 
Translator(https://www.khronos.org/registry/webgl/conformance-suites/1.0.3/extra
/webgl-translate-shader.html) in chrome and try to compile below shader:
void main()
{
const float val = abs(float (-42.0));
const float val2 = max(float(42.0), float(13.0));
const float val3 = min(float(42.0), float(13.0));
}

Original issue reported on code.google.com by apat...@nvidia.com on 12 Feb 2015 at 11:30

GoogleCodeExporter commented 9 years ago
I am trying to debug this and looks like TParseContext::executeInitializer and 
grammar will need some modifications to fix it.

Original comment by apat...@nvidia.com on 12 Feb 2015 at 11:34