D3D: Fix incorrect instanced vertex offsets.

The spec says that DrawElements is equivalent to the instanced
call with an instance ID of zero. This patch fixes a bug in our
VertexDataManager where we would sometimes ignore the attribute divisor
for DrawElements, and stream the wrong amount of data/wrong start
offset.

BUG=angleproject:1213
TEST=dEQP-GLES3.functional.draw.draw_elements.*
TEST=dEQP-GLES3.functional.draw.draw_range_elements.*
TEST=dEQP-GLES3.functional.draw.random.*

Change-Id: I1c430a14ab3be68a24e233e9cdd1e4fd88c920a0
Reviewed-on: https://chromium-review.googlesource.com/312062
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/VertexDataManager.cpp b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
index 5376e6c..b392d0f 100644
--- a/src/libANGLE/renderer/d3d/VertexDataManager.cpp
+++ b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
@@ -290,7 +290,7 @@
     bool directStorage = vertexBuffer->directStoragePossible(attrib, translated->currentValueType);
 
     // Instanced vertices do not apply the 'start' offset
-    GLint firstVertexIndex = (instances > 0 && attrib.divisor > 0 ? 0 : start);
+    GLint firstVertexIndex = (attrib.divisor > 0 ? 0 : start);
 
     translated->vertexBuffer = vertexBuffer->getVertexBuffer();
 
@@ -357,7 +357,8 @@
             (static_cast<unsigned int>(attrib.offset) /
              static_cast<unsigned int>(ComputeVertexAttributeStride(attrib))) *
             outputElementSize;
-        unsigned int startOffset = (instances == 0 || attrib.divisor == 0) ? firstVertexIndex * outputElementSize : 0;
+        ASSERT(attrib.divisor == 0 || firstVertexIndex == 0);
+        unsigned int startOffset = firstVertexIndex * outputElementSize;
         if (streamOffset + firstElementOffset + startOffset < streamOffset)
         {
             return gl::Error(GL_OUT_OF_MEMORY);
diff --git a/src/tests/deqp_support/deqp_gles3_test_expectations.txt b/src/tests/deqp_support/deqp_gles3_test_expectations.txt
index e0d7548..2d447ad 100644
--- a/src/tests/deqp_support/deqp_gles3_test_expectations.txt
+++ b/src/tests/deqp_support/deqp_gles3_test_expectations.txt
@@ -1051,23 +1051,8 @@
 1101 WIN : dEQP-GLES3.functional.state_query.internal_format.rgb_samples = FAIL
 1101 WIN : dEQP-GLES3.functional.polygon_offset.fixed16_render_with_units = FAIL
 1101 WIN : dEQP-GLES3.functional.polygon_offset.fixed24_render_with_units = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.draw_elements.points.instanced_attributes = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.draw_elements.triangle_strip.instanced_attributes = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.draw_elements.lines.instanced_attributes = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.draw_elements.line_strip.instanced_attributes = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.draw_elements.line_loop.instanced_attributes = FAIL
 1101 WIN : dEQP-GLES3.functional.draw.draw_arrays_instanced.line_loop.instanced_attributes = FAIL
 1101 WIN : dEQP-GLES3.functional.draw.draw_elements_instanced.line_loop.instanced_attributes = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.draw_range_elements.points.instanced_attributes = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.draw_range_elements.triangles.instanced_attributes = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.draw_range_elements.triangle_fan.instanced_attributes = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.draw_range_elements.triangle_strip.instanced_attributes = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.draw_range_elements.lines.instanced_attributes = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.draw_range_elements.line_strip.instanced_attributes = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.draw_range_elements.line_loop.instanced_attributes = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.random.50 = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.random.186 = FAIL
-1101 WIN : dEQP-GLES3.functional.draw.random.210 = FAIL
 1101 WIN : dEQP-GLES3.functional.flush_finish.flush = FAIL
 1101 WIN : dEQP-GLES3.functional.lifetime.gen.transform_feedback = FAIL
 1101 WIN : dEQP-GLES3.functional.lifetime.gen.vertex_array = FAIL