diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp index 1d7e0910348a4..a8d2fe3637dda 100644 --- a/src/libANGLE/validationES.cpp +++ b/src/libANGLE/validationES.cpp @@ -523,6 +523,14 @@ bool IsCompatibleDrawModeWithGeometryShader(GLenum drawMode, } // anonymous namespace +void SetRobustLengthParam(GLsizei *length, GLsizei value) +{ + if (length) + { + *length = value; + } +} + bool IsETC2EACFormat(const GLenum format) { // ES 3.1, Table 8.19 @@ -1482,17 +1490,25 @@ bool ValidateReadPixelsRobustANGLE(Context *context, return false; } - if (!ValidateReadPixelsBase(context, x, y, width, height, format, type, bufSize, length, - columns, rows, pixels)) + GLsizei writeLength = 0; + GLsizei writeColumns = 0; + GLsizei writeRows = 0; + + if (!ValidateReadPixelsBase(context, x, y, width, height, format, type, bufSize, &writeLength, + &writeColumns, &writeRows, pixels)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, writeLength)) { return false; } + SetRobustLengthParam(length, writeLength); + SetRobustLengthParam(columns, writeColumns); + SetRobustLengthParam(rows, writeRows); + return true; } @@ -1529,22 +1545,30 @@ bool ValidateReadnPixelsRobustANGLE(Context *context, GLsizei *rows, void *data) { + GLsizei writeLength = 0; + GLsizei writeColumns = 0; + GLsizei writeRows = 0; + if (!ValidateRobustEntryPoint(context, bufSize)) { return false; } - if (!ValidateReadPixelsBase(context, x, y, width, height, format, type, bufSize, length, - columns, rows, data)) + if (!ValidateReadPixelsBase(context, x, y, width, height, format, type, bufSize, &writeLength, + &writeColumns, &writeRows, data)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, writeLength)) { return false; } + SetRobustLengthParam(length, writeLength); + SetRobustLengthParam(columns, writeColumns); + SetRobustLengthParam(rows, writeRows); + return true; } @@ -1780,16 +1804,20 @@ bool ValidateGetQueryivRobustANGLE(Context *context, return false; } - if (!ValidateGetQueryivBase(context, target, pname, length)) + GLsizei numParams = 0; + + if (!ValidateGetQueryivBase(context, target, pname, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } @@ -1861,16 +1889,20 @@ bool ValidateGetQueryObjectivRobustANGLE(Context *context, return false; } - if (!ValidateGetQueryObjectValueBase(context, id, pname, length)) + GLsizei numParams = 0; + + if (!ValidateGetQueryObjectValueBase(context, id, pname, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } @@ -1904,16 +1936,20 @@ bool ValidateGetQueryObjectuivRobustANGLE(Context *context, return false; } - if (!ValidateGetQueryObjectValueBase(context, id, pname, length)) + GLsizei numParams = 0; + + if (!ValidateGetQueryObjectValueBase(context, id, pname, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } @@ -1945,16 +1981,20 @@ bool ValidateGetQueryObjecti64vRobustANGLE(Context *context, return false; } - if (!ValidateGetQueryObjectValueBase(context, id, pname, length)) + GLsizei numParams = 0; + + if (!ValidateGetQueryObjectValueBase(context, id, pname, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } @@ -1986,16 +2026,20 @@ bool ValidateGetQueryObjectui64vRobustANGLE(Context *context, return false; } - if (!ValidateGetQueryObjectValueBase(context, id, pname, length)) + GLsizei numParams = 0; + + if (!ValidateGetQueryObjectValueBase(context, id, pname, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } @@ -2242,6 +2286,87 @@ bool ValidateStateQuery(Context *context, GLenum pname, GLenum *nativeType, unsi return true; } +bool ValidateGetBooleanvRobustANGLE(Context *context, + GLenum pname, + GLsizei bufSize, + GLsizei *length, + GLboolean *params) +{ + GLenum nativeType; + unsigned int numParams = 0; + + if (!ValidateRobustStateQuery(context, pname, bufSize, &nativeType, &numParams)) + { + return false; + } + + SetRobustLengthParam(length, numParams); + + return true; +} + +bool ValidateGetFloatvRobustANGLE(Context *context, + GLenum pname, + GLsizei bufSize, + GLsizei *length, + GLfloat *params) +{ + GLenum nativeType; + unsigned int numParams = 0; + + if (!ValidateRobustStateQuery(context, pname, bufSize, &nativeType, &numParams)) + { + return false; + } + + SetRobustLengthParam(length, numParams); + + return true; +} + +bool ValidateGetIntegervRobustANGLE(Context *context, + GLenum pname, + GLsizei bufSize, + GLsizei *length, + GLint *data) +{ + GLenum nativeType; + unsigned int numParams = 0; + + if (!ValidateRobustStateQuery(context, pname, bufSize, &nativeType, &numParams)) + { + return false; + } + + SetRobustLengthParam(length, numParams); + + return true; +} + +bool ValidateGetInteger64vRobustANGLE(Context *context, + GLenum pname, + GLsizei bufSize, + GLsizei *length, + GLint64 *data) +{ + GLenum nativeType; + unsigned int numParams = 0; + + if (!ValidateRobustStateQuery(context, pname, bufSize, &nativeType, &numParams)) + { + return false; + } + + if (nativeType == GL_INT_64_ANGLEX) + { + CastStateValues(context, nativeType, pname, numParams, data); + return false; + } + + SetRobustLengthParam(length, numParams); + return true; +} + bool ValidateRobustStateQuery(Context *context, GLenum pname, GLsizei bufSize, @@ -3158,8 +3283,17 @@ bool ValidateGetUniformfvRobustANGLE(Context *context, return false; } + GLsizei writeLength = 0; + // bufSize is validated in ValidateSizedGetUniform - return ValidateSizedGetUniform(context, program, location, bufSize, length); + if (!ValidateSizedGetUniform(context, program, location, bufSize, &writeLength)) + { + return false; + } + + SetRobustLengthParam(length, writeLength); + + return true; } bool ValidateGetUniformivRobustANGLE(Context *context, @@ -3174,8 +3308,17 @@ bool ValidateGetUniformivRobustANGLE(Context *context, return false; } + GLsizei writeLength = 0; + // bufSize is validated in ValidateSizedGetUniform - return ValidateSizedGetUniform(context, program, location, bufSize, length); + if (!ValidateSizedGetUniform(context, program, location, bufSize, &writeLength)) + { + return false; + } + + SetRobustLengthParam(length, writeLength); + + return true; } bool ValidateGetUniformuivRobustANGLE(Context *context, @@ -3196,8 +3339,17 @@ bool ValidateGetUniformuivRobustANGLE(Context *context, return false; } + GLsizei writeLength = 0; + // bufSize is validated in ValidateSizedGetUniform - return ValidateSizedGetUniform(context, program, location, bufSize, length); + if (!ValidateSizedGetUniform(context, program, location, bufSize, &writeLength)) + { + return false; + } + + SetRobustLengthParam(length, writeLength); + + return true; } bool ValidateDiscardFramebufferBase(Context *context, @@ -4090,24 +4242,28 @@ bool ValidateGetFramebufferAttachmentParameterivRobustANGLE(Context *context, GLenum attachment, GLenum pname, GLsizei bufSize, - GLsizei *numParams) + GLsizei *length, + GLint *params) { if (!ValidateRobustEntryPoint(context, bufSize)) { return false; } + GLsizei numParams = 0; if (!ValidateGetFramebufferAttachmentParameterivBase(context, target, attachment, pname, - numParams)) + &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *numParams)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } @@ -4123,16 +4279,19 @@ bool ValidateGetBufferParameterivRobustANGLE(Context *context, return false; } - if (!ValidateGetBufferParameterBase(context, target, pname, false, length)) + GLsizei numParams = 0; + + if (!ValidateGetBufferParameterBase(context, target, pname, false, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); return true; } @@ -4143,21 +4302,25 @@ bool ValidateGetBufferParameteri64vRobustANGLE(Context *context, GLsizei *length, GLint64 *params) { + GLsizei numParams = 0; + if (!ValidateRobustEntryPoint(context, bufSize)) { return false; } - if (!ValidateGetBufferParameterBase(context, target, pname, false, length)) + if (!ValidateGetBufferParameterBase(context, target, pname, false, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } @@ -4282,23 +4445,28 @@ bool ValidateGetProgramivRobustANGLE(Context *context, GLuint program, GLenum pname, GLsizei bufSize, - GLsizei *numParams) + GLsizei *length, + GLint *params) { if (!ValidateRobustEntryPoint(context, bufSize)) { return false; } - if (!ValidateGetProgramivBase(context, program, pname, numParams)) + GLsizei numParams = 0; + + if (!ValidateGetProgramivBase(context, program, pname, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *numParams)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } @@ -4314,16 +4482,20 @@ bool ValidateGetRenderbufferParameterivRobustANGLE(Context *context, return false; } - if (!ValidateGetRenderbufferParameterivBase(context, target, pname, length)) + GLsizei numParams = 0; + + if (!ValidateGetRenderbufferParameterivBase(context, target, pname, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } @@ -4339,16 +4511,20 @@ bool ValidateGetShaderivRobustANGLE(Context *context, return false; } - if (!ValidateGetShaderivBase(context, shader, pname, length)) + GLsizei numParams = 0; + + if (!ValidateGetShaderivBase(context, shader, pname, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } @@ -4364,16 +4540,20 @@ bool ValidateGetTexParameterfvRobustANGLE(Context *context, return false; } - if (!ValidateGetTexParameterBase(context, target, pname, length)) + GLsizei numParams = 0; + + if (!ValidateGetTexParameterBase(context, target, pname, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } @@ -4384,21 +4564,23 @@ bool ValidateGetTexParameterivRobustANGLE(Context *context, GLsizei *length, GLint *params) { + if (!ValidateRobustEntryPoint(context, bufSize)) { return false; } - - if (!ValidateGetTexParameterBase(context, target, pname, length)) + GLsizei numParams = 0; + if (!ValidateGetTexParameterBase(context, target, pname, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); return true; } @@ -4442,23 +4624,26 @@ bool ValidateGetSamplerParameterfvRobustANGLE(Context *context, return false; } - if (!ValidateGetSamplerParameterBase(context, sampler, pname, length)) + GLsizei numParams = 0; + + if (!ValidateGetSamplerParameterBase(context, sampler, pname, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); return true; } bool ValidateGetSamplerParameterivRobustANGLE(Context *context, GLuint sampler, GLenum pname, - GLuint bufSize, + GLsizei bufSize, GLsizei *length, GLint *params) { @@ -4467,16 +4652,19 @@ bool ValidateGetSamplerParameterivRobustANGLE(Context *context, return false; } - if (!ValidateGetSamplerParameterBase(context, sampler, pname, length)) + GLsizei numParams = 0; + + if (!ValidateGetSamplerParameterBase(context, sampler, pname, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); return true; } @@ -4520,16 +4708,19 @@ bool ValidateGetVertexAttribfvRobustANGLE(Context *context, return false; } - if (!ValidateGetVertexAttribBase(context, index, pname, length, false, false)) + GLsizei writeLength = 0; + + if (!ValidateGetVertexAttribBase(context, index, pname, &writeLength, false, false)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, writeLength)) { return false; } + SetRobustLengthParam(length, writeLength); return true; } @@ -4545,16 +4736,20 @@ bool ValidateGetVertexAttribivRobustANGLE(Context *context, return false; } - if (!ValidateGetVertexAttribBase(context, index, pname, length, false, false)) + GLsizei writeLength = 0; + + if (!ValidateGetVertexAttribBase(context, index, pname, &writeLength, false, false)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, writeLength)) { return false; } + SetRobustLengthParam(length, writeLength); + return true; } @@ -4570,16 +4765,20 @@ bool ValidateGetVertexAttribPointervRobustANGLE(Context *context, return false; } - if (!ValidateGetVertexAttribBase(context, index, pname, length, true, false)) + GLsizei writeLength = 0; + + if (!ValidateGetVertexAttribBase(context, index, pname, &writeLength, true, false)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, writeLength)) { return false; } + SetRobustLengthParam(length, writeLength); + return true; } @@ -4595,16 +4794,20 @@ bool ValidateGetVertexAttribIivRobustANGLE(Context *context, return false; } - if (!ValidateGetVertexAttribBase(context, index, pname, length, false, true)) + GLsizei writeLength = 0; + + if (!ValidateGetVertexAttribBase(context, index, pname, &writeLength, false, true)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, writeLength)) { return false; } + SetRobustLengthParam(length, writeLength); + return true; } @@ -4620,16 +4823,20 @@ bool ValidateGetVertexAttribIuivRobustANGLE(Context *context, return false; } - if (!ValidateGetVertexAttribBase(context, index, pname, length, false, true)) + GLsizei writeLength = 0; + + if (!ValidateGetVertexAttribBase(context, index, pname, &writeLength, false, true)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, writeLength)) { return false; } + SetRobustLengthParam(length, writeLength); + return true; } @@ -4646,16 +4853,21 @@ bool ValidateGetActiveUniformBlockivRobustANGLE(Context *context, return false; } - if (!ValidateGetActiveUniformBlockivBase(context, program, uniformBlockIndex, pname, length)) + GLsizei writeLength = 0; + + if (!ValidateGetActiveUniformBlockivBase(context, program, uniformBlockIndex, pname, + &writeLength)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, writeLength)) { return false; } + SetRobustLengthParam(length, writeLength); + return true; } @@ -4672,16 +4884,21 @@ bool ValidateGetInternalFormativRobustANGLE(Context *context, return false; } - if (!ValidateGetInternalFormativBase(context, target, internalformat, pname, bufSize, length)) + GLsizei numParams = 0; + + if (!ValidateGetInternalFormativBase(context, target, internalformat, pname, bufSize, + &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } diff --git a/src/libANGLE/validationES.h b/src/libANGLE/validationES.h index 59954a002e932..7835b19a59613 100644 --- a/src/libANGLE/validationES.h +++ b/src/libANGLE/validationES.h @@ -31,6 +31,7 @@ struct LinkedUniform; class Program; class Shader; +void SetRobustLengthParam(GLsizei *length, GLsizei value); bool IsETC2EACFormat(const GLenum format); bool ValidTextureTarget(const Context *context, TextureType type); bool ValidTexture2DTarget(const Context *context, TextureType type); @@ -227,12 +228,30 @@ bool ValidateUniformMatrix(Context *context, GLint location, GLsizei count, GLboolean transpose); - +bool ValidateGetBooleanvRobustANGLE(Context *context, + GLenum pname, + GLsizei bufSize, + GLsizei *length, + GLboolean *params); +bool ValidateGetFloatvRobustANGLE(Context *context, + GLenum pname, + GLsizei bufSize, + GLsizei *length, + GLfloat *params); bool ValidateStateQuery(Context *context, GLenum pname, GLenum *nativeType, unsigned int *numParams); - +bool ValidateGetIntegervRobustANGLE(Context *context, + GLenum pname, + GLsizei bufSize, + GLsizei *length, + GLint *data); +bool ValidateGetInteger64vRobustANGLE(Context *context, + GLenum pname, + GLsizei bufSize, + GLsizei *length, + GLint64 *data); bool ValidateRobustStateQuery(Context *context, GLenum pname, GLsizei bufSize, @@ -391,7 +410,8 @@ bool ValidateGetFramebufferAttachmentParameterivRobustANGLE(Context *context, GLenum attachment, GLenum pname, GLsizei bufSize, - GLsizei *numParams); + GLsizei *length, + GLint *params); bool ValidateGetBufferParameterBase(Context *context, BufferBinding target, @@ -417,7 +437,8 @@ bool ValidateGetProgramivRobustANGLE(Context *context, GLuint program, GLenum pname, GLsizei bufSize, - GLsizei *numParams); + GLsizei *length, + GLint *params); bool ValidateGetRenderbufferParameterivBase(Context *context, GLenum target, @@ -481,7 +502,7 @@ bool ValidateGetSamplerParameterfvRobustANGLE(Context *context, bool ValidateGetSamplerParameterivRobustANGLE(Context *context, GLuint sampler, GLenum pname, - GLuint bufSize, + GLsizei bufSize, GLsizei *length, GLint *params); diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp index ab448a6dc77c2..3d3c593ba2edc 100644 --- a/src/libANGLE/validationES2.cpp +++ b/src/libANGLE/validationES2.cpp @@ -3483,6 +3483,16 @@ bool ValidateStencilStrokePathCHROMIUM(Context *context, GLuint path, GLint refe return true; } +bool ValidateCoverFillPathCHROMIUM(Context *context, GLuint path, GLenum coverMode) +{ + return ValidateCoverPathCHROMIUM(context, path, coverMode); +} + +bool ValidateCoverStrokePathCHROMIUM(Context *context, GLuint path, GLenum coverMode) +{ + return ValidateCoverPathCHROMIUM(context, path, coverMode); +} + bool ValidateCoverPathCHROMIUM(Context *context, GLuint path, GLenum coverMode) { if (!context->getExtensions().pathRendering) @@ -3528,7 +3538,7 @@ bool ValidateStencilThenCoverStrokePathCHROMIUM(Context *context, ValidateCoverPathCHROMIUM(context, path, coverMode); } -bool ValidateIsPathCHROMIUM(Context *context) +bool ValidateIsPathCHROMIUM(Context *context, GLuint path) { if (!context->getExtensions().pathRendering) { diff --git a/src/libANGLE/validationES2.h b/src/libANGLE/validationES2.h index f14fc5425d6e5..85a33dd347a1c 100644 --- a/src/libANGLE/validationES2.h +++ b/src/libANGLE/validationES2.h @@ -247,6 +247,8 @@ bool ValidateGetPathParameterivCHROMIUM(Context *context, GLuint path, GLenum pn bool ValidatePathStencilFuncCHROMIUM(Context *context, GLenum func, GLint ref, GLuint mask); bool ValidateStencilFillPathCHROMIUM(Context *context, GLuint path, GLenum fillMode, GLuint mask); bool ValidateStencilStrokePathCHROMIUM(Context *context, GLuint path, GLint reference, GLuint mask); +bool ValidateCoverFillPathCHROMIUM(Context *context, GLuint path, GLenum coverMode); +bool ValidateCoverStrokePathCHROMIUM(Context *context, GLuint path, GLenum coverMode); bool ValidateCoverPathCHROMIUM(Context *context, GLuint path, GLenum coverMode); bool ValidateStencilThenCoverFillPathCHROMIUM(Context *context, GLuint path, @@ -258,7 +260,7 @@ bool ValidateStencilThenCoverStrokePathCHROMIUM(Context *context, GLint reference, GLuint mask, GLenum coverMode); -bool ValidateIsPathCHROMIUM(Context *context); +bool ValidateIsPathCHROMIUM(Context *context, GLuint path); bool ValidateCoverFillPathInstancedCHROMIUM(Context *context, GLsizei numPaths, GLenum pathNameType, diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp index 7ff676c30c5b4..42f9df6404801 100644 --- a/src/libANGLE/validationES3.cpp +++ b/src/libANGLE/validationES3.cpp @@ -2194,16 +2194,20 @@ bool ValidateGetBufferPointervRobustANGLE(Context *context, return false; } - if (!ValidateGetBufferPointervBase(context, target, pname, length, params)) + GLsizei numParams = 0; + + if (!ValidateGetBufferPointervBase(context, target, pname, &numParams, params)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } @@ -2421,16 +2425,20 @@ bool ValidateGetIntegeri_vRobustANGLE(Context *context, return false; } - if (!ValidateIndexedStateQuery(context, target, index, length)) + GLsizei numParams = 0; + + if (!ValidateIndexedStateQuery(context, target, index, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } @@ -2462,16 +2470,20 @@ bool ValidateGetInteger64i_vRobustANGLE(Context *context, return false; } - if (!ValidateIndexedStateQuery(context, target, index, length)) + GLsizei numParams = 0; + + if (!ValidateIndexedStateQuery(context, target, index, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); + return true; } diff --git a/src/libANGLE/validationES31.cpp b/src/libANGLE/validationES31.cpp index beea0393b83c6..12a1867573ecb 100644 --- a/src/libANGLE/validationES31.cpp +++ b/src/libANGLE/validationES31.cpp @@ -389,16 +389,19 @@ bool ValidateGetBooleani_vRobustANGLE(Context *context, return false; } - if (!ValidateIndexedStateQuery(context, target, index, length)) + GLsizei numParams = 0; + + if (!ValidateIndexedStateQuery(context, target, index, &numParams)) { return false; } - if (!ValidateRobustBufferSize(context, bufSize, *length)) + if (!ValidateRobustBufferSize(context, bufSize, numParams)) { return false; } + SetRobustLengthParam(length, numParams); return true; } diff --git a/src/libGLESv2/entry_points_gles_2_0_ext.cpp b/src/libGLESv2/entry_points_gles_2_0_ext.cpp index 80724ff56e221..d67d41d608962 100644 --- a/src/libGLESv2/entry_points_gles_2_0_ext.cpp +++ b/src/libGLESv2/entry_points_gles_2_0_ext.cpp @@ -33,19 +33,6 @@ namespace gl { -namespace -{ - -void SetRobustLengthParam(GLsizei *length, GLsizei value) -{ - if (length) - { - *length = value; - } -} - -} // anonymous namespace - ANGLE_EXPORT void GL_APIENTRY BindUniformLocationCHROMIUM(GLuint program, GLint location, const GLchar *name) @@ -150,7 +137,7 @@ ANGLE_EXPORT GLboolean GL_APIENTRY IsPathCHROMIUM(GLuint path) Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateIsPathCHROMIUM(context)) + if (!context->skipValidation() && !ValidateIsPathCHROMIUM(context, path)) { return GL_FALSE; } @@ -305,7 +292,7 @@ ANGLE_EXPORT void GL_APIENTRY CoverFillPathCHROMIUM(GLuint path, GLenum coverMod Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateCoverPathCHROMIUM(context, path, coverMode)) + if (!context->skipValidation() && !ValidateCoverFillPathCHROMIUM(context, path, coverMode)) { return; } @@ -320,7 +307,8 @@ ANGLE_EXPORT void GL_APIENTRY CoverStrokePathCHROMIUM(GLuint path, GLenum coverM Context *context = GetValidGlobalContext(); if (context) { - if (!context->skipValidation() && !ValidateCoverPathCHROMIUM(context, path, coverMode)) + if (!context->skipValidation() && + !ValidateCoverStrokePathCHROMIUM(context, path, coverMode)) { return; } @@ -718,15 +706,12 @@ ANGLE_EXPORT void GL_APIENTRY GetBooleanvRobustANGLE(GLenum pname, Context *context = GetValidGlobalContext(); if (context) { - GLenum nativeType; - unsigned int numParams = 0; - if (!ValidateRobustStateQuery(context, pname, bufSize, &nativeType, &numParams)) + if (!ValidateGetBooleanvRobustANGLE(context, pname, bufSize, length, params)) { return; } context->getBooleanv(pname, params); - SetRobustLengthParam(length, numParams); } } @@ -744,16 +729,14 @@ ANGLE_EXPORT void GL_APIENTRY GetBufferParameterivRobustANGLE(GLenum target, { BufferBinding targetPacked = FromGLenum(target); - GLsizei numParams = 0; - if (!ValidateGetBufferParameterivRobustANGLE(context, targetPacked, pname, bufSize, - &numParams, params)) + if (!ValidateGetBufferParameterivRobustANGLE(context, targetPacked, pname, bufSize, length, + params)) { return; } Buffer *buffer = context->getGLState().getTargetBuffer(targetPacked); QueryBufferParameteriv(buffer, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -770,15 +753,12 @@ ANGLE_EXPORT void GL_APIENTRY GetFloatvRobustANGLE(GLenum pname, Context *context = GetValidGlobalContext(); if (context) { - GLenum nativeType; - unsigned int numParams = 0; - if (!ValidateRobustStateQuery(context, pname, bufSize, &nativeType, &numParams)) + if (!ValidateGetFloatvRobustANGLE(context, pname, bufSize, length, params)) { return; } context->getFloatv(pname, params); - SetRobustLengthParam(length, numParams); } } @@ -797,16 +777,14 @@ ANGLE_EXPORT void GL_APIENTRY GetFramebufferAttachmentParameterivRobustANGLE(GLe Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; if (!ValidateGetFramebufferAttachmentParameterivRobustANGLE(context, target, attachment, - pname, bufSize, &numParams)) + pname, bufSize, length, params)) { return; } const Framebuffer *framebuffer = context->getGLState().getTargetFramebuffer(target); QueryFramebufferAttachmentParameteriv(context, framebuffer, attachment, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -823,15 +801,12 @@ ANGLE_EXPORT void GL_APIENTRY GetIntegervRobustANGLE(GLenum pname, Context *context = GetValidGlobalContext(); if (context) { - GLenum nativeType; - unsigned int numParams = 0; - if (!ValidateRobustStateQuery(context, pname, bufSize, &nativeType, &numParams)) + if (!ValidateGetIntegervRobustANGLE(context, pname, bufSize, length, data)) { return; } context->getIntegerv(pname, data); - SetRobustLengthParam(length, numParams); } } @@ -849,15 +824,13 @@ ANGLE_EXPORT void GL_APIENTRY GetProgramivRobustANGLE(GLuint program, Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!ValidateGetProgramivRobustANGLE(context, program, pname, bufSize, &numParams)) + if (!ValidateGetProgramivRobustANGLE(context, program, pname, bufSize, length, params)) { return; } Program *programObject = context->getProgram(program); QueryProgramiv(context, programObject, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -875,16 +848,14 @@ ANGLE_EXPORT void GL_APIENTRY GetRenderbufferParameterivRobustANGLE(GLenum targe Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!ValidateGetRenderbufferParameterivRobustANGLE(context, target, pname, bufSize, - &numParams, params)) + if (!ValidateGetRenderbufferParameterivRobustANGLE(context, target, pname, bufSize, length, + params)) { return; } Renderbuffer *renderbuffer = context->getGLState().getCurrentRenderbuffer(); QueryRenderbufferiv(context, renderbuffer, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -899,15 +870,13 @@ GetShaderivRobustANGLE(GLuint shader, GLenum pname, GLsizei bufSize, GLsizei *le Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!ValidateGetShaderivRobustANGLE(context, shader, pname, bufSize, &numParams, params)) + if (!ValidateGetShaderivRobustANGLE(context, shader, pname, bufSize, length, params)) { return; } Shader *shaderObject = context->getShader(shader); QueryShaderiv(context, shaderObject, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -925,9 +894,8 @@ ANGLE_EXPORT void GL_APIENTRY GetTexParameterfvRobustANGLE(GLenum target, Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; TextureType targetPacked = FromGLenum(target); - if (!ValidateGetTexParameterfvRobustANGLE(context, targetPacked, pname, bufSize, &numParams, + if (!ValidateGetTexParameterfvRobustANGLE(context, targetPacked, pname, bufSize, length, params)) { return; @@ -935,7 +903,6 @@ ANGLE_EXPORT void GL_APIENTRY GetTexParameterfvRobustANGLE(GLenum target, Texture *texture = context->getTargetTexture(targetPacked); QueryTexParameterfv(texture, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -953,9 +920,8 @@ ANGLE_EXPORT void GL_APIENTRY GetTexParameterivRobustANGLE(GLenum target, Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; TextureType targetPacked = FromGLenum(target); - if (!ValidateGetTexParameterivRobustANGLE(context, targetPacked, pname, bufSize, &numParams, + if (!ValidateGetTexParameterivRobustANGLE(context, targetPacked, pname, bufSize, length, params)) { return; @@ -963,7 +929,6 @@ ANGLE_EXPORT void GL_APIENTRY GetTexParameterivRobustANGLE(GLenum target, Texture *texture = context->getTargetTexture(targetPacked); QueryTexParameteriv(texture, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -981,9 +946,7 @@ ANGLE_EXPORT void GL_APIENTRY GetUniformfvRobustANGLE(GLuint program, Context *context = GetValidGlobalContext(); if (context) { - GLsizei writeLength = 0; - if (!ValidateGetUniformfvRobustANGLE(context, program, location, bufSize, &writeLength, - params)) + if (!ValidateGetUniformfvRobustANGLE(context, program, location, bufSize, length, params)) { return; } @@ -992,7 +955,6 @@ ANGLE_EXPORT void GL_APIENTRY GetUniformfvRobustANGLE(GLuint program, ASSERT(programObject); programObject->getUniformfv(context, location, params); - SetRobustLengthParam(length, writeLength); } } @@ -1010,9 +972,7 @@ ANGLE_EXPORT void GL_APIENTRY GetUniformivRobustANGLE(GLuint program, Context *context = GetValidGlobalContext(); if (context) { - GLsizei writeLength = 0; - if (!ValidateGetUniformivRobustANGLE(context, program, location, bufSize, &writeLength, - params)) + if (!ValidateGetUniformivRobustANGLE(context, program, location, bufSize, length, params)) { return; } @@ -1021,7 +981,6 @@ ANGLE_EXPORT void GL_APIENTRY GetUniformivRobustANGLE(GLuint program, ASSERT(programObject); programObject->getUniformiv(context, location, params); - SetRobustLengthParam(length, writeLength); } } @@ -1039,15 +998,12 @@ ANGLE_EXPORT void GL_APIENTRY GetVertexAttribfvRobustANGLE(GLuint index, Context *context = GetValidGlobalContext(); if (context) { - GLsizei writeLength = 0; - if (!ValidateGetVertexAttribfvRobustANGLE(context, index, pname, bufSize, &writeLength, - params)) + if (!ValidateGetVertexAttribfvRobustANGLE(context, index, pname, bufSize, length, params)) { return; } context->getVertexAttribfv(index, pname, params); - SetRobustLengthParam(length, writeLength); } } @@ -1065,15 +1021,12 @@ ANGLE_EXPORT void GL_APIENTRY GetVertexAttribivRobustANGLE(GLuint index, Context *context = GetValidGlobalContext(); if (context) { - GLsizei writeLength = 0; - if (!ValidateGetVertexAttribivRobustANGLE(context, index, pname, bufSize, &writeLength, - params)) + if (!ValidateGetVertexAttribivRobustANGLE(context, index, pname, bufSize, length, params)) { return; } context->getVertexAttribiv(index, pname, params); - SetRobustLengthParam(length, writeLength); } } @@ -1091,15 +1044,13 @@ ANGLE_EXPORT void GL_APIENTRY GetVertexAttribPointervRobustANGLE(GLuint index, Context *context = GetValidGlobalContext(); if (context) { - GLsizei writeLength = 0; - if (!ValidateGetVertexAttribPointervRobustANGLE(context, index, pname, bufSize, - &writeLength, pointer)) + if (!ValidateGetVertexAttribPointervRobustANGLE(context, index, pname, bufSize, length, + pointer)) { return; } context->getVertexAttribPointerv(index, pname, pointer); - SetRobustLengthParam(length, writeLength); } } @@ -1124,20 +1075,13 @@ ANGLE_EXPORT void GL_APIENTRY ReadPixelsRobustANGLE(GLint x, Context *context = GetValidGlobalContext(); if (context) { - GLsizei writeLength = 0; - GLsizei writeColumns = 0; - GLsizei writeRows = 0; if (!ValidateReadPixelsRobustANGLE(context, x, y, width, height, format, type, bufSize, - &writeLength, &writeColumns, &writeRows, pixels)) + length, columns, rows, pixels)) { return; } context->readPixels(x, y, width, height, format, type, pixels); - - SetRobustLengthParam(length, writeLength); - SetRobustLengthParam(columns, writeColumns); - SetRobustLengthParam(rows, writeRows); } } @@ -1472,14 +1416,12 @@ GetQueryivRobustANGLE(GLenum target, GLenum pname, GLsizei bufSize, GLsizei *len Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!ValidateGetQueryivRobustANGLE(context, target, pname, bufSize, &numParams, params)) + if (!ValidateGetQueryivRobustANGLE(context, target, pname, bufSize, length, params)) { return; } context->getQueryiv(target, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -1497,14 +1439,12 @@ ANGLE_EXPORT void GL_APIENTRY GetQueryObjectuivRobustANGLE(GLuint id, Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!ValidateGetQueryObjectuivRobustANGLE(context, id, pname, bufSize, &numParams, params)) + if (!ValidateGetQueryObjectuivRobustANGLE(context, id, pname, bufSize, length, params)) { return; } context->getQueryObjectuiv(id, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -1524,15 +1464,13 @@ ANGLE_EXPORT void GL_APIENTRY GetBufferPointervRobustANGLE(GLenum target, { BufferBinding targetPacked = FromGLenum(target); - GLsizei numParams = 0; - if (!ValidateGetBufferPointervRobustANGLE(context, targetPacked, pname, bufSize, &numParams, + if (!ValidateGetBufferPointervRobustANGLE(context, targetPacked, pname, bufSize, length, params)) { return; } context->getBufferPointerv(targetPacked, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -1547,14 +1485,12 @@ GetIntegeri_vRobustANGLE(GLenum target, GLuint index, GLsizei bufSize, GLsizei * Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!ValidateGetIntegeri_vRobustANGLE(context, target, index, bufSize, &numParams, data)) + if (!ValidateGetIntegeri_vRobustANGLE(context, target, index, bufSize, length, data)) { return; } context->getIntegeri_v(target, index, data); - SetRobustLengthParam(length, numParams); } } @@ -1573,16 +1509,14 @@ ANGLE_EXPORT void GL_APIENTRY GetInternalformativRobustANGLE(GLenum target, Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; if (!ValidateGetInternalFormativRobustANGLE(context, target, internalformat, pname, bufSize, - &numParams, params)) + length, params)) { return; } const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); QueryInternalFormativ(formatCaps, pname, bufSize, params); - SetRobustLengthParam(length, numParams); } } @@ -1600,15 +1534,12 @@ ANGLE_EXPORT void GL_APIENTRY GetVertexAttribIivRobustANGLE(GLuint index, Context *context = GetValidGlobalContext(); if (context) { - GLsizei writeLength = 0; - if (!ValidateGetVertexAttribIivRobustANGLE(context, index, pname, bufSize, &writeLength, - params)) + if (!ValidateGetVertexAttribIivRobustANGLE(context, index, pname, bufSize, length, params)) { return; } context->getVertexAttribIiv(index, pname, params); - SetRobustLengthParam(length, writeLength); } } @@ -1626,15 +1557,12 @@ ANGLE_EXPORT void GL_APIENTRY GetVertexAttribIuivRobustANGLE(GLuint index, Context *context = GetValidGlobalContext(); if (context) { - GLsizei writeLength = 0; - if (!ValidateGetVertexAttribIuivRobustANGLE(context, index, pname, bufSize, &writeLength, - params)) + if (!ValidateGetVertexAttribIuivRobustANGLE(context, index, pname, bufSize, length, params)) { return; } context->getVertexAttribIuiv(index, pname, params); - SetRobustLengthParam(length, writeLength); } } @@ -1652,9 +1580,7 @@ ANGLE_EXPORT void GL_APIENTRY GetUniformuivRobustANGLE(GLuint program, Context *context = GetValidGlobalContext(); if (context) { - GLsizei writeLength = 0; - if (!ValidateGetUniformuivRobustANGLE(context, program, location, bufSize, &writeLength, - params)) + if (!ValidateGetUniformuivRobustANGLE(context, program, location, bufSize, length, params)) { return; } @@ -1663,7 +1589,6 @@ ANGLE_EXPORT void GL_APIENTRY GetUniformuivRobustANGLE(GLuint program, ASSERT(programObject); programObject->getUniformuiv(context, location, params); - SetRobustLengthParam(length, writeLength); } } @@ -1682,16 +1607,14 @@ ANGLE_EXPORT void GL_APIENTRY GetActiveUniformBlockivRobustANGLE(GLuint program, Context *context = GetValidGlobalContext(); if (context) { - GLsizei writeLength = 0; if (!ValidateGetActiveUniformBlockivRobustANGLE(context, program, uniformBlockIndex, pname, - bufSize, &writeLength, params)) + bufSize, length, params)) { return; } const Program *programObject = context->getProgram(program); QueryActiveUniformBlockiv(programObject, uniformBlockIndex, pname, params); - SetRobustLengthParam(length, writeLength); } } @@ -1708,22 +1631,12 @@ ANGLE_EXPORT void GL_APIENTRY GetInteger64vRobustANGLE(GLenum pname, Context *context = GetValidGlobalContext(); if (context) { - GLenum nativeType; - unsigned int numParams = 0; - if (!ValidateRobustStateQuery(context, pname, bufSize, &nativeType, &numParams)) + if (!ValidateGetInteger64vRobustANGLE(context, pname, bufSize, length, data)) { return; } - if (nativeType == GL_INT_64_ANGLEX) - { - context->getInteger64v(pname, data); - } - else - { - CastStateValues(context, nativeType, pname, numParams, data); - } - SetRobustLengthParam(length, numParams); + context->getInteger64v(pname, data); } } @@ -1741,14 +1654,12 @@ ANGLE_EXPORT void GL_APIENTRY GetInteger64i_vRobustANGLE(GLenum target, Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!ValidateGetInteger64i_vRobustANGLE(context, target, index, bufSize, &numParams, data)) + if (!ValidateGetInteger64i_vRobustANGLE(context, target, index, bufSize, length, data)) { return; } context->getInteger64i_v(target, index, data); - SetRobustLengthParam(length, numParams); } } @@ -1766,16 +1677,14 @@ ANGLE_EXPORT void GL_APIENTRY GetBufferParameteri64vRobustANGLE(GLenum target, { BufferBinding targetPacked = FromGLenum(target); - GLsizei numParams = 0; if (!ValidateGetBufferParameteri64vRobustANGLE(context, targetPacked, pname, bufSize, - &numParams, params)) + length, params)) { return; } Buffer *buffer = context->getGLState().getTargetBuffer(targetPacked); QueryBufferParameteri64v(buffer, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -1837,15 +1746,13 @@ ANGLE_EXPORT void GL_APIENTRY GetSamplerParameterivRobustANGLE(GLuint sampler, Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!ValidateGetSamplerParameterivRobustANGLE(context, sampler, pname, bufSize, &numParams, + if (!ValidateGetSamplerParameterivRobustANGLE(context, sampler, pname, bufSize, length, params)) { return; } context->getSamplerParameteriv(sampler, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -1863,15 +1770,13 @@ ANGLE_EXPORT void GL_APIENTRY GetSamplerParameterfvRobustANGLE(GLuint sampler, Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!ValidateGetSamplerParameterfvRobustANGLE(context, sampler, pname, bufSize, &numParams, + if (!ValidateGetSamplerParameterfvRobustANGLE(context, sampler, pname, bufSize, length, params)) { return; } context->getSamplerParameterfv(sampler, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -1915,14 +1820,12 @@ ANGLE_EXPORT void GL_APIENTRY GetBooleani_vRobustANGLE(GLenum target, Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!ValidateGetBooleani_vRobustANGLE(context, target, index, bufSize, &numParams, data)) + if (!ValidateGetBooleani_vRobustANGLE(context, target, index, bufSize, length, data)) { return; } context->getBooleani_v(target, index, data); - SetRobustLengthParam(length, numParams); } } @@ -2000,20 +1903,13 @@ ANGLE_EXPORT void GL_APIENTRY ReadnPixelsRobustANGLE(GLint x, Context *context = GetValidGlobalContext(); if (context) { - GLsizei writeLength = 0; - GLsizei writeColumns = 0; - GLsizei writeRows = 0; if (!ValidateReadnPixelsRobustANGLE(context, x, y, width, height, format, type, bufSize, - &writeLength, &writeColumns, &writeRows, data)) + length, columns, rows, data)) { return; } context->readPixels(x, y, width, height, format, type, data); - - SetRobustLengthParam(length, writeLength); - SetRobustLengthParam(columns, writeColumns); - SetRobustLengthParam(rows, writeRows); } } @@ -2170,14 +2066,12 @@ ANGLE_EXPORT void GL_APIENTRY GetQueryObjectivRobustANGLE(GLuint id, Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!ValidateGetQueryObjectivRobustANGLE(context, id, pname, bufSize, &numParams, params)) + if (!ValidateGetQueryObjectivRobustANGLE(context, id, pname, bufSize, length, params)) { return; } context->getQueryObjectiv(id, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -2195,14 +2089,12 @@ ANGLE_EXPORT void GL_APIENTRY GetQueryObjecti64vRobustANGLE(GLuint id, Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!ValidateGetQueryObjecti64vRobustANGLE(context, id, pname, bufSize, &numParams, params)) + if (!ValidateGetQueryObjecti64vRobustANGLE(context, id, pname, bufSize, length, params)) { return; } context->getQueryObjecti64v(id, pname, params); - SetRobustLengthParam(length, numParams); } } @@ -2220,15 +2112,12 @@ ANGLE_EXPORT void GL_APIENTRY GetQueryObjectui64vRobustANGLE(GLuint id, Context *context = GetValidGlobalContext(); if (context) { - GLsizei numParams = 0; - if (!ValidateGetQueryObjectui64vRobustANGLE(context, id, pname, bufSize, &numParams, - params)) + if (!ValidateGetQueryObjectui64vRobustANGLE(context, id, pname, bufSize, length, params)) { return; } context->getQueryObjectui64v(id, pname, params); - SetRobustLengthParam(length, numParams); } }