Allow different multiplication order in reflect()
authorPyry Haulos <phaulos@google.com>
Fri, 29 May 2015 21:09:59 +0000 (14:09 -0700)
committerPyry Haulos <phaulos@google.com>
Fri, 29 May 2015 21:49:18 +0000 (14:49 -0700)
GLSL spec allows compiler to assume that multiplication is commutative.
reflect() contains three multiplications which compiler can re-order
based on the spec language. This change relaxes reflect() tests to
allow both evaluation orders.

Bug: 19408572
Change-Id: I78e5b6e6f7bc761b4c49f5e1d4a283fcc60bf512

android/cts/master/com.drawelements.deqp.gles3.xml
android/cts/master/gles3-master.txt
android/cts/master/src/gles3-test-issues.txt
modules/glshared/glsBuiltinPrecisionTests.cpp

index d5f16a3..adaa5c6 100644 (file)
                                                                </Test>
                                                        </TestCase>
                                                </TestSuite>
+                                               <TestSuite name="reflect">
+                                                       <TestCase name="lowp_vertex">
+                                                               <Test name="scalar">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec2">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec3">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec4">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                       </TestCase>
+                                                       <TestCase name="lowp_fragment">
+                                                               <Test name="scalar">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec2">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec3">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec4">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                       </TestCase>
+                                                       <TestCase name="mediump_vertex">
+                                                               <Test name="scalar">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec2">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec3">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec4">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                       </TestCase>
+                                                       <TestCase name="mediump_fragment">
+                                                               <Test name="scalar">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec2">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec3">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec4">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                       </TestCase>
+                                                       <TestCase name="highp_vertex">
+                                                               <Test name="scalar">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec2">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec3">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec4">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                       </TestCase>
+                                                       <TestCase name="highp_fragment">
+                                                               <Test name="scalar">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec2">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec3">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                               <Test name="vec4">
+                                                                       <TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+                                                               </Test>
+                                                       </TestCase>
+                                               </TestSuite>
                                                <TestSuite name="refract">
                                                        <TestCase name="lowp_vertex">
                                                                <Test name="scalar">
index 9ab6ea5..910726a 100644 (file)
@@ -18039,6 +18039,30 @@ dEQP-GLES3.functional.shaders.builtin_functions.precision.faceforward.highp_frag
 dEQP-GLES3.functional.shaders.builtin_functions.precision.faceforward.highp_fragment.vec2
 dEQP-GLES3.functional.shaders.builtin_functions.precision.faceforward.highp_fragment.vec3
 dEQP-GLES3.functional.shaders.builtin_functions.precision.faceforward.highp_fragment.vec4
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.lowp_vertex.scalar
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.lowp_vertex.vec2
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.lowp_vertex.vec3
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.lowp_vertex.vec4
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.lowp_fragment.scalar
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.lowp_fragment.vec2
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.lowp_fragment.vec3
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.lowp_fragment.vec4
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.mediump_vertex.scalar
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.mediump_vertex.vec2
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.mediump_vertex.vec3
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.mediump_vertex.vec4
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.mediump_fragment.scalar
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.mediump_fragment.vec2
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.mediump_fragment.vec3
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.mediump_fragment.vec4
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.highp_vertex.scalar
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.highp_vertex.vec2
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.highp_vertex.vec3
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.highp_vertex.vec4
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.highp_fragment.scalar
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.highp_fragment.vec2
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.highp_fragment.vec3
+dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.highp_fragment.vec4
 dEQP-GLES3.functional.shaders.builtin_functions.precision.refract.lowp_vertex.scalar
 dEQP-GLES3.functional.shaders.builtin_functions.precision.refract.lowp_vertex.vec2
 dEQP-GLES3.functional.shaders.builtin_functions.precision.refract.lowp_vertex.vec3
index d11aebb..1a6d2f5 100644 (file)
@@ -38,9 +38,6 @@ dEQP-GLES3.functional.shaders.builtin_functions.precision.atan.mediump_fragment.
 dEQP-GLES3.functional.shaders.builtin_functions.precision.atan.mediump_fragment.vec3
 dEQP-GLES3.functional.shaders.builtin_functions.precision.atan.mediump_fragment.vec4
 
-# Bug 19408572
-dEQP-GLES3.functional.shaders.builtin_functions.precision.reflect.*
-
 # Bug 18323060
 dEQP-GLES3.functional.shaders.random.all_features.fragment.16
 
index b954cad..73cdaa9 100644 (file)
@@ -3055,6 +3055,8 @@ class Reflect : public DerivedFunc<
 {
 public:
        typedef typename        Reflect::Ret            Ret;
+       typedef typename        Reflect::Arg0           Arg0;
+       typedef typename        Reflect::Arg1           Arg1;
        typedef typename        Reflect::ArgExprs       ArgExprs;
 
        string          getName         (void) const
@@ -3063,9 +3065,14 @@ public:
        }
 
 protected:
-       ExprP<Ret>      doExpand        (ExpandContext&, const ArgExprs& args) const
+       ExprP<Ret>      doExpand        (ExpandContext& ctx, const ArgExprs& args) const
        {
-               return args.a - (args.b * dot(args.b, args.a) * constant(2.0f));
+               const ExprP<Arg0>&      i               = args.a;
+               const ExprP<Arg1>&      n               = args.b;
+               const ExprP<float>      dotNI   = bindExpression("dotNI", ctx, dot(n, i));
+
+               return i - alternatives((n * dotNI) * constant(2.0f),
+                                                               n * (dotNI * constant(2.0f)));
        }
 };