Redesign HLSL scoped structures to a unique ID.

A unique ID gives a more flexible renaming scheme than our
current method of using nested scope identifiers. The reduced
complexity allows for fewer points of breakage and fixes an
outstanding bug with scoped structures (with added test).

BUG=angle:618

Change-Id: I6551248bb9fa2d185ab67248721f898dd50151f0
Reviewed-on: https://chromium-review.googlesource.com/202183
Reviewed-by: Nicolas Capens <nicolascapens@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/tests/angle_tests/GLSLStructTest.cpp b/tests/angle_tests/GLSLStructTest.cpp
index 318f41d..531afe1 100644
--- a/tests/angle_tests/GLSLStructTest.cpp
+++ b/tests/angle_tests/GLSLStructTest.cpp
@@ -12,19 +12,79 @@
         setConfigBlueBits(8);
         setConfigAlphaBits(8);
     }
+
+    virtual void SetUp()
+    {
+        ANGLETest::SetUp();
+
+        mVertexShaderSource = SHADER_SOURCE
+        (
+            attribute vec4 inputAttribute;
+            void main()
+            {
+                gl_Position = inputAttribute;
+            }
+        );
+    }
+
+    std::string mVertexShaderSource;
 };
 
-TEST_F(GLSLStructTest, scoped_structs_bug)
+TEST_F(GLSLStructTest, nameless_scoped_structs)
 {
-    const std::string vertexShaderSource = SHADER_SOURCE
+    const std::string fragmentShaderSource = SHADER_SOURCE
     (
-        attribute vec4 inputAttribute;
+        precision mediump float;
+
         void main()
         {
-            gl_Position = inputAttribute;
+            struct
+            {
+                float q;
+            } b;
+
+            gl_FragColor = vec4(1, 0, 0, 1);
+            gl_FragColor.a += b.q;
         }
     );
 
+    GLuint program = compileProgram(mVertexShaderSource, fragmentShaderSource);
+    EXPECT_NE(0u, program);
+}
+TEST_F(GLSLStructTest, scoped_structs_order_bug)
+{
+    const std::string fragmentShaderSource = SHADER_SOURCE
+    (
+        precision mediump float;
+
+        struct T
+        {
+            float f;
+        };
+
+        void main()
+        {
+            T a;
+
+            struct T
+            {
+                float q;
+            };
+
+            T b;
+
+            gl_FragColor = vec4(1, 0, 0, 1);
+            gl_FragColor.a += a.f;
+            gl_FragColor.a += b.q;
+        }
+    );
+
+    GLuint program = compileProgram(mVertexShaderSource, fragmentShaderSource);
+    EXPECT_NE(0u, program);
+}
+
+TEST_F(GLSLStructTest, scoped_structs_bug)
+{
     const std::string fragmentShaderSource = SHADER_SOURCE
     (
         precision mediump float;
@@ -51,6 +111,6 @@
         }
     );
 
-    GLuint program = compileProgram(vertexShaderSource, fragmentShaderSource);
+    GLuint program = compileProgram(mVertexShaderSource, fragmentShaderSource);
     EXPECT_NE(0u, program);
 }