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);