D3D11: Allow gl_PointCoord when not rendering points.

ANGLE D3D11 uses a geometry shader to expand points into quads.
This led to an edge case with gl_PointCoord. When the user references
gl_PointCoord in the fragment shader but renders with GL_TRIANGLES or
other non-point primitives, gl_PointCoord is undefined, but ANGLE
would produce a link error. This would break some very odd edge-case
shaders (e.g. a shader that is used with both points and triangles).

We can fix this by simply adding a dummy PointCoord value to our
vertex shader is all cases. If the user renders points, we ignore the
PointCoord value passed to the geometry shader. If they render tris
or lines and use PointCoord, the shader signatures will match, and
PointCoord will even have a sane value of (0.5, 0.5).

BUG=angleproject:1380

Change-Id: I322155cd3801d0241cabc9bb639a5aaa502831b3
Reviewed-on: https://chromium-review.googlesource.com/362779
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
diff --git a/src/tests/gl_tests/GLSLTest.cpp b/src/tests/gl_tests/GLSLTest.cpp
index f8b77a9..4850aa6 100644
--- a/src/tests/gl_tests/GLSLTest.cpp
+++ b/src/tests/gl_tests/GLSLTest.cpp
@@ -2134,6 +2134,30 @@
     EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
 }
 
+// Test that using gl_PointCoord with GL_TRIANGLES doesn't produce a link error.
+// From WebGL test conformance/rendering/point-specific-shader-variables.html
+// See http://anglebug.com/1380
+TEST_P(GLSLTest, RenderTrisWithPointCoord)
+{
+    const std::string &vert =
+        "attribute vec2 aPosition;\n"
+        "void main()\n"
+        "{\n"
+        "    gl_Position = vec4(aPosition, 0, 1);\n"
+        "    gl_PointSize = 1.0;\n"
+        "}";
+    const std::string &frag =
+        "void main()\n"
+        "{\n"
+        "    gl_FragColor = vec4(gl_PointCoord.xy, 0, 1);\n"
+        "    gl_FragColor = vec4(0, 1, 0, 1);\n"
+        "}";
+
+    ANGLE_GL_PROGRAM(prog, vert, frag);
+    drawQuad(prog.get(), "aPosition", 0.5f);
+    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
+}
+
 // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
 ANGLE_INSTANTIATE_TEST(GLSLTest,
                        ES2_D3D9(),