ShCheckVariablesWithinPackingLimits add sh::ShaderVariable overload

This overload doesn't take a stripped down version of the variable
information, which makes it possible to handle varying structs
correctly by flattening them as individual variables.

BUG=621031

Change-Id: I367629fce3d17dd7e1f876c5937eb37f3d97c7f4
Reviewed-on: https://chromium-review.googlesource.com/361460
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/VariablePacker.cpp b/src/compiler/translator/VariablePacker.cpp
index e690521..a981c8a 100644
--- a/src/compiler/translator/VariablePacker.cpp
+++ b/src/compiler/translator/VariablePacker.cpp
@@ -148,15 +148,21 @@
     return true;
 }
 
-template <typename VarT>
-bool VariablePacker::CheckVariablesWithinPackingLimits(unsigned int maxVectors,
-                                                       const std::vector<VarT> &in_variables)
+bool VariablePacker::CheckVariablesWithinPackingLimits(
+    unsigned int maxVectors,
+    const std::vector<sh::ShaderVariable> &in_variables)
 {
     ASSERT(maxVectors > 0);
     maxRows_ = maxVectors;
     topNonFullRow_ = 0;
     bottomNonFullRow_ = maxRows_ - 1;
-    std::vector<VarT> variables(in_variables);
+    std::vector<sh::ShaderVariable> variables;
+
+    for (const auto &variable : in_variables)
+    {
+        ExpandVariable(variable, variable.name, variable.mappedName, variable.staticUse,
+                       &variables);
+    }
 
     // Check whether each variable fits in the available vectors.
     for (size_t i = 0; i < variables.size(); i++) {
@@ -261,9 +267,3 @@
 
     return true;
 }
-
-// Instantiate all possible variable packings
-template bool VariablePacker::CheckVariablesWithinPackingLimits(unsigned int, const std::vector<sh::ShaderVariable> &);
-template bool VariablePacker::CheckVariablesWithinPackingLimits(unsigned int, const std::vector<sh::Attribute> &);
-template bool VariablePacker::CheckVariablesWithinPackingLimits(unsigned int, const std::vector<sh::Uniform> &);
-template bool VariablePacker::CheckVariablesWithinPackingLimits(unsigned int, const std::vector<sh::Varying> &);