Commit 41997e76 by Olli Etuaho Committed by Commit Bot

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/332142Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent f26ada3b
......@@ -1098,18 +1098,7 @@ bool ValidateReadnPixelsEXT(Context *context,
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 @@ bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n, const GLuint *ids)
return false;
}
return ValidateGenQueriesBase(context, n, ids);
}
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;
return ValidateGenOrDelete(context, n);
}
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 @@ bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n, const GLuint *ids
return false;
}
return ValidateDeleteQueriesBase(context, n, ids);
return ValidateGenOrDelete(context, n);
}
bool ValidateBeginQueryBase(gl::Context *context, GLenum target, GLuint id)
......@@ -2442,28 +2420,6 @@ bool ValidateBindVertexArrayBase(Context *context, GLuint array)
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 @@ bool ValidateCopyTexSubImage2D(Context *context,
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
......@@ -105,10 +105,8 @@ bool ValidateReadnPixelsEXT(Context *context,
GLsizei bufSize,
GLvoid *pixels);
bool ValidateGenQueriesBase(gl::Context *context, GLsizei n, const GLuint *ids);
bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n, const GLuint *ids);
bool ValidateDeleteQueriesBase(gl::Context *context, GLsizei n, const GLuint *ids);
bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n, const GLuint *ids);
bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n);
bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n);
bool ValidateBeginQueryBase(Context *context, GLenum target, GLuint id);
bool ValidateBeginQueryEXT(Context *context, GLenum target, GLuint id);
bool ValidateEndQueryBase(Context *context, GLenum target);
......@@ -202,8 +200,6 @@ bool ValidateEGLImageTargetRenderbufferStorageOES(Context *context,
egl::Image *image);
bool ValidateBindVertexArrayBase(Context *context, GLuint array);
bool ValidateDeleteVertexArraysBase(Context *context, GLsizei n);
bool ValidateGenVertexArraysBase(Context *context, GLsizei n);
bool ValidateProgramBinaryBase(Context *context,
GLuint program,
......@@ -237,6 +233,17 @@ bool ValidateCopyTexSubImage2D(Context *context,
GLsizei width,
GLsizei height);
bool ValidateGenBuffers(Context *context, GLint n, GLuint *buffers);
bool ValidateDeleteBuffers(Context *context, GLint n, const GLuint *buffers);
bool ValidateGenFramebuffers(Context *context, GLint n, GLuint *framebuffers);
bool ValidateDeleteFramebuffers(Context *context, GLint n, const GLuint *framebuffers);
bool ValidateGenRenderbuffers(Context *context, GLint n, GLuint *renderbuffers);
bool ValidateDeleteRenderbuffers(Context *context, GLint n, const GLuint *renderbuffers);
bool ValidateGenTextures(Context *context, GLint n, GLuint *textures);
bool ValidateDeleteTextures(Context *context, GLint n, const GLuint *textures);
bool ValidateGenOrDelete(Context *context, GLint n);
// Error messages shared here for use in testing.
extern const char *g_ExceedsMaxElementErrorMessage;
} // namespace gl
......
......@@ -1050,7 +1050,7 @@ bool ValidateDeleteVertexArraysOES(Context *context, GLsizei n)
return false;
}
return ValidateDeleteVertexArraysBase(context, n);
return ValidateGenOrDelete(context, n);
}
bool ValidateGenVertexArraysOES(Context *context, GLsizei n)
......@@ -1061,7 +1061,7 @@ bool ValidateGenVertexArraysOES(Context *context, GLsizei n)
return false;
}
return ValidateGenVertexArraysBase(context, n);
return ValidateGenOrDelete(context, n);
}
bool ValidateIsVertexArrayOES(Context *context)
......
......@@ -1116,28 +1116,6 @@ bool ValidateES3TexStorage3DParameters(Context *context,
height, depth);
}
bool ValidateGenQueries(gl::Context *context, GLsizei n, const GLuint *ids)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION, "GLES version < 3.0"));
return false;
}
return ValidateGenQueriesBase(context, n, ids);
}
bool ValidateDeleteQueries(gl::Context *context, GLsizei n, const GLuint *ids)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION, "GLES version < 3.0"));
return false;
}
return ValidateDeleteQueriesBase(context, n, ids);
}
bool ValidateBeginQuery(gl::Context *context, GLenum target, GLuint id)
{
if (context->getClientVersion() < 3)
......@@ -1527,28 +1505,6 @@ bool ValidateBindVertexArray(Context *context, GLuint array)
return ValidateBindVertexArrayBase(context, array);
}
bool ValidateDeleteVertexArrays(Context *context, GLsizei n)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
}
return ValidateDeleteVertexArraysBase(context, n);
}
bool ValidateGenVertexArrays(Context *context, GLsizei n)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
}
return ValidateGenVertexArraysBase(context, n);
}
bool ValidateIsVertexArray(Context *context)
{
if (context->getClientVersion() < 3)
......@@ -1868,4 +1824,84 @@ bool ValidateCompressedTexSubImage3D(Context *context,
width, height, depth, 0, GL_NONE, GL_NONE, data);
}
bool ValidateGenQueries(Context *context, GLint n, GLuint *)
{
return ValidateGenOrDeleteES3(context, n);
}
bool ValidateDeleteQueries(Context *context, GLint n, const GLuint *)
{
return ValidateGenOrDeleteES3(context, n);
}
bool ValidateGenSamplers(Context *context, GLint count, GLuint *)
{
return ValidateGenOrDeleteCountES3(context, count);
}
bool ValidateDeleteSamplers(Context *context, GLint count, const GLuint *)
{
return ValidateGenOrDeleteCountES3(context, count);
}
bool ValidateGenTransformFeedbacks(Context *context, GLint n, GLuint *)
{
return ValidateGenOrDeleteES3(context, n);
}
bool ValidateDeleteTransformFeedbacks(Context *context, GLint n, const GLuint *ids)
{
if (!ValidateGenOrDeleteES3(context, n))
{
return false;
}
for (GLint i = 0; i < n; ++i)
{
auto *transformFeedback = context->getTransformFeedback(ids[i]);
if (transformFeedback != nullptr && transformFeedback->isActive())
{
// ES 3.0.4 section 2.15.1 page 86
context->recordError(
Error(GL_INVALID_OPERATION, "Attempt to delete active transform feedback."));
return false;
}
}
return true;
}
bool ValidateGenVertexArrays(Context *context, GLint n, GLuint *)
{
return ValidateGenOrDeleteES3(context, n);
}
bool ValidateDeleteVertexArrays(Context *context, GLint n, const GLuint *)
{
return ValidateGenOrDeleteES3(context, n);
}
bool ValidateGenOrDeleteES3(Context *context, GLint n)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3."));
return false;
}
return ValidateGenOrDelete(context, n);
}
bool ValidateGenOrDeleteCountES3(Context *context, GLint count)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3."));
return false;
}
if (count < 0)
{
context->recordError(Error(GL_INVALID_VALUE, "count < 0"));
return false;
}
return true;
}
} // namespace gl
......@@ -141,10 +141,6 @@ bool ValidateES3TexStorage3DParameters(Context *context,
GLsizei height,
GLsizei depth);
bool ValidateGenQueries(Context *context, GLsizei n, const GLuint *ids);
bool ValidateDeleteQueries(Context *context, GLsizei n, const GLuint *ids);
bool ValidateBeginQuery(Context *context, GLenum target, GLuint id);
bool ValidateEndQuery(Context *context, GLenum target);
......@@ -182,8 +178,6 @@ bool ValidateCompressedTexImage3D(Context *context,
const GLvoid *data);
bool ValidateBindVertexArray(Context *context, GLuint array);
bool ValidateDeleteVertexArrays(Context *context, GLsizei n);
bool ValidateGenVertexArrays(Context *context, GLsizei n);
bool ValidateIsVertexArray(Context *context);
bool ValidateProgramBinary(Context *context,
......@@ -273,6 +267,18 @@ bool ValidateCompressedTexSubImage3D(Context *context,
GLsizei imageSize,
const GLvoid *data);
bool ValidateGenQueries(Context *context, GLint n, GLuint *ids);
bool ValidateDeleteQueries(Context *context, GLint n, const GLuint *ids);
bool ValidateGenSamplers(Context *context, GLint count, GLuint *samplers);
bool ValidateDeleteSamplers(Context *context, GLint count, const GLuint *samplers);
bool ValidateGenTransformFeedbacks(Context *context, GLint n, GLuint *ids);
bool ValidateDeleteTransformFeedbacks(Context *context, GLint n, const GLuint *ids);
bool ValidateGenVertexArrays(Context *context, GLint n, GLuint *arrays);
bool ValidateDeleteVertexArrays(Context *context, GLint n, const GLuint *arrays);
bool ValidateGenOrDeleteES3(Context *context, GLint n);
bool ValidateGenOrDeleteCountES3(Context *context, GLint count);
} // namespace gl
#endif // LIBANGLE_VALIDATION_ES3_H_
......@@ -813,9 +813,8 @@ void GL_APIENTRY DeleteBuffers(GLsizei n, const GLuint* buffers)
Context *context = GetValidGlobalContext();
if (context)
{
if (n < 0)
if (!context->skipValidation() && !ValidateDeleteBuffers(context, n, buffers))
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
......@@ -833,9 +832,8 @@ void GL_APIENTRY DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
Context *context = GetValidGlobalContext();
if (context)
{
if (n < 0)
if (!context->skipValidation() && !ValidateDeleteFramebuffers(context, n, framebuffers))
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
......@@ -886,9 +884,8 @@ void GL_APIENTRY DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
Context *context = GetValidGlobalContext();
if (context)
{
if (n < 0)
if (!context->skipValidation() && !ValidateDeleteRenderbuffers(context, n, renderbuffers))
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
......@@ -936,9 +933,8 @@ void GL_APIENTRY DeleteTextures(GLsizei n, const GLuint* textures)
Context *context = GetValidGlobalContext();
if (context)
{
if (n < 0)
if (!context->skipValidation() && !ValidateDeleteTextures(context, n, textures))
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
......@@ -1250,9 +1246,8 @@ void GL_APIENTRY GenBuffers(GLsizei n, GLuint* buffers)
Context *context = GetValidGlobalContext();
if (context)
{
if (n < 0)
if (!context->skipValidation() && !ValidateGenBuffers(context, n, buffers))
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
......@@ -1348,9 +1343,8 @@ void GL_APIENTRY GenFramebuffers(GLsizei n, GLuint* framebuffers)
Context *context = GetValidGlobalContext();
if (context)
{
if (n < 0)
if (!context->skipValidation() && !ValidateGenFramebuffers(context, n, framebuffers))
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
......@@ -1368,9 +1362,8 @@ void GL_APIENTRY GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
Context *context = GetValidGlobalContext();
if (context)
{
if (n < 0)
if (!context->skipValidation() && !ValidateGenRenderbuffers(context, n, renderbuffers))
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
......@@ -1388,9 +1381,8 @@ void GL_APIENTRY GenTextures(GLsizei n, GLuint* textures)
Context *context = GetValidGlobalContext();
if (context)
{
if (n < 0)
if (!context->skipValidation() && !ValidateGenTextures(context, n, textures))
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
......
......@@ -34,7 +34,7 @@ void GL_APIENTRY GenQueriesEXT(GLsizei n, GLuint *ids)
Context *context = GetValidGlobalContext();
if (context)
{
if (!ValidateGenQueriesEXT(context, n, ids))
if (!context->skipValidation() && !ValidateGenQueriesEXT(context, n))
{
return;
}
......@@ -53,7 +53,7 @@ void GL_APIENTRY DeleteQueriesEXT(GLsizei n, const GLuint *ids)
Context *context = GetValidGlobalContext();
if (context)
{
if (!ValidateDeleteQueriesEXT(context, n, ids))
if (!context->skipValidation() && !ValidateDeleteQueriesEXT(context, n))
{
return;
}
......
......@@ -199,7 +199,7 @@ void GL_APIENTRY GenQueries(GLsizei n, GLuint* ids)
Context *context = GetValidGlobalContext();
if (context)
{
if (!ValidateGenQueries(context, n, ids))
if (!context->skipValidation() && !ValidateGenQueries(context, n, ids))
{
return;
}
......@@ -218,7 +218,7 @@ void GL_APIENTRY DeleteQueries(GLsizei n, const GLuint* ids)
Context *context = GetValidGlobalContext();
if (context)
{
if (!ValidateDeleteQueries(context, n, ids))
if (!context->skipValidation() && !ValidateDeleteQueries(context, n, ids))
{
return;
}
......@@ -609,7 +609,7 @@ void GL_APIENTRY DeleteVertexArrays(GLsizei n, const GLuint* arrays)
Context *context = GetValidGlobalContext();
if (context)
{
if (!ValidateDeleteVertexArrays(context, n))
if (!context->skipValidation() && !ValidateDeleteVertexArrays(context, n, arrays))
{
return;
}
......@@ -631,7 +631,7 @@ void GL_APIENTRY GenVertexArrays(GLsizei n, GLuint* arrays)
Context *context = GetValidGlobalContext();
if (context)
{
if (!ValidateGenVertexArrays(context, n))
if (!context->skipValidation() && !ValidateGenVertexArrays(context, n, arrays))
{
return;
}
......@@ -2327,15 +2327,8 @@ void GL_APIENTRY GenSamplers(GLsizei count, GLuint* samplers)
Context *context = GetValidGlobalContext();
if (context)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION));
return;
}
if (count < 0)
if (!context->skipValidation() && !ValidateGenSamplers(context, count, samplers))
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
......@@ -2353,15 +2346,8 @@ void GL_APIENTRY DeleteSamplers(GLsizei count, const GLuint* samplers)
Context *context = GetValidGlobalContext();
if (context)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION));
return;
}
if (count < 0)
if (!context->skipValidation() && !ValidateDeleteSamplers(context, count, samplers))
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
......@@ -2627,9 +2613,8 @@ void GL_APIENTRY DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
Context *context = GetValidGlobalContext();
if (context)
{
if (context->getClientVersion() < 3)
if (!context->skipValidation() && !ValidateDeleteTransformFeedbacks(context, n, ids))
{
context->recordError(Error(GL_INVALID_OPERATION));
return;
}
......@@ -2647,9 +2632,8 @@ void GL_APIENTRY GenTransformFeedbacks(GLsizei n, GLuint* ids)
Context *context = GetValidGlobalContext();
if (context)
{
if (context->getClientVersion() < 3)
if (!context->skipValidation() && !ValidateGenTransformFeedbacks(context, n, ids))
{
context->recordError(Error(GL_INVALID_OPERATION));
return;
}
......
......@@ -57,8 +57,6 @@
1101 WIN LINUX : dEQP-GLES3.functional.negative_api.shader.link_program = FAIL
1101 WIN LINUX : dEQP-GLES3.functional.negative_api.shader.use_program = FAIL
1101 WIN LINUX : dEQP-GLES3.functional.negative_api.shader.sampler_parameterfv = FAIL
1101 WIN LINUX : dEQP-GLES3.functional.negative_api.shader.gen_transform_feedbacks = FAIL
1101 WIN LINUX : dEQP-GLES3.functional.negative_api.shader.delete_transform_feedbacks = FAIL
1101 WIN LINUX : dEQP-GLES3.functional.negative_api.fragment.begin_query = FAIL
1101 WIN LINUX : dEQP-GLES3.functional.negative_api.vertex_array.vertex_attrib_i_pointer = FAIL
1101 WIN LINUX : dEQP-GLES3.functional.negative_api.vertex_array.draw_range_elements = FAIL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment