commit 409078f1e7c4ec79a1cbc58e3d0b3c399831ac5b
Author: Zhenyao Mo <zmo@chromium.org>
Date:   Tue Oct 28 13:23:18 2014 -0700

    Remove ShGetVariableInfo() and related code.
    
    BUG=angle:775
    TEST=chromium builds and runs fine
    
    Change-Id: Ic62d3a3c9a8f034880b77a96f7f1c6be2691985e
    Reviewed-on: https://chromium-review.googlesource.com/226004
    Tested-by: Zhenyao Mo <zmo@chromium.org>
    Reviewed-by: Jamie Madill <jmadill@chromium.org>
    Reviewed-by: Shannon Woods <shannonwoods@chromium.org>

diff --git a/include/GLSLANG/ShaderLang.h b/include/GLSLANG/ShaderLang.h
index 76012cf..def4946 100644
--- a/include/GLSLANG/ShaderLang.h
+++ b/include/GLSLANG/ShaderLang.h
@@ -48,7 +48,7 @@ extern "C" {
 
 // Version number for shader translation API.
 // It is incremented every time the API changes.
-#define ANGLE_SH_VERSION 130
+#define ANGLE_SH_VERSION 131
 
 typedef enum {
   SH_GLES2_SPEC = 0x8B40,
@@ -86,21 +86,8 @@ typedef enum {
 } ShShaderOutput;
 
 typedef enum {
-  SH_PRECISION_HIGHP     = 0x5001,
-  SH_PRECISION_MEDIUMP   = 0x5002,
-  SH_PRECISION_LOWP      = 0x5003,
-  SH_PRECISION_UNDEFINED = 0
-} ShPrecisionType;
-
-typedef enum {
   SH_INFO_LOG_LENGTH                = 0x8B84,
   SH_OBJECT_CODE_LENGTH             = 0x8B88,  // GL_SHADER_SOURCE_LENGTH
-  SH_ACTIVE_UNIFORMS                = 0x8B86,
-  SH_ACTIVE_UNIFORM_MAX_LENGTH      = 0x8B87,
-  SH_ACTIVE_ATTRIBUTES              = 0x8B89,
-  SH_ACTIVE_ATTRIBUTE_MAX_LENGTH    = 0x8B8A,
-  SH_VARYINGS                       = 0x8BBB,
-  SH_VARYING_MAX_LENGTH             = 0x8BBC,
   SH_MAPPED_NAME_MAX_LENGTH         = 0x6000,
   SH_NAME_MAX_LENGTH                = 0x6001,
   SH_HASHED_NAME_MAX_LENGTH         = 0x6002,
@@ -364,17 +351,6 @@ COMPILER_EXPORT int ShCompile(
 //                     including the null termination character.
 // SH_OBJECT_CODE_LENGTH: the number of characters in the object code
 //                        including the null termination character.
-// SH_ACTIVE_ATTRIBUTES: the number of active attribute variables.
-// SH_ACTIVE_ATTRIBUTE_MAX_LENGTH: the length of the longest active attribute
-//                                 variable name including the null
-//                                 termination character.
-// SH_ACTIVE_UNIFORMS: the number of active uniform variables.
-// SH_ACTIVE_UNIFORM_MAX_LENGTH: the length of the longest active uniform
-//                               variable name including the null
-//                               termination character.
-// SH_VARYINGS: the number of varying variables.
-// SH_VARYING_MAX_LENGTH: the length of the longest varying variable name
-//                        including the null termination character.
 // SH_MAPPED_NAME_MAX_LENGTH: the length of the mapped variable name including
 //                            the null termination character.
 // SH_NAME_MAX_LENGTH: the max length of a user-defined name including the
@@ -410,44 +386,6 @@ COMPILER_EXPORT void ShGetInfoLog(const ShHandle handle, char* infoLog);
 //          ShGetInfo with SH_OBJECT_CODE_LENGTH.
 COMPILER_EXPORT void ShGetObjectCode(const ShHandle handle, char* objCode);
 
-// Returns information about a shader variable.
-// Parameters:
-// handle: Specifies the compiler
-// variableType: Specifies the variable type; options include
-//               SH_ACTIVE_ATTRIBUTES, SH_ACTIVE_UNIFORMS, SH_VARYINGS.
-// index: Specifies the index of the variable to be queried.
-// length: Returns the number of characters actually written in the string
-//         indicated by name (excluding the null terminator) if a value other
-//         than NULL is passed.
-// size: Returns the size of the variable.
-// type: Returns the data type of the variable.
-// precision: Returns the precision of the variable.
-// staticUse: Returns 1 if the variable is accessed in a statement after
-//            pre-processing, whether or not run-time flow of control will
-//            cause that statement to be executed.
-//            Returns 0 otherwise.
-// name: Returns a null terminated string containing the name of the
-//       variable. It is assumed that name has enough memory to accormodate
-//       the variable name. The size of the buffer required to store the
-//       variable name can be obtained by calling ShGetInfo with
-//       SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, SH_ACTIVE_UNIFORM_MAX_LENGTH,
-//       SH_VARYING_MAX_LENGTH.
-// mappedName: Returns a null terminated string containing the mapped name of
-//             the variable, It is assumed that mappedName has enough memory
-//             (SH_MAPPED_NAME_MAX_LENGTH), or NULL if don't care about the
-//             mapped name. If the name is not mapped, then name and mappedName
-//             are the same.
-COMPILER_EXPORT void ShGetVariableInfo(const ShHandle handle,
-                                       ShShaderInfo variableType,
-                                       int index,
-                                       size_t* length,
-                                       int* size,
-                                       sh::GLenum* type,
-                                       ShPrecisionType* precision,
-                                       int* staticUse,
-                                       char* name,
-                                       char* mappedName);
-
 // Returns information about a name hashing entry from the latest compile.
 // Parameters:
 // handle: Specifies the compiler
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 2824064..a93d7e6 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -384,7 +384,6 @@ void TCompiler::clearResults()
     uniforms.clear();
     expandedUniforms.clear();
     varyings.clear();
-    expandedVaryings.clear();
     interfaceBlocks.clear();
 
     builtInFunctionEmulator.Cleanup();
@@ -518,10 +517,8 @@ void TCompiler::collectVariables(TIntermNode* root)
                                  symbolTable);
     root->traverse(&collect);
 
-    // For backwards compatiblity with ShGetVariableInfo, expand struct
-    // uniforms and varyings into separate variables for each field.
-    sh::ExpandVariables(uniforms, &expandedUniforms);
-    sh::ExpandVariables(varyings, &expandedVaryings);
+    // This is for enforcePackingRestriction().
+    sh::ExpandUniforms(uniforms, &expandedUniforms);
 }
 
 bool TCompiler::enforcePackingRestrictions()
diff --git a/src/compiler/translator/Compiler.h b/src/compiler/translator/Compiler.h
index 6d1e225..145ecb4 100644
--- a/src/compiler/translator/Compiler.h
+++ b/src/compiler/translator/Compiler.h
@@ -72,9 +72,7 @@ class TCompiler : public TShHandleBase
     const std::vector<sh::Attribute> &getAttributes() const { return attributes; }
     const std::vector<sh::Attribute> &getOutputVariables() const { return outputVariables; }
     const std::vector<sh::Uniform> &getUniforms() const { return uniforms; }
-    const std::vector<sh::ShaderVariable> &getExpandedUniforms() const { return expandedUniforms; }
     const std::vector<sh::Varying> &getVaryings() const { return varyings; }
-    const std::vector<sh::ShaderVariable> &getExpandedVaryings() const { return expandedVaryings; }
     const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return interfaceBlocks; }
 
     ShHashFunction64 getHashFunction() const { return hashFunction; }
@@ -144,7 +142,6 @@ class TCompiler : public TShHandleBase
     std::vector<sh::Uniform> uniforms;
     std::vector<sh::ShaderVariable> expandedUniforms;
     std::vector<sh::Varying> varyings;
-    std::vector<sh::ShaderVariable> expandedVaryings;
     std::vector<sh::InterfaceBlock> interfaceBlocks;
 
   private:
diff --git a/src/compiler/translator/ShaderLang.cpp b/src/compiler/translator/ShaderLang.cpp
index 144ef90..35dac5f 100644
--- a/src/compiler/translator/ShaderLang.cpp
+++ b/src/compiler/translator/ShaderLang.cpp
@@ -37,72 +37,6 @@ bool isInitialized = false;
 // and the shading language compiler.
 //
 
-static bool CheckVariableMaxLengths(const ShHandle handle,
-                                    size_t expectedValue)
-{
-    size_t activeUniformLimit = 0;
-    ShGetInfo(handle, SH_ACTIVE_UNIFORM_MAX_LENGTH, &activeUniformLimit);
-    size_t activeAttribLimit = 0;
-    ShGetInfo(handle, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, &activeAttribLimit);
-    size_t varyingLimit = 0;
-    ShGetInfo(handle, SH_VARYING_MAX_LENGTH, &varyingLimit);
-    return (expectedValue == activeUniformLimit &&
-            expectedValue == activeAttribLimit &&
-            expectedValue == varyingLimit);
-}
-
-bool CheckMappedNameMaxLength(const ShHandle handle, size_t expectedValue)
-{
-    size_t mappedNameMaxLength = 0;
-    ShGetInfo(handle, SH_MAPPED_NAME_MAX_LENGTH, &mappedNameMaxLength);
-    return (expectedValue == mappedNameMaxLength);
-}
-
-template <typename VarT>
-const sh::ShaderVariable *ReturnVariable(const std::vector<VarT> &infoList, int index)
-{
-    if (index < 0 || static_cast<size_t>(index) >= infoList.size())
-    {
-        return NULL;
-    }
-
-    return &infoList[index];
-}
-
-const sh::ShaderVariable *GetVariable(const TCompiler *compiler, ShShaderInfo varType, int index)
-{
-    switch (varType)
-    {
-      case SH_ACTIVE_ATTRIBUTES:
-        return ReturnVariable(compiler->getAttributes(), index);
-      case SH_ACTIVE_UNIFORMS:
-        return ReturnVariable(compiler->getExpandedUniforms(), index);
-      case SH_VARYINGS:
-        return ReturnVariable(compiler->getExpandedVaryings(), index);
-      default:
-        UNREACHABLE();
-        return NULL;
-    }
-}
-
-ShPrecisionType ConvertPrecision(sh::GLenum precision)
-{
-    switch (precision)
-    {
-      case GL_HIGH_FLOAT:
-      case GL_HIGH_INT:
-        return SH_PRECISION_HIGHP;
-      case GL_MEDIUM_FLOAT:
-      case GL_MEDIUM_INT:
-        return SH_PRECISION_MEDIUMP;
-      case GL_LOW_FLOAT:
-      case GL_LOW_INT:
-        return SH_PRECISION_LOWP;
-      default:
-        return SH_PRECISION_UNDEFINED;
-    }
-}
-
 template <typename VarT>
 const std::vector<VarT> *GetVariableList(const TCompiler *compiler, ShaderVariableType variableType);
 
@@ -315,24 +249,6 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, size_t* params)
     case SH_OBJECT_CODE_LENGTH:
         *params = compiler->getInfoSink().obj.size() + 1;
         break;
-    case SH_ACTIVE_UNIFORMS:
-        *params = compiler->getExpandedUniforms().size();
-        break;
-    case SH_ACTIVE_UNIFORM_MAX_LENGTH:
-        *params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
-        break;
-    case SH_ACTIVE_ATTRIBUTES:
-        *params = compiler->getAttributes().size();
-        break;
-    case SH_ACTIVE_ATTRIBUTE_MAX_LENGTH:
-        *params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
-        break;
-    case SH_VARYINGS:
-        *params = compiler->getExpandedVaryings().size();
-        break;
-    case SH_VARYING_MAX_LENGTH:
-        *params = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
-        break;
     case SH_MAPPED_NAME_MAX_LENGTH:
         // Use longer length than MAX_SHORTENED_IDENTIFIER_SIZE to
         // handle array and struct dereferences.
@@ -400,58 +316,6 @@ void ShGetObjectCode(const ShHandle handle, char* objCode)
     strcpy(objCode, infoSink.obj.c_str());
 }
 
-void ShGetVariableInfo(const ShHandle handle,
-                       ShShaderInfo varType,
-                       int index,
-                       size_t* length,
-                       int* size,
-                       sh::GLenum* type,
-                       ShPrecisionType* precision,
-                       int* staticUse,
-                       char* name,
-                       char* mappedName)
-{
-    if (!handle || !size || !type || !precision || !staticUse || !name)
-        return;
-    ASSERT((varType == SH_ACTIVE_ATTRIBUTES) ||
-           (varType == SH_ACTIVE_UNIFORMS) ||
-           (varType == SH_VARYINGS));
-
-    TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
-    TCompiler* compiler = base->getAsCompiler();
-    if (compiler == 0)
-        return;
-
-    const sh::ShaderVariable *varInfo = GetVariable(compiler, varType, index);
-    if (!varInfo)
-    {
-        return;
-    }
-
-    if (length) *length = varInfo->name.size();
-    *size = varInfo->elementCount();
-    *type = varInfo->type;
-    *precision = ConvertPrecision(varInfo->precision);
-    *staticUse = varInfo->staticUse ? 1 : 0;
-
-    // This size must match that queried by
-    // SH_ACTIVE_UNIFORM_MAX_LENGTH, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, SH_VARYING_MAX_LENGTH
-    // in ShGetInfo, below.
-    size_t variableLength = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
-    ASSERT(CheckVariableMaxLengths(handle, variableLength));
-    strncpy(name, varInfo->name.c_str(), variableLength);
-    name[variableLength - 1] = 0;
-    if (mappedName)
-    {
-        // This size must match that queried by
-        // SH_MAPPED_NAME_MAX_LENGTH in ShGetInfo, below.
-        size_t maxMappedNameLength = 1 + GetGlobalMaxTokenSize(compiler->getShaderSpec());
-        ASSERT(CheckMappedNameMaxLength(handle, maxMappedNameLength));
-        strncpy(mappedName, varInfo->mappedName.c_str(), maxMappedNameLength);
-        mappedName[maxMappedNameLength - 1] = 0;
-    }
-}
-
 void ShGetNameHashingEntry(const ShHandle handle,
                            int index,
                            char* name,
diff --git a/src/compiler/translator/VariableInfo.cpp b/src/compiler/translator/VariableInfo.cpp
index cd92706..d8e1378 100644
--- a/src/compiler/translator/VariableInfo.cpp
+++ b/src/compiler/translator/VariableInfo.cpp
@@ -466,9 +466,8 @@ bool CollectVariables::visitBinary(Visit, TIntermBinary *binaryNode)
     return true;
 }
 
-template <typename VarT>
-void ExpandVariables(const std::vector<VarT> &compact,
-                     std::vector<ShaderVariable> *expanded)
+void ExpandUniforms(const std::vector<Uniform> &compact,
+                    std::vector<ShaderVariable> *expanded)
 {
     for (size_t variableIndex = 0; variableIndex < compact.size(); variableIndex++)
     {
@@ -477,7 +476,4 @@ void ExpandVariables(const std::vector<VarT> &compact,
     }
 }
 
-template void ExpandVariables(const std::vector<Uniform> &, std::vector<ShaderVariable> *);
-template void ExpandVariables(const std::vector<Varying> &, std::vector<ShaderVariable> *);
-
 }
diff --git a/src/compiler/translator/VariableInfo.h b/src/compiler/translator/VariableInfo.h
index 9c6b6ba..92d376d 100644
--- a/src/compiler/translator/VariableInfo.h
+++ b/src/compiler/translator/VariableInfo.h
@@ -59,10 +59,9 @@ class CollectVariables : public TIntermTraverser
     const TSymbolTable &mSymbolTable;
 };
 
-// Expand struct variables to flattened lists of split variables
-template <typename VarT>
-void ExpandVariables(const std::vector<VarT> &compact,
-                     std::vector<ShaderVariable> *expanded);
+// Expand struct uniforms to flattened lists of split variables
+void ExpandUniforms(const std::vector<Uniform> &compact,
+                    std::vector<ShaderVariable> *expanded);
 
 }
 
