Fix std140 UBO layouts.

A call to "prePadding" instaed of "prePaddingString" was confusing
the HLSL output engine.

A separate bug was causing HLSL errors because HLSL puts all cbuffer
members in a flattened namespace, which caused our internal padding
variables to overlap.

BUG=angle:725

Change-Id: I69a01fefa430a83e433385c64a532a69e6851ae8
Reviewed-on: https://chromium-review.googlesource.com/212930
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Nicolas Capens <capn@chromium.org>
diff --git a/src/compiler/translator/StructureHLSL.h b/src/compiler/translator/StructureHLSL.h
index 068fa2e..ed002fe 100644
--- a/src/compiler/translator/StructureHLSL.h
+++ b/src/compiler/translator/StructureHLSL.h
@@ -26,7 +26,8 @@
 class Std140PaddingHelper
 {
   public:
-    explicit Std140PaddingHelper(const std::map<TString, int> &structElementIndexes);
+    explicit Std140PaddingHelper(const std::map<TString, int> &structElementIndexes,
+                                 unsigned *uniqueCounter);
 
     int elementIndex() const { return mElementIndex; }
     int prePadding(const TType &type);
@@ -34,7 +35,9 @@
     TString postPaddingString(const TType &type, bool useHLSLRowMajorPacking);
 
   private:
-    int mPaddingCounter;
+    TString next();
+
+    unsigned *mPaddingCounter;
     int mElementIndex;
     const std::map<TString, int> &mStructElementIndexes;
 };
@@ -50,9 +53,11 @@
     TString defineQualified(const TStructure &structure, bool useHLSLRowMajorPacking, bool useStd140Packing);
     static TString defineNameless(const TStructure &structure);
 
-    Std140PaddingHelper getPaddingHelper() const { return Std140PaddingHelper(mStd140StructElementIndexes); }
+    Std140PaddingHelper getPaddingHelper();
 
   private:
+    unsigned mUniquePaddingCounter;
+
     std::map<TString, int> mStd140StructElementIndexes;
 
     typedef std::set<TString> StructNames;