Store compact and expanded shader variables.

The current shader API ShGetVariableInfo relies on an expanded
list of shader variables. That means that struct, or user-defined
variables, are expanded into separate entries for the app to
easily query struct members. The new API will preserve the struct
layout, so we can store both to support both the old and new
queries.

BUG=angle:466

Change-Id: Id30a1d7d1bb49c7e745510e0d699f94ad3184b9c
Reviewed-on: https://chromium-review.googlesource.com/206569
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Nicolas Capens <capn@chromium.org>
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 383beca..642f8dd 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -360,7 +360,9 @@
     attributes.clear();
     outputVariables.clear();
     uniforms.clear();
+    expandedUniforms.clear();
     varyings.clear();
+    expandedVaryings.clear();
     interfaceBlocks.clear();
 
     builtInFunctionEmulator.Cleanup();
@@ -487,12 +489,17 @@
 {
     CollectVariables collect(&attributes, &uniforms, &varyings, hashFunction);
     root->traverse(&collect);
+
+    // For backwards compatiblity with ShGetVariableInfo, expand struct
+    // uniforms and varyings into separate variables for each field.
+    ExpandVariables(uniforms, &expandedUniforms);
+    ExpandVariables(varyings, &expandedVaryings);
 }
 
 bool TCompiler::enforcePackingRestrictions()
 {
     VariablePacker packer;
-    return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms);
+    return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, expandedUniforms);
 }
 
 void TCompiler::initializeGLPosition(TIntermNode* root)