Implement remaining robust Get entry points. BUG=angleproject:1354 Change-Id: I204962a7178d47a43034d0213c81b82d8f6a25be Reviewed-on: https://chromium-review.googlesource.com/399043 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp index 6fdae40..a41e3f6 100644 --- a/src/libANGLE/validationES.cpp +++ b/src/libANGLE/validationES.cpp
@@ -167,19 +167,6 @@ } } -bool ValidateRobustBufferSize(ValidationContext *context, GLsizei bufSize, GLsizei numParams) -{ - if (bufSize < numParams) - { - context->handleError(Error(GL_INVALID_OPERATION, - "%u parameters are required but %i were provided.", numParams, - bufSize)); - return false; - } - - return true; -} - bool ValidateReadPixelsBase(ValidationContext *context, GLint x, GLint y, @@ -3946,6 +3933,19 @@ return true; } +bool ValidateRobustBufferSize(ValidationContext *context, GLsizei bufSize, GLsizei numParams) +{ + if (bufSize < numParams) + { + context->handleError(Error(GL_INVALID_OPERATION, + "%u parameters are required but %i were provided.", numParams, + bufSize)); + return false; + } + + return true; +} + bool ValidateGetFramebufferAttachmentParameteriv(ValidationContext *context, GLenum target, GLenum attachment,
diff --git a/src/libANGLE/validationES.h b/src/libANGLE/validationES.h index 0f872bf..0fc5999 100644 --- a/src/libANGLE/validationES.h +++ b/src/libANGLE/validationES.h
@@ -322,6 +322,7 @@ bool ValidateIsEnabled(Context *context, GLenum cap); bool ValidateRobustEntryPoint(ValidationContext *context, GLsizei bufSize); +bool ValidateRobustBufferSize(ValidationContext *context, GLsizei bufSize, GLsizei numParams); bool ValidateGetFramebufferAttachmentParameteriv(ValidationContext *context, GLenum target,
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp index 3585e67..03b48b3 100644 --- a/src/libANGLE/validationES3.cpp +++ b/src/libANGLE/validationES3.cpp
@@ -1779,8 +1779,16 @@ return ValidateFlushMappedBufferRangeBase(context, target, offset, length); } -bool ValidateIndexedStateQuery(ValidationContext *context, GLenum pname, GLuint index) +bool ValidateIndexedStateQuery(ValidationContext *context, + GLenum pname, + GLuint index, + GLsizei *length) { + if (length) + { + *length = 0; + } + GLenum nativeType; unsigned int numParams; if (!context->getIndexedQueryParameterInfo(pname, &nativeType, &numParams)) @@ -1824,10 +1832,9 @@ return false; } - // pname is valid, but there are no parameters to return - if (numParams == 0) + if (length) { - return false; + *length = 1; } return true; @@ -1840,7 +1847,7 @@ context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.0")); return false; } - return ValidateIndexedStateQuery(context, target, index); + return ValidateIndexedStateQuery(context, target, index, nullptr); } bool ValidateGetInteger64i_v(ValidationContext *context, GLenum target, GLuint index, GLint64 *data) @@ -1850,7 +1857,38 @@ context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.0")); return false; } - return ValidateIndexedStateQuery(context, target, index); + return ValidateIndexedStateQuery(context, target, index, nullptr); +} + +bool ValidateGetInteger64i_vRobustANGLE(ValidationContext *context, + GLenum target, + GLuint index, + GLsizei bufSize, + GLsizei *length, + GLint64 *data) +{ + if (!context->getGLVersion().isES3OrGreater()) + { + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.0")); + return false; + } + + if (!ValidateRobustEntryPoint(context, bufSize)) + { + return false; + } + + if (!ValidateIndexedStateQuery(context, target, index, length)) + { + return false; + } + + if (!ValidateRobustBufferSize(context, bufSize, *length)) + { + return false; + } + + return true; } } // namespace gl
diff --git a/src/libANGLE/validationES3.h b/src/libANGLE/validationES3.h index 17fe507..4fa5737 100644 --- a/src/libANGLE/validationES3.h +++ b/src/libANGLE/validationES3.h
@@ -303,12 +303,21 @@ GLintptr offset, GLsizeiptr length); -bool ValidateIndexedStateQuery(ValidationContext *context, GLenum pname, GLuint index); +bool ValidateIndexedStateQuery(ValidationContext *context, + GLenum pname, + GLuint index, + GLsizei *length); bool ValidateGetIntegeri_v(ValidationContext *context, GLenum target, GLuint index, GLint *data); bool ValidateGetInteger64i_v(ValidationContext *context, GLenum target, GLuint index, GLint64 *data); +bool ValidateGetInteger64i_vRobustANGLE(ValidationContext *context, + GLenum target, + GLuint index, + GLsizei bufSize, + GLsizei *length, + GLint64 *data); } // namespace gl #endif // LIBANGLE_VALIDATION_ES3_H_
diff --git a/src/libANGLE/validationES31.cpp b/src/libANGLE/validationES31.cpp index f740609..7d5bb4f 100644 --- a/src/libANGLE/validationES31.cpp +++ b/src/libANGLE/validationES31.cpp
@@ -6,10 +6,11 @@ // validationES31.cpp: Validation functions for OpenGL ES 3.1 entry point parameters -#include "libANGLE/validationES3.h" #include "libANGLE/validationES31.h" #include "libANGLE/Context.h" +#include "libANGLE/validationES.h" +#include "libANGLE/validationES3.h" using namespace angle; @@ -24,7 +25,38 @@ return false; } - if (!ValidateIndexedStateQuery(context, target, index)) + if (!ValidateIndexedStateQuery(context, target, index, nullptr)) + { + return false; + } + + return true; +} + +bool ValidateGetBooleani_vRobustANGLE(Context *context, + GLenum target, + GLuint index, + GLsizei bufSize, + GLsizei *length, + GLboolean *data) +{ + if (!context->getGLVersion().isES31()) + { + context->handleError(Error(GL_INVALID_OPERATION, "Context does not support GLES3.1")); + return false; + } + + if (!ValidateRobustEntryPoint(context, bufSize)) + { + return false; + } + + if (!ValidateIndexedStateQuery(context, target, index, length)) + { + return false; + } + + if (!ValidateRobustBufferSize(context, bufSize, *length)) { return false; }
diff --git a/src/libANGLE/validationES31.h b/src/libANGLE/validationES31.h index 517720c..63ca0db 100644 --- a/src/libANGLE/validationES31.h +++ b/src/libANGLE/validationES31.h
@@ -16,6 +16,12 @@ class Context; bool ValidateGetBooleani_v(Context *context, GLenum target, GLuint index, GLboolean *data); +bool ValidateGetBooleani_vRobustANGLE(Context *context, + GLenum target, + GLuint index, + GLsizei bufSize, + GLsizei *length, + GLboolean *data); } // namespace gl
diff --git a/src/libGLESv2/entry_points_gles_2_0_ext.cpp b/src/libGLESv2/entry_points_gles_2_0_ext.cpp index 31078e9..6197907 100644 --- a/src/libGLESv2/entry_points_gles_2_0_ext.cpp +++ b/src/libGLESv2/entry_points_gles_2_0_ext.cpp
@@ -23,6 +23,7 @@ #include "libANGLE/validationES.h" #include "libANGLE/validationES2.h" #include "libANGLE/validationES3.h" +#include "libANGLE/validationES31.h" #include "common/debug.h" #include "common/utilities.h" @@ -2733,7 +2734,27 @@ "(GLenum pname = 0x%X, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLint64* params = " "0x%0.8p)", pname, bufSize, length, data); - UNIMPLEMENTED(); + + Context *context = GetValidGlobalContext(); + if (context) + { + GLenum nativeType; + unsigned int numParams = 0; + if (!ValidateRobustStateQuery(context, pname, bufSize, &nativeType, &numParams)) + { + return; + } + + if (nativeType == GL_INT_64_ANGLEX) + { + context->getInteger64v(pname, data); + } + else + { + CastStateValues(context, nativeType, pname, numParams, data); + } + SetRobustLengthParam(length, numParams); + } } ANGLE_EXPORT void GL_APIENTRY GetInteger64i_vRobustANGLE(GLenum target, @@ -2746,7 +2767,19 @@ "(GLenum target = 0x%X, GLuint index = %u, GLsizei bufsize = %d, GLsizei* length = " "0x%0.8p, GLint64* data = 0x%0.8p)", target, index, bufSize, length, data); - UNIMPLEMENTED(); + + Context *context = GetValidGlobalContext(); + if (context) + { + GLsizei numParams = 0; + if (!ValidateGetInteger64i_vRobustANGLE(context, target, index, bufSize, &numParams, data)) + { + return; + } + + context->getInteger64i_v(target, index, data); + SetRobustLengthParam(length, numParams); + } } ANGLE_EXPORT void GL_APIENTRY GetBufferParameteri64vRobustANGLE(GLenum target, @@ -2893,7 +2926,18 @@ "(GLenum target = 0x%X, GLuint index = %u, GLsizei bufsize = %d, GLsizei* length = " "0x%0.8p, GLboolean* data = 0x%0.8p)", target, index, bufSize, length, data); - UNIMPLEMENTED(); + Context *context = GetValidGlobalContext(); + if (context) + { + GLsizei numParams = 0; + if (!ValidateGetBooleani_vRobustANGLE(context, target, index, bufSize, &numParams, data)) + { + return; + } + + context->getBooleani_v(target, index, data); + SetRobustLengthParam(length, numParams); + } } ANGLE_EXPORT void GL_APIENTRY GetMultisamplefvRobustANGLE(GLenum pname,