Compiler - fix redeclaration of initialized globals
TRAC #11617
Signed-off-by: Andrew Lewycky
Signed-off-by: Daniel Koch

Author:    Nicolas Capens

git-svn-id: https://angleproject.googlecode.com/svn/trunk@87 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index 84cb8ed..601a386 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -53,6 +53,10 @@
                     varyingInput += "    " + typeString(type) + " " + name + arrayString(type) + semantic + ";\n";
                     varyingGlobals += "static " + typeString(type) + " " + name + arrayString(type) + " = " + initializer(type) + ";\n";
                 }
+                else if (qualifier == EvqGlobal)
+                {
+                    // Globals are declared and intialized as an aggregate node
+                }
                 else if (qualifier == EvqConst)
                 {
                     // Constants are repeated as literals where used
@@ -106,14 +110,13 @@
                "}\n"
                "\n";
     }
-    else
+    else   // Vertex shader
     {
         TString uniforms;
         TString attributeInput;
         TString attributeGlobals;
         TString varyingOutput;
         TString varyingGlobals;
-        TString globals;
 
         TSymbolTableLevel *symbols = context.symbolTable.getGlobalLevel();
         int semanticIndex = 0;
@@ -149,7 +152,7 @@
                 }
                 else if (qualifier == EvqGlobal)
                 {
-                    globals += typeString(type) + " " + name + arrayString(type) + ";\n";
+                    // Globals are declared and intialized as an aggregate node
                 }
                 else if (qualifier == EvqConst)
                 {
@@ -162,8 +165,6 @@
         out << "uniform float2 gl_HalfPixelSize;\n"
                "\n";
         out <<  uniforms;
-        out << "\n";
-        out <<  globals;
         out << "\n"
                "struct VS_INPUT\n"   // FIXME: Prevent name clashes
                "{\n";
@@ -451,16 +452,8 @@
                "\n"
                "    PS_OUTPUT output;\n"                    // FIXME: Prevent name clashes
                "    output.gl_Color[0] = gl_Color[0];\n";   // FIXME: Prevent name clashes
-
-        TSymbolTableLevel *symbols = context.symbolTable.getGlobalLevel();
-
-        for (TSymbolTableLevel::const_iterator namedSymbol = symbols->begin(); namedSymbol != symbols->end(); namedSymbol++)
-        {
-            const TSymbol *symbol = (*namedSymbol).second;
-            const TString &name = symbol->getName();
-        }
     }
-    else
+    else   // Vertex shader
     {
         out << "VS_OUTPUT main(VS_INPUT input)\n"   // FIXME: Prevent name clashes
                "{\n";
@@ -749,7 +742,7 @@
             TIntermTyped *variable = sequence[0]->getAsTyped();
             bool visit = true;
 
-            if (variable && variable->getQualifier() == EvqTemporary)
+            if (variable && (variable->getQualifier() == EvqTemporary || variable->getQualifier() == EvqGlobal))
             {
                 out << typeString(variable->getType()) + " ";