Fix buffer mapping validation and refactor entry points

Checks for extension support are added to GetBufferPointervOES,
mapBufferOES, unmapBufferOES, mapBufferRangeEXT and
flushMappedBufferRangeEXT.

The GetBufferPointerv function now checks if state is queried from
buffer object zero.

The code is also refactored so that validation happens in separate
validation functions and the implementations are in Context functions.

BUG=angleproject:1101
TEST=dEQP-GLES3.functional.negative_api.state.get_buffer_pointerv
     dEQP-GLES3.functional.*buffer*map* (no regression)

Change-Id: I0f439abd12c92c51324f2e5a31bf621f61534306
Reviewed-on: https://chromium-review.googlesource.com/336164
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
index 56b9450..c879ea5 100644
--- a/src/libANGLE/validationES3.cpp
+++ b/src/libANGLE/validationES3.cpp
@@ -2009,4 +2009,55 @@
     return ValidateSamplerParameteri(context, sampler, pname, static_cast<GLint>(param));
 }
 
+bool ValidateGetBufferPointerv(Context *context, GLenum target, GLenum pname, GLvoid **params)
+{
+    if (context->getClientVersion() < 3)
+    {
+        context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3."));
+        return false;
+    }
+
+    return ValidateGetBufferPointervBase(context, target, pname, params);
+}
+
+bool ValidateUnmapBuffer(Context *context, GLenum target)
+{
+    if (context->getClientVersion() < 3)
+    {
+        context->recordError(Error(GL_INVALID_OPERATION));
+        return false;
+    }
+
+    return ValidateUnmapBufferBase(context, target);
+}
+
+bool ValidateMapBufferRange(Context *context,
+                            GLenum target,
+                            GLintptr offset,
+                            GLsizeiptr length,
+                            GLbitfield access)
+{
+    if (context->getClientVersion() < 3)
+    {
+        context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3."));
+        return false;
+    }
+
+    return ValidateMapBufferRangeBase(context, target, offset, length, access);
+}
+
+bool ValidateFlushMappedBufferRange(Context *context,
+                                    GLenum target,
+                                    GLintptr offset,
+                                    GLsizeiptr length)
+{
+    if (context->getClientVersion() < 3)
+    {
+        context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3."));
+        return false;
+    }
+
+    return ValidateFlushMappedBufferRangeBase(context, target, offset, length);
+}
+
 }  // namespace gl