KalebDark / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 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

GoogleCodeExporter commented 9 years ago
Project  : angle/angle
Branch   : master
Author   : Arun Patole <apatole@nvidia.com>
Committer: Olli Etuaho <oetuaho@nvidia.com>
Commit   : af930db15010cacfcdc74bee630372b8f6eb3eeb

Code-Review  0 : Arun Patole, Jamie Madill, Nicolas Capens
Code-Review  +2: Olli Etuaho
Verified     0 : Arun Patole, Jamie Madill, Nicolas Capens
Verified     +1: Olli Etuaho
Commit Queue   : Chumped
Change-Id      : I2ed4360532469fe0d70048d5f2300a8db6f9fcda
Reviewed-at    : https://chromium-review.googlesource.com/263679

Support constant folding of trigonometry built-ins

This change adds constant folding support for trigonometry built-in
functions. Constant folding for these functions also fixes constant
expression issues where constant initializer is a built-in trignometry
function whose arguments are all constant expressions.

BUG=angleproject:913
TEST= dEQP tests
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.angle_and_t
rigonometry*
(112 out of 120 tests pass with this change)

src/compiler/translator/IntermNode.cpp
src/compiler/translator/IntermNode.h

Original comment by bugdro...@chromium.org on 10 Apr 2015 at 10:56

GoogleCodeExporter commented 9 years ago
Project  : angle/angle
Branch   : master
Author   : Arun Patole <apatole@nvidia.com>
Committer: Olli Etuaho <oetuaho@nvidia.com>
Commit   : 1c89caef47a27c63a7d0f988e74816692a9b9b39

Code-Review  0 : Arun Patole, Jamie Madill
Code-Review  +2: Olli Etuaho
Verified     0 : Arun Patole, Jamie Madill
Verified     +1: Olli Etuaho
Commit Queue   : Chumped
Change-Id      : I22af56876d1b7ce305697bf9bf43ad9ec5d8a3a5
Reviewed-at    : https://chromium-review.googlesource.com/263708

Support constant folding of exponential built-ins

This change adds constant folding support for unary exponential
built-ins - exp, log, exp2, log2, sqrt and inversesqrt.

BUG=angleproject:913
TEST= dEQP tests
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.exponential
*
(48 out of 56 tests started passing with this change)

src/compiler/translator/IntermNode.cpp

Original comment by bugdro...@chromium.org on 10 Apr 2015 at 11:05

GoogleCodeExporter commented 9 years ago
Project  : angle/angle
Branch   : master
Author   : Arun Patole <apatole@nvidia.com>
Committer: Olli Etuaho <oetuaho@nvidia.com>
Commit   : 0273c68c507a10af3e45c6e4a52a44adcd0cf742

Code-Review  0 : Arun Patole, Jamie Madill
Code-Review  +2: Olli Etuaho
Verified     0 : Arun Patole, Jamie Madill
Verified     +1: Olli Etuaho
Commit Queue   : Chumped
Change-Id      : I09f2f99b3108e0d2fb1919a0631e4317b6a28be3
Reviewed-at    : https://chromium-review.googlesource.com/263709

Support constant folding of common built-ins

This change adds constant folding support for unary common built-ins:
abs, sign, floor, trunc, round, roundEven, ceil and fract.

BUG=angleproject:913
TEST= dEQP tests
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common*
(80 out of 210 tests started passing with this change)

src/compiler/translator/IntermNode.cpp

Original comment by bugdro...@chromium.org on 10 Apr 2015 at 11:17

GoogleCodeExporter commented 9 years ago
Project  : angle/angle
Branch   : master
Author   : Arun Patole <apatole@nvidia.com>
Committer: Olli Etuaho <oetuaho@nvidia.com>
Commit   : 1767e6b4f9148a6aa462d23e3838810c0080ce78

Code-Review  0 : Arun Patole
Code-Review  +1: Olli Etuaho
Code-Review  +2: Jamie Madill
Verified     0 : Arun Patole, Jamie Madill
Verified     +1: Olli Etuaho
Commit Queue   : Chumped
Change-Id      : I66275b2ae9faecef63d76763d21a9b67d9bb68fa
Reviewed-at    : https://chromium-review.googlesource.com/265392

Support constant folding of trigonometry built-ins

This change adds constant folding support for trigonometry built-in
functions. Constant folding for these functions also fixes constant
expression issues where constant initializer is a built-in trignometry
function whose arguments are all constant expressions.

BUG=angleproject:913
TEST= dEQP tests
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.angle_and_t
rigonometry*
(112 out of 120 tests pass with this change)

src/compiler/translator/IntermNode.cpp
src/compiler/translator/IntermNode.h

Original comment by bugdro...@chromium.org on 14 Apr 2015 at 9:10

GoogleCodeExporter commented 9 years ago
Project  : angle/angle
Branch   : master
Author   : Arun Patole <apatole@nvidia.com>
Committer: Olli Etuaho <oetuaho@nvidia.com>
Commit   : 2b1da6ed1dbe5960bed8c1b2fa3d33cb00c6c116

Code-Review  0 : Arun Patole
Code-Review  +1: Olli Etuaho
Code-Review  +2: Jamie Madill
Verified     0 : Arun Patole, Jamie Madill
Verified     +1: Olli Etuaho
Commit Queue   : Chumped
Change-Id      : I06800ed0e03764c0f7aab6bcd45c4f122de5a3c1
Reviewed-at    : https://chromium-review.googlesource.com/265394

Support constant folding of common built-ins

This change adds constant folding support for unary common built-ins:
abs, sign, floor, trunc, round, roundEven, ceil and fract.

BUG=angleproject:913
TEST= dEQP tests
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common*
(80 out of 210 tests started passing with this change)

src/compiler/translator/IntermNode.cpp

Original comment by bugdro...@chromium.org on 14 Apr 2015 at 9:11

GoogleCodeExporter commented 9 years ago
Project  : angle/angle
Branch   : master
Author   : Arun Patole <apatole@nvidia.com>
Committer: Olli Etuaho <oetuaho@nvidia.com>
Commit   : 62e2c8d2bc55c41db4e6095eac012b8861131585

Code-Review  0 : Arun Patole
Code-Review  +1: Olli Etuaho
Code-Review  +2: Jamie Madill
Verified     0 : Arun Patole, Jamie Madill
Verified     +1: Olli Etuaho
Commit Queue   : Chumped
Change-Id      : Ie7808cd57d6ed7598c642a9a0940b8f5bd293741
Reviewed-at    : https://chromium-review.googlesource.com/265393

Support constant folding of exponential built-ins

This change adds constant folding support for unary exponential
built-ins - exp, log, exp2, log2, sqrt and inversesqrt.

BUG=angleproject:913
TEST= dEQP tests
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.exponential
*
(48 out of 56 tests started passing with this change)

src/compiler/translator/IntermNode.cpp

Original comment by bugdro...@chromium.org on 14 Apr 2015 at 9:11

GoogleCodeExporter commented 9 years ago
Project  : angle/angle
Branch   : master
Author   : Arun Patole <apatole@nvidia.com>
Committer: Jamie Madill <jmadill@chromium.org>
Commit   : 9dea48f3e668b0e97e1ff30258c4cd55ae7ea606

Code-Review  0 : Arun Patole, Olli Etuaho
Code-Review  +2: Jamie Madill
Verified     0 : Arun Patole, Olli Etuaho
Verified     +1: Jamie Madill
Commit Queue   : Chumped
Change-Id      : I2b7a61320819dcd095827faa1fd16e835f4688b4
Reviewed-at    : https://chromium-review.googlesource.com/265819

Support constant folding of trigonometry built-ins

This change adds constant folding support for trigonometry built-in
functions. Constant folding for these functions also fixes constant
expression issues where constant initializer is a built-in trignometry
function whose arguments are all constant expressions.

BUG=angleproject:913
TEST= dEQP tests
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.angle_and_t
rigonometry*
(112 out of 120 tests pass with this change)

src/compiler/translator/IntermNode.cpp
src/compiler/translator/IntermNode.h

Original comment by bugdro...@chromium.org on 17 Apr 2015 at 3:13

GoogleCodeExporter commented 9 years ago
Project  : angle/angle
Branch   : master
Author   : Arun Patole <apatole@nvidia.com>
Committer: Jamie Madill <jmadill@chromium.org>
Commit   : 1623a1b90f24cd1afd8839c0726ad276a887fbda

Code-Review  0 : Olli Etuaho
Code-Review  +2: Jamie Madill
Verified     0 : Olli Etuaho
Verified     +1: Jamie Madill
Commit Queue   : Chumped
Change-Id      : I63133ee8c04c4a8d6cb30da5788e9227c05d4cbe
Reviewed-at    : https://chromium-review.googlesource.com/266071

Support constant folding of exponential built-ins

This change adds constant folding support for unary exponential
built-ins - exp, log, exp2, log2, sqrt and inversesqrt.

BUG=angleproject:913
TEST= dEQP tests
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.exponential
*
(48 out of 56 tests started passing with this change)

src/compiler/translator/IntermNode.cpp

Original comment by bugdro...@chromium.org on 17 Apr 2015 at 4:40

GoogleCodeExporter commented 9 years ago
Project  : angle/angle
Branch   : master
Author   : Arun Patole <apatole@nvidia.com>
Committer: Jamie Madill <jmadill@chromium.org>
Commit   : 97dc22e03ce006fb9e51dc958f473c143a9d5e80

Code-Review  0 : Arun Patole, Olli Etuaho
Code-Review  +2: Jamie Madill
Verified     0 : Arun Patole, Olli Etuaho
Verified     +1: Jamie Madill
Commit Queue   : Chumped
Change-Id      : I46312fec43084601d4fca8195ddaaa5292f1c02a
Reviewed-at    : https://chromium-review.googlesource.com/265967

Support constant folding of common built-ins

This change adds constant folding support for unary common built-ins:
abs, sign, floor, trunc, round, roundEven, ceil and fract.

BUG=angleproject:913
TEST= dEQP tests
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common*
(80 out of 210 tests started passing with this change)

src/compiler/translator/IntermNode.cpp

Original comment by bugdro...@chromium.org on 20 Apr 2015 at 1:59

GoogleCodeExporter commented 9 years ago
Project  : angle/angle
Branch   : master
Author   : Arun Patole <apatole@nvidia.com>
Committer: Olli Etuaho <oetuaho@nvidia.com>
Commit   : 28eb65e3d9fa4f4d6dd618cee0283c646bcd083c

Code-Review  0 : Arun Patole
Code-Review  +1: Olli Etuaho
Code-Review  +2: Jamie Madill
Verified     0 : Arun Patole, Jamie Madill
Verified     +1: Olli Etuaho
Commit Queue   : Chumped
Change-Id      : I4b98782c4c4b72dd7d60dfc4f18ba6961526ec41
Reviewed-at    : https://chromium-review.googlesource.com/266797

Support constant folding of exponential built-ins

This change adds constant folding support for unary exponential
built-ins - exp, log, exp2, log2, sqrt and inversesqrt.

BUG=angleproject:913
TEST= dEQP tests
dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.exponential
*
(48 out of 56 tests started passing with this change)

src/compiler/translator/IntermNode.cpp

Original comment by bugdro...@chromium.org on 22 Apr 2015 at 2:08

GoogleCodeExporter commented 9 years ago
Project  : angle/angle
Branch   : master
Author   : Olli Etuaho <oetuaho@nvidia.com>
Committer: Zhenyao Mo <zmo@chromium.org>
Commit   : 2cb7b83595c2a88462b7f9481f920e2960556492

Code-Review  0 : Olli Etuaho
Code-Review  +1: Jamie Madill
Code-Review  +2: Zhenyao Mo
Verified     0 : Jamie Madill, Zhenyao Mo
Verified     +1: Olli Etuaho
Commit Queue   : Chumped
Change-Id      : Ice8fe3682d8e97f42747752302a1fba116132df4
Reviewed-at    : https://chromium-review.googlesource.com/266843

Clean up binary operation constant folding code

Fix mixed up comments, remove unnecessary type conversions, clarify
variable names and improve formatting in a few places.

TEST=angle_unittests, WebGL conformance tests
BUG=angleproject:913

src/compiler/translator/IntermNode.cpp
src/compiler/translator/IntermNode.h
src/compiler/translator/Intermediate.cpp

Original comment by bugdro...@chromium.org on 24 Apr 2015 at 5:36