Don't no-op draw calls for zero count in validation.

Make the no-op happen in the Context, so we can properly generator
more errors for negative WebGL tests. Some validation tests still
need to check for no-ops, such as range checks.

BUG=angleproject:2050

Change-Id: I48d0b3cf640f7f128679600e5df108146cfd6348
Reviewed-on: https://chromium-review.googlesource.com/522869
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index 65252e8..5aeb75c 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -1781,6 +1781,12 @@
 
 void Context::drawArrays(GLenum mode, GLint first, GLsizei count)
 {
+    // No-op if zero count
+    if (count == 0)
+    {
+        return;
+    }
+
     ANGLE_CONTEXT_TRY(prepareForDraw());
     ANGLE_CONTEXT_TRY(mImplementation->drawArrays(this, mode, first, count));
     MarkTransformFeedbackBufferUsage(mGLState.getCurrentTransformFeedback());
@@ -1788,6 +1794,12 @@
 
 void Context::drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
 {
+    // No-op if zero count
+    if (count == 0 || instanceCount == 0)
+    {
+        return;
+    }
+
     ANGLE_CONTEXT_TRY(prepareForDraw());
     ANGLE_CONTEXT_TRY(
         mImplementation->drawArraysInstanced(this, mode, first, count, instanceCount));
@@ -1796,6 +1808,12 @@
 
 void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices)
 {
+    // No-op if zero count
+    if (count == 0)
+    {
+        return;
+    }
+
     ANGLE_CONTEXT_TRY(prepareForDraw());
     ANGLE_CONTEXT_TRY(mImplementation->drawElements(this, mode, count, type, indices));
 }
@@ -1806,6 +1824,12 @@
                                     const void *indices,
                                     GLsizei instances)
 {
+    // No-op if zero count
+    if (count == 0 || instances == 0)
+    {
+        return;
+    }
+
     ANGLE_CONTEXT_TRY(prepareForDraw());
     ANGLE_CONTEXT_TRY(
         mImplementation->drawElementsInstanced(this, mode, count, type, indices, instances));
@@ -1818,6 +1842,12 @@
                                 GLenum type,
                                 const void *indices)
 {
+    // No-op if zero count
+    if (count == 0)
+    {
+        return;
+    }
+
     ANGLE_CONTEXT_TRY(prepareForDraw());
     ANGLE_CONTEXT_TRY(
         mImplementation->drawRangeElements(this, mode, start, end, count, type, indices));