Improve validation of Gen/Delete calls
Add checks for negative count to GenTransformFeedbacks and
DeleteTransformFeedbacks, and check for active transform feedbacks in
DeleteTransformFeedbacks.
Unify validation and error messages of all other Gen/Delete calls.
BUG=angleproject:1101
TEST=dEQP-GLES3.functional.negative_api.* (two more tests pass)
Change-Id: I128063fab3db27a25e282a10c916c53646d68b9c
Reviewed-on: https://chromium-review.googlesource.com/332142
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index ddc32c4..9d015b6 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -1098,18 +1098,7 @@
return ValidateReadPixels(context, x, y, width, height, format, type, pixels);
}
-bool ValidateGenQueriesBase(gl::Context *context, GLsizei n, const GLuint *ids)
-{
- if (n < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE, "Query count < 0"));
- return false;
- }
-
- return true;
-}
-
-bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n, const GLuint *ids)
+bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n)
{
if (!context->getExtensions().occlusionQueryBoolean &&
!context->getExtensions().disjointTimerQuery)
@@ -1118,21 +1107,10 @@
return false;
}
- return ValidateGenQueriesBase(context, n, ids);
+ return ValidateGenOrDelete(context, n);
}
-bool ValidateDeleteQueriesBase(gl::Context *context, GLsizei n, const GLuint *ids)
-{
- if (n < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE, "Query count < 0"));
- return false;
- }
-
- return true;
-}
-
-bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n, const GLuint *ids)
+bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n)
{
if (!context->getExtensions().occlusionQueryBoolean &&
!context->getExtensions().disjointTimerQuery)
@@ -1141,7 +1119,7 @@
return false;
}
- return ValidateDeleteQueriesBase(context, n, ids);
+ return ValidateGenOrDelete(context, n);
}
bool ValidateBeginQueryBase(gl::Context *context, GLenum target, GLuint id)
@@ -2442,28 +2420,6 @@
return true;
}
-bool ValidateDeleteVertexArraysBase(Context *context, GLsizei n)
-{
- if (n < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- return true;
-}
-
-bool ValidateGenVertexArraysBase(Context *context, GLsizei n)
-{
- if (n < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- return true;
-}
-
bool ValidateProgramBinaryBase(Context *context,
GLuint program,
GLenum binaryFormat,
@@ -2640,4 +2596,54 @@
yoffset, 0, x, y, width, height, 0);
}
+bool ValidateGenBuffers(Context *context, GLint n, GLuint *)
+{
+ return ValidateGenOrDelete(context, n);
+}
+
+bool ValidateDeleteBuffers(Context *context, GLint n, const GLuint *)
+{
+ return ValidateGenOrDelete(context, n);
+}
+
+bool ValidateGenFramebuffers(Context *context, GLint n, GLuint *)
+{
+ return ValidateGenOrDelete(context, n);
+}
+
+bool ValidateDeleteFramebuffers(Context *context, GLint n, const GLuint *)
+{
+ return ValidateGenOrDelete(context, n);
+}
+
+bool ValidateGenRenderbuffers(Context *context, GLint n, GLuint *)
+{
+ return ValidateGenOrDelete(context, n);
+}
+
+bool ValidateDeleteRenderbuffers(Context *context, GLint n, const GLuint *)
+{
+ return ValidateGenOrDelete(context, n);
+}
+
+bool ValidateGenTextures(Context *context, GLint n, GLuint *)
+{
+ return ValidateGenOrDelete(context, n);
+}
+
+bool ValidateDeleteTextures(Context *context, GLint n, const GLuint *)
+{
+ return ValidateGenOrDelete(context, n);
+}
+
+bool ValidateGenOrDelete(Context *context, GLint n)
+{
+ if (n < 0)
+ {
+ context->recordError(Error(GL_INVALID_VALUE, "n < 0"));
+ return false;
+ }
+ return true;
+}
+
} // namespace gl