Commit f0e0449e by Jamie Madill Committed by Commit Bot

Format ES3 query entry points.

Also refactor some query extension entry points. BUG=angleproject:747 Change-Id: I5a8a3b2616a3872b5645a655641ec9c12739f804 Reviewed-on: https://chromium-review.googlesource.com/636062Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent ff325f1b
...@@ -656,14 +656,6 @@ GLuint Context::createFenceNV() ...@@ -656,14 +656,6 @@ GLuint Context::createFenceNV()
return handle; return handle;
} }
// Returns an unused query name
GLuint Context::createQuery()
{
GLuint handle = mQueryHandleAllocator.allocate();
mQueryMap.assign(handle, nullptr);
return handle;
}
void Context::deleteBuffer(GLuint buffer) void Context::deleteBuffer(GLuint buffer)
{ {
if (mState.mBuffers->getBuffer(buffer)) if (mState.mBuffers->getBuffer(buffer))
...@@ -869,19 +861,6 @@ void Context::deleteFenceNV(GLuint fence) ...@@ -869,19 +861,6 @@ void Context::deleteFenceNV(GLuint fence)
} }
} }
void Context::deleteQuery(GLuint query)
{
Query *queryObject = nullptr;
if (mQueryMap.erase(query, &queryObject))
{
mQueryHandleAllocator.release(query);
if (queryObject)
{
queryObject->release(this);
}
}
}
Buffer *Context::getBuffer(GLuint handle) const Buffer *Context::getBuffer(GLuint handle) const
{ {
return mState.mBuffers->getBuffer(handle); return mState.mBuffers->getBuffer(handle);
...@@ -1181,45 +1160,37 @@ void Context::bindTransformFeedback(GLuint transformFeedbackHandle) ...@@ -1181,45 +1160,37 @@ void Context::bindTransformFeedback(GLuint transformFeedbackHandle)
mGLState.setTransformFeedbackBinding(this, transformFeedback); mGLState.setTransformFeedbackBinding(this, transformFeedback);
} }
Error Context::beginQuery(GLenum target, GLuint query) void Context::beginQuery(GLenum target, GLuint query)
{ {
Query *queryObject = getQuery(query, true, target); Query *queryObject = getQuery(query, true, target);
ASSERT(queryObject); ASSERT(queryObject);
// begin query // begin query
Error error = queryObject->begin(); ANGLE_CONTEXT_TRY(queryObject->begin());
if (error.isError())
{
return error;
}
// set query as active for specified target only if begin succeeded // set query as active for specified target only if begin succeeded
mGLState.setActiveQuery(this, target, queryObject); mGLState.setActiveQuery(this, target, queryObject);
return NoError();
} }
Error Context::endQuery(GLenum target) void Context::endQuery(GLenum target)
{ {
Query *queryObject = mGLState.getActiveQuery(target); Query *queryObject = mGLState.getActiveQuery(target);
ASSERT(queryObject); ASSERT(queryObject);
gl::Error error = queryObject->end(); handleError(queryObject->end());
// Always unbind the query, even if there was an error. This may delete the query object. // Always unbind the query, even if there was an error. This may delete the query object.
mGLState.setActiveQuery(this, target, nullptr); mGLState.setActiveQuery(this, target, nullptr);
return error;
} }
Error Context::queryCounter(GLuint id, GLenum target) void Context::queryCounter(GLuint id, GLenum target)
{ {
ASSERT(target == GL_TIMESTAMP_EXT); ASSERT(target == GL_TIMESTAMP_EXT);
Query *queryObject = getQuery(id, true, target); Query *queryObject = getQuery(id, true, target);
ASSERT(queryObject); ASSERT(queryObject);
return queryObject->queryCounter(); handleError(queryObject->queryCounter());
} }
void Context::getQueryiv(GLenum target, GLenum pname, GLint *params) void Context::getQueryiv(GLenum target, GLenum pname, GLint *params)
...@@ -4952,4 +4923,37 @@ void Context::uniform4uiv(GLint location, GLsizei count, const GLuint *value) ...@@ -4952,4 +4923,37 @@ void Context::uniform4uiv(GLint location, GLsizei count, const GLuint *value)
program->setUniform4uiv(location, count, value); program->setUniform4uiv(location, count, value);
} }
void Context::genQueries(GLsizei n, GLuint *ids)
{
for (GLsizei i = 0; i < n; i++)
{
GLuint handle = mQueryHandleAllocator.allocate();
mQueryMap.assign(handle, nullptr);
ids[i] = handle;
}
}
void Context::deleteQueries(GLsizei n, const GLuint *ids)
{
for (int i = 0; i < n; i++)
{
GLuint query = ids[i];
Query *queryObject = nullptr;
if (mQueryMap.erase(query, &queryObject))
{
mQueryHandleAllocator.release(query);
if (queryObject)
{
queryObject->release(this);
}
}
}
}
GLboolean Context::isQuery(GLuint id)
{
return (getQuery(id, false, GL_NONE) != nullptr) ? GL_TRUE : GL_FALSE;
}
} // namespace gl } // namespace gl
...@@ -120,10 +120,6 @@ class Context final : public ValidationContext ...@@ -120,10 +120,6 @@ class Context final : public ValidationContext
GLuint createFenceNV(); GLuint createFenceNV();
void deleteFenceNV(GLuint fence); void deleteFenceNV(GLuint fence);
// Queries are owned by the Context;
GLuint createQuery();
void deleteQuery(GLuint query);
// Vertex arrays are owned by the Context // Vertex arrays are owned by the Context
GLuint createVertexArray(); GLuint createVertexArray();
void deleteVertexArray(GLuint vertexArray); void deleteVertexArray(GLuint vertexArray);
...@@ -174,9 +170,9 @@ class Context final : public ValidationContext ...@@ -174,9 +170,9 @@ class Context final : public ValidationContext
void bindTransformFeedback(GLuint transformFeedbackHandle); void bindTransformFeedback(GLuint transformFeedbackHandle);
void bindDrawIndirectBuffer(GLuint bufferHandle); void bindDrawIndirectBuffer(GLuint bufferHandle);
Error beginQuery(GLenum target, GLuint query); void beginQuery(GLenum target, GLuint query);
Error endQuery(GLenum target); void endQuery(GLenum target);
Error queryCounter(GLuint id, GLenum target); void queryCounter(GLuint id, GLenum target);
void getQueryiv(GLenum target, GLenum pname, GLint *params); void getQueryiv(GLenum target, GLenum pname, GLint *params);
void getQueryObjectiv(GLuint id, GLenum pname, GLint *params); void getQueryObjectiv(GLuint id, GLenum pname, GLint *params);
void getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params); void getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params);
...@@ -780,6 +776,10 @@ class Context final : public ValidationContext ...@@ -780,6 +776,10 @@ class Context final : public ValidationContext
void uniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void uniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
void validateProgram(GLuint program); void validateProgram(GLuint program);
void genQueries(GLsizei n, GLuint *ids);
void deleteQueries(GLsizei n, const GLuint *ids);
GLboolean isQuery(GLuint id);
void uniform1ui(GLint location, GLuint v0); void uniform1ui(GLint location, GLuint v0);
void uniform2ui(GLint location, GLuint v0, GLuint v1); void uniform2ui(GLint location, GLuint v0, GLuint v1);
void uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2); void uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2);
......
...@@ -1916,7 +1916,7 @@ bool ValidateReadnPixelsRobustANGLE(Context *context, ...@@ -1916,7 +1916,7 @@ bool ValidateReadnPixelsRobustANGLE(Context *context,
return true; return true;
} }
bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n) bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n, GLuint *ids)
{ {
if (!context->getExtensions().occlusionQueryBoolean && if (!context->getExtensions().occlusionQueryBoolean &&
!context->getExtensions().disjointTimerQuery) !context->getExtensions().disjointTimerQuery)
...@@ -1928,7 +1928,7 @@ bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n) ...@@ -1928,7 +1928,7 @@ bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n)
return ValidateGenOrDelete(context, n); return ValidateGenOrDelete(context, n);
} }
bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n) bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n, const GLuint *ids)
{ {
if (!context->getExtensions().occlusionQueryBoolean && if (!context->getExtensions().occlusionQueryBoolean &&
!context->getExtensions().disjointTimerQuery) !context->getExtensions().disjointTimerQuery)
...@@ -1940,6 +1940,18 @@ bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n) ...@@ -1940,6 +1940,18 @@ bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n)
return ValidateGenOrDelete(context, n); return ValidateGenOrDelete(context, n);
} }
bool ValidateIsQueryEXT(gl::Context *context, GLuint id)
{
if (!context->getExtensions().occlusionQueryBoolean &&
!context->getExtensions().disjointTimerQuery)
{
ANGLE_VALIDATION_ERR(context, InvalidOperation(), QueryExtensionNotEnabled);
return false;
}
return true;
}
bool ValidateBeginQueryBase(gl::Context *context, GLenum target, GLuint id) bool ValidateBeginQueryBase(gl::Context *context, GLenum target, GLuint id)
{ {
if (!ValidQueryType(context, target)) if (!ValidQueryType(context, target))
......
...@@ -160,8 +160,9 @@ bool ValidateReadnPixelsRobustANGLE(Context *context, ...@@ -160,8 +160,9 @@ bool ValidateReadnPixelsRobustANGLE(Context *context,
GLsizei *rows, GLsizei *rows,
void *data); void *data);
bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n); bool ValidateGenQueriesEXT(gl::Context *context, GLsizei n, GLuint *ids);
bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n); bool ValidateDeleteQueriesEXT(gl::Context *context, GLsizei n, const GLuint *ids);
bool ValidateIsQueryEXT(gl::Context *context, GLuint id);
bool ValidateBeginQueryBase(Context *context, GLenum target, GLuint id); bool ValidateBeginQueryBase(Context *context, GLenum target, GLuint id);
bool ValidateBeginQueryEXT(Context *context, GLenum target, GLuint id); bool ValidateBeginQueryEXT(Context *context, GLenum target, GLuint id);
bool ValidateEndQueryBase(Context *context, GLenum target); bool ValidateEndQueryBase(Context *context, GLenum target);
......
...@@ -2833,4 +2833,15 @@ bool ValidateUniform4uiv(Context *context, GLint location, GLsizei count, const ...@@ -2833,4 +2833,15 @@ bool ValidateUniform4uiv(Context *context, GLint location, GLsizei count, const
return ValidateUniformES3(context, GL_UNSIGNED_INT_VEC4, location, count); return ValidateUniformES3(context, GL_UNSIGNED_INT_VEC4, location, count);
} }
bool ValidateIsQuery(Context *context, GLuint id)
{
if (context->getClientMajorVersion() < 3)
{
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
return false;
}
return true;
}
} // namespace gl } // namespace gl
...@@ -443,6 +443,8 @@ bool ValidateFramebufferTextureMultiviewSideBySideANGLE(Context *context, ...@@ -443,6 +443,8 @@ bool ValidateFramebufferTextureMultiviewSideBySideANGLE(Context *context,
GLsizei numViews, GLsizei numViews,
const GLint *viewportOffsets); const GLint *viewportOffsets);
bool ValidateIsQuery(Context *context, GLuint id);
bool ValidateUniform1ui(Context *context, GLint location, GLuint v0); bool ValidateUniform1ui(Context *context, GLint location, GLuint v0);
bool ValidateUniform2ui(Context *context, GLint location, GLuint v0, GLuint v1); bool ValidateUniform2ui(Context *context, GLint location, GLuint v0, GLuint v1);
bool ValidateUniform3ui(Context *context, GLint location, GLuint v0, GLuint v1, GLuint v2); bool ValidateUniform3ui(Context *context, GLint location, GLuint v0, GLuint v1, GLuint v2);
......
...@@ -52,15 +52,12 @@ void GL_APIENTRY GenQueriesEXT(GLsizei n, GLuint *ids) ...@@ -52,15 +52,12 @@ void GL_APIENTRY GenQueriesEXT(GLsizei n, GLuint *ids)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!context->skipValidation() && !ValidateGenQueriesEXT(context, n)) if (!context->skipValidation() && !ValidateGenQueriesEXT(context, n, ids))
{ {
return; return;
} }
for (GLsizei i = 0; i < n; i++) context->genQueries(n, ids);
{
ids[i] = context->createQuery();
}
} }
} }
...@@ -71,15 +68,12 @@ void GL_APIENTRY DeleteQueriesEXT(GLsizei n, const GLuint *ids) ...@@ -71,15 +68,12 @@ void GL_APIENTRY DeleteQueriesEXT(GLsizei n, const GLuint *ids)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!context->skipValidation() && !ValidateDeleteQueriesEXT(context, n)) if (!context->skipValidation() && !ValidateDeleteQueriesEXT(context, n, ids))
{ {
return; return;
} }
for (int i = 0; i < n; i++) context->deleteQueries(n, ids);
{
context->deleteQuery(ids[i]);
}
} }
} }
...@@ -90,7 +84,12 @@ GLboolean GL_APIENTRY IsQueryEXT(GLuint id) ...@@ -90,7 +84,12 @@ GLboolean GL_APIENTRY IsQueryEXT(GLuint id)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
return (context->getQuery(id, false, GL_NONE) != nullptr) ? GL_TRUE : GL_FALSE; if (!context->skipValidation() && !ValidateIsQueryEXT(context, id))
{
return GL_FALSE;
}
return context->isQuery(id);
} }
return GL_FALSE; return GL_FALSE;
...@@ -103,17 +102,12 @@ void GL_APIENTRY BeginQueryEXT(GLenum target, GLuint id) ...@@ -103,17 +102,12 @@ void GL_APIENTRY BeginQueryEXT(GLenum target, GLuint id)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateBeginQueryEXT(context, target, id)) if (!context->skipValidation() && !ValidateBeginQueryEXT(context, target, id))
{ {
return; return;
} }
Error error = context->beginQuery(target, id); context->beginQuery(target, id);
if (error.isError())
{
context->handleError(error);
return;
}
} }
} }
...@@ -124,17 +118,12 @@ void GL_APIENTRY EndQueryEXT(GLenum target) ...@@ -124,17 +118,12 @@ void GL_APIENTRY EndQueryEXT(GLenum target)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateEndQueryEXT(context, target)) if (!context->skipValidation() && !ValidateEndQueryEXT(context, target))
{ {
return; return;
} }
Error error = context->endQuery(target); context->endQuery(target);
if (error.isError())
{
context->handleError(error);
return;
}
} }
} }
...@@ -145,17 +134,12 @@ void GL_APIENTRY QueryCounterEXT(GLuint id, GLenum target) ...@@ -145,17 +134,12 @@ void GL_APIENTRY QueryCounterEXT(GLuint id, GLenum target)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateQueryCounterEXT(context, id, target)) if (!context->skipValidation() && !ValidateQueryCounterEXT(context, id, target))
{ {
return; return;
} }
Error error = context->queryCounter(id, target); context->queryCounter(id, target);
if (error.isError())
{
context->handleError(error);
return;
}
} }
} }
......
...@@ -245,10 +245,7 @@ void GL_APIENTRY GenQueries(GLsizei n, GLuint *ids) ...@@ -245,10 +245,7 @@ void GL_APIENTRY GenQueries(GLsizei n, GLuint *ids)
return; return;
} }
for (GLsizei i = 0; i < n; i++) context->genQueries(n, ids);
{
ids[i] = context->createQuery();
}
} }
} }
...@@ -264,10 +261,7 @@ void GL_APIENTRY DeleteQueries(GLsizei n, const GLuint *ids) ...@@ -264,10 +261,7 @@ void GL_APIENTRY DeleteQueries(GLsizei n, const GLuint *ids)
return; return;
} }
for (int i = 0; i < n; i++) context->deleteQueries(n, ids);
{
context->deleteQuery(ids[i]);
}
} }
} }
...@@ -278,13 +272,12 @@ GLboolean GL_APIENTRY IsQuery(GLuint id) ...@@ -278,13 +272,12 @@ GLboolean GL_APIENTRY IsQuery(GLuint id)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (context->getClientMajorVersion() < 3) if (!context->skipValidation() && !ValidateIsQuery(context, id))
{ {
context->handleError(InvalidOperation());
return GL_FALSE; return GL_FALSE;
} }
return (context->getQuery(id, false, GL_NONE) != nullptr) ? GL_TRUE : GL_FALSE; return context->isQuery(id);
} }
return GL_FALSE; return GL_FALSE;
...@@ -297,17 +290,12 @@ void GL_APIENTRY BeginQuery(GLenum target, GLuint id) ...@@ -297,17 +290,12 @@ void GL_APIENTRY BeginQuery(GLenum target, GLuint id)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateBeginQuery(context, target, id)) if (!context->skipValidation() && !ValidateBeginQuery(context, target, id))
{ {
return; return;
} }
Error error = context->beginQuery(target, id); context->beginQuery(target, id);
if (error.isError())
{
context->handleError(error);
return;
}
} }
} }
...@@ -318,17 +306,12 @@ void GL_APIENTRY EndQuery(GLenum target) ...@@ -318,17 +306,12 @@ void GL_APIENTRY EndQuery(GLenum target)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateEndQuery(context, target)) if (!context->skipValidation() && !ValidateEndQuery(context, target))
{ {
return; return;
} }
Error error = context->endQuery(target); context->endQuery(target);
if (error.isError())
{
context->handleError(error);
return;
}
} }
} }
...@@ -340,7 +323,7 @@ void GL_APIENTRY GetQueryiv(GLenum target, GLenum pname, GLint *params) ...@@ -340,7 +323,7 @@ void GL_APIENTRY GetQueryiv(GLenum target, GLenum pname, GLint *params)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateGetQueryiv(context, target, pname, params)) if (!context->skipValidation() && !ValidateGetQueryiv(context, target, pname, params))
{ {
return; return;
} }
...@@ -356,7 +339,7 @@ void GL_APIENTRY GetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) ...@@ -356,7 +339,7 @@ void GL_APIENTRY GetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateGetQueryObjectuiv(context, id, pname, params)) if (!context->skipValidation() && !ValidateGetQueryObjectuiv(context, id, pname, params))
{ {
return; return;
} }
......
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