Revert "Add constant folding support for geometric built-ins"

This is failing gpu_unittests on Mac:

ShaderTranslatorTest.BuiltInFunctionEmulation:
../../gpu/command_buffer/service/shader_translator_unittest.cc:314: Failure
Value of: strstr(translated_source.c_str(), "webgl_dot_emu") != NULL
Actual: false
Expected: true

Reverting until we can fix the overly-narrow test.

BUG=angleproject:913

This reverts commit b50788d11dec046415565af1cc7da334e2979577.

Change-Id: I5bd9df83704e771e419339745eceaa43a20bd1e6
Reviewed-on: https://chromium-review.googlesource.com/275320
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/IntermNode.cpp b/src/compiler/translator/IntermNode.cpp
index 5aed4f8..5319bc7 100644
--- a/src/compiler/translator/IntermNode.cpp
+++ b/src/compiler/translator/IntermNode.cpp
@@ -168,25 +168,6 @@
     }
 }
 
-float VectorLength(TConstantUnion *paramArray, size_t paramArraySize)
-{
-    float result = 0.0f;
-    for (size_t i = 0; i < paramArraySize; i++)
-    {
-        float f = paramArray[i].getFConst();
-        result += f * f;
-    }
-    return sqrtf(result);
-}
-
-float VectorDotProduct(TConstantUnion *paramArray1, TConstantUnion *paramArray2, size_t paramArraySize)
-{
-    float result = 0.0f;
-    for (size_t i = 0; i < paramArraySize; i++)
-        result += paramArray1[i].getFConst() * paramArray2[i].getFConst();
-    return result;
-}
-
 }  // namespace anonymous
 
 
@@ -1198,15 +1179,14 @@
 
         return tempNode;
     }
-    else if (op == EOpAny || op == EOpAll || op == EOpLength)
+    else if (op == EOpAny || op == EOpAll)
     {
         // Do operations where the return type is different from the operand type.
 
-        TType returnType;
+        TType returnType(EbtBool, EbpUndefined, EvqConst);
         TConstantUnion *tempConstArray = nullptr;
-        switch (op)
+        if (op == EOpAny)
         {
-          case EOpAny:
             if (getType().getBasicType() == EbtBool)
             {
                 tempConstArray = new TConstantUnion();
@@ -1219,16 +1199,17 @@
                         break;
                     }
                 }
-                returnType = TType(EbtBool, EbpUndefined, EvqConst);
-                break;
             }
             else
             {
-                infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant");
+                infoSink.info.message(
+                    EPrefixInternalError, getLine(),
+                    "Unary operation not folded into constant");
                 return nullptr;
             }
-
-          case EOpAll:
+        }
+        else if (op == EOpAll)
+        {
             if (getType().getBasicType() == EbtBool)
             {
                 tempConstArray = new TConstantUnion();
@@ -1241,33 +1222,15 @@
                         break;
                     }
                 }
-                returnType = TType(EbtBool, EbpUndefined, EvqConst);
-                break;
             }
             else
             {
-                infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant");
+                infoSink.info.message(
+                    EPrefixInternalError, getLine(),
+                    "Unary operation not folded into constant");
                 return nullptr;
             }
-
-          case EOpLength:
-            if (getType().getBasicType() == EbtFloat)
-            {
-                tempConstArray = new TConstantUnion();
-                tempConstArray->setFConst(VectorLength(unionArray, objectSize));
-                returnType = TType(EbtFloat, getType().getPrecision(), EvqConst);
-                break;
-            }
-            else
-            {
-                infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant");
-                return nullptr;
-            }
-
-          default:
-            break;
         }
-
         TIntermConstantUnion *tempNode = new TIntermConstantUnion(tempConstArray, returnType);
         tempNode->setLine(getLine());
         return tempNode;
@@ -1612,20 +1575,6 @@
                     "Unary operation not folded into constant");
                 return nullptr;
 
-              case EOpNormalize:
-                if (getType().getBasicType() == EbtFloat)
-                {
-                    float x = unionArray[i].getFConst();
-                    float length = VectorLength(unionArray, objectSize);
-                    if (length)
-                        tempConstArray[i].setFConst(x / length);
-                    else
-                        UndefinedConstantFoldingError(getLine(), op, getType().getBasicType(), infoSink, &tempConstArray[i]);
-                    break;
-                }
-                infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant");
-                return nullptr;
-
               default:
                 return nullptr;
             }
@@ -1969,70 +1918,6 @@
             }
             break;
 
-          case EOpDistance:
-            if (basicType == EbtFloat)
-            {
-                TConstantUnion *distanceArray = new TConstantUnion[maxObjectSize];
-                tempConstArray = new TConstantUnion();
-                for (size_t i = 0; i < maxObjectSize; i++)
-                {
-                    float x = unionArrays[0][i].getFConst();
-                    float y = unionArrays[1][i].getFConst();
-                    distanceArray[i].setFConst(x - y);
-                }
-                tempConstArray->setFConst(VectorLength(distanceArray, maxObjectSize));
-            }
-            else
-                UNREACHABLE();
-            break;
-
-          case EOpDot:
-            if (basicType == EbtFloat)
-            {
-                tempConstArray = new TConstantUnion();
-                tempConstArray->setFConst(VectorDotProduct(unionArrays[0], unionArrays[1], maxObjectSize));
-            }
-            else
-                UNREACHABLE();
-            break;
-
-          case EOpCross:
-            if (basicType == EbtFloat && maxObjectSize == 3)
-            {
-                tempConstArray = new TConstantUnion[maxObjectSize];
-                float x0 = unionArrays[0][0].getFConst();
-                float x1 = unionArrays[0][1].getFConst();
-                float x2 = unionArrays[0][2].getFConst();
-                float y0 = unionArrays[1][0].getFConst();
-                float y1 = unionArrays[1][1].getFConst();
-                float y2 = unionArrays[1][2].getFConst();
-                tempConstArray[0].setFConst(x1 * y2 - y1 * x2);
-                tempConstArray[1].setFConst(x2 * y0 - y2 * x0);
-                tempConstArray[2].setFConst(x0 * y1 - y0 * x1);
-            }
-            else
-                UNREACHABLE();
-            break;
-
-          case EOpReflect:
-            if (basicType == EbtFloat)
-            {
-                // genType reflect (genType I, genType N) :
-                //     For the incident vector I and surface orientation N, returns the reflection direction:
-                //     I - 2 * dot(N, I) * N.
-                tempConstArray = new TConstantUnion[maxObjectSize];
-                float dotProduct = VectorDotProduct(unionArrays[1], unionArrays[0], maxObjectSize);
-                for (size_t i = 0; i < maxObjectSize; i++)
-                {
-                    float result = unionArrays[0][i].getFConst() -
-                                   2.0f * dotProduct * unionArrays[1][i].getFConst();
-                    tempConstArray[i].setFConst(result);
-                }
-            }
-            else
-                UNREACHABLE();
-            break;
-
           default:
             UNREACHABLE();
             // TODO: Add constant folding support for other built-in operations that take 2 parameters and not handled above.
@@ -2158,53 +2043,6 @@
             }
             break;
 
-          case EOpFaceForward:
-            if (basicType == EbtFloat)
-            {
-                // genType faceforward(genType N, genType I, genType Nref) :
-                //     If dot(Nref, I) < 0 return N, otherwise return -N.
-                tempConstArray = new TConstantUnion[maxObjectSize];
-                float dotProduct = VectorDotProduct(unionArrays[2], unionArrays[1], maxObjectSize);
-                for (size_t i = 0; i < maxObjectSize; i++)
-                {
-                    if (dotProduct < 0)
-                        tempConstArray[i].setFConst(unionArrays[0][i].getFConst());
-                    else
-                        tempConstArray[i].setFConst(-unionArrays[0][i].getFConst());
-                }
-            }
-            else
-                UNREACHABLE();
-            break;
-
-          case EOpRefract:
-            if (basicType == EbtFloat)
-            {
-                // genType refract(genType I, genType N, float eta) :
-                //     For the incident vector I and surface normal N, and the ratio of indices of refraction eta,
-                //     return the refraction vector. The result is computed by
-                //         k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
-                //         if (k < 0.0)
-                //             return genType(0.0)
-                //         else
-                //             return eta * I - (eta * dot(N, I) + sqrt(k)) * N
-                tempConstArray = new TConstantUnion[maxObjectSize];
-                float dotProduct = VectorDotProduct(unionArrays[1], unionArrays[0], maxObjectSize);
-                for (size_t i = 0; i < maxObjectSize; i++)
-                {
-                    float eta = unionArrays[2][i].getFConst();
-                    float k = 1.0f - eta * eta * (1.0f - dotProduct * dotProduct);
-                    if (k < 0.0f)
-                        tempConstArray[i].setFConst(0.0f);
-                    else
-                        tempConstArray[i].setFConst(eta * unionArrays[0][i].getFConst() -
-                                                    (eta * dotProduct + sqrtf(k)) * unionArrays[1][i].getFConst());
-                }
-            }
-            else
-                UNREACHABLE();
-            break;
-
           default:
             UNREACHABLE();
             // TODO: Add constant folding support for other built-in operations that take 3 parameters and not handled above.