Move index range calculations into VertexArray.

This is in preparation for removing the entire DrawCallParams struct.
This struct was big enough to cause a performance hit on draw call perf
tests just by virtue of initializing the fields. Also dereferencing the
struct members is slower than reading function parameters since it adds
an indirection.

Also includes some error refactoring to enable moving code to a shared
location.

In total this patch series reduces overhead by up to 5%.

Bug: angleproject:2933
Change-Id: Ib663f2538c14ac30d4c31fd10d6350be469626e2
Reviewed-on: https://chromium-review.googlesource.com/c/1298380
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
index d5719fc..329d21b 100644
--- a/src/libANGLE/validationES3.cpp
+++ b/src/libANGLE/validationES3.cpp
@@ -17,6 +17,7 @@
 #include "libANGLE/FramebufferAttachment.h"
 #include "libANGLE/Renderbuffer.h"
 #include "libANGLE/Texture.h"
+#include "libANGLE/VertexArray.h"
 #include "libANGLE/formatutils.h"
 #include "libANGLE/validationES.h"
 
@@ -1432,11 +1433,10 @@
         return true;
     }
 
-    // Use the parameter buffer to retrieve and cache the index range.
-    const DrawCallParams &params = context->getParams<DrawCallParams>();
-    ANGLE_VALIDATION_TRY(params.ensureIndexRangeResolved(context));
-
-    const IndexRange &indexRange = params.getIndexRange();
+    // Note that resolving the index range is a bit slow. We should probably optimize this.
+    IndexRange indexRange;
+    ANGLE_VALIDATION_TRY(context->getGLState().getVertexArray()->getIndexRange(
+        context, type, count, indices, &indexRange));
 
     if (indexRange.end > end || indexRange.start < start)
     {