Validate uniforms and attributes name conflicts when linking
Uniforms and attribute names have global scope, according to:
GLSL 1.017 sections 4.2.6, 4.3.3 and 4.3.4.
Thus, they can't have same names.
BUG=angleproject:2014
Change-Id: Ibeb064aca877e404a67b9e3e9b57a0cc42e86f9f
diff --git a/src/tests/gl_tests/WebGLCompatibilityTest.cpp b/src/tests/gl_tests/WebGLCompatibilityTest.cpp
index 22b3368..eea9553 100644
--- a/src/tests/gl_tests/WebGLCompatibilityTest.cpp
+++ b/src/tests/gl_tests/WebGLCompatibilityTest.cpp
@@ -1511,6 +1511,28 @@
EXPECT_EQ(0u, program);
}
+// Tests global namespace conflicts between uniforms and attributes.
+// Based on WebGL test conformance/glsl/misc/shaders-with-name-conflicts.html.
+TEST_P(WebGLCompatibilityTest, GlobalNamesConflict)
+{
+ const std::string vertexShader =
+ "attribute vec4 foo;\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = foo;\n"
+ "}";
+ const std::string fragmentShader =
+ "precision mediump float;\n"
+ "uniform vec4 foo;\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = foo;\n"
+ "}";
+
+ GLuint program = CompileProgram(vertexShader, fragmentShader);
+ EXPECT_EQ(0u, program);
+}
+
// Test dimension and image size validation of compressed textures
TEST_P(WebGLCompatibilityTest, CompressedTextureS3TC)
{