Remove SH_EMULATE_BUILT_IN_FUNCTIONS which isn't used

The flag is not used in chrome. We decide to do per emulation per flag.

BUG=chromium:642227

Change-Id: I936d53e5015186e35e672d0cb51c853a941582d2
Reviewed-on: https://chromium-review.googlesource.com/379077
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/include/GLSLANG/ShaderLang.h b/include/GLSLANG/ShaderLang.h
index a86f137..c614d62 100644
--- a/include/GLSLANG/ShaderLang.h
+++ b/include/GLSLANG/ShaderLang.h
@@ -49,7 +49,7 @@
 
 // Version number for shader translation API.
 // It is incremented every time the API changes.
-#define ANGLE_SH_VERSION 157
+#define ANGLE_SH_VERSION 158
 
 typedef enum {
     SH_GLES2_SPEC,
@@ -110,8 +110,9 @@
     // This is to work around a mac driver bug.
     SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX = 0x0080,
 
-    // This is needed only as a workaround for certain OpenGL driver bugs.
-    SH_EMULATE_BUILT_IN_FUNCTIONS = 0x0100,
+    // This flag works around bug in Intel Mac drivers related to abs(i) where
+    // i is an integer.
+    SH_EMULATE_ABS_INT_FUNCTION = 0x0100,
 
     // This is an experimental flag to enforce restrictions that aim to prevent
     // timing attacks.
@@ -210,10 +211,6 @@
     // This flag works around an issue in translating GLSL function texelFetchOffset on
     // INTEL drivers. It works by translating texelFetchOffset into texelFetch.
     SH_REWRITE_TEXELFETCHOFFSET_TO_TEXELFETCH = 0x4000000,
-
-    // This flag works around bug in Intel Mac drivers related to abs(i) where
-    // i is an integer.
-    SH_EMULATE_ABS_INT_FUNCTION = 0x8000000,
 } ShCompileOptions;
 
 // Defines alternate strategies for implementing array index clamping.
diff --git a/src/compiler/translator/BuiltInFunctionEmulatorGLSL.cpp b/src/compiler/translator/BuiltInFunctionEmulatorGLSL.cpp
index a27db6a..3a83858 100644
--- a/src/compiler/translator/BuiltInFunctionEmulatorGLSL.cpp
+++ b/src/compiler/translator/BuiltInFunctionEmulatorGLSL.cpp
@@ -21,33 +21,6 @@
     }
 }
 
-void InitBuiltInFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *emu, sh::GLenum shaderType)
-{
-    // we use macros here instead of function definitions to work around more GLSL
-    // compiler bugs, in particular on NVIDIA hardware on Mac OSX. Macros are
-    // problematic because if the argument has side-effects they will be repeatedly
-    // evaluated. This is unlikely to show up in real shaders, but is something to
-    // consider.
-
-    const TType *float1 = TCache::getType(EbtFloat);
-    const TType *float2 = TCache::getType(EbtFloat, 2);
-    const TType *float3 = TCache::getType(EbtFloat, 3);
-    const TType *float4 = TCache::getType(EbtFloat, 4);
-
-    if (shaderType == GL_FRAGMENT_SHADER)
-    {
-        emu->addEmulatedFunction(EOpCos, float1, "webgl_emu_precision float webgl_cos_emu(webgl_emu_precision float a) { return cos(a); }");
-        emu->addEmulatedFunction(EOpCos, float2, "webgl_emu_precision vec2 webgl_cos_emu(webgl_emu_precision vec2 a) { return cos(a); }");
-        emu->addEmulatedFunction(EOpCos, float3, "webgl_emu_precision vec3 webgl_cos_emu(webgl_emu_precision vec3 a) { return cos(a); }");
-        emu->addEmulatedFunction(EOpCos, float4, "webgl_emu_precision vec4 webgl_cos_emu(webgl_emu_precision vec4 a) { return cos(a); }");
-    }
-    emu->addEmulatedFunction(EOpDistance, float1, float1, "#define webgl_distance_emu(x, y) ((x) >= (y) ? (x) - (y) : (y) - (x))");
-    emu->addEmulatedFunction(EOpDot, float1, float1, "#define webgl_dot_emu(x, y) ((x) * (y))");
-    emu->addEmulatedFunction(EOpLength, float1, "#define webgl_length_emu(x) ((x) >= 0.0 ? (x) : -(x))");
-    emu->addEmulatedFunction(EOpNormalize, float1, "#define webgl_normalize_emu(x) ((x) == 0.0 ? 0.0 : ((x) > 0.0 ? 1.0 : -1.0))");
-    emu->addEmulatedFunction(EOpReflect, float1, float1, "#define webgl_reflect_emu(I, N) ((I) - 2.0 * (N) * (I) * (N))");
-}
-
 // Emulate built-in functions missing from GLSL 1.30 and higher
 void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator *emu, sh::GLenum shaderType,
                                                         int targetGLSLVersion)
diff --git a/src/compiler/translator/BuiltInFunctionEmulatorGLSL.h b/src/compiler/translator/BuiltInFunctionEmulatorGLSL.h
index e551748..d37dda3 100644
--- a/src/compiler/translator/BuiltInFunctionEmulatorGLSL.h
+++ b/src/compiler/translator/BuiltInFunctionEmulatorGLSL.h
@@ -18,11 +18,6 @@
                                                       sh::GLenum shaderType);
 
 //
-// This is only a workaround for OpenGL driver bugs, and isn't needed in general.
-//
-void InitBuiltInFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *emu, sh::GLenum shaderType);
-
-//
 // This function is emulating built-in functions missing from GLSL 1.30 and higher.
 //
 void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator *emu, sh::GLenum shaderType,
diff --git a/src/compiler/translator/TranslatorESSL.cpp b/src/compiler/translator/TranslatorESSL.cpp
index fef1768..d3a45310 100644
--- a/src/compiler/translator/TranslatorESSL.cpp
+++ b/src/compiler/translator/TranslatorESSL.cpp
@@ -6,7 +6,6 @@
 
 #include "compiler/translator/TranslatorESSL.h"
 
-#include "compiler/translator/BuiltInFunctionEmulatorGLSL.h"
 #include "compiler/translator/EmulatePrecision.h"
 #include "compiler/translator/RecordConstantPrecision.h"
 #include "compiler/translator/OutputESSL.h"
@@ -17,14 +16,6 @@
 {
 }
 
-void TranslatorESSL::initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu, int compileOptions)
-{
-    if (compileOptions & SH_EMULATE_BUILT_IN_FUNCTIONS)
-    {
-        InitBuiltInFunctionEmulatorForGLSLWorkarounds(emu, getShaderType());
-    }
-}
-
 void TranslatorESSL::translate(TIntermNode *root, int compileOptions)
 {
     TInfoSinkBase& sink = getInfoSink().obj;
diff --git a/src/compiler/translator/TranslatorESSL.h b/src/compiler/translator/TranslatorESSL.h
index 0fbc47d..a231476 100644
--- a/src/compiler/translator/TranslatorESSL.h
+++ b/src/compiler/translator/TranslatorESSL.h
@@ -15,8 +15,6 @@
     TranslatorESSL(sh::GLenum type, ShShaderSpec spec);
 
   protected:
-    void initBuiltInFunctionEmulator(BuiltInFunctionEmulator *emu, int compileOptions) override;
-
     void translate(TIntermNode *root, int compileOptions) override;
     bool shouldFlattenPragmaStdglInvariantAll() override;
 
diff --git a/src/compiler/translator/TranslatorGLSL.cpp b/src/compiler/translator/TranslatorGLSL.cpp
index 643ce79..1febbc7 100644
--- a/src/compiler/translator/TranslatorGLSL.cpp
+++ b/src/compiler/translator/TranslatorGLSL.cpp
@@ -26,10 +26,6 @@
     {
         InitBuiltInAbsFunctionEmulatorForGLSLWorkarounds(emu, getShaderType());
     }
-    if (compileOptions & SH_EMULATE_BUILT_IN_FUNCTIONS)
-    {
-        InitBuiltInFunctionEmulatorForGLSLWorkarounds(emu, getShaderType());
-    }
 
     int targetGLSLVersion = ShaderOutputTypeToGLSLVersion(getOutputType());
     InitBuiltInFunctionEmulatorForGLSLMissingFunctions(emu, getShaderType(), targetGLSLVersion);
diff --git a/src/tests/angle_unittests.gypi b/src/tests/angle_unittests.gypi
index 9eeb21e..64ab154 100644
--- a/src/tests/angle_unittests.gypi
+++ b/src/tests/angle_unittests.gypi
@@ -42,7 +42,6 @@
             '<(angle_path)/src/libANGLE/validationES_unittest.cpp',
             '<(angle_path)/src/tests/angle_unittests_utils.h',
             '<(angle_path)/src/tests/compiler_tests/API_test.cpp',
-            '<(angle_path)/src/tests/compiler_tests/BuiltInFunctionEmulator_test.cpp',
             '<(angle_path)/src/tests/compiler_tests/CollectVariables_test.cpp',
             '<(angle_path)/src/tests/compiler_tests/ConstantFolding_test.cpp',
             '<(angle_path)/src/tests/compiler_tests/DebugShaderPrecision_test.cpp',
diff --git a/src/tests/compiler_tests/BuiltInFunctionEmulator_test.cpp b/src/tests/compiler_tests/BuiltInFunctionEmulator_test.cpp
deleted file mode 100644
index edf979f..0000000
--- a/src/tests/compiler_tests/BuiltInFunctionEmulator_test.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// BuiltInFunctionEmulator_test.cpp:
-//   Tests for writing the code for built-in function emulation.
-//
-
-#include "angle_gl.h"
-#include "gtest/gtest.h"
-#include "GLSLANG/ShaderLang.h"
-#include "tests/test_utils/compiler_test.h"
-
-namespace
-{
-
-// Test for the SH_EMULATE_BUILT_IN_FUNCTIONS flag.
-class EmulateBuiltInFunctionsTest : public MatchOutputCodeTest
-{
-  public:
-    EmulateBuiltInFunctionsTest()
-        : MatchOutputCodeTest(GL_VERTEX_SHADER,
-                              SH_EMULATE_BUILT_IN_FUNCTIONS,
-                              SH_GLSL_COMPATIBILITY_OUTPUT)
-    {
-    }
-};
-
-TEST_F(EmulateBuiltInFunctionsTest, DotEmulated)
-{
-    const std::string shaderString =
-        "precision mediump float;\n"
-        "uniform float u;\n"
-        "void main()\n"
-        "{\n"
-        "   gl_Position = vec4(dot(u, 1.0), 1.0, 1.0, 1.0);\n"
-        "}\n";
-    compile(shaderString);
-    ASSERT_TRUE(foundInCode("webgl_dot_emu("));
-}
-
-} // namespace