D3D11: Fix provoking vertex for flat triangle strips.

Triangle strips alternate the provoking vertex based on the
primitive, so use the primitive ID in the GS to determine this.
This might interact poorly with primitive restart, so we might have
to use a slow path for that.

BUG=angleproject:754

Change-Id: I4f6f520887d4c4c52d2ad020e6db148607f68325
Reviewed-on: https://chromium-review.googlesource.com/309156
Tryjob-Request: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/DynamicHLSL.cpp b/src/libANGLE/renderer/d3d/DynamicHLSL.cpp
index 32791b2..fa684f4 100644
--- a/src/libANGLE/renderer/d3d/DynamicHLSL.cpp
+++ b/src/libANGLE/renderer/d3d/DynamicHLSL.cpp
@@ -1436,17 +1436,30 @@
 
     shaderStream << preambleString << "\n"
                  << "[maxvertexcount(" << maxVertexOutput << ")]\n"
-                 << "void main(" << inputPT << " GS_INPUT input[" << inputSize << "],"
-                                                                                  " inout "
-                 << outputPT << "Stream<GS_OUTPUT> outStream)\n"
+                 << "void main(" << inputPT << " GS_INPUT input[" << inputSize << "], ";
+
+    if (primitiveType == PRIMITIVE_TRIANGLE_STRIP)
+    {
+        shaderStream << "uint primitiveID : SV_PrimitiveID, ";
+    }
+
+    shaderStream << " inout " << outputPT << "Stream<GS_OUTPUT> outStream)\n"
                  << "{\n"
                  << "    GS_OUTPUT output = (GS_OUTPUT)0;\n";
 
-    int flatVertexIndex = inputSize - 1;
+    if (primitiveType == PRIMITIVE_TRIANGLE_STRIP)
+    {
+        shaderStream << "    uint lastVertexIndex = (primitiveID % 2 == 0 ? 2 : 1);\n";
+    }
+    else
+    {
+        shaderStream << "    uint lastVertexIndex = " << (inputSize - 1) << ";\n";
+    }
+
     for (int vertexIndex = 0; vertexIndex < inputSize; ++vertexIndex)
     {
-        shaderStream << "    copyVertex(output, input[" << vertexIndex << "], input["
-                     << flatVertexIndex << "]);\n";
+        shaderStream << "    copyVertex(output, input[" << vertexIndex
+                     << "], input[lastVertexIndex]);\n";
 
         if (!pointSprites)
         {