Implement support for ES 3.0 instanced arrays
BUG=angle:863
Change-Id: I3918c478b33b26b2b179a7f8dd6e4210ecb0cf5c
Reviewed-on: https://chromium-review.googlesource.com/239170
Tested-by: Gregoire Payen de La Garanderie <Gregory.Payen@imgtec.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/VertexDataManager.cpp b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
index d3eab8b..237c0ad 100644
--- a/src/libANGLE/renderer/d3d/VertexDataManager.cpp
+++ b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
@@ -46,7 +46,9 @@
// non-instanced vertices, and the instanced vertex index advances once every "mDivisor" instances.
if (instanceDrawCount > 0 && attrib.divisor > 0)
{
- return instanceDrawCount / attrib.divisor;
+ // When instanceDrawCount is not a multiple attrib.divisor, the division must round up.
+ // For instance, with 5 non-instanced vertices and a divisor equal to 3, we need 2 instanced vertices.
+ return (instanceDrawCount + attrib.divisor - 1) / attrib.divisor;
}
return vertexDrawCount;
diff --git a/src/libGLESv2/entry_points_gles_3_0.cpp b/src/libGLESv2/entry_points_gles_3_0.cpp
index 426b4b2..515f982 100644
--- a/src/libGLESv2/entry_points_gles_3_0.cpp
+++ b/src/libGLESv2/entry_points_gles_3_0.cpp
@@ -2265,8 +2265,17 @@
return;
}
- // glDrawArraysInstanced
- UNIMPLEMENTED();
+ if (!ValidateDrawArraysInstanced(context, mode, first, count, instanceCount))
+ {
+ return;
+ }
+
+ Error error = context->drawArrays(mode, first, count, instanceCount);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
}
@@ -2284,8 +2293,18 @@
return;
}
- // glDrawElementsInstanced
- UNIMPLEMENTED();
+ rx::RangeUI indexRange;
+ if (!ValidateDrawElementsInstanced(context, mode, count, type, indices, instanceCount, &indexRange))
+ {
+ return;
+ }
+
+ Error error = context->drawElements(mode, count, type, indices, instanceCount, indexRange);
+ if (error.isError())
+ {
+ context->recordError(error);
+ return;
+ }
}
}