Properly validate struct uniform linking between the vertex and pixel shaders.

This also implements proper struct validation for uniform blocks.

TRAC #22932

Signed-off-by: Nicolas Capens
Signed-off-by: Geoff Lang
Author: Jamie Madill

git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2336 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index fd5daa9..3b6ad2d 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -3094,50 +3094,38 @@
     return index;
 }
 
-void OutputHLSL::declareUniform(const TType &type, const TString &name, int index)
+void OutputHLSL::declareUniformToList(const TType &type, const TString &name, int index, ActiveUniforms& output)
 {
     const TTypeList *structure = type.getStruct();
 
     if (!structure)
     {
-        mActiveUniforms.push_back(Uniform(glVariableType(type), glVariablePrecision(type), name.c_str(), (unsigned int)type.getArraySize(), (unsigned int)index));
+        output.push_back(Uniform(glVariableType(type), glVariablePrecision(type), name.c_str(), (unsigned int)type.getArraySize(), (unsigned int)index));
     }
     else
     {
-        if (type.isArray())
+        Uniform structUniform(GL_NONE, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), (unsigned int)index);
+
+        int fieldIndex = index;
+
+        for (size_t i = 0; i < structure->size(); i++)
         {
-            int elementIndex = index;
+            const TType &fieldType = *(*structure)[i].type;
+            const TString &fieldName = fieldType.getFieldName();
 
-            for (int i = 0; i < type.getArraySize(); i++)
-            {
-                for (size_t j = 0; j < structure->size(); j++)
-                {
-                    const TType &fieldType = *(*structure)[j].type;
-                    const TString &fieldName = fieldType.getFieldName();
-
-                    const TString uniformName = name + "[" + str(i) + "]." + fieldName;
-                    declareUniform(fieldType, uniformName, elementIndex);
-                    elementIndex += fieldType.totalRegisterCount();
-                }
-            }
+            declareUniformToList(fieldType, fieldName, fieldIndex, structUniform.fields);
+            fieldIndex += fieldType.totalRegisterCount();
         }
-        else
-        {
-            int fieldIndex = index;
 
-            for (size_t i = 0; i < structure->size(); i++)
-            {
-                const TType &fieldType = *(*structure)[i].type;
-                const TString &fieldName = fieldType.getFieldName();
-
-                const TString uniformName = name + "." + fieldName;
-                declareUniform(fieldType, uniformName, fieldIndex);
-                fieldIndex += fieldType.totalRegisterCount();
-            }
-        }
+        output.push_back(structUniform);
     }
 }
 
+void OutputHLSL::declareUniform(const TType &type, const TString &name, int index)
+{
+    declareUniformToList(type, name, index, mActiveUniforms);
+}
+
 GLenum OutputHLSL::glVariableType(const TType &type)
 {
     if (type.getBasicType() == EbtFloat)