Refactor all the Bind* GLES 2.0 entry points.
This requires storing a reference the the Context's Framebuffer map
in the ValidationContext. Likely we'll need to do this as well for
the other non-shared object types.
BUG=angleproject:747
Change-Id: I73ee8b0be3c3b9e54b7e48e49d6f738cf1d926dd
Reviewed-on: https://chromium-review.googlesource.com/407843
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp
index b3de87e..78931cd 100644
--- a/src/libANGLE/validationES2.cpp
+++ b/src/libANGLE/validationES2.cpp
@@ -3618,4 +3618,78 @@
return true;
}
+bool ValidateBindAttribLocation(ValidationContext *context,
+ GLuint program,
+ GLuint index,
+ const GLchar *name)
+{
+ if (index >= MAX_VERTEX_ATTRIBS)
+ {
+ context->handleError(Error(GL_INVALID_VALUE, "Index exceeds MAX_VERTEX_ATTRIBS"));
+ return false;
+ }
+
+ if (strncmp(name, "gl_", 3) == 0)
+ {
+ context->handleError(Error(GL_INVALID_OPERATION, "Cannot Bind built-in attributes"));
+ return false;
+ }
+
+ return GetValidProgram(context, program) != nullptr;
+}
+
+bool ValidateBindBuffer(ValidationContext *context, GLenum target, GLuint buffer)
+{
+ if (!ValidBufferTarget(context, target))
+ {
+ context->handleError(Error(GL_INVALID_ENUM, "Invalid Buffer target"));
+ return false;
+ }
+
+ if (!context->getGLState().isBindGeneratesResourceEnabled() &&
+ !context->isBufferGenerated(buffer))
+ {
+ context->handleError(Error(GL_INVALID_OPERATION, "Buffer was not generated"));
+ return false;
+ }
+
+ return true;
+}
+
+bool ValidateBindFramebuffer(ValidationContext *context, GLenum target, GLuint framebuffer)
+{
+ if (!ValidFramebufferTarget(target))
+ {
+ context->handleError(Error(GL_INVALID_ENUM, "Invalid Framebuffer target"));
+ return false;
+ }
+
+ if (!context->getGLState().isBindGeneratesResourceEnabled() &&
+ !context->isFramebufferGenerated(framebuffer))
+ {
+ context->handleError(Error(GL_INVALID_OPERATION, "Framebuffer was not generated"));
+ return false;
+ }
+
+ return true;
+}
+
+bool ValidateBindRenderbuffer(ValidationContext *context, GLenum target, GLuint renderbuffer)
+{
+ if (target != GL_RENDERBUFFER)
+ {
+ context->handleError(Error(GL_INVALID_ENUM, "Invalid Renderbuffer target"));
+ return false;
+ }
+
+ if (!context->getGLState().isBindGeneratesResourceEnabled() &&
+ !context->isRenderbufferGenerated(renderbuffer))
+ {
+ context->handleError(Error(GL_INVALID_OPERATION, "Renderbuffer was not generated"));
+ return false;
+ }
+
+ return true;
+}
+
} // namespace gl